From 1d2e9b69461bafb9a79264981265cabafd2954c9 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:29:33 +0200 Subject: [PATCH] fix is required on shared variables --- app/Livewire/Project/Shared/EnvironmentVariable/Show.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php index 0538a6bdb..53c4374df 100644 --- a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php +++ b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php @@ -112,14 +112,20 @@ class Show extends Component $this->validate(); } - if ($this->env->is_required && str($this->env->real_value)->isEmpty()) { + if (! $this->isSharedVariable && $this->env->is_required && str($this->env->real_value)->isEmpty()) { $oldValue = $this->env->getOriginal('value'); $this->env->value = $oldValue; $this->dispatch('error', 'Required environment variable cannot be empty.'); return; } + $this->serialize(); + + if ($this->isSharedVariable) { + unset($this->env->is_required); + } + $this->env->save(); $this->dispatch('success', 'Environment variable updated.'); $this->dispatch('envsUpdated');