From bcbdee1dcc245d50bcab9cc8982e3d88fc1c2390 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 25 Mar 2024 13:10:05 +0100 Subject: [PATCH] Refactor Docker-related code and add conditional rendering --- app/Livewire/Destination/New/Docker.php | 4 +++- resources/views/destination/all.blade.php | 16 +++++++++++----- resources/views/livewire/server/create.blade.php | 2 +- .../views/livewire/server/new/by-ip.blade.php | 12 ++++++------ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/Livewire/Destination/New/Docker.php b/app/Livewire/Destination/New/Docker.php index d68bf84d4..d87f4bc0a 100644 --- a/app/Livewire/Destination/New/Docker.php +++ b/app/Livewire/Destination/New/Docker.php @@ -49,7 +49,9 @@ public function mount() } else { $this->network = new Cuid2(7); } - $this->name = str("{$this->servers->first()->name}-{$this->network}")->kebab(); + if ($this->servers->count() > 0) { + $this->name = str("{$this->servers->first()->name}-{$this->network}")->kebab(); + } } public function generate_name() diff --git a/resources/views/destination/all.blade.php b/resources/views/destination/all.blade.php index 91ab2032e..0326d8a67 100644 --- a/resources/views/destination/all.blade.php +++ b/resources/views/destination/all.blade.php @@ -1,11 +1,13 @@

Destinations

- - - + @if ($servers->count() > 0) + + + + @endif
-
Endpoints to deploy your resources.
+
Network endpoints to deploy your resources.
@forelse ($destinations as $destination) @if ($destination->getMorphClass() === 'App\Models\StandaloneDocker') @@ -27,7 +29,11 @@ @endif @empty
-
No destinations found.
+ @if ($servers->count() === 0) +
No servers found. Please add one first.
+ @else +
No destinations found.
+ @endif
@endforelse
diff --git a/resources/views/livewire/server/create.blade.php b/resources/views/livewire/server/create.blade.php index 29d412a95..acab92374 100644 --- a/resources/views/livewire/server/create.blade.php +++ b/resources/views/livewire/server/create.blade.php @@ -1,3 +1,3 @@ -
+
diff --git a/resources/views/livewire/server/new/by-ip.blade.php b/resources/views/livewire/server/new/by-ip.blade.php index 0120f1f2c..59c8c6b74 100644 --- a/resources/views/livewire/server/new/by-ip.blade.php +++ b/resources/views/livewire/server/new/by-ip.blade.php @@ -1,10 +1,10 @@ -
+
@if ($limit_reached) @else -
-
- + +
+
@@ -23,10 +23,10 @@ @endif @endforeach -
+
-
+

Swarm (experimental)

Read the docs