mirror of
https://github.com/tiennm99/coolify.git
synced 2026-07-14 03:03:39 +00:00
fix: server env shows not found on application variables input field on autocomplete
This commit is contained in:
@@ -67,6 +67,7 @@ class Add extends Component
|
||||
'team' => [],
|
||||
'project' => [],
|
||||
'environment' => [],
|
||||
'server' => [],
|
||||
];
|
||||
|
||||
// Early return if no team
|
||||
@@ -122,6 +123,46 @@ class Add extends Component
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user