diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index dfbc3b17c..f6bc366c2 100644 --- a/app/Http/Livewire/SlackSettingsForm.php +++ b/app/Http/Livewire/SlackSettingsForm.php @@ -17,6 +17,7 @@ class SlackSettingsForm extends Component public $webhook_placeholder; public $webhook_icon; public $webhook_selected; + public array $webhook_text; public Setting $setting; @@ -25,34 +26,29 @@ class SlackSettingsForm extends Component 'webhook_channel' => 'required_with:webhook_endpoint|starts_with:#|nullable', 'webhook_botname' => 'string|nullable', ]; - static $webhook_text= [ - "Slack" => array( - "name" => "Slack", + + + public function mount(){ + $this->webhook_text= [ + "slack" => array( + "name" => trans('admin/settings/general.slack') , "icon" => 'fab fa-slack', "placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX", "link" => 'https://api.slack.com/messaging/webhooks', ), -// "Discord" => array( -// "name" => "Discord", -// "icon" => 'fab fa-discord', -// "placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX", -// "link" => 'https://support.discord.com/hc/en-us/articles/360045093012-Server-Integrations-Page', -// ), - "General"=> array( - "name" => "General", - "icon" => "fab fa-hashtag", - "placeholder" => "", - "link" => "", - ), - ]; - - public function mount(){ + "general"=> array( + "name" => trans('admin/settings/general.general_webhook'), + "icon" => "fab fa-hashtag", + "placeholder" => "", + "link" => "", + ), + ]; $this->setting = Setting::getSettings(); $this->webhook_selected = $this->setting->webhook_selected; - $this->webhook_placeholder = self::$webhook_text[$this->setting->webhook_selected]["placeholder"]; - $this->webhook_name = self::$webhook_text[$this->setting->webhook_selected]["name"]; - $this->webhook_icon = self::$webhook_text[$this->setting->webhook_selected]["icon"]; + $this->webhook_placeholder = $this->webhook_text[$this->setting->webhook_selected]["placeholder"]; + $this->webhook_name = $this->webhook_text[$this->setting->webhook_selected]["name"]; + $this->webhook_icon = $this->webhook_text[$this->setting->webhook_selected]["icon"]; $this->webhook_endpoint = $this->setting->webhook_endpoint; $this->webhook_channel = $this->setting->webhook_channel; $this->webhook_botname = $this->setting->webhook_botname; @@ -61,15 +57,15 @@ class SlackSettingsForm extends Component } public function updated($field){ - if($this->webhook_selected != 'General') { + if($this->webhook_selected != 'general') { $this->validateOnly($field, $this->rules); } } public function updatedWebhookSelected(){ - $this->webhook_name = self::$webhook_text[$this->webhook_selected]['name']; - $this->webhook_icon = self::$webhook_text[$this->webhook_selected]["icon"]; ; - $this->webhook_placeholder = self::$webhook_text[$this->webhook_selected]["placeholder"]; - $this->webhook_link = self::$webhook_text[$this->webhook_selected]["link"]; + $this->webhook_name = $this->webhook_text[$this->webhook_selected]['name']; + $this->webhook_icon = $this->webhook_text[$this->webhook_selected]["icon"]; ; + $this->webhook_placeholder = $this->webhook_text[$this->webhook_selected]["placeholder"]; + $this->webhook_link = $this->webhook_text[$this->webhook_selected]["link"]; } @@ -119,7 +115,7 @@ class SlackSettingsForm extends Component } public function submit() { - if($this->webhook_selected != 'General') { + if($this->webhook_selected != 'general') { $this->validate($this->rules); } diff --git a/database/migrations/2023_02_28_173527_adds_webhook_option_to_settings_table.php b/database/migrations/2023_02_28_173527_adds_webhook_option_to_settings_table.php index 9e7a27872..c3409c9d6 100644 --- a/database/migrations/2023_02_28_173527_adds_webhook_option_to_settings_table.php +++ b/database/migrations/2023_02_28_173527_adds_webhook_option_to_settings_table.php @@ -14,7 +14,7 @@ class AddsWebhookOptionToSettingsTable extends Migration public function up() { Schema::table('settings', function (Blueprint $table) { - $table->string('webhook_selected')->after('slack_botname')->default('Slack')->nullable(); + $table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable(); $table->renameColumn('slack_botname', 'webhook_botname'); $table->renameColumn('slack_endpoint', 'webhook_endpoint'); $table->renameColumn('slack_channel', 'webhook_channel'); diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index 4ccb7419b..3316ed09f 100644 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -199,6 +199,8 @@ return [ 'show_images_in_email_help' => 'Uncheck this box if your Snipe-IT installation is behind a VPN or closed network and users outside the network will not be able to load images served from this installation in their emails.', 'site_name' => 'Site Name', 'integrations' => 'Integrations', + 'slack' => 'Slack', + 'general_webhook' => 'General Webhook', 'webhook' => ':app', 'webhook_title' => 'Update Webhook Settings', 'webhook_help' => 'Integration settings', diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php index cdfd03c8c..aed73af59 100644 --- a/resources/views/livewire/slack-settings-form.blade.php +++ b/resources/views/livewire/slack-settings-form.blade.php @@ -24,7 +24,7 @@
- @if($webhook_selected != 'General') + @if($webhook_selected != 'general')

{!! trans('admin/settings/general.webhook_integration_help',array('webhook_link' => $webhook_link, 'app' => $webhook_name)) !!}

@@ -64,9 +64,9 @@ aria-label="webhook_selected" class="form-control " > - + {{-- --}} - +