fix: server env shows not found on application variables input field on autocomplete
This commit is contained in:
parent
e8d985211e
commit
81009c29cf
5 changed files with 91 additions and 5 deletions
|
|
@ -67,6 +67,7 @@ public function availableSharedVariables(): array
|
||||||
'team' => [],
|
'team' => [],
|
||||||
'project' => [],
|
'project' => [],
|
||||||
'environment' => [],
|
'environment' => [],
|
||||||
|
'server' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Early return if no team
|
// Early return if no team
|
||||||
|
|
@ -122,6 +123,46 @@ public function availableSharedVariables(): array
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get server variables
|
||||||
|
$serverUuid = data_get($this->parameters, 'server_uuid');
|
||||||
|
if ($serverUuid) {
|
||||||
|
// If we have a specific server_uuid, show variables for that server
|
||||||
|
$server = \App\Models\Server::where('team_id', $team->id)
|
||||||
|
->where('uuid', $serverUuid)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($server) {
|
||||||
|
try {
|
||||||
|
$this->authorize('view', $server);
|
||||||
|
$result['server'] = $server->environment_variables()
|
||||||
|
->pluck('key')
|
||||||
|
->toArray();
|
||||||
|
} catch (\Illuminate\Auth\Access\AuthorizationException $e) {
|
||||||
|
// User not authorized to view server variables
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// For application environment variables, try to use the application's destination server
|
||||||
|
$applicationUuid = data_get($this->parameters, 'application_uuid');
|
||||||
|
if ($applicationUuid) {
|
||||||
|
$application = \App\Models\Application::whereRelation('environment.project.team', 'id', $team->id)
|
||||||
|
->where('uuid', $applicationUuid)
|
||||||
|
->with('destination.server')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($application && $application->destination && $application->destination->server) {
|
||||||
|
try {
|
||||||
|
$this->authorize('view', $application->destination->server);
|
||||||
|
$result['server'] = $application->destination->server->environment_variables()
|
||||||
|
->pluck('key')
|
||||||
|
->toArray();
|
||||||
|
} catch (\Illuminate\Auth\Access\AuthorizationException $e) {
|
||||||
|
// User not authorized to view server variables
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,7 @@ public function availableSharedVariables(): array
|
||||||
'team' => [],
|
'team' => [],
|
||||||
'project' => [],
|
'project' => [],
|
||||||
'environment' => [],
|
'environment' => [],
|
||||||
|
'server' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Early return if no team
|
// Early return if no team
|
||||||
|
|
@ -259,6 +260,46 @@ public function availableSharedVariables(): array
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get server variables
|
||||||
|
$serverUuid = data_get($this->parameters, 'server_uuid');
|
||||||
|
if ($serverUuid) {
|
||||||
|
// If we have a specific server_uuid, show variables for that server
|
||||||
|
$server = \App\Models\Server::where('team_id', $team->id)
|
||||||
|
->where('uuid', $serverUuid)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($server) {
|
||||||
|
try {
|
||||||
|
$this->authorize('view', $server);
|
||||||
|
$result['server'] = $server->environment_variables()
|
||||||
|
->pluck('key')
|
||||||
|
->toArray();
|
||||||
|
} catch (\Illuminate\Auth\Access\AuthorizationException $e) {
|
||||||
|
// User not authorized to view server variables
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// For application environment variables, try to use the application's destination server
|
||||||
|
$applicationUuid = data_get($this->parameters, 'application_uuid');
|
||||||
|
if ($applicationUuid) {
|
||||||
|
$application = \App\Models\Application::whereRelation('environment.project.team', 'id', $team->id)
|
||||||
|
->where('uuid', $applicationUuid)
|
||||||
|
->with('destination.server')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($application && $application->destination && $application->destination->server) {
|
||||||
|
try {
|
||||||
|
$this->authorize('view', $application->destination->server);
|
||||||
|
$result['server'] = $application->destination->server->environment_variables()
|
||||||
|
->pluck('key')
|
||||||
|
->toArray();
|
||||||
|
} catch (\Illuminate\Auth\Access\AuthorizationException $e) {
|
||||||
|
// User not authorized to view server variables
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
selectedIndex: 0,
|
selectedIndex: 0,
|
||||||
cursorPosition: 0,
|
cursorPosition: 0,
|
||||||
currentScope: null,
|
currentScope: null,
|
||||||
availableScopes: ['team', 'project', 'environment'],
|
availableScopes: ['team', 'project', 'environment', 'server'],
|
||||||
availableVars: @js($availableVars),
|
availableVars: @js($availableVars),
|
||||||
scopeUrls: @js($scopeUrls),
|
scopeUrls: @js($scopeUrls),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
<x-forms.env-var-input placeholder="production" id="value" label="Value" required
|
<x-forms.env-var-input placeholder="production" id="value" label="Value" required
|
||||||
:availableVars="$shared ? [] : $this->availableSharedVariables"
|
:availableVars="$shared ? [] : $this->availableSharedVariables"
|
||||||
:projectUuid="data_get($parameters, 'project_uuid')"
|
:projectUuid="data_get($parameters, 'project_uuid')"
|
||||||
:environmentUuid="data_get($parameters, 'environment_uuid')" />
|
:environmentUuid="data_get($parameters, 'environment_uuid')"
|
||||||
|
:serverUuid="data_get($parameters, 'server_uuid')" />
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (!$shared && !$is_multiline)
|
@if (!$shared && !$is_multiline)
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,8 @@
|
||||||
id="value"
|
id="value"
|
||||||
:availableVars="$this->availableSharedVariables"
|
:availableVars="$this->availableSharedVariables"
|
||||||
:projectUuid="data_get($parameters, 'project_uuid')"
|
:projectUuid="data_get($parameters, 'project_uuid')"
|
||||||
:environmentUuid="data_get($parameters, 'environment_uuid')" />
|
:environmentUuid="data_get($parameters, 'environment_uuid')"
|
||||||
|
:serverUuid="data_get($parameters, 'server_uuid')" />
|
||||||
@if ($is_shared)
|
@if ($is_shared)
|
||||||
<x-forms.input disabled type="password" id="real_value" />
|
<x-forms.input disabled type="password" id="real_value" />
|
||||||
@endif
|
@endif
|
||||||
|
|
@ -129,7 +130,8 @@
|
||||||
id="value"
|
id="value"
|
||||||
:availableVars="$this->availableSharedVariables"
|
:availableVars="$this->availableSharedVariables"
|
||||||
:projectUuid="data_get($parameters, 'project_uuid')"
|
:projectUuid="data_get($parameters, 'project_uuid')"
|
||||||
:environmentUuid="data_get($parameters, 'environment_uuid')" />
|
:environmentUuid="data_get($parameters, 'environment_uuid')"
|
||||||
|
:serverUuid="data_get($parameters, 'server_uuid')" />
|
||||||
@endif
|
@endif
|
||||||
@if ($is_shared)
|
@if ($is_shared)
|
||||||
<x-forms.input :disabled="$is_redis_credential" :required="$is_redis_credential" disabled type="password" id="real_value" />
|
<x-forms.input :disabled="$is_redis_credential" :required="$is_redis_credential" disabled type="password" id="real_value" />
|
||||||
|
|
@ -145,7 +147,8 @@
|
||||||
id="value"
|
id="value"
|
||||||
:availableVars="$this->availableSharedVariables"
|
:availableVars="$this->availableSharedVariables"
|
||||||
:projectUuid="data_get($parameters, 'project_uuid')"
|
:projectUuid="data_get($parameters, 'project_uuid')"
|
||||||
:environmentUuid="data_get($parameters, 'environment_uuid')" />
|
:environmentUuid="data_get($parameters, 'environment_uuid')"
|
||||||
|
:serverUuid="data_get($parameters, 'server_uuid')" />
|
||||||
@if ($is_shared)
|
@if ($is_shared)
|
||||||
<x-forms.input disabled type="password" id="real_value" />
|
<x-forms.input disabled type="password" id="real_value" />
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue