diff --git a/app/Livewire/Notifications/Discord.php b/app/Livewire/Notifications/Discord.php index 77d8f31de..7a177a227 100644 --- a/app/Livewire/Notifications/Discord.php +++ b/app/Livewire/Notifications/Discord.php @@ -41,7 +41,7 @@ public function mount() $this->team = auth()->user()->currentTeam(); $this->syncData(); } catch (\Throwable $e) { - handleError($e, $this); + return handleError($e, $this); } } @@ -57,11 +57,8 @@ public function syncData(bool $toModel = false) $this->team->discord_notifications_database_backups = $this->discordNotificationsDatabaseBackups; $this->team->discord_notifications_scheduled_tasks = $this->discordNotificationsScheduledTasks; $this->team->discord_notifications_server_disk_usage = $this->discordNotificationsServerDiskUsage; - try { - $this->saveModel(); - } catch (\Throwable $e) { - return handleError($e, $this); - } + $this->team->save(); + refreshSession(); } else { $this->discordEnabled = $this->team->discord_enabled; $this->discordWebhookUrl = $this->team->discord_webhook_url; @@ -74,6 +71,22 @@ public function syncData(bool $toModel = false) } } + public function instantSaveDiscordEnabled() + { + try { + $this->validate([ + 'discordWebhookUrl' => 'required', + ], [ + 'discordWebhookUrl.required' => 'Discord Webhook URL is required.', + ]); + $this->saveModel(); + } catch (\Throwable $e) { + $this->discordEnabled = false; + + return handleError($e, $this); + } + } + public function instantSave() { try { @@ -96,7 +109,7 @@ public function submit() public function saveModel() { - $this->team->save(); + $this->syncData(true); refreshSession(); $this->dispatch('success', 'Settings saved.'); } diff --git a/app/Livewire/Notifications/Email.php b/app/Livewire/Notifications/Email.php index ae053b8be..b49638b48 100644 --- a/app/Livewire/Notifications/Email.php +++ b/app/Livewire/Notifications/Email.php @@ -108,6 +108,7 @@ public function syncData(bool $toModel = false) $this->team->resend_enabled = $this->resendEnabled; $this->team->resend_api_key = $this->resendApiKey; $this->team->save(); + refreshSession(); } else { $this->smtpEnabled = $this->team->smtp_enabled; $this->smtpFromAddress = $this->team->smtp_from_address; @@ -170,8 +171,8 @@ public function instantSaveSmtpEnabled() 'smtpHost' => 'required', 'smtpPort' => 'required|numeric', ], [ - 'smtpHost.required' => 'SMTP Host is required', - 'smtpPort.required' => 'SMTP Port is required', + 'smtpHost.required' => 'SMTP Host is required.', + 'smtpPort.required' => 'SMTP Port is required.', ]); $this->resendEnabled = false; $this->saveModel(); @@ -186,9 +187,8 @@ public function instantSaveResend() { try { $this->validate([ - 'resendApiKey' => 'required', ], [ - 'resendApiKey.required' => 'Resend API Key is required', + 'resendApiKey.required' => 'Resend API Key is required.', ]); $this->smtpEnabled = false; $this->saveModel(); diff --git a/app/Livewire/Notifications/Telegram.php b/app/Livewire/Notifications/Telegram.php index 06feb8804..15ec20577 100644 --- a/app/Livewire/Notifications/Telegram.php +++ b/app/Livewire/Notifications/Telegram.php @@ -81,11 +81,8 @@ public function syncData(bool $toModel = false) $this->team->telegram_notifications_database_backups_message_thread_id = $this->telegramNotificationsDatabaseBackupsMessageThreadId; $this->team->telegram_notifications_scheduled_tasks_thread_id = $this->telegramNotificationsScheduledTasksThreadId; $this->team->telegram_notifications_server_disk_usage = $this->telegramNotificationsServerDiskUsage; - try { - $this->saveModel(); - } catch (\Throwable $e) { - return handleError($e, $this); - } + $this->team->save(); + refreshSession(); } else { $this->telegramEnabled = $this->team->telegram_enabled; $this->telegramToken = $this->team->telegram_token; @@ -125,9 +122,27 @@ public function submit() } } + public function instantSaveTelegramEnabled() + { + try { + $this->validate([ + 'telegramToken' => 'required', + 'telegramChatId' => 'required', + ], [ + 'telegramToken.required' => 'Telegram Token is required.', + 'telegramChatId.required' => 'Telegram Chat ID is required.', + ]); + $this->saveModel(); + } catch (\Throwable $e) { + $this->telegramEnabled = false; + + return handleError($e, $this); + } + } + public function saveModel() { - $this->team->save(); + $this->syncData(true); refreshSession(); $this->dispatch('success', 'Settings saved.'); } diff --git a/resources/views/components/notification/navbar.blade.php b/resources/views/components/notification/navbar.blade.php index 0fbbc69a2..b43fc38af 100644 --- a/resources/views/components/notification/navbar.blade.php +++ b/resources/views/components/notification/navbar.blade.php @@ -3,15 +3,15 @@
Get notified about your infrastructure.
- +
- +