diff --git a/app/Livewire/SlackSettingsForm.php b/app/Livewire/SlackSettingsForm.php index 8bc775a27acc..535a83413fae 100644 --- a/app/Livewire/SlackSettingsForm.php +++ b/app/Livewire/SlackSettingsForm.php @@ -71,7 +71,7 @@ public function mount() { $this->setting = Setting::getSettings(); $this->save_button = trans('general.save'); - $this->webhook_selected = $this->setting->webhook_selected ?? 'slack'; + $this->webhook_selected = ($this->setting->webhook_selected !== '') ? $this->setting->webhook_selected : 'slack'; $this->webhook_name = $this->webhook_text[$this->setting->webhook_selected]["name"] ?? $this->webhook_text['slack']["name"]; $this->webhook_icon = $this->webhook_text[$this->setting->webhook_selected]["icon"] ?? $this->webhook_text['slack']["icon"]; $this->webhook_placeholder = $this->webhook_text[$this->setting->webhook_selected]["placeholder"] ?? $this->webhook_text['slack']["placeholder"]; @@ -191,7 +191,6 @@ public function clearSettings(){ $this->setting->webhook_endpoint = ''; $this->setting->webhook_channel = ''; $this->setting->webhook_botname = ''; - $this->setting->webhook_selected = ''; $this->setting->save(); diff --git a/database/migrations/2025_05_20_190317_repopulate_webhook_selected_setting.php b/database/migrations/2025_05_20_190317_repopulate_webhook_selected_setting.php new file mode 100644 index 000000000000..be14ea04eae3 --- /dev/null +++ b/database/migrations/2025_05_20_190317_repopulate_webhook_selected_setting.php @@ -0,0 +1,41 @@ +first(); + + if ($settings) { + /** If webhook settings were cleared via the integration settings page, + * the webhook_selected was cleared as well when it should have reset to "slack". + */ + if ( + empty($settings->webhook_selected) && + (empty($settings->webhook_botname) && empty($settings->webhook_channel) && empty($settings->webhook_endpoint)) + ) { + DB::table('settings')->update(['webhook_selected' => 'slack']); + } + + /** If webhook settings were cleared via the integration settings page, + * then slack settings were re-added; then webhook_selected was not being set to "slack" as needed. + */ + if (str_contains($settings->webhook_endpoint, 'slack.com')) { + DB::table('settings')->update(['webhook_selected' => 'slack']); + } + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +}; diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php index 849dfabdfa22..abb776bcea39 100644 --- a/resources/views/livewire/slack-settings-form.blade.php +++ b/resources/views/livewire/slack-settings-form.blade.php @@ -72,6 +72,7 @@ :options="['slack' => trans('admin/settings/general.slack'), 'general' => trans('admin/settings/general.general_webhook'),'google' => trans('admin/settings/general.google_workspaces'), 'microsoft' => trans('admin/settings/general.ms_teams')]" :selected="old('webhook_selected', $webhook_selected)" :disabled="Helper::isDemoMode()" + :for-livewire="true" data-minimum-results-for-search="-1" class="form-control" style="width:100%" @@ -174,22 +175,3 @@ class="btn btn-default btn-sm pull-left"> - - - - -@section('moar_scripts') - -@endsection - -