fix: service env orders, application env orders
This commit is contained in:
@@ -53,30 +53,16 @@ class All extends Component
|
|||||||
|
|
||||||
public function sortEnvironmentVariables()
|
public function sortEnvironmentVariables()
|
||||||
{
|
{
|
||||||
if ($this->resource->type() === 'application') {
|
if (! data_get($this->resource, 'settings.is_env_sorting_enabled')) {
|
||||||
$this->resource->load(['environment_variables', 'environment_variables_preview']);
|
if ($this->resource->environment_variables) {
|
||||||
} else {
|
$this->resource->environment_variables = $this->resource->environment_variables->sortBy('order')->values();
|
||||||
$this->resource->load(['environment_variables']);
|
}
|
||||||
|
|
||||||
|
if ($this->resource->environment_variables_preview) {
|
||||||
|
$this->resource->environment_variables_preview = $this->resource->environment_variables_preview->sortBy('order')->values();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sortBy = data_get($this->resource, 'settings.is_env_sorting_enabled') ? 'key' : 'order';
|
|
||||||
|
|
||||||
$sortFunction = function ($variables) use ($sortBy) {
|
|
||||||
if (! $variables) {
|
|
||||||
return $variables;
|
|
||||||
}
|
|
||||||
if ($sortBy === 'key') {
|
|
||||||
return $variables->sortBy(function ($item) {
|
|
||||||
return strtolower($item->key);
|
|
||||||
}, SORT_NATURAL | SORT_FLAG_CASE)->values();
|
|
||||||
} else {
|
|
||||||
return $variables->sortBy('order')->values();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$this->resource->environment_variables = $sortFunction($this->resource->environment_variables);
|
|
||||||
$this->resource->environment_variables_preview = $sortFunction($this->resource->environment_variables_preview);
|
|
||||||
|
|
||||||
$this->getDevView();
|
$this->getDevView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +107,8 @@ class All extends Component
|
|||||||
$this->sortEnvironmentVariables();
|
$this->sortEnvironmentVariables();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
|
} finally {
|
||||||
|
$this->refreshEnvs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1076,12 +1076,12 @@ class Service extends BaseModel
|
|||||||
public function environment_variables(): HasMany
|
public function environment_variables(): HasMany
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->hasMany(EnvironmentVariable::class)->orderByRaw("key LIKE 'SERVICE%' DESC, value ASC");
|
return $this->hasMany(EnvironmentVariable::class)->orderByRaw("LOWER(key) LIKE LOWER('SERVICE%') DESC, LOWER(key) ASC");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function environment_variables_preview(): HasMany
|
public function environment_variables_preview(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->orderBy('key', 'asc');
|
return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->orderByRaw("LOWER(key) LIKE LOWER('SERVICE%') DESC, LOWER(key) ASC");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function workdir()
|
public function workdir()
|
||||||
|
|||||||
Reference in New Issue
Block a user