From be0453d9dff8b5b344c2b4aa4827df3dfd84071f Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 26 May 2025 21:06:00 +0200 Subject: [PATCH] fix: Traefik start on new server validation fix: Multiple server selection ui flow --- .../Project/Application/Configuration.php | 1 + app/Livewire/Project/Shared/Destination.php | 7 +++- app/Livewire/Server/ValidateAndInstall.php | 23 ----------- .../project/shared/destination.blade.php | 2 +- .../server/validate-and-install.blade.php | 38 ++++--------------- 5 files changed, 14 insertions(+), 57 deletions(-) diff --git a/app/Livewire/Project/Application/Configuration.php b/app/Livewire/Project/Application/Configuration.php index f0b95a9c8..021731c20 100644 --- a/app/Livewire/Project/Application/Configuration.php +++ b/app/Livewire/Project/Application/Configuration.php @@ -24,6 +24,7 @@ class Configuration extends Component return [ "echo-private:team.{$teamId},ServiceChecked" => '$refresh', 'buildPackUpdated' => '$refresh', + 'refresh' => '$refresh', ]; } diff --git a/app/Livewire/Project/Shared/Destination.php b/app/Livewire/Project/Shared/Destination.php index 9d5331ff6..a4343bff9 100644 --- a/app/Livewire/Project/Shared/Destination.php +++ b/app/Livewire/Project/Shared/Destination.php @@ -26,6 +26,7 @@ class Destination extends Component return [ "echo-private:team.{$teamId},ApplicationStatusChanged" => 'loadData', + 'refresh' => 'mount', ]; } @@ -114,6 +115,7 @@ class Destination extends Component $this->resource->additional_networks()->detach($network_id, ['server_id' => $server_id]); $this->resource->additional_networks()->attach($main_destination->id, ['server_id' => $main_destination->server->id]); $this->refreshServers(); + $this->resource->refresh(); } public function refreshServers() @@ -126,7 +128,7 @@ class Destination extends Component public function addServer(int $network_id, int $server_id) { $this->resource->additional_networks()->attach($network_id, ['server_id' => $server_id]); - $this->loadData(); + $this->dispatch('refresh'); } public function removeServer(int $network_id, int $server_id, $password) @@ -141,7 +143,7 @@ class Destination extends Component } if ($this->resource->destination->server->id == $server_id && $this->resource->destination->id == $network_id) { - $this->dispatch('error', 'You cannot remove this destination server.', 'You are trying to remove the main server.'); + $this->dispatch('error', 'You are trying to remove the main server.'); return; } @@ -149,6 +151,7 @@ class Destination extends Component StopApplicationOneServer::run($this->resource, $server); $this->resource->additional_networks()->detach($network_id, ['server_id' => $server_id]); $this->loadData(); + $this->dispatch('refresh'); ApplicationStatusChanged::dispatch(data_get($this->resource, 'environment.project.team.id')); } catch (\Exception $e) { return handleError($e, $this); diff --git a/app/Livewire/Server/ValidateAndInstall.php b/app/Livewire/Server/ValidateAndInstall.php index 791ef9350..ba8fd9d4f 100644 --- a/app/Livewire/Server/ValidateAndInstall.php +++ b/app/Livewire/Server/ValidateAndInstall.php @@ -2,8 +2,6 @@ namespace App\Livewire\Server; -use App\Actions\Proxy\CheckProxy; -use App\Actions\Proxy\StartProxy; use App\Models\Server; use Livewire\Component; @@ -39,7 +37,6 @@ class ValidateAndInstall extends Component 'validateOS', 'validateDockerEngine', 'validateDockerVersion', - 'startProxy', 'refresh' => '$refresh', ]; @@ -64,25 +61,6 @@ class ValidateAndInstall extends Component $this->init(); } - public function startProxy() - { - try { - $shouldStart = CheckProxy::run($this->server); - if ($shouldStart) { - $proxy = StartProxy::run($this->server, false); - if ($proxy === 'OK') { - $this->proxy_started = true; - } else { - throw new \Exception('Proxy could not be started.'); - } - } else { - $this->proxy_started = true; - } - } catch (\Throwable $e) { - return handleError($e, $this); - } - } - public function validateConnection() { ['uptime' => $this->uptime, 'error' => $error] = $this->server->validateConnection(); @@ -172,7 +150,6 @@ class ValidateAndInstall extends Component if ($this->server->isBuildServer()) { return; } - $this->dispatch('startProxy'); } public function render() diff --git a/resources/views/livewire/project/shared/destination.blade.php b/resources/views/livewire/project/shared/destination.blade.php index f0ae90830..c6a3e2370 100644 --- a/resources/views/livewire/project/shared/destination.blade.php +++ b/resources/views/livewire/project/shared/destination.blade.php @@ -34,7 +34,7 @@ @if ($resource?->additional_networks?->count() > 0 && data_get($resource, 'build_pack') !== 'dockercompose')