Skip to content

Commit

Permalink
add banner if server is in "conflict state"
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 committed Nov 21, 2024
1 parent 79b51b7 commit 6cd6cbc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers;

use App\Filament\Server\Pages\Console;
use App\Models;
use App\Models\ApiKey;
use App\Models\Node;
Expand All @@ -11,6 +12,8 @@
use Dedoc\Scramble\Support\Generator\SecurityScheme;
use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;
use Filament\Support\Facades\FilamentView;
use Filament\View\PanelsRenderHook;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Event;
Expand Down Expand Up @@ -75,6 +78,12 @@ public function boot(Application $app): void
'warning' => Color::Amber,
]);

FilamentView::registerRenderHook(
PanelsRenderHook::CONTENT_START,
fn () => view('filament.server-conflict-banner'),
scopes: Console::class,
);

Gate::before(function (User $user, $ability) {
return $user->isRootAdmin() ? true : null;
});
Expand Down
19 changes: 19 additions & 0 deletions resources/views/filament/server-conflict-banner.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@php
$shouldShow = false;
try {
\Filament\Facades\Filament::getTenant()->validateCurrentState();
} catch (\App\Exceptions\Http\Server\ServerStateConflictException $exception) {
$shouldShow = true;
$message = $exception->getMessage();
}
@endphp

@if ($shouldShow)
<div class="mt-2 p-2 rounded-lg text-white" style="background-color: #D97706;">
<div class="flex items-center">
<x-filament::icon icon="tabler-alert-triangle" class="h-6 w-6 mr-2 text-gray-500 dark:text-gray-400 text-white" />
<p>{!! $message !!}</p>
</div>
</div>
@endif

0 comments on commit 6cd6cbc

Please sign in to comment.