From 76ba3653253a72010a0d143d76eac03a8806ad96 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 23 Jun 2024 17:47:58 +0200 Subject: [PATCH] fix: slash in env names ui: placement of env switcher --- app/Console/Commands/Init.php | 14 ++++++++++++++ app/Models/Environment.php | 2 +- .../livewire/project/environment-edit.blade.php | 6 ------ .../resource/environment-select.blade.php | 16 ++++++++-------- .../livewire/project/resource/index.blade.php | 11 +++++------ 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index 50c9fe29b..7949b2457 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -5,6 +5,7 @@ use App\Enums\ApplicationDeploymentStatus; use App\Jobs\CleanupHelperContainersJob; use App\Models\ApplicationDeploymentQueue; +use App\Models\Environment; use App\Models\InstanceSettings; use App\Models\ScheduledDatabaseBackup; use App\Models\Server; @@ -24,6 +25,8 @@ public function handle() get_public_ips(); $full_cleanup = $this->option('full-cleanup'); $cleanup_deployments = $this->option('cleanup-deployments'); + + $this->replace_slash_in_environment_name(); if ($cleanup_deployments) { echo "Running cleanup deployments.\n"; $this->cleanup_in_progress_application_deployments(); @@ -150,4 +153,15 @@ private function cleanup_in_progress_application_deployments() echo "Error: {$e->getMessage()}\n"; } } + + private function replace_slash_in_environment_name() + { + $environments = Environment::all(); + foreach ($environments as $environment) { + if (str_contains($environment->name, '/')) { + $environment->name = str_replace('/', '-', $environment->name); + $environment->save(); + } + } + } } diff --git a/app/Models/Environment.php b/app/Models/Environment.php index e84b6989b..b2bb51092 100644 --- a/app/Models/Environment.php +++ b/app/Models/Environment.php @@ -109,7 +109,7 @@ public function services() protected function name(): Attribute { return Attribute::make( - set: fn (string $value) => strtolower($value), + set: fn (string $value) => str($value)->lower()->trim()->replace('/', '-')->toString(), ); } } diff --git a/resources/views/livewire/project/environment-edit.blade.php b/resources/views/livewire/project/environment-edit.blade.php index b4c37a37b..203525959 100644 --- a/resources/views/livewire/project/environment-edit.blade.php +++ b/resources/views/livewire/project/environment-edit.blade.php @@ -27,12 +27,6 @@
{{ data_get($parameters, 'environment_name') }} -
  • diff --git a/resources/views/livewire/project/resource/environment-select.blade.php b/resources/views/livewire/project/resource/environment-select.blade.php index cd9219efc..ab160dcda 100644 --- a/resources/views/livewire/project/resource/environment-select.blade.php +++ b/resources/views/livewire/project/resource/environment-select.blade.php @@ -1,8 +1,8 @@ - - - - @foreach ($environments as $environment) - - @endforeach - + + + + @foreach ($environments as $environment) + + @endforeach + diff --git a/resources/views/livewire/project/resource/index.blade.php b/resources/views/livewire/project/resource/index.blade.php index f623b41b5..cbe9f8a46 100644 --- a/resources/views/livewire/project/resource/index.blade.php +++ b/resources/views/livewire/project/resource/index.blade.php @@ -21,7 +21,7 @@ class="button">+ @endif -