Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: New Slack notification UI

peaklabs-devb4b48692afb9
diff --git a/app/Livewire/Notifications/Slack.php b/app/Livewire/Notifications/Slack.php
index edd32a071e..7fa881641b 100644
--- a/app/Livewire/Notifications/Slack.php
+++ b/app/Livewire/Notifications/Slack.php
@@ -2,6 +2,7 @@
namespace App\Livewire\Notifications;
+use App\Models\SlackNotificationSettings;
use App\Models\Team;
use App\Notifications\Test;
use Livewire\Attributes\Validate;
@@ -11,6 +12,8 @@ class Slack extends Component
{
public Team $team;
+ public SlackNotificationSettings $settings;
+
#[Validate(['boolean'])]
public bool $slackEnabled = false;
@@ -18,27 +21,43 @@ class Slack extends Component
public ?string $slackWebhookUrl = null;
#[Validate(['boolean'])]
- public bool $slackNotificationsTest = false;
+ public bool $deploymentSuccessSlackNotifications = false;
+
+ #[Validate(['boolean'])]
+ public bool $deploymentFailureSlackNotifications = true;
+
+ #[Validate(['boolean'])]
+ public bool $statusChangeSlackNotifications = false;
+
+ #[Validate(['boolean'])]
+ public bool $backupSuccessSlackNotifications = false;
+
+ #[Validate(['boolean'])]
+ public bool $backupFailureSlackNotifications = true;
#[Validate(['boolean'])]
- public bool $slackNotificationsDeployments = false;
+ public bool $scheduledTaskSuccessSlackNotifications = false;
#[Validate(['boolean'])]
- public bool $slackNotificationsStatusChanges = false;
+ public bool $scheduledTaskFailureSlackNotifications = true;
#[Validate(['boolean'])]
- public bool $slackNotificationsDatabaseBackups = false;
+ public bool $dockerCleanupSlackNotifications = false;
#[Validate(['boolean'])]
- public bool $slackNotificationsScheduledTasks = false;
+ public bool $serverDiskUsageSlackNotifications = true;
#[Validate(['boolean'])]
- public bool $slackNotificationsServerDiskUsage = false;
+ public bool $serverReachableSlackNotifications = false;
+
+ #[Validate(['boolean'])]
+ public bool $serverUnreachableSlackNotifications = true;
public function mount()
{
try {
$this->team = auth()->user()->currentTeam();
+ $this->settings = $this->team->slackNotificationSettings;
$this->syncData();
} catch (\Throwable $e) {
return handleError($e, $this);
@@ -49,25 +68,38 @@ class Slack extends Component
{
if ($toModel) {
$this->validate();
- $this->team->slack_enabled = $this->slackEnabled;
- $this->team->slack_webhook_url = $this->slackWebhookUrl;
- $this->team->slack_notifications_test = $this->slackNotificationsTest;
- $this->team->slack_notifications_deployments = $this->slackNotificationsDeployments;
- $this->team->slack_notifications_status_changes = $this->slackNotificationsStatusChanges;
- $this->team->slack_notifications_database_backups = $this->slackNotificationsDatabaseBackups;
- $this->team->slack_notifications_scheduled_tasks = $this->slackNotificationsScheduledTasks;
- $this->team->slack_notifications_server_disk_usage = $this->slackNotificationsServerDiskUsage;
- $this->team->save();
+ $this->settings->slack_enabled = $this->slackEnabled;
+ $this->settings->slack_webhook_url = $this->slackWebhookUrl;
+
+ $this->settings->deployment_success_slack_notifications = $this->deploymentSuccessSlackNotifications;
+ $this->settings->deployment_failure_slack_notifications = $this->deploymentFailureSlackNotifications;
+ $this->settings->status_change_slack_notifications = $this->statusChangeSlackNotifications;
+ $this->settings->backup_success_slack_notifications = $this->backupSuccessSlackNotifications;
+ $this->settings->backup_failure_slack_notifications = $this->backupFailureSlackNotifications;
+ $this->settings->scheduled_task_success_slack_notifications = $this->scheduledTaskSuccessSlackNotifications;
+ $this->settings->scheduled_task_failure_slack_notifications = $this->scheduledTaskFailureSlackNotifications;
+ $this->settings->docker_cleanup_slack_notifications = $this->dockerCleanupSlackNotifications;
+ $this->settings->server_disk_usage_slack_notifications = $this->serverDiskUsageSlackNotifications;
+ $this->settings->server_reachable_slack_notifications = $this->serverReachableSlackNotifications;
+ $this->settings->server_unreachable_slack_notifications = $this->serverUnreachableSlackNotifications;
+
+ $this->settings->save();
refreshSession();
} else {
- $this->slackEnabled = $this->team->slack_enabled;
- $this->slackWebhookUrl = $this->team->slack_webhook_url;
- $this->slackNotificationsTest = $this->team->slack_notifications_test;
- $this->slackNotificationsDeployments = $this->team->slack_notifications_deployments;
- $this->slackNotificationsStatusChanges = $this->team->slack_notifications_status_changes;
- $this->slackNotificationsDatabaseBackups = $this->team->slack_notifications_database_backups;
- $this->slackNotificationsScheduledTasks = $this->team->slack_notifications_scheduled_tasks;
- $this->slackNotificationsServerDiskUsage = $this->team->slack_notifications_server_disk_usage;
+ $this->slackEnabled = $this->settings->slack_enabled;
+ $this->slackWebhookUrl = $this->settings->slack_webhook_url;
+
+ $this->deploymentSuccessSlackNotifications = $this->settings->deployment_success_slack_notifications;
+ $this->deploymentFailureSlackNotifications = $this->settings->deployment_failure_slack_notifications;
+ $this->statusChangeSlackNotifications = $this->settings->status_change_slack_notifications;
+ $this->backupSuccessSlackNotifications = $this->settings->backup_success_slack_notifications;
+ $this->backupFailureSlackNotifications = $this->settings->backup_failure_slack_notifications;
+ $this->scheduledTaskSuccessSlackNotifications = $this->settings->scheduled_task_success_slack_notifications;
+ $this->scheduledTaskFailureSlackNotifications = $this->settings->scheduled_task_failure_slack_notifications;
+ $this->dockerCleanupSlackNotifications = $this->settings->docker_cleanup_slack_notifications;
+ $this->serverDiskUsageSlackNotifications = $this->settings->server_disk_usage_slack_notifications;
+ $this->serverReachableSlackNotifications = $this->settings->server_reachable_slack_notifications;
+ $this->serverUnreachableSlackNotifications = $this->settings->server_unreachable_slack_notifications;
}
}
@@ -82,6 +114,7 @@ class Slack extends Component
$this->saveModel();
} catch (\Throwable $e) {
$this->slackEnabled = false;
+
return handleError($e, $this);
}
}
@@ -127,4 +160,4 @@ class Slack extends Component
{
return view('livewire.notifications.slack');
}
-}
\ No newline at end of file
+}
diff --git a/resources/views/livewire/notifications/slack.blade.php b/resources/views/livewire/notifications/slack.blade.php
index b3685173c6..0525818378 100644
--- a/resources/views/livewire/notifications/slack.blade.php
+++ b/resources/views/livewire/notifications/slack.blade.php
@@ -1,43 +1,65 @@
<div>
<x-slot:title>
Notifications | Coolify
- </x-slot>
- <x-notification.navbar />
- <form wire:submit='submit' class="flex flex-col gap-4">
- <div class="flex items-center gap-2">
- <h2>Slack</h2>
- <x-forms.button type="submit">
- Save
+ </x-slot>
+ <x-notification.navbar />
+ <form wire:submit='submit' class="flex flex-col gap-4">
+ <div class="flex items-center gap-2">
+ <h2>Slack</h2>
+ <x-forms.button type="submit">
+ Save
+ </x-forms.button>
+ @if ($slackEnabled)
+ <x-forms.button class="normal-case dark:text-white btn btn-xs no-animation btn-primary"
+ wire:click="sendTestNotification">
+ Send Test Notification
</x-forms.button>
- @if ($slackEnabled)
- <x-forms.button class="normal-case dark:text-white btn btn-xs no-animation btn-primary"
- wire:click="sendTestNotification">
- Send Test Notifications
- </x-forms.button>
- @endif
+ @endif
+ </div>
+ <div class="w-32">
+ <x-forms.checkbox instantSave="instantSaveSlackEnabled" id="slackEnabled" label="Enabled" />
+ </div>
+ <x-forms.input type="password"
+ helper="Generate a webhook in Slack.<br>Example: https://hooks.slack.com/services/...." required
+ id="slackWebhookUrl" label="Webhook" />
+ </form>
+ @if ($slackEnabled)
+ <h2 class="mt-8 mb-4">Notification Settings</h2>
+ <p class="mb-4">
+ Select events for which you would like to receive Slack notifications.
+ </p>
+ <div class="flex flex-col gap-4 max-w-2xl">
+ <div class="border dark:border-coolgray-300 p-4 rounded-lg">
+ <h3 class="font-medium mb-3">Deployments</h3>
+ <div class="flex flex-col gap-1.5 pl-1">
+ <x-forms.checkbox instantSave="saveModel" id="deploymentSuccessSlackNotifications" label="Deployment Success" />
+ <x-forms.checkbox instantSave="saveModel" id="deploymentFailureSlackNotifications" label="Deployment Failure" />
+ <x-forms.checkbox instantSave="saveModel" helper="Send a notification when a container status changes. It will notify for Stopped and Restarted events of a container." id="statusChangeSlackNotifications" label="Container Status Changes" />
+ </div>
</div>
- <div class="w-32">
- <x-forms.checkbox instantSave="instantSaveSlackEnabled" id="slackEnabled" label="Enabled" />
+ <div class="border dark:border-coolgray-300 p-4 rounded-lg">
+ <h3 class="font-medium mb-3">Backups</h3>
+ <div class="flex flex-col gap-1.5 pl-1">
+ <x-forms.checkbox instantSave="saveModel" id="backupSuccessSlackNotifications" label="Backup Success" />
+ <x-forms.checkbox instantSave="saveModel" id="backupFailureSlackNotifications" label="Backup Failure" />
+ </div>
</div>
- <x-forms.input type="password"
- helper="Generate a webhook in Slack.<br>Example: https://hooks.slack.com/services/...." required
- id="slackWebhookUrl" label="Webhook" />
- </form>
- @if ($slackEnabled)
- <h2 class="mt-4">Subscribe to events</h2>
- <div class="w-64">
- @if (isDev())
- <x-forms.checkbox instantSave="saveModel" id="slackNotificationsTest" label="Test" />
- @endif
- <x-forms.checkbox instantSave="saveModel" id="slackNotificationsStatusChanges"
- label="Container Status Changes" />
- <x-forms.checkbox instantSave="saveModel" id="slackNotificationsDeployments"
- label="Application Deployments" />
- <x-forms.checkbox instantSave="saveModel" id="slackNotificationsDatabaseBackups" label="Backup Status" />
- <x-forms.checkbox instantSave="saveModel" id="slackNotificationsScheduledTasks"
- label="Scheduled Tasks Status" />
- <x-forms.checkbox instantSave="saveModel" id="slackNotificationsServerDiskUsage"
- label="Server Disk Usage" />
+ <div class="border dark:border-coolgray-300 p-4 rounded-lg">
+ <h3 class="font-medium mb-3">Scheduled Tasks</h3>
+ <div class="flex flex-col gap-1.5 pl-1">
+ <x-forms.checkbox instantSave="saveModel" id="scheduledTaskSuccessSlackNotifications" label="Scheduled Task Success" />
+ <x-forms.checkbox instantSave="saveModel" id="scheduledTaskFailureSlackNotifications" label="Scheduled Task Failure" />
+ </div>
</div>
- @endif
+ <div class="border dark:border-coolgray-300 p-4 rounded-lg">
+ <h3 class="font-medium mb-3">Server</h3>
+ <div class="flex flex-col gap-1.5 pl-1">
+ <x-forms.checkbox instantSave="saveModel" helper="Send a notification when Docker Cleanup is run on a server." id="dockerCleanupSlackNotifications" label="Docker Cleanup" />
+ <x-forms.checkbox instantSave="saveModel" helper="Send a notification when server disk usage is high." id="serverDiskUsageSlackNotifications" label="Server Disk Usage" />
+ <x-forms.checkbox instantSave="saveModel" id="serverReachableSlackNotifications" label="Server Reachable" />
+ <x-forms.checkbox instantSave="saveModel" id="serverUnreachableSlackNotifications" label="Server Unreachable" />
+ </div>
+ </div>
+ </div>
+ @endif
</div>
\ No newline at end of file