refactor: Load environment variables based on resource type in sortEnvironmentVariables()
This commit is contained in:
@@ -52,11 +52,18 @@ class All extends Component
|
|||||||
|
|
||||||
public function sortEnvironmentVariables()
|
public function sortEnvironmentVariables()
|
||||||
{
|
{
|
||||||
|
if ($this->resource->type() === 'application') {
|
||||||
$this->resource->load(['environment_variables', 'environment_variables_preview']);
|
$this->resource->load(['environment_variables', 'environment_variables_preview']);
|
||||||
|
} else {
|
||||||
|
$this->resource->load(['environment_variables']);
|
||||||
|
}
|
||||||
|
|
||||||
$sortBy = data_get($this->resource, 'settings.is_env_sorting_enabled') ? 'key' : 'order';
|
$sortBy = data_get($this->resource, 'settings.is_env_sorting_enabled') ? 'key' : 'order';
|
||||||
|
|
||||||
$sortFunction = function ($variables) use ($sortBy) {
|
$sortFunction = function ($variables) use ($sortBy) {
|
||||||
|
if (!$variables) {
|
||||||
|
return $variables;
|
||||||
|
}
|
||||||
if ($sortBy === 'key') {
|
if ($sortBy === 'key') {
|
||||||
return $variables->sortBy(function ($item) {
|
return $variables->sortBy(function ($item) {
|
||||||
return strtolower($item->key);
|
return strtolower($item->key);
|
||||||
|
|||||||
Reference in New Issue
Block a user