Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/Livewire/SlackSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
$settings = DB::table('settings')->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
{
//
}
};
20 changes: 1 addition & 19 deletions resources/views/livewire/slack-settings-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand Down Expand Up @@ -174,22 +175,3 @@ class="btn btn-default btn-sm pull-left">
</div> <!-- /.row -->
</form>
</div> <!-- /livewire div -->




@section('moar_scripts')
<script>
$(document).ready(function () {
$('#select2').select2();
$('#select2').on('change', function (e) {
var data = $('#select2').select2("val");
@this.set('webhook_selected', data);
});
});
</script>
@endsection


Loading