fix: not able to use other shared envs

This commit is contained in:
Andras Bacsai
2024-01-31 13:40:15 +01:00
parent 5f797ec0ae
commit 52fd7ad571
4 changed files with 34 additions and 2 deletions

View File

@@ -71,12 +71,26 @@ class All extends Component
continue;
}
$found->value = $variable;
if (str($found->value)->startsWith('{{') && str($found->value)->endsWith('}}')) {
$type = str($found->value)->after("{{")->before(".")->value;
if (!collect(['team', 'project', 'environment'])->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
return;
}
}
$found->save();
continue;
} else {
$environment = new EnvironmentVariable();
$environment->key = $key;
$environment->value = $variable;
if (str($environment->value)->startsWith('{{') && str($environment->value)->endsWith('}}')) {
$type = str($environment->value)->after("{{")->before(".")->value;
if (!collect(['team', 'project', 'environment'])->contains($type)) {
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
return;
}
}
$environment->is_build_time = false;
$environment->is_preview = $isPreview ? true : false;
switch ($this->resource->type()) {