From e9fd2d8d6fbc6eae113add11d639cff6c62e0569 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 28 Jan 2025 13:38:26 +0100 Subject: [PATCH] feat(core): add dynamic label reset for application settings --- app/Livewire/Project/Application/Advanced.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Project/Application/Advanced.php b/app/Livewire/Project/Application/Advanced.php index cb63f0e1a..bd1388806 100644 --- a/app/Livewire/Project/Application/Advanced.php +++ b/app/Livewire/Project/Application/Advanced.php @@ -124,9 +124,20 @@ class Advanced extends Component } } + private function resetDefaultLabels() + { + if ($this->application->settings->is_container_label_readonly_enabled === false) { + return; + } + $customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n"); + $this->application->custom_labels = base64_encode($customLabels); + $this->application->save(); + } + public function instantSave() { try { + $reset = false; if ($this->isLogDrainEnabled) { if (! $this->application->destination->server->isLogDrainEnabled()) { $this->isLogDrainEnabled = false; @@ -140,7 +151,7 @@ class Advanced extends Component $this->application->isGzipEnabled() !== $this->isGzipEnabled || $this->application->isStripprefixEnabled() !== $this->isStripprefixEnabled ) { - $this->dispatch('resetDefaultLabels', false); + $reset = true; } if ($this->application->settings->is_raw_compose_deployment_enabled) { @@ -149,6 +160,11 @@ class Advanced extends Component $this->application->parse(); } $this->syncData(true); + + if ($reset) { + $this->resetDefaultLabels(); + } + $this->dispatch('success', 'Settings saved.'); $this->dispatch('configurationChanged'); } catch (\Throwable $e) {