diff --git a/app/Actions/Server/StartSentinel.php b/app/Actions/Server/StartSentinel.php index 1ecf882dc..dd1a7ed53 100644 --- a/app/Actions/Server/StartSentinel.php +++ b/app/Actions/Server/StartSentinel.php @@ -2,6 +2,7 @@ namespace App\Actions\Server; +use App\Events\SentinelRestarted; use App\Models\Server; use Lorisleiva\Actions\Concerns\AsAction; @@ -61,5 +62,8 @@ class StartSentinel $server->settings->is_sentinel_enabled = true; $server->settings->save(); $server->sentinelHeartbeat(); + + // Dispatch event to notify UI components + SentinelRestarted::dispatch($server, $version); } } diff --git a/app/Events/SentinelRestarted.php b/app/Events/SentinelRestarted.php new file mode 100644 index 000000000..9ddc3a07f --- /dev/null +++ b/app/Events/SentinelRestarted.php @@ -0,0 +1,39 @@ +teamId = $server->team_id; + $this->serverUuid = $server->uuid; + $this->version = $version; + } + + public function broadcastOn(): array + { + if (is_null($this->teamId)) { + return []; + } + + return [ + new PrivateChannel("team.{$this->teamId}"), + ]; + } +} diff --git a/app/Livewire/Server/Show.php b/app/Livewire/Server/Show.php index 70c5be5db..f4ae6dd7e 100644 --- a/app/Livewire/Server/Show.php +++ b/app/Livewire/Server/Show.php @@ -67,8 +67,11 @@ class Show extends Component public function getListeners() { + $teamId = $this->server->team_id ?? auth()->user()->currentTeam()->id; + return [ 'refreshServerShow' => 'refresh', + "echo-private:team.{$teamId},SentinelRestarted" => 'handleSentinelRestarted', ]; } @@ -221,6 +224,16 @@ class Show extends Component $this->syncData(); } + public function handleSentinelRestarted($event) + { + // Only refresh if the event is for this server + if (isset($event['serverUuid']) && $event['serverUuid'] === $this->server->uuid) { + $this->server->refresh(); + $this->syncData(); + $this->dispatch('success', 'Sentinel has been restarted successfully.'); + } + } + public function validateServer($install = true) { try { @@ -255,7 +268,7 @@ class Show extends Component try { $this->authorize('manageSentinel', $this->server); $this->server->restartSentinel(); - $this->dispatch('success', 'Sentinel restarted.'); + $this->dispatch('success', 'Restarting Sentinel.'); } catch (\Throwable $e) { return handleError($e, $this); } @@ -304,7 +317,7 @@ class Show extends Component try { $this->authorize('manageSentinel', $this->server); $this->server->settings->generateSentinelToken(); - $this->dispatch('success', 'Token regenerated & Sentinel restarted.'); + $this->dispatch('success', 'Token regenerated. Restarting Sentinel.'); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Source/Gitlab/Change.php b/app/Livewire/Source/Gitlab/Change.php deleted file mode 100644 index 34600bb7d..000000000 --- a/app/Livewire/Source/Gitlab/Change.php +++ /dev/null @@ -1,13 +0,0 @@ -