From 7612c5d8529ac1fba942608ab814d599bbd2c244 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 13 Mar 2023 15:26:51 -0700 Subject: [PATCH 1/3] lowercases variables --- app/Http/Livewire/SlackSettingsForm.php | 12 ++++++------ ..._173527_adds_webhook_option_to_settings_table.php | 2 +- .../views/livewire/slack-settings-form.blade.php | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index dfbc3b17c..6a1932cb0 100644 --- a/app/Http/Livewire/SlackSettingsForm.php +++ b/app/Http/Livewire/SlackSettingsForm.php @@ -26,8 +26,8 @@ class SlackSettingsForm extends Component 'webhook_botname' => 'string|nullable', ]; static $webhook_text= [ - "Slack" => array( - "name" => "Slack", + "slack" => array( + "name" => "slack", "icon" => 'fab fa-slack', "placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX", "link" => 'https://api.slack.com/messaging/webhooks', @@ -38,8 +38,8 @@ class SlackSettingsForm extends Component // "placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX", // "link" => 'https://support.discord.com/hc/en-us/articles/360045093012-Server-Integrations-Page', // ), - "General"=> array( - "name" => "General", + "general"=> array( + "name" => "general", "icon" => "fab fa-hashtag", "placeholder" => "", "link" => "", @@ -61,7 +61,7 @@ class SlackSettingsForm extends Component } public function updated($field){ - if($this->webhook_selected != 'General') { + if($this->webhook_selected != 'general') { $this->validateOnly($field, $this->rules); } } @@ -119,7 +119,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/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php index cdfd03c8c..8d9ae7183 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 " > - + {{-- --}} - +



From 6474249ea897d907cb7268310852e2e1077ae0e7 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 13 Mar 2023 15:29:53 -0700 Subject: [PATCH 2/3] uppercased names --- app/Http/Livewire/SlackSettingsForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index 6a1932cb0..960ec2a92 100644 --- a/app/Http/Livewire/SlackSettingsForm.php +++ b/app/Http/Livewire/SlackSettingsForm.php @@ -27,7 +27,7 @@ class SlackSettingsForm extends Component ]; static $webhook_text= [ "slack" => array( - "name" => "slack", + "name" => "Slack", "icon" => 'fab fa-slack', "placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX", "link" => 'https://api.slack.com/messaging/webhooks', @@ -39,7 +39,7 @@ class SlackSettingsForm extends Component // "link" => 'https://support.discord.com/hc/en-us/articles/360045093012-Server-Integrations-Page', // ), "general"=> array( - "name" => "general", + "name" => "General", "icon" => "fab fa-hashtag", "placeholder" => "", "link" => "", From 1bd37b49e9a7a2a0eafc9e0b53a7f4725db6c0ae Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 13 Mar 2023 16:13:02 -0700 Subject: [PATCH 3/3] adds translations for webhook names --- app/Http/Livewire/SlackSettingsForm.php | 46 +++++++++---------- resources/lang/en/admin/settings/general.php | 2 + .../livewire/slack-settings-form.blade.php | 4 +- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index 960ec2a92..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; @@ -66,10 +62,10 @@ class SlackSettingsForm extends Component } } 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"]; } 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 8d9ae7183..aed73af59 100644 --- a/resources/views/livewire/slack-settings-form.blade.php +++ b/resources/views/livewire/slack-settings-form.blade.php @@ -64,9 +64,9 @@ aria-label="webhook_selected" class="form-control " > - + {{-- --}} - +