From aae178a60652d61796cd99e277cebd7398924c8b Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 1 Mar 2023 17:10:10 -0800 Subject: [PATCH] gets select working, placeholders update dynamically --- app/Http/Livewire/SlackSettingsForm.php | 55 +++++++++--------- .../livewire/slack-settings-form.blade.php | 58 +++++-------------- resources/views/settings/slack.blade.php | 36 ++++++++++-- 3 files changed, 73 insertions(+), 76 deletions(-) diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index 996a30e236..ac94743383 100644 --- a/app/Http/Livewire/SlackSettingsForm.php +++ b/app/Http/Livewire/SlackSettingsForm.php @@ -13,29 +13,9 @@ class SlackSettingsForm extends Component public $webhook_botname; public $isDisabled ='disabled' ; public $webhook_link; + public $webhook_placeholder; + public $webhook_icon; public $webhook_selected; - public $webhook_options = array( - array( - "name" => 'Slack', - "icon" => 'fab fa-slack', - "placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX", - "link" => 'https://api.slack.com/messaging/webhooks' - ), - 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' - ), - array( - "name" => 'Rocket Chat', - "icon" => 'fab fa-rocketchat', - "placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX", - "link" => '', - ), - ); - public $keys; - public $icon; public Setting $setting; @@ -44,6 +24,23 @@ class SlackSettingsForm extends Component 'webhook_channel' => 'required_with:slack_endpoint|starts_with:#|nullable', 'webhook_botname' => 'string|nullable', ]; + static $webhook_text= [ + "Slack" => array( + "icon" => 'fab fa-slack', + "placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX", + "link" => 'https://api.slack.com/messaging/webhooks' + ), + "Discord" => array( + "icon" => 'fab fa-discord', + "placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX", + "link" => 'https://support.discord.com/hc/en-us/articles/360045093012-Server-Integrations-Page' + ), + "RocketChat"=> array( + "icon" => 'fab fa-rocketchat', + "placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX", + "link" => '', + ), + ]; public function mount(){ @@ -51,15 +48,21 @@ class SlackSettingsForm extends Component $this->webhook_endpoint = $this->setting->webhook_endpoint; $this->webhook_channel = $this->setting->webhook_channel; $this->webhook_botname = $this->setting->webhook_botname; -// $this->webhook_options = $this->setting->webhook_selected;lma - $this->keys = array_column($this->webhook_options, 'name'); + $this->webhook_options = $this->setting->webhook_selected; } public function updated($field){ - $this->webhook_selected = $this->webhook_options; +// $this->webhook_selected = $this->webhook_options; $this->validateOnly($field ,$this->rules); } + public function updatedWebhookSelected(){ + + $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"]; + + } public function render() { @@ -109,7 +112,7 @@ class SlackSettingsForm extends Component { $this->validate($this->rules); - $this->setting->webhook_options = $this->webhook_options; + $this->setting->webhook_selected = $this->webhwebhook_selected; $this->setting->webhook_endpoint = $this->webhook_endpoint; $this->setting->webhook_channel = $this->webhook_channel; $this->setting->webhook_botname = $this->webhook_botname; diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php index b863a0aaed..c435ae0c4a 100644 --- a/resources/views/livewire/slack-settings-form.blade.php +++ b/resources/views/livewire/slack-settings-form.blade.php @@ -1,32 +1,4 @@ -{{-- Page title --}} -@section('title') - {{ trans('admin/settings/general.webhook_title', ['app' => $webhook_selected->name ]) }} - @parent -@stop - -@section('header_right') - {{ trans('general.back') }} -@stop - - -{{-- Page content --}} -@section('content') - -
-
-
-
-

- {{ trans('admin/settings/general.webhook',['app' => $webhook_selected->name ]) }} -

-
-
-
-

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

-
-
+
@if (session()->has('save')) @@ -50,23 +22,21 @@ {{session('message')}}
@endif +
-{{-- --}} +



@@ -84,10 +54,10 @@

{{ trans('general.feature_disabled') }}

+ placeholder={{$webhook_placeholder}} {{old('webhook_endpoint', $webhook_endpoint)}}> @else + placeholder={{$webhook_placeholder}} {{old('webhook_endpoint', $webhook_endpoint)}}> @endif {!! $errors->first('webhook_endpoint', '') !!}
@@ -160,9 +130,7 @@
-
- @stop @push('scripts')