feat: add environment_uuid support and update API documentation
- Introduced `environment_uuid` as a required field in various API endpoints and schemas. - Updated descriptions to clarify that either `environment_name` or `environment_uuid` must be provided. - Modified routes and controller methods to accommodate the new UUID parameter. - Adjusted frontend components to utilize `environment_uuid` for better consistency and clarity. - Removed deprecated fields related to environment handling. This change enhances the API's flexibility in identifying environments, improving overall usability.
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Livewire\Project\Resource;
|
||||
|
||||
use App\Models\Environment;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Component;
|
||||
|
||||
class Index extends Component
|
||||
@@ -12,39 +13,42 @@ class Index extends Component
|
||||
|
||||
public Environment $environment;
|
||||
|
||||
public $applications = [];
|
||||
public Collection $applications;
|
||||
|
||||
public $postgresqls = [];
|
||||
public Collection $postgresqls;
|
||||
|
||||
public $redis = [];
|
||||
public Collection $redis;
|
||||
|
||||
public $mongodbs = [];
|
||||
public Collection $mongodbs;
|
||||
|
||||
public $mysqls = [];
|
||||
public Collection $mysqls;
|
||||
|
||||
public $mariadbs = [];
|
||||
public Collection $mariadbs;
|
||||
|
||||
public $keydbs = [];
|
||||
public Collection $keydbs;
|
||||
|
||||
public $dragonflies = [];
|
||||
public Collection $dragonflies;
|
||||
|
||||
public $clickhouses = [];
|
||||
public Collection $clickhouses;
|
||||
|
||||
public $services = [];
|
||||
public Collection $services;
|
||||
|
||||
public array $parameters;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->applications = $this->postgresqls = $this->redis = $this->mongodbs = $this->mysqls = $this->mariadbs = $this->keydbs = $this->dragonflies = $this->clickhouses = $this->services = collect();
|
||||
$this->parameters = get_route_parameters();
|
||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||
if (! $project) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
$environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first();
|
||||
if (! $environment) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
$project = currentTeam()
|
||||
->projects()
|
||||
->select('id', 'uuid', 'team_id', 'name')
|
||||
->where('uuid', request()->route('project_uuid'))
|
||||
->firstOrFail();
|
||||
$environment = $project->environments()
|
||||
->select('id', 'uuid', 'name', 'project_id')
|
||||
->where('uuid', request()->route('environment_uuid'))
|
||||
->firstOrFail();
|
||||
|
||||
$this->project = $project;
|
||||
$this->environment = $environment->loadCount([
|
||||
'applications',
|
||||
@@ -69,9 +73,9 @@ class Index extends Component
|
||||
])->get()->sortBy('name');
|
||||
$this->applications = $this->applications->map(function ($application) {
|
||||
$application->hrefLink = route('project.application.configuration', [
|
||||
'project_uuid' => data_get($application, 'environment.project.uuid'),
|
||||
'environment_uuid' => data_get($application, 'environment.uuid'),
|
||||
'application_uuid' => data_get($application, 'uuid'),
|
||||
'project_uuid' => data_get($application, 'environment.project.uuid'),
|
||||
'environment_uuid' => data_get($application, 'environment.uuid'),
|
||||
'application_uuid' => data_get($application, 'uuid'),
|
||||
]);
|
||||
|
||||
return $application;
|
||||
@@ -89,14 +93,6 @@ class Index extends Component
|
||||
'clickhouses' => 'clickhouses',
|
||||
];
|
||||
|
||||
// Load all server-related data first to prevent duplicate queries
|
||||
$serverData = $this->environment->applications()
|
||||
->with(['destination.server.settings'])
|
||||
->get()
|
||||
->pluck('destination.server')
|
||||
->filter()
|
||||
->unique('id');
|
||||
|
||||
foreach ($databaseTypes as $property => $relation) {
|
||||
$this->{$property} = $this->environment->{$relation}()->with([
|
||||
'tags',
|
||||
@@ -108,6 +104,7 @@ class Index extends Component
|
||||
'database_uuid' => $db->uuid,
|
||||
'environment_uuid' => data_get($this->environment, 'uuid'),
|
||||
]);
|
||||
|
||||
return $db;
|
||||
});
|
||||
}
|
||||
@@ -119,10 +116,11 @@ class Index extends Component
|
||||
])->get()->sortBy('name');
|
||||
$this->services = $this->services->map(function ($service) {
|
||||
$service->hrefLink = route('project.service.configuration', [
|
||||
'project_uuid' => data_get($service, 'environment.project.uuid'),
|
||||
'environment_uuid' => data_get($service, 'environment.uuid'),
|
||||
'service_uuid' => data_get($service, 'uuid'),
|
||||
'project_uuid' => data_get($service, 'environment.project.uuid'),
|
||||
'environment_uuid' => data_get($service, 'environment.uuid'),
|
||||
'service_uuid' => data_get($service, 'uuid'),
|
||||
]);
|
||||
|
||||
return $service;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user