From 9d719009529aa8941f957d87a6a766141254449f Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Thu, 29 May 2025 14:26:48 +0200 Subject: [PATCH] refactor(terminal-access): streamline resource retrieval and enhance terminal access messaging in UI --- .../Project/Shared/ExecuteContainerCommand.php | 9 ++++++--- .../shared/execute-container-command.blade.php | 18 +++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/Livewire/Project/Shared/ExecuteContainerCommand.php b/app/Livewire/Project/Shared/ExecuteContainerCommand.php index 3c2323206..ce6314d63 100644 --- a/app/Livewire/Project/Shared/ExecuteContainerCommand.php +++ b/app/Livewire/Project/Shared/ExecuteContainerCommand.php @@ -55,7 +55,7 @@ class ExecuteContainerCommand extends Component $this->servers = collect(); if (data_get($this->parameters, 'application_uuid')) { $this->type = 'application'; - $this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail(); + $this->resource = Application::whereUuid($this->parameters['application_uuid'])->firstOrFail(); if ($this->resource->destination->server->isFunctional() && $this->resource->destination->server->isTerminalEnabled()) { $this->servers = $this->servers->push($this->resource->destination->server); } @@ -78,14 +78,14 @@ class ExecuteContainerCommand extends Component $this->loadContainers(); } elseif (data_get($this->parameters, 'service_uuid')) { $this->type = 'service'; - $this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail(); + $this->resource = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail(); if ($this->resource->server->isFunctional() && $this->resource->server->isTerminalEnabled()) { $this->servers = $this->servers->push($this->resource->server); } $this->loadContainers(); } elseif (data_get($this->parameters, 'server_uuid')) { $this->type = 'server'; - $this->resource = Server::where('uuid', $this->parameters['server_uuid'])->firstOrFail(); + $this->resource = Server::ownedByCurrentTeam()->whereUuid($this->parameters['server_uuid'])->firstOrFail(); $this->server = $this->resource; } } @@ -175,6 +175,9 @@ class ExecuteContainerCommand extends Component if ($this->server->isForceDisabled()) { throw new \RuntimeException('Server is disabled.'); } + if (! $this->server->isTerminalEnabled()) { + throw new \RuntimeException('Terminal access is disabled on this server.'); + } $this->hasShell = true; $this->dispatch( 'send-terminal-command', diff --git a/resources/views/livewire/project/shared/execute-container-command.blade.php b/resources/views/livewire/project/shared/execute-container-command.blade.php index 3625c4318..f007c3cbb 100644 --- a/resources/views/livewire/project/shared/execute-container-command.blade.php +++ b/resources/views/livewire/project/shared/execute-container-command.blade.php @@ -35,13 +35,17 @@ @else @if ($type === 'server') -
- Reconnect -
-
- -
+ @if ($server->isTerminalEnabled()) +
+ Reconnect +
+
+ +
+ @else +
Terminal access is disabled on this server.
+ @endif @else @if (count($containers) === 0)
No containers are running on this server or terminal access is disabled.