Merge pull request #3947 from peaklabs-dev/fix-is-required

Fix: Required environment variable throws and errors when updating shared variables
This commit is contained in:
Andras Bacsai
2024-10-22 11:15:26 +02:00
committed by GitHub

View File

@@ -112,14 +112,20 @@ class Show extends Component
$this->validate(); $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'); $oldValue = $this->env->getOriginal('value');
$this->env->value = $oldValue; $this->env->value = $oldValue;
$this->dispatch('error', 'Required environment variable cannot be empty.'); $this->dispatch('error', 'Required environment variable cannot be empty.');
return; return;
} }
$this->serialize(); $this->serialize();
if ($this->isSharedVariable) {
unset($this->env->is_required);
}
$this->env->save(); $this->env->save();
$this->dispatch('success', 'Environment variable updated.'); $this->dispatch('success', 'Environment variable updated.');
$this->dispatch('envsUpdated'); $this->dispatch('envsUpdated');