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
commit bfd6923ba6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -112,14 +112,20 @@ public function submit()
$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');