From e69040c7990ac90283c8d15a1d6c5ed5fe6d0b66 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 9 May 2023 14:50:19 +0200 Subject: [PATCH] no destination found --- .../Project/New/GithubPrivateRepository.php | 15 +++++++++++---- .../new/github-private-repository.blade.php | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepository.php b/app/Http/Livewire/Project/New/GithubPrivateRepository.php index 85f30aea1..2016af07a 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepository.php @@ -103,10 +103,17 @@ public function loadServers() } public function loadDestinations() { - $server = $this->servers->where('id', $this->selected_server_id)->first(); - $this->destinations = $server->standaloneDockers->merge($server->swarmDockers); - $this->selected_destination_id = $this->destinations[0]['id']; - $this->selected_destination_class = $this->destinations[0]->getMorphClass(); + try { + $server = $this->servers->where('id', $this->selected_server_id)->first(); + if ($server->standaloneDockers->count() === 0 && $server->swarmDockers->count() === 0) { + $this->destinations = 0; + } + $this->destinations = $server->standaloneDockers->merge($server->swarmDockers); + $this->selected_destination_id = $this->destinations[0]['id']; + $this->selected_destination_class = $this->destinations[0]->getMorphClass(); + } catch (\Exception $e) { + return generalErrorHandler($e); + } } public function submit() { diff --git a/resources/views/livewire/project/new/github-private-repository.blade.php b/resources/views/livewire/project/new/github-private-repository.blade.php index 2d162aba8..ba4ff126e 100644 --- a/resources/views/livewire/project/new/github-private-repository.blade.php +++ b/resources/views/livewire/project/new/github-private-repository.blade.php @@ -72,6 +72,11 @@ @endforeach Select Destination + @else +

No destinations found on this server.

+ Add + a + destination @endif @else