From cc1bf023be9a09787a38ee0d111bd420221d7af6 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 18 Sep 2023 10:41:06 +0200 Subject: [PATCH] fix: do not remove localhost in boarding --- app/Http/Livewire/Boarding/Index.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/Http/Livewire/Boarding/Index.php b/app/Http/Livewire/Boarding/Index.php index dace2eb94..024d1cf44 100644 --- a/app/Http/Livewire/Boarding/Index.php +++ b/app/Http/Livewire/Boarding/Index.php @@ -15,6 +15,7 @@ class Index extends Component { public string $currentState = 'welcome'; + public ?string $selectedServerType = null; public ?Collection $privateKeys = null; public ?int $selectedExistingPrivateKey = null; public ?string $privateKeyType = null; @@ -64,11 +65,13 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== public function restartBoarding() { - if ($this->createdServer) { - $this->createdServer->delete(); - } - if ($this->createdPrivateKey) { - $this->createdPrivateKey->delete(); + if ($this->selectedServerType !== 'localhost') { + if ($this->createdServer) { + $this->createdServer->delete(); + } + if ($this->createdPrivateKey) { + $this->createdPrivateKey->delete(); + } } return redirect()->route('boarding'); } @@ -84,13 +87,14 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== public function setServerType(string $type) { - if ($type === 'localhost') { + $this->selectedServerType = $type; + if ($this->selectedServerType === 'localhost') { $this->createdServer = Server::find(0); if (!$this->createdServer) { return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.'); } return $this->validateServer('localhost'); - } elseif ($type === 'remote') { + } elseif ($this->selectedServerType === 'remote') { $this->privateKeys = PrivateKey::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get(); if ($this->privateKeys->count() > 0) { $this->selectedExistingPrivateKey = $this->privateKeys->first()->id; @@ -156,7 +160,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== { $this->validate([ 'remoteServerName' => 'required', - 'remoteServerHost' => 'required|ip', + 'remoteServerHost' => 'required', 'remoteServerPort' => 'required|integer', 'remoteServerUser' => 'required', ]);