diff --git a/app/Livewire/Project/AddEmpty.php b/app/Livewire/Project/AddEmpty.php index fd976548a..07873c059 100644 --- a/app/Livewire/Project/AddEmpty.php +++ b/app/Livewire/Project/AddEmpty.php @@ -5,6 +5,7 @@ namespace App\Livewire\Project; use App\Models\Project; use Livewire\Attributes\Validate; use Livewire\Component; +use Visus\Cuid2\Cuid2; class AddEmpty extends Component { @@ -22,6 +23,7 @@ class AddEmpty extends Component 'name' => $this->name, 'description' => $this->description, 'team_id' => currentTeam()->id, + 'uuid' => (string) new Cuid2, ]); return redirect()->route('project.show', $project->uuid); diff --git a/app/Livewire/Project/Application/Configuration.php b/app/Livewire/Project/Application/Configuration.php index d4ec8f581..2b781a8c7 100644 --- a/app/Livewire/Project/Application/Configuration.php +++ b/app/Livewire/Project/Application/Configuration.php @@ -20,7 +20,7 @@ class Configuration extends Component if (! $project) { return redirect()->route('dashboard'); } - $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']); + $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']); if (! $environment) { return redirect()->route('dashboard'); } diff --git a/app/Livewire/Project/Application/Deployment/Index.php b/app/Livewire/Project/Application/Deployment/Index.php index 4f761c2cf..b847c40ef 100644 --- a/app/Livewire/Project/Application/Deployment/Index.php +++ b/app/Livewire/Project/Application/Deployment/Index.php @@ -34,7 +34,7 @@ class Index extends Component if (! $project) { return redirect()->route('dashboard'); } - $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']); + $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']); if (! $environment) { return redirect()->route('dashboard'); } diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php index d42bf03d7..bdf62706c 100644 --- a/app/Livewire/Project/Application/Previews.php +++ b/app/Livewire/Project/Application/Previews.php @@ -171,7 +171,7 @@ class Previews extends Component 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $this->deployment_uuid, - 'environment_name' => $this->parameters['environment_name'], + 'environment_uuid' => $this->parameters['environment_uuid'], ]); } catch (\Throwable $e) { return handleError($e, $this); diff --git a/app/Livewire/Project/Application/Rollback.php b/app/Livewire/Project/Application/Rollback.php index 1e58a1458..ff5db1e08 100644 --- a/app/Livewire/Project/Application/Rollback.php +++ b/app/Livewire/Project/Application/Rollback.php @@ -37,7 +37,7 @@ class Rollback extends Component 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $deployment_uuid, - 'environment_name' => $this->parameters['environment_name'], + 'environment_uuid' => $this->parameters['environment_uuid'], ]); } diff --git a/app/Livewire/Project/CloneMe.php b/app/Livewire/Project/CloneMe.php index 4d2bc6589..e2013a50d 100644 --- a/app/Livewire/Project/CloneMe.php +++ b/app/Livewire/Project/CloneMe.php @@ -12,7 +12,7 @@ class CloneMe extends Component { public string $project_uuid; - public string $environment_name; + public string $environment_uuid; public int $project_id; @@ -44,7 +44,7 @@ class CloneMe extends Component { $this->project_uuid = $project_uuid; $this->project = Project::where('uuid', $project_uuid)->firstOrFail(); - $this->environment = $this->project->environments->where('name', $this->environment_name)->first(); + $this->environment = $this->project->environments->where('uuid', $this->environment_uuid)->first(); $this->project_id = $this->project->id; $this->servers = currentTeam()->servers; $this->newName = str($this->project->name.'-clone-'.(string) new Cuid2)->slug(); @@ -89,6 +89,7 @@ class CloneMe extends Component if ($this->environment->name !== 'production') { $project->environments()->create([ 'name' => $this->environment->name, + 'uuid' => (string) new Cuid2, ]); } $environment = $project->environments->where('name', $this->environment->name)->first(); @@ -100,6 +101,7 @@ class CloneMe extends Component $project = $this->project; $environment = $this->project->environments()->create([ 'name' => $this->newName, + 'uuid' => (string) new Cuid2, ]); } $applications = $this->environment->applications; @@ -183,7 +185,7 @@ class CloneMe extends Component return redirect()->route('project.resource.index', [ 'project_uuid' => $project->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, ]); } catch (\Exception $e) { return handleError($e, $this); diff --git a/app/Livewire/Project/Database/Backup/Execution.php b/app/Livewire/Project/Database/Backup/Execution.php index 564091659..4ac3b2e2c 100644 --- a/app/Livewire/Project/Database/Backup/Execution.php +++ b/app/Livewire/Project/Database/Backup/Execution.php @@ -22,7 +22,7 @@ class Execution extends Component if (! $project) { return redirect()->route('dashboard'); } - $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']); + $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']); if (! $environment) { return redirect()->route('dashboard'); } diff --git a/app/Livewire/Project/Database/Backup/Index.php b/app/Livewire/Project/Database/Backup/Index.php index 9ff2f48d5..2df32ec7b 100644 --- a/app/Livewire/Project/Database/Backup/Index.php +++ b/app/Livewire/Project/Database/Backup/Index.php @@ -14,7 +14,7 @@ class Index extends Component if (! $project) { return redirect()->route('dashboard'); } - $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']); + $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']); if (! $environment) { return redirect()->route('dashboard'); } @@ -31,7 +31,7 @@ class Index extends Component ) { return redirect()->route('project.database.configuration', [ 'project_uuid' => $project->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid, ]); } diff --git a/app/Livewire/Project/Database/Configuration.php b/app/Livewire/Project/Database/Configuration.php index e14b27cf6..bbe8e81f6 100644 --- a/app/Livewire/Project/Database/Configuration.php +++ b/app/Livewire/Project/Database/Configuration.php @@ -14,7 +14,7 @@ class Configuration extends Component if (! $project) { return redirect()->route('dashboard'); } - $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']); + $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']); if (! $environment) { return redirect()->route('dashboard'); } diff --git a/app/Livewire/Project/EnvironmentEdit.php b/app/Livewire/Project/EnvironmentEdit.php index f48220b3d..e98b088ec 100644 --- a/app/Livewire/Project/EnvironmentEdit.php +++ b/app/Livewire/Project/EnvironmentEdit.php @@ -23,11 +23,11 @@ class EnvironmentEdit extends Component #[Validate(['nullable', 'string', 'max:255'])] public ?string $description = null; - public function mount(string $project_uuid, string $environment_name) + public function mount(string $project_uuid, string $environment_uuid) { try { $this->project = Project::ownedByCurrentTeam()->where('uuid', $project_uuid)->firstOrFail(); - $this->environment = $this->project->environments()->where('name', $environment_name)->firstOrFail(); + $this->environment = $this->project->environments()->where('uuid', $environment_uuid)->firstOrFail(); $this->syncData(); } catch (\Throwable $e) { return handleError($e, $this); @@ -52,7 +52,10 @@ class EnvironmentEdit extends Component { try { $this->syncData(true); - $this->redirectRoute('project.environment.edit', ['environment_name' => $this->environment->name, 'project_uuid' => $this->project->uuid]); + $this->redirectRoute('project.environment.edit', [ + 'environment_uuid' => $this->environment->uuid, + 'project_uuid' => $this->project->uuid, + ]); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/New/DockerCompose.php b/app/Livewire/Project/New/DockerCompose.php index 199a20cf6..c1361c7ac 100644 --- a/app/Livewire/Project/New/DockerCompose.php +++ b/app/Livewire/Project/New/DockerCompose.php @@ -59,7 +59,7 @@ class DockerCompose extends Component } $project = Project::where('uuid', $this->parameters['project_uuid'])->first(); - $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first(); + $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first(); $destination_uuid = $this->query['destination']; $destination = StandaloneDocker::where('uuid', $destination_uuid)->first(); @@ -96,7 +96,7 @@ class DockerCompose extends Component return redirect()->route('project.service.configuration', [ 'service_uuid' => $service->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid, ]); } catch (\Throwable $e) { diff --git a/app/Livewire/Project/New/DockerImage.php b/app/Livewire/Project/New/DockerImage.php index 417fb2ea0..942924437 100644 --- a/app/Livewire/Project/New/DockerImage.php +++ b/app/Livewire/Project/New/DockerImage.php @@ -45,7 +45,7 @@ class DockerImage extends Component $destination_class = $destination->getMorphClass(); $project = Project::where('uuid', $this->parameters['project_uuid'])->first(); - $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first(); + $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first(); $application = Application::create([ 'name' => 'docker-image-'.new Cuid2, 'repository_project_id' => 0, @@ -69,7 +69,7 @@ class DockerImage extends Component return redirect()->route('project.application.configuration', [ 'application_uuid' => $application->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid, ]); } diff --git a/app/Livewire/Project/New/EmptyProject.php b/app/Livewire/Project/New/EmptyProject.php index 28249b442..54cfc4b4d 100644 --- a/app/Livewire/Project/New/EmptyProject.php +++ b/app/Livewire/Project/New/EmptyProject.php @@ -4,6 +4,7 @@ namespace App\Livewire\Project\New; use App\Models\Project; use Livewire\Component; +use Visus\Cuid2\Cuid2; class EmptyProject extends Component { @@ -12,8 +13,9 @@ class EmptyProject extends Component $project = Project::create([ 'name' => generate_random_name(), 'team_id' => currentTeam()->id, + 'uuid' => (string) new Cuid2, ]); - return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production']); + return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_uuid' => $project->environments->first()->uuid]); } } diff --git a/app/Livewire/Project/New/GithubPrivateRepository.php b/app/Livewire/Project/New/GithubPrivateRepository.php index 2f4f5a25c..370d00555 100644 --- a/app/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Livewire/Project/New/GithubPrivateRepository.php @@ -177,7 +177,7 @@ class GithubPrivateRepository extends Component $destination_class = $destination->getMorphClass(); $project = Project::where('uuid', $this->parameters['project_uuid'])->first(); - $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first(); + $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first(); $application = Application::create([ 'name' => generate_application_name($this->selected_repository_owner.'/'.$this->selected_repository_repo, $this->selected_branch_name), @@ -211,7 +211,7 @@ class GithubPrivateRepository extends Component return redirect()->route('project.application.configuration', [ 'application_uuid' => $application->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid, ]); } catch (\Throwable $e) { diff --git a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index b46c4a794..01b0c9ae8 100644 --- a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -136,7 +136,7 @@ class GithubPrivateRepositoryDeployKey extends Component $this->get_git_source(); $project = Project::where('uuid', $this->parameters['project_uuid'])->first(); - $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first(); + $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first(); if ($this->git_source === 'other') { $application_init = [ 'name' => generate_random_name(), @@ -184,7 +184,7 @@ class GithubPrivateRepositoryDeployKey extends Component return redirect()->route('project.application.configuration', [ 'application_uuid' => $application->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid, ]); } catch (\Throwable $e) { diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php index bd35dccef..2f2331fc0 100644 --- a/app/Livewire/Project/New/PublicGitRepository.php +++ b/app/Livewire/Project/New/PublicGitRepository.php @@ -225,7 +225,7 @@ class PublicGitRepository extends Component $this->validate(); $destination_uuid = $this->query['destination']; $project_uuid = $this->parameters['project_uuid']; - $environment_name = $this->parameters['environment_name']; + $environment_uuid = $this->parameters['environment_uuid']; $destination = StandaloneDocker::where('uuid', $destination_uuid)->first(); if (! $destination) { @@ -237,7 +237,7 @@ class PublicGitRepository extends Component $destination_class = $destination->getMorphClass(); $project = Project::where('uuid', $project_uuid)->first(); - $environment = $project->load(['environments'])->environments->where('name', $environment_name)->first(); + $environment = $project->load(['environments'])->environments->where('uuid', $environment_uuid)->first(); if ($this->build_pack === 'dockercompose' && isDev() && $this->new_compose_services) { $server = $destination->server; @@ -260,7 +260,7 @@ class PublicGitRepository extends Component return redirect()->route('project.service.configuration', [ 'service_uuid' => $service->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid, ]); @@ -319,7 +319,7 @@ class PublicGitRepository extends Component return redirect()->route('project.application.configuration', [ 'application_uuid' => $application->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid, ]); } catch (\Throwable $e) { diff --git a/app/Livewire/Project/New/Select.php b/app/Livewire/Project/New/Select.php index 3dedc11af..7ef688718 100644 --- a/app/Livewire/Project/New/Select.php +++ b/app/Livewire/Project/New/Select.php @@ -61,7 +61,7 @@ class Select extends Component } $projectUuid = data_get($this->parameters, 'project_uuid'); $this->environments = Project::whereUuid($projectUuid)->first()->environments; - $this->selectedEnvironment = data_get($this->parameters, 'environment_name'); + $this->selectedEnvironment = data_get($this->parameters, 'environment_uuid'); } public function render() @@ -73,20 +73,10 @@ class Select extends Component { return redirect()->route('project.resource.create', [ 'project_uuid' => $this->parameters['project_uuid'], - 'environment_name' => $this->selectedEnvironment, + 'environment_uuid' => $this->selectedEnvironment, ]); } - // public function addExistingPostgresql() - // { - // try { - // instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'"); - // $this->dispatch('success', 'Successfully connected to the database.'); - // } catch (\Throwable $e) { - // return handleError($e, $this); - // } - // } - public function loadServices() { $services = get_service_templates(true); @@ -304,7 +294,7 @@ class Select extends Component return redirect()->route('project.resource.create', [ 'project_uuid' => $this->parameters['project_uuid'], - 'environment_name' => $this->parameters['environment_name'], + 'environment_uuid' => $this->parameters['environment_uuid'], 'type' => $this->type, 'destination' => $this->destination_uuid, 'server_id' => $this->server_id, @@ -319,7 +309,7 @@ class Select extends Component } else { return redirect()->route('project.resource.create', [ 'project_uuid' => $this->parameters['project_uuid'], - 'environment_name' => $this->parameters['environment_name'], + 'environment_uuid' => $this->parameters['environment_uuid'], 'type' => $this->type, 'destination' => $this->destination_uuid, 'server_id' => $this->server_id, diff --git a/app/Livewire/Project/New/SimpleDockerfile.php b/app/Livewire/Project/New/SimpleDockerfile.php index 3c7f42329..c3ed6039a 100644 --- a/app/Livewire/Project/New/SimpleDockerfile.php +++ b/app/Livewire/Project/New/SimpleDockerfile.php @@ -46,7 +46,7 @@ CMD ["nginx", "-g", "daemon off;"] $destination_class = $destination->getMorphClass(); $project = Project::where('uuid', $this->parameters['project_uuid'])->first(); - $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first(); + $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first(); $port = get_port_from_dockerfile($this->dockerfile); if (! $port) { @@ -78,7 +78,7 @@ CMD ["nginx", "-g", "daemon off;"] return redirect()->route('project.application.configuration', [ 'application_uuid' => $application->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid, ]); } diff --git a/app/Livewire/Project/Resource/Create.php b/app/Livewire/Project/Resource/Create.php index 9266a57fc..48c396dc0 100644 --- a/app/Livewire/Project/Resource/Create.php +++ b/app/Livewire/Project/Resource/Create.php @@ -25,7 +25,7 @@ class Create extends Component return redirect()->route('dashboard'); } $this->project = $project; - $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first(); + $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first(); if (! $environment) { return redirect()->route('dashboard'); } @@ -57,7 +57,7 @@ class Create extends Component return redirect()->route('project.database.configuration', [ 'project_uuid' => $project->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid, ]); } @@ -106,7 +106,7 @@ class Create extends Component return redirect()->route('project.service.configuration', [ 'service_uuid' => $service->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid, ]); } diff --git a/app/Livewire/Project/Resource/Index.php b/app/Livewire/Project/Resource/Index.php index 283496887..fc394e88f 100644 --- a/app/Livewire/Project/Resource/Index.php +++ b/app/Livewire/Project/Resource/Index.php @@ -41,7 +41,7 @@ class Index extends Component if (! $project) { return redirect()->route('dashboard'); } - $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first(); + $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first(); if (! $environment) { return redirect()->route('dashboard'); } @@ -52,7 +52,7 @@ class Index extends Component if (data_get($application, 'environment.project.uuid')) { $application->hrefLink = route('project.application.configuration', [ 'project_uuid' => data_get($application, 'environment.project.uuid'), - 'environment_name' => data_get($application, 'environment.name'), + 'environment_uuid' => data_get($application, 'environment.uuid'), 'application_uuid' => data_get($application, 'uuid'), ]); } @@ -64,7 +64,7 @@ class Index extends Component if (data_get($postgresql, 'environment.project.uuid')) { $postgresql->hrefLink = route('project.database.configuration', [ 'project_uuid' => data_get($postgresql, 'environment.project.uuid'), - 'environment_name' => data_get($postgresql, 'environment.name'), + 'environment_uuid' => data_get($postgresql, 'environment.uuid'), 'database_uuid' => data_get($postgresql, 'uuid'), ]); } @@ -76,7 +76,7 @@ class Index extends Component if (data_get($redis, 'environment.project.uuid')) { $redis->hrefLink = route('project.database.configuration', [ 'project_uuid' => data_get($redis, 'environment.project.uuid'), - 'environment_name' => data_get($redis, 'environment.name'), + 'environment_uuid' => data_get($redis, 'environment.uuid'), 'database_uuid' => data_get($redis, 'uuid'), ]); } @@ -88,7 +88,7 @@ class Index extends Component if (data_get($mongodb, 'environment.project.uuid')) { $mongodb->hrefLink = route('project.database.configuration', [ 'project_uuid' => data_get($mongodb, 'environment.project.uuid'), - 'environment_name' => data_get($mongodb, 'environment.name'), + 'environment_uuid' => data_get($mongodb, 'environment.uuid'), 'database_uuid' => data_get($mongodb, 'uuid'), ]); } @@ -100,7 +100,7 @@ class Index extends Component if (data_get($mysql, 'environment.project.uuid')) { $mysql->hrefLink = route('project.database.configuration', [ 'project_uuid' => data_get($mysql, 'environment.project.uuid'), - 'environment_name' => data_get($mysql, 'environment.name'), + 'environment_uuid' => data_get($mysql, 'environment.uuid'), 'database_uuid' => data_get($mysql, 'uuid'), ]); } @@ -112,7 +112,7 @@ class Index extends Component if (data_get($mariadb, 'environment.project.uuid')) { $mariadb->hrefLink = route('project.database.configuration', [ 'project_uuid' => data_get($mariadb, 'environment.project.uuid'), - 'environment_name' => data_get($mariadb, 'environment.name'), + 'environment_uuid' => data_get($mariadb, 'environment.uuid'), 'database_uuid' => data_get($mariadb, 'uuid'), ]); } @@ -124,7 +124,7 @@ class Index extends Component if (data_get($keydb, 'environment.project.uuid')) { $keydb->hrefLink = route('project.database.configuration', [ 'project_uuid' => data_get($keydb, 'environment.project.uuid'), - 'environment_name' => data_get($keydb, 'environment.name'), + 'environment_uuid' => data_get($keydb, 'environment.uuid'), 'database_uuid' => data_get($keydb, 'uuid'), ]); } @@ -136,7 +136,7 @@ class Index extends Component if (data_get($dragonfly, 'environment.project.uuid')) { $dragonfly->hrefLink = route('project.database.configuration', [ 'project_uuid' => data_get($dragonfly, 'environment.project.uuid'), - 'environment_name' => data_get($dragonfly, 'environment.name'), + 'environment_uuid' => data_get($dragonfly, 'environment.uuid'), 'database_uuid' => data_get($dragonfly, 'uuid'), ]); } @@ -148,7 +148,7 @@ class Index extends Component if (data_get($clickhouse, 'environment.project.uuid')) { $clickhouse->hrefLink = route('project.database.configuration', [ 'project_uuid' => data_get($clickhouse, 'environment.project.uuid'), - 'environment_name' => data_get($clickhouse, 'environment.name'), + 'environment_uuid' => data_get($clickhouse, 'environment.uuid'), 'database_uuid' => data_get($clickhouse, 'uuid'), ]); } @@ -160,7 +160,7 @@ class Index extends Component if (data_get($service, 'environment.project.uuid')) { $service->hrefLink = route('project.service.configuration', [ 'project_uuid' => data_get($service, 'environment.project.uuid'), - 'environment_name' => data_get($service, 'environment.name'), + 'environment_uuid' => data_get($service, 'environment.uuid'), 'service_uuid' => data_get($service, 'uuid'), ]); $service->status = $service->status(); diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php index a0b4ac2c4..7da48f9fb 100644 --- a/app/Livewire/Project/Shared/Danger.php +++ b/app/Livewire/Project/Shared/Danger.php @@ -20,7 +20,7 @@ class Danger extends Component public $projectUuid; - public $environmentName; + public $environmentUuid; public bool $delete_configurations = true; @@ -39,7 +39,7 @@ class Danger extends Component $parameters = get_route_parameters(); $this->modalId = new Cuid2; $this->projectUuid = data_get($parameters, 'project_uuid'); - $this->environmentName = data_get($parameters, 'environment_name'); + $this->environmentUuid = data_get($parameters, 'environment_uuid'); if ($this->resource === null) { if (isset($parameters['service_uuid'])) { @@ -107,7 +107,7 @@ class Danger extends Component return redirect()->route('project.resource.index', [ 'project_uuid' => $this->projectUuid, - 'environment_name' => $this->environmentName, + 'environment_uuid' => $this->environmentUuid, ]); } catch (\Throwable $e) { return handleError($e, $this); diff --git a/app/Livewire/Project/Shared/Destination.php b/app/Livewire/Project/Shared/Destination.php index c305e817c..e28ff1d5b 100644 --- a/app/Livewire/Project/Shared/Destination.php +++ b/app/Livewire/Project/Shared/Destination.php @@ -85,7 +85,7 @@ class Destination extends Component 'project_uuid' => data_get($this->resource, 'environment.project.uuid'), 'application_uuid' => data_get($this->resource, 'uuid'), 'deployment_uuid' => $deployment_uuid, - 'environment_name' => data_get($this->resource, 'environment.name'), + 'environment_uuid' => data_get($this->resource, 'environment.uuid'), ]); } diff --git a/app/Livewire/Project/Shared/ResourceOperations.php b/app/Livewire/Project/Shared/ResourceOperations.php index e67df6aa9..81313c133 100644 --- a/app/Livewire/Project/Shared/ResourceOperations.php +++ b/app/Livewire/Project/Shared/ResourceOperations.php @@ -15,7 +15,7 @@ class ResourceOperations extends Component public $projectUuid; - public $environmentName; + public $environmentUuid; public $projects; @@ -25,7 +25,7 @@ class ResourceOperations extends Component { $parameters = get_route_parameters(); $this->projectUuid = data_get($parameters, 'project_uuid'); - $this->environmentName = data_get($parameters, 'environment_name'); + $this->environmentUuid = data_get($parameters, 'environment_uuid'); $this->projects = Project::ownedByCurrentTeam()->get(); $this->servers = currentTeam()->servers; } @@ -72,7 +72,7 @@ class ResourceOperations extends Component } $route = route('project.application.configuration', [ 'project_uuid' => $this->projectUuid, - 'environment_name' => $this->environmentName, + 'environment_uuid' => $this->environmentUuid, 'application_uuid' => $new_resource->uuid, ]).'#resource-operations'; @@ -115,7 +115,7 @@ class ResourceOperations extends Component } $route = route('project.database.configuration', [ 'project_uuid' => $this->projectUuid, - 'environment_name' => $this->environmentName, + 'environment_uuid' => $this->environmentUuid, 'database_uuid' => $new_resource->uuid, ]).'#resource-operations'; @@ -141,7 +141,7 @@ class ResourceOperations extends Component $new_resource->parse(); $route = route('project.service.configuration', [ 'project_uuid' => $this->projectUuid, - 'environment_name' => $this->environmentName, + 'environment_uuid' => $this->environmentUuid, 'service_uuid' => $new_resource->uuid, ]).'#resource-operations'; @@ -159,7 +159,7 @@ class ResourceOperations extends Component if ($this->resource->type() === 'application') { $route = route('project.application.configuration', [ 'project_uuid' => $new_environment->project->uuid, - 'environment_name' => $new_environment->name, + 'environment_uuid' => $new_environment->uuid, 'application_uuid' => $this->resource->uuid, ]).'#resource-operations'; @@ -167,7 +167,7 @@ class ResourceOperations extends Component } elseif (str($this->resource->type())->startsWith('standalone-')) { $route = route('project.database.configuration', [ 'project_uuid' => $new_environment->project->uuid, - 'environment_name' => $new_environment->name, + 'environment_uuid' => $new_environment->uuid, 'database_uuid' => $this->resource->uuid, ]).'#resource-operations'; @@ -175,7 +175,7 @@ class ResourceOperations extends Component } elseif ($this->resource->type() === 'service') { $route = route('project.service.configuration', [ 'project_uuid' => $new_environment->project->uuid, - 'environment_name' => $new_environment->name, + 'environment_uuid' => $new_environment->uuid, 'service_uuid' => $this->resource->uuid, ]).'#resource-operations'; diff --git a/app/Livewire/SharedVariables/Environment/Show.php b/app/Livewire/SharedVariables/Environment/Show.php index daf1df212..68aa4f01b 100644 --- a/app/Livewire/SharedVariables/Environment/Show.php +++ b/app/Livewire/SharedVariables/Environment/Show.php @@ -42,8 +42,8 @@ class Show extends Component public function mount() { $this->parameters = get_route_parameters(); - $this->project = Project::ownedByCurrentTeam()->where('uuid', request()->route('project_uuid'))->first(); - $this->environment = $this->project->environments()->where('name', request()->route('environment_name'))->first(); + $this->project = Project::ownedByCurrentTeam()->where('uuid', request()->route('project_uuid'))->firstOrFail(); + $this->environment = $this->project->environments()->where('uuid', request()->route('environment_uuid'))->firstOrFail(); } public function render() diff --git a/app/Livewire/Source/Github/Change.php b/app/Livewire/Source/Github/Change.php index 07cef54f9..0e84756f8 100644 --- a/app/Livewire/Source/Github/Change.php +++ b/app/Livewire/Source/Github/Change.php @@ -116,14 +116,14 @@ class Change extends Component } else { $parameters = data_get(session('from'), 'parameters'); $back = data_get(session('from'), 'back'); - $environment_name = data_get($parameters, 'environment_name'); + $environment_uuid = data_get($parameters, 'environment_uuid'); $project_uuid = data_get($parameters, 'project_uuid'); $type = data_get($parameters, 'type'); $destination = data_get($parameters, 'destination'); session()->forget('from'); return redirect()->route($back, [ - 'environment_name' => $environment_name, + 'environment_uuid' => $environment_uuid, 'project_uuid' => $project_uuid, 'type' => $type, 'destination' => $destination, diff --git a/app/Models/Application.php b/app/Models/Application.php index c284528f1..0e611931b 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -318,7 +318,7 @@ class Application extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.application.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'application_uuid' => data_get($this, 'uuid'), ]); } @@ -331,7 +331,7 @@ class Application extends BaseModel if (data_get($this, 'environment.project.uuid')) { $route = route('project.application.scheduled-tasks', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'application_uuid' => data_get($this, 'uuid'), 'task_uuid' => $task_uuid, ]); diff --git a/app/Models/Project.php b/app/Models/Project.php index f27e6c208..3b50b9b33 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -3,6 +3,7 @@ namespace App\Models; use OpenApi\Attributes as OA; +use Visus\Cuid2\Cuid2; #[OA\Schema( description: 'Project model', @@ -24,8 +25,6 @@ class Project extends BaseModel { protected $guarded = []; - protected $appends = ['default_environment']; - public static function ownedByCurrentTeam() { return Project::whereTeamId(currentTeam()->id)->orderByRaw('LOWER(name)'); @@ -40,6 +39,7 @@ class Project extends BaseModel Environment::create([ 'name' => 'production', 'project_id' => $project->id, + 'uuid' => (string) new Cuid2, ]); }); static::deleting(function ($project) { @@ -140,18 +140,4 @@ class Project extends BaseModel { return $this->postgresqls()->get()->merge($this->redis()->get())->merge($this->mongodbs()->get())->merge($this->mysqls()->get())->merge($this->mariadbs()->get())->merge($this->keydbs()->get())->merge($this->dragonflies()->get())->merge($this->clickhouses()->get()); } - - public function getDefaultEnvironmentAttribute() - { - $default = $this->environments()->where('name', 'production')->first(); - if ($default) { - return $default->name; - } - $default = $this->environments()->get(); - if ($default->count() > 0) { - return $default->sortBy('created_at')->first()->name; - } - - return null; - } } diff --git a/app/Models/Service.php b/app/Models/Service.php index 6d3d2024b..1ba86a95f 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -1132,7 +1132,7 @@ class Service extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.service.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'service_uuid' => data_get($this, 'uuid'), ]); } @@ -1145,7 +1145,7 @@ class Service extends BaseModel if (data_get($this, 'environment.project.uuid')) { $route = route('project.service.scheduled-tasks', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'service_uuid' => data_get($this, 'uuid'), 'task_uuid' => $task_uuid, ]); diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.php index 6d66c6854..4776be4a8 100644 --- a/app/Models/StandaloneClickhouse.php +++ b/app/Models/StandaloneClickhouse.php @@ -169,7 +169,7 @@ class StandaloneClickhouse extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.database.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'database_uuid' => data_get($this, 'uuid'), ]); } diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.php index f7d83f0a3..6eaf81a14 100644 --- a/app/Models/StandaloneDragonfly.php +++ b/app/Models/StandaloneDragonfly.php @@ -174,7 +174,7 @@ class StandaloneDragonfly extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.database.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'database_uuid' => data_get($this, 'uuid'), ]); } diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.php index 083c743d9..b096d4bde 100644 --- a/app/Models/StandaloneKeydb.php +++ b/app/Models/StandaloneKeydb.php @@ -174,7 +174,7 @@ class StandaloneKeydb extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.database.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'database_uuid' => data_get($this, 'uuid'), ]); } diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php index 833dad6c4..0b19d13c7 100644 --- a/app/Models/StandaloneMariadb.php +++ b/app/Models/StandaloneMariadb.php @@ -174,7 +174,7 @@ class StandaloneMariadb extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.database.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'database_uuid' => data_get($this, 'uuid'), ]); } diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php index dd8893180..e4f400952 100644 --- a/app/Models/StandaloneMongodb.php +++ b/app/Models/StandaloneMongodb.php @@ -183,7 +183,7 @@ class StandaloneMongodb extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.database.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'database_uuid' => data_get($this, 'uuid'), ]); } diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php index 710fea1bc..46556c04d 100644 --- a/app/Models/StandaloneMysql.php +++ b/app/Models/StandaloneMysql.php @@ -175,7 +175,7 @@ class StandaloneMysql extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.database.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'database_uuid' => data_get($this, 'uuid'), ]); } diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php index 4a457a6cf..762afe884 100644 --- a/app/Models/StandalonePostgresql.php +++ b/app/Models/StandalonePostgresql.php @@ -170,7 +170,7 @@ class StandalonePostgresql extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.database.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'database_uuid' => data_get($this, 'uuid'), ]); } diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php index 826bb951c..5aeb283a1 100644 --- a/app/Models/StandaloneRedis.php +++ b/app/Models/StandaloneRedis.php @@ -170,7 +170,7 @@ class StandaloneRedis extends BaseModel if (data_get($this, 'environment.project.uuid')) { return route('project.database.configuration', [ 'project_uuid' => data_get($this, 'environment.project.uuid'), - 'environment_name' => data_get($this, 'environment.name'), + 'environment_uuid' => data_get($this, 'environment.uuid'), 'database_uuid' => data_get($this, 'uuid'), ]); } diff --git a/resources/views/components/resources/breadcrumbs.blade.php b/resources/views/components/resources/breadcrumbs.blade.php index f9733f63a..f1c1ca99e 100644 --- a/resources/views/components/resources/breadcrumbs.blade.php +++ b/resources/views/components/resources/breadcrumbs.blade.php @@ -21,7 +21,9 @@