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.

ui: make notifications separate view fix: popup if no notifications are set

Andras Bacsai129a644781fe
diff --git a/app/Livewire/LayoutPopups.php b/app/Livewire/LayoutPopups.php
index dd7f146787..b6f06f808f 100644
--- a/app/Livewire/LayoutPopups.php
+++ b/app/Livewire/LayoutPopups.php
@@ -17,10 +17,14 @@ class LayoutPopups extends Component
{
$this->dispatch('success', 'Realtime events configured!');
}
- public function disable()
+ public function disableSponsorship()
{
auth()->user()->update(['is_notification_sponsorship_enabled' => false]);
}
+ public function disableNotifications()
+ {
+ auth()->user()->update(['is_notification_notifications_enabled' => false]);
+ }
public function render()
{
return view('livewire.layout-popups');
diff --git a/app/Models/Team.php b/app/Models/Team.php
index 656c4009b5..7cb1601de6 100644
--- a/app/Models/Team.php
+++ b/app/Models/Team.php
@@ -48,13 +48,15 @@ class Team extends Model implements SendsDiscord, SendsEmail
}
return explode(',', $recipients);
}
- static public function serverLimitReached() {
+ static public function serverLimitReached()
+ {
$serverLimit = Team::serverLimit();
$team = currentTeam();
$servers = $team->servers->count();
return $servers >= $serverLimit;
}
- public function serverOverflow() {
+ public function serverOverflow()
+ {
if ($this->serverLimit() < $this->servers->count()) {
return true;
}
@@ -170,4 +172,17 @@ class Team extends Model implements SendsDiscord, SendsEmail
]);
}
}
+ public function isAnyNotificationEnabled()
+ {
+ if (isCloud()) {
+ return true;
+ }
+ if (!data_get(auth()->user(), 'is_notification_notifications_enabled')) {
+ return true;
+ }
+ if ($this->smtp_enabled || $this->resend_enabled || $this->discord_enabled || $this->telegram_enabled || $this->use_instance_email_settings) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/database/migrations/2024_03_07_115054_add_notifications_notification_disable.php b/database/migrations/2024_03_07_115054_add_notifications_notification_disable.php
new file mode 100644
index 0000000000..8633b971ef
--- /dev/null
+++ b/database/migrations/2024_03_07_115054_add_notifications_notification_disable.php
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->boolean('is_notification_notifications_enabled')->default(true);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn('is_notification_notifications_enabled');
+ });
+ }
+};
diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php
index 3bd1730be8..65d2f0736f 100644
--- a/resources/views/components/navbar.blade.php
+++ b/resources/views/components/navbar.blade.php
@@ -150,7 +150,17 @@
</a>
</li>
@endif
-
+ <li title="Notifications" class="hover:bg-coolgray-200">
+ <a class="hover:bg-transparent hover:no-underline" href="{{ route('notification.index') }}">
+ <svg class="{{ request()->is('notifications*') ? 'text-warning icon' : 'icon' }}"
+ xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
+ <path fill="none" stroke="currentColor" stroke-linecap="round"
+ stroke-linejoin="round" stroke-width="2"
+ d="M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3H4a4 4 0 0 0 2-3v-3a7 7 0 0 1 4-6M9 17v1a3 3 0 0 0 6 0v-1" />
+ </svg>
+ Notifications
+ </a>
+ </li>
@if (isInstanceAdmin())
<li title="Settings" class="hover:bg-coolgray-200">
<a class="hover:bg-transparent hover:no-underline" href="/settings">
diff --git a/resources/views/components/notifications/navbar.blade.php b/resources/views/components/notifications/navbar.blade.php
new file mode 100644
index 0000000000..65b374249b
--- /dev/null
+++ b/resources/views/components/notifications/navbar.blade.php
@@ -0,0 +1,25 @@
+<div class="pb-6">
+ <div class="flex items-end gap-2">
+ <h1>Team Notifications</h1>
+ </div>
+ <nav class="flex pt-2 pb-10">
+ <ol class="inline-flex items-center">
+ <li>
+ <div class="flex items-center">
+ <span>Currently active team: <span
+ class="text-warning">{{ session('currentTeam.name') }}</span></span>
+ </div>
+ </li>
+ </ol>
+ </nav>
+ <nav class="navbar-main">
+ <a class="{{ request()->routeIs('notification.index') ? 'text-white' : '' }}"
+ href="{{ route('notification.index') }}">
+ <button>General</button>
+ </a>
+ <div class="flex-1"></div>
+ <div class="-mt-9">
+ <livewire:switch-team />
+ </div>
+ </nav>
+</div>
diff --git a/resources/views/components/team/navbar.blade.php b/resources/views/components/team/navbar.blade.php
index 971b9de85a..a3f13b4afd 100644
--- a/resources/views/components/team/navbar.blade.php
+++ b/resources/views/components/team/navbar.blade.php
@@ -1,7 +1,7 @@
<div class="pb-6">
<div class="flex items-end gap-2">
<h1>Team</h1>
- <a href="/team/new"><x-forms.button>+ Add Team</x-forms.button></a>
+ <a href="/team/new"><x-forms.button>+ Add Team</x-forms.button></a>
</div>
<nav class="flex pt-2 pb-10">
<ol class="inline-flex items-center">
@@ -17,18 +17,15 @@
<a class="{{ request()->routeIs('team.index') ? 'text-white' : '' }}" href="{{ route('team.index') }}">
<button>General</button>
</a>
- <a class="{{ request()->routeIs('team.member.index') ? 'text-white' : '' }}" href="{{ route('team.member.index') }}">
+ <a class="{{ request()->routeIs('team.member.index') ? 'text-white' : '' }}"
+ href="{{ route('team.member.index') }}">
<button>Members</button>
</a>
<a class="{{ request()->routeIs('team.storage.index') ? 'text-white' : '' }}"
href="{{ route('team.storage.index') }}">
<button>S3 Storages</button>
</a>
- <a class="{{ request()->routeIs('team.notification.index') ? 'text-white' : '' }}"
- href="{{ route('team.notification.index') }}">
- <button>Notifications</button>
- </a>
- <a class="{{ request()->routeIs('team.shared-variables.index') ? 'text-white' : '' }}"
+ <a class="{{ request()->routeIs('team.shared-variables.index') ? 'text-white' : '' }}"
href="{{ route('team.shared-variables.index') }}">
<button>Shared Variables</button>
</a>
diff --git a/resources/views/livewire/layout-popups.blade.php b/resources/views/livewire/layout-popups.blade.php
index 23b9bfe649..afacccc727 100644
--- a/resources/views/livewire/layout-popups.blade.php
+++ b/resources/views/livewire/layout-popups.blade.php
@@ -7,7 +7,8 @@
consider donating!</a>💜</span>
<span>It enables us to keep creating features without paywalls, ensuring our work remains free and
open.</span>
- <x-forms.button class="bg-coolgray-400" wire:click='disable'>Disable This Popup</x-forms.button>
+ <x-forms.button class="bg-coolgray-400" wire:click='disableSponsorship'>Disable This
+ Popup</x-forms.button>
</div>
</div>
@endif
@@ -20,4 +21,16 @@
</div>
</x-banner>
@endif
+ @if (!currentTeam()->isAnyNotificationEnabled())
+ <div class="toast">
+ <div class="flex flex-col text-white rounded alert bg-coolgray-200">
+ <span><span class="font-bold text-red-500">WARNING:</span> No notifications enabled.<br><br> It is highly recommended to enable at least
+ one
+ notification channel to receive important alerts.<br>Visit <a href="{{ route('notification.index') }}"
+ class="text-white underline">/notification</a> to enable notifications.</span>
+ <x-forms.button class="bg-coolgray-400" wire:click='disableNotifications'>Disable This
+ Popup</x-forms.button>
+ </div>
+ </div>
+ @endif
</div>
diff --git a/resources/views/livewire/team/notification/index.blade.php b/resources/views/livewire/team/notification/index.blade.php
index ed961deb03..e5eaffe17a 100644
--- a/resources/views/livewire/team/notification/index.blade.php
+++ b/resources/views/livewire/team/notification/index.blade.php
@@ -1,5 +1,5 @@
<div>
- <x-team.navbar />
+ <x-notifications.navbar />
<h2 class="pb-4">Notifications</h2>
<div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'email' }" class="flex h-full">
<div class="flex flex-col gap-4 min-w-fit">
diff --git a/routes/web.php b/routes/web.php
index f49d1b278d..c442f6c752 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -121,11 +121,13 @@ Route::middleware(['auth', 'verified'])->group(function () {
Route::get('/', TagsIndex::class)->name('tags.index');
Route::get('/{tag_name}', TagsShow::class)->name('tags.show');
});
+ Route::prefix('notifications')->group(function () {
+ Route::get('/', TeamNotificationIndex::class)->name('notification.index');
+ });
Route::prefix('team')->group(function () {
Route::get('/', TeamIndex::class)->name('team.index');
Route::get('/new', TeamCreate::class)->name('team.create');
Route::get('/members', TeamMemberIndex::class)->name('team.member.index');
- Route::get('/notifications', TeamNotificationIndex::class)->name('team.notification.index');
Route::get('/shared-variables', TeamSharedVariablesIndex::class)->name('team.shared-variables.index');
Route::get('/storages', TeamStorageIndex::class)->name('team.storage.index');
Route::get('/storages/new', TeamStorageCreate::class)->name('team.storage.create');