From 0f071031a9b654211dfeb7898fcd3cc23f71bd98 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 15 Feb 2024 12:01:59 +0100 Subject: [PATCH] Refactor application FQDN handling --- app/Livewire/Project/Application/General.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 673d2473f..732be62d0 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -163,6 +163,7 @@ public function generateDomain(string $serviceName) } return $domain; } + public function updatedApplicationBuildPack() { if ($this->application->build_pack !== 'nixpacks') { @@ -202,6 +203,13 @@ public function resetDefaultLabels($showToaster = true) public function updatedApplicationFqdn() { + $this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim(); + $this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim(); + $this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { + return str($domain)->trim()->lower(); + }); + $this->application->fqdn = $this->application->fqdn->unique()->implode(','); + $this->application->save(); $this->resetDefaultLabels(false); // $this->dispatch('success', 'Labels reset to default!'); } @@ -228,11 +236,7 @@ public function submit($showToaster = true) ]); } if (data_get($this->application, 'fqdn')) { - $this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim(); - $domains = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { - return str($domain)->trim()->lower(); - }); - $domains = $domains->unique(); + $domains = str($this->application->fqdn)->trim()->explode(','); if ($this->application->additional_servers->count() === 0) { foreach ($domains as $domain) { if (!validate_dns_entry($domain, $this->application->destination->server)) { @@ -243,7 +247,6 @@ public function submit($showToaster = true) check_fqdn_usage($this->application); $this->application->fqdn = $domains->implode(','); } - if (data_get($this->application, 'custom_docker_run_options')) { $this->application->custom_docker_run_options = str($this->application->custom_docker_run_options)->trim(); }