fix(env): shared variables can not be updated
This commit is contained in:
@@ -77,18 +77,28 @@ class Show extends Component
|
|||||||
public function syncData(bool $toModel = false)
|
public function syncData(bool $toModel = false)
|
||||||
{
|
{
|
||||||
if ($toModel) {
|
if ($toModel) {
|
||||||
$this->validate();
|
if ($this->isSharedVariable) {
|
||||||
|
$this->validate([
|
||||||
|
'key' => 'required|string',
|
||||||
|
'value' => 'nullable',
|
||||||
|
'is_multiline' => 'required|boolean',
|
||||||
|
'is_literal' => 'required|boolean',
|
||||||
|
'is_shown_once' => 'required|boolean',
|
||||||
|
'real_value' => 'nullable',
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$this->validate();
|
||||||
|
$this->env->is_build_time = $this->is_build_time;
|
||||||
|
$this->env->is_required = $this->is_required;
|
||||||
|
$this->env->is_shared = $this->is_shared;
|
||||||
|
}
|
||||||
$this->env->key = $this->key;
|
$this->env->key = $this->key;
|
||||||
$this->env->value = $this->value;
|
$this->env->value = $this->value;
|
||||||
$this->env->is_build_time = $this->is_build_time;
|
|
||||||
$this->env->is_multiline = $this->is_multiline;
|
$this->env->is_multiline = $this->is_multiline;
|
||||||
$this->env->is_literal = $this->is_literal;
|
$this->env->is_literal = $this->is_literal;
|
||||||
$this->env->is_shown_once = $this->is_shown_once;
|
$this->env->is_shown_once = $this->is_shown_once;
|
||||||
$this->env->is_required = $this->is_required;
|
|
||||||
$this->env->is_shared = $this->is_shared;
|
|
||||||
$this->env->save();
|
$this->env->save();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$this->key = $this->env->key;
|
$this->key = $this->env->key;
|
||||||
$this->value = $this->env->value;
|
$this->value = $this->env->value;
|
||||||
$this->is_build_time = $this->env->is_build_time ?? false;
|
$this->is_build_time = $this->env->is_build_time ?? false;
|
||||||
@@ -141,30 +151,15 @@ class Show extends Component
|
|||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($this->isSharedVariable) {
|
|
||||||
$this->validate([
|
|
||||||
'key' => 'required|string',
|
|
||||||
'value' => 'nullable',
|
|
||||||
'is_shown_once' => 'required|boolean',
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
$this->validate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $this->isSharedVariable && $this->is_required && str($this->value)->isEmpty()) {
|
if (! $this->isSharedVariable && $this->is_required && str($this->value)->isEmpty()) {
|
||||||
$oldValue = $this->env->getOriginal('value');
|
$oldValue = $this->env->getOriginal('value');
|
||||||
$this->value = $oldValue;
|
$this->value = $oldValue;
|
||||||
$this->dispatch('error', 'Required environment variable cannot be empty.');
|
$this->dispatch('error', 'Required environment variables cannot be empty.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->serialize();
|
$this->serialize();
|
||||||
|
|
||||||
if ($this->isSharedVariable) {
|
|
||||||
unset($this->is_required);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->syncData(true);
|
$this->syncData(true);
|
||||||
$this->dispatch('success', 'Environment variable updated.');
|
$this->dispatch('success', 'Environment variable updated.');
|
||||||
$this->dispatch('envsUpdated');
|
$this->dispatch('envsUpdated');
|
||||||
|
Reference in New Issue
Block a user