diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php index 6e7370bb37..1e6a3d2469 100644 --- a/app/Http/Controllers/Api/ApplicationsController.php +++ b/app/Http/Controllers/Api/ApplicationsController.php @@ -117,11 +117,12 @@ public function applications(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['project_uuid', 'server_uuid', 'environment_name', 'git_repository', 'git_branch', 'build_pack', 'ports_exposes'], + required: ['project_uuid', 'server_uuid', 'environment_name', 'environment_uuid', 'git_repository', 'git_branch', 'build_pack', 'ports_exposes'], properties: [ 'project_uuid' => ['type' => 'string', 'description' => 'The project UUID.'], 'server_uuid' => ['type' => 'string', 'description' => 'The server UUID.'], - 'environment_name' => ['type' => 'string', 'description' => 'The environment name.'], + 'environment_name' => ['type' => 'string', 'description' => 'The environment name. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.'], 'git_repository' => ['type' => 'string', 'description' => 'The git repository URL.'], 'git_branch' => ['type' => 'string', 'description' => 'The git branch.'], 'build_pack' => ['type' => 'string', 'enum' => ['nixpacks', 'static', 'dockerfile', 'dockercompose'], 'description' => 'The build pack type.'], @@ -223,11 +224,12 @@ public function create_public_application(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['project_uuid', 'server_uuid', 'environment_name', 'github_app_uuid', 'git_repository', 'git_branch', 'build_pack', 'ports_exposes'], + required: ['project_uuid', 'server_uuid', 'environment_name', 'environment_uuid', 'github_app_uuid', 'git_repository', 'git_branch', 'build_pack', 'ports_exposes'], properties: [ 'project_uuid' => ['type' => 'string', 'description' => 'The project UUID.'], 'server_uuid' => ['type' => 'string', 'description' => 'The server UUID.'], - 'environment_name' => ['type' => 'string', 'description' => 'The environment name.'], + 'environment_name' => ['type' => 'string', 'description' => 'The environment name. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.'], 'github_app_uuid' => ['type' => 'string', 'description' => 'The Github App UUID.'], 'git_repository' => ['type' => 'string', 'description' => 'The git repository URL.'], 'git_branch' => ['type' => 'string', 'description' => 'The git branch.'], @@ -329,11 +331,12 @@ public function create_private_gh_app_application(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['project_uuid', 'server_uuid', 'environment_name', 'private_key_uuid', 'git_repository', 'git_branch', 'build_pack', 'ports_exposes'], + required: ['project_uuid', 'server_uuid', 'environment_name', 'environment_uuid', 'private_key_uuid', 'git_repository', 'git_branch', 'build_pack', 'ports_exposes'], properties: [ 'project_uuid' => ['type' => 'string', 'description' => 'The project UUID.'], 'server_uuid' => ['type' => 'string', 'description' => 'The server UUID.'], - 'environment_name' => ['type' => 'string', 'description' => 'The environment name.'], + 'environment_name' => ['type' => 'string', 'description' => 'The environment name. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.'], 'private_key_uuid' => ['type' => 'string', 'description' => 'The private key UUID.'], 'git_repository' => ['type' => 'string', 'description' => 'The git repository URL.'], 'git_branch' => ['type' => 'string', 'description' => 'The git branch.'], @@ -435,11 +438,12 @@ public function create_private_deploy_key_application(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['project_uuid', 'server_uuid', 'environment_name', 'dockerfile'], + required: ['project_uuid', 'server_uuid', 'environment_name', 'environment_uuid', 'dockerfile'], properties: [ 'project_uuid' => ['type' => 'string', 'description' => 'The project UUID.'], 'server_uuid' => ['type' => 'string', 'description' => 'The server UUID.'], - 'environment_name' => ['type' => 'string', 'description' => 'The environment name.'], + 'environment_name' => ['type' => 'string', 'description' => 'The environment name. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.'], 'dockerfile' => ['type' => 'string', 'description' => 'The Dockerfile content.'], 'build_pack' => ['type' => 'string', 'enum' => ['nixpacks', 'static', 'dockerfile', 'dockercompose'], 'description' => 'The build pack type.'], 'ports_exposes' => ['type' => 'string', 'description' => 'The ports to expose.'], @@ -525,11 +529,12 @@ public function create_dockerfile_application(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['project_uuid', 'server_uuid', 'environment_name', 'docker_registry_image_name', 'ports_exposes'], + required: ['project_uuid', 'server_uuid', 'environment_name', 'environment_uuid', 'docker_registry_image_name', 'ports_exposes'], properties: [ 'project_uuid' => ['type' => 'string', 'description' => 'The project UUID.'], 'server_uuid' => ['type' => 'string', 'description' => 'The server UUID.'], - 'environment_name' => ['type' => 'string', 'description' => 'The environment name.'], + 'environment_name' => ['type' => 'string', 'description' => 'The environment name. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.'], 'docker_registry_image_name' => ['type' => 'string', 'description' => 'The docker registry image name.'], 'docker_registry_image_tag' => ['type' => 'string', 'description' => 'The docker registry image tag.'], 'ports_exposes' => ['type' => 'string', 'description' => 'The ports to expose.'], @@ -612,11 +617,12 @@ public function create_dockerimage_application(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['project_uuid', 'server_uuid', 'environment_name', 'docker_compose_raw'], + required: ['project_uuid', 'server_uuid', 'environment_name', 'environment_uuid', 'docker_compose_raw'], properties: [ 'project_uuid' => ['type' => 'string', 'description' => 'The project UUID.'], 'server_uuid' => ['type' => 'string', 'description' => 'The server UUID.'], - 'environment_name' => ['type' => 'string', 'description' => 'The environment name.'], + 'environment_name' => ['type' => 'string', 'description' => 'The environment name. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.'], 'docker_compose_raw' => ['type' => 'string', 'description' => 'The Docker Compose raw content.'], 'destination_uuid' => ['type' => 'string', 'description' => 'The destination UUID if the server has more than one destinations.'], 'name' => ['type' => 'string', 'description' => 'The application name.'], @@ -650,7 +656,7 @@ public function create_dockercompose_application(Request $request) private function create_application(Request $request, $type) { - $allowedFields = ['project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'private_key_uuid', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'redirect', 'github_app_uuid', 'instant_deploy', 'dockerfile', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'watch_paths', 'use_build_server', 'static_image', 'custom_nginx_configuration']; + $allowedFields = ['project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'private_key_uuid', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'redirect', 'github_app_uuid', 'instant_deploy', 'dockerfile', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'watch_paths', 'use_build_server', 'static_image', 'custom_nginx_configuration']; $teamId = getTeamIdFromToken(); if (is_null($teamId)) { return invalidTokenResponse(); @@ -664,7 +670,8 @@ private function create_application(Request $request, $type) 'name' => 'string|max:255', 'description' => 'string|nullable', 'project_uuid' => 'string|required', - 'environment_name' => 'string|required', + 'environment_name' => 'string|nullable', + 'environment_uuid' => 'string|nullable', 'server_uuid' => 'string|required', 'destination_uuid' => 'string', ]); @@ -684,6 +691,11 @@ private function create_application(Request $request, $type) ], 422); } + $environmentUuid = $request->environment_uuid; + $environmentName = $request->environment_name; + if (blank($environmentUuid) && blank($environmentName)) { + return response()->json(['message' => 'You need to provide at least one of environment_name or environment_uuid.'], 422); + } $serverUuid = $request->server_uuid; $fqdn = $request->domains; $instantDeploy = $request->instant_deploy; @@ -716,7 +728,10 @@ private function create_application(Request $request, $type) if (! $project) { return response()->json(['message' => 'Project not found.'], 404); } - $environment = $project->environments()->where('name', $request->environment_name)->first(); + $environment = $project->environments()->where('name', $environmentName)->first(); + if (! $environment) { + $environment = $project->environments()->where('uuid', $environmentUuid)->first(); + } if (! $environment) { return response()->json(['message' => 'Environment not found.'], 404); } @@ -733,12 +748,6 @@ private function create_application(Request $request, $type) } $destination = $destinations->first(); if ($type === 'public') { - if (! $request->has('name')) { - $request->offsetSet('name', generate_application_name($request->git_repository, $request->git_branch)); - } - if ($request->build_pack === 'dockercompose') { - $request->offsetSet('ports_exposes', '80'); - } $validationRules = [ 'git_repository' => 'string|required', 'git_branch' => 'string|required', @@ -748,7 +757,7 @@ private function create_application(Request $request, $type) 'docker_compose_raw' => 'string|nullable', 'docker_compose_domains' => 'array|nullable', ]; - $validationRules = array_merge($validationRules, sharedDataApplications()); + $validationRules = array_merge(sharedDataApplications(), $validationRules); $validator = customApiValidator($request->all(), $validationRules); if ($validator->fails()) { return response()->json([ @@ -756,6 +765,12 @@ private function create_application(Request $request, $type) 'errors' => $validator->errors(), ], 422); } + if (! $request->has('name')) { + $request->offsetSet('name', generate_application_name($request->git_repository, $request->git_branch)); + } + if ($request->build_pack === 'dockercompose') { + $request->offsetSet('ports_exposes', '80'); + } $return = $this->validateDataApplications($request, $server); if ($return instanceof \Illuminate\Http\JsonResponse) { @@ -820,12 +835,6 @@ private function create_application(Request $request, $type) 'domains' => data_get($application, 'domains'), ])); } elseif ($type === 'private-gh-app') { - if (! $request->has('name')) { - $request->offsetSet('name', generate_application_name($request->git_repository, $request->git_branch)); - } - if ($request->build_pack === 'dockercompose') { - $request->offsetSet('ports_exposes', '80'); - } $validationRules = [ 'git_repository' => 'string|required', 'git_branch' => 'string|required', @@ -836,7 +845,7 @@ private function create_application(Request $request, $type) 'docker_compose_location' => 'string', 'docker_compose_raw' => 'string|nullable', ]; - $validationRules = array_merge($validationRules, sharedDataApplications()); + $validationRules = array_merge(sharedDataApplications(), $validationRules); $validator = customApiValidator($request->all(), $validationRules); if ($validator->fails()) { @@ -845,6 +854,14 @@ private function create_application(Request $request, $type) 'errors' => $validator->errors(), ], 422); } + + if (! $request->has('name')) { + $request->offsetSet('name', generate_application_name($request->git_repository, $request->git_branch)); + } + if ($request->build_pack === 'dockercompose') { + $request->offsetSet('ports_exposes', '80'); + } + $return = $this->validateDataApplications($request, $server); if ($return instanceof \Illuminate\Http\JsonResponse) { return $return; @@ -919,12 +936,6 @@ private function create_application(Request $request, $type) 'domains' => data_get($application, 'domains'), ])); } elseif ($type === 'private-deploy-key') { - if (! $request->has('name')) { - $request->offsetSet('name', generate_application_name($request->git_repository, $request->git_branch)); - } - if ($request->build_pack === 'dockercompose') { - $request->offsetSet('ports_exposes', '80'); - } $validationRules = [ 'git_repository' => 'string|required', @@ -937,7 +948,7 @@ private function create_application(Request $request, $type) 'docker_compose_raw' => 'string|nullable', ]; - $validationRules = array_merge($validationRules, sharedDataApplications()); + $validationRules = array_merge(sharedDataApplications(), $validationRules); $validator = customApiValidator($request->all(), $validationRules); if ($validator->fails()) { @@ -946,6 +957,13 @@ private function create_application(Request $request, $type) 'errors' => $validator->errors(), ], 422); } + if (! $request->has('name')) { + $request->offsetSet('name', generate_application_name($request->git_repository, $request->git_branch)); + } + if ($request->build_pack === 'dockercompose') { + $request->offsetSet('ports_exposes', '80'); + } + $return = $this->validateDataApplications($request, $server); if ($return instanceof \Illuminate\Http\JsonResponse) { return $return; @@ -1015,14 +1033,10 @@ private function create_application(Request $request, $type) 'domains' => data_get($application, 'domains'), ])); } elseif ($type === 'dockerfile') { - if (! $request->has('name')) { - $request->offsetSet('name', 'dockerfile-'.new Cuid2); - } - $validationRules = [ 'dockerfile' => 'string|required', ]; - $validationRules = array_merge($validationRules, sharedDataApplications()); + $validationRules = array_merge(sharedDataApplications(), $validationRules); $validator = customApiValidator($request->all(), $validationRules); if ($validator->fails()) { @@ -1031,6 +1045,10 @@ private function create_application(Request $request, $type) 'errors' => $validator->errors(), ], 422); } + if (! $request->has('name')) { + $request->offsetSet('name', 'dockerfile-'.new Cuid2); + } + $return = $this->validateDataApplications($request, $server); if ($return instanceof \Illuminate\Http\JsonResponse) { return $return; @@ -1100,15 +1118,12 @@ private function create_application(Request $request, $type) 'domains' => data_get($application, 'domains'), ])); } elseif ($type === 'dockerimage') { - if (! $request->has('name')) { - $request->offsetSet('name', 'docker-image-'.new Cuid2); - } $validationRules = [ 'docker_registry_image_name' => 'string|required', 'docker_registry_image_tag' => 'string', 'ports_exposes' => 'string|regex:/^(\d+)(,\d+)*$/|required', ]; - $validationRules = array_merge($validationRules, sharedDataApplications()); + $validationRules = array_merge(sharedDataApplications(), $validationRules); $validator = customApiValidator($request->all(), $validationRules); if ($validator->fails()) { @@ -1117,6 +1132,9 @@ private function create_application(Request $request, $type) 'errors' => $validator->errors(), ], 422); } + if (! $request->has('name')) { + $request->offsetSet('name', 'docker-image-'.new Cuid2); + } $return = $this->validateDataApplications($request, $server); if ($return instanceof \Illuminate\Http\JsonResponse) { return $return; @@ -1164,7 +1182,7 @@ private function create_application(Request $request, $type) 'domains' => data_get($application, 'domains'), ])); } elseif ($type === 'dockercompose') { - $allowedFields = ['project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'instant_deploy', 'docker_compose_raw']; + $allowedFields = ['project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'instant_deploy', 'docker_compose_raw']; $extraFields = array_diff(array_keys($request->all()), $allowedFields); if ($validator->fails() || ! empty($extraFields)) { @@ -1186,7 +1204,7 @@ private function create_application(Request $request, $type) $validationRules = [ 'docker_compose_raw' => 'string|required', ]; - $validationRules = array_merge($validationRules, sharedDataApplications()); + $validationRules = array_merge(sharedDataApplications(), $validationRules); $validator = customApiValidator($request->all(), $validationRules); if ($validator->fails()) { @@ -1554,7 +1572,7 @@ public function update_by_uuid(Request $request) 'docker_compose_custom_build_command' => 'string|nullable', 'custom_nginx_configuration' => 'string|nullable', ]; - $validationRules = array_merge($validationRules, sharedDataApplications()); + $validationRules = array_merge(sharedDataApplications(), $validationRules); $validator = customApiValidator($request->all(), $validationRules); // Validate ports_exposes diff --git a/app/Http/Controllers/Api/DatabasesController.php b/app/Http/Controllers/Api/DatabasesController.php index 917171e5cd..504665f6a8 100644 --- a/app/Http/Controllers/Api/DatabasesController.php +++ b/app/Http/Controllers/Api/DatabasesController.php @@ -523,11 +523,12 @@ public function update_by_uuid(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'], properties: [ 'server_uuid' => ['type' => 'string', 'description' => 'UUID of the server'], 'project_uuid' => ['type' => 'string', 'description' => 'UUID of the project'], - 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment'], + 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.'], 'postgres_user' => ['type' => 'string', 'description' => 'PostgreSQL user'], 'postgres_password' => ['type' => 'string', 'description' => 'PostgreSQL password'], 'postgres_db' => ['type' => 'string', 'description' => 'PostgreSQL database'], @@ -589,11 +590,12 @@ public function create_database_postgresql(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'], properties: [ 'server_uuid' => ['type' => 'string', 'description' => 'UUID of the server'], 'project_uuid' => ['type' => 'string', 'description' => 'UUID of the project'], - 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment'], + 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.'], 'destination_uuid' => ['type' => 'string', 'description' => 'UUID of the destination if the server has multiple destinations'], 'clickhouse_admin_user' => ['type' => 'string', 'description' => 'Clickhouse admin user'], 'clickhouse_admin_password' => ['type' => 'string', 'description' => 'Clickhouse admin password'], @@ -651,11 +653,12 @@ public function create_database_clickhouse(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'], properties: [ 'server_uuid' => ['type' => 'string', 'description' => 'UUID of the server'], 'project_uuid' => ['type' => 'string', 'description' => 'UUID of the project'], - 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment'], + 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.'], 'destination_uuid' => ['type' => 'string', 'description' => 'UUID of the destination if the server has multiple destinations'], 'dragonfly_password' => ['type' => 'string', 'description' => 'DragonFly password'], 'name' => ['type' => 'string', 'description' => 'Name of the database'], @@ -712,11 +715,12 @@ public function create_database_dragonfly(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'], properties: [ 'server_uuid' => ['type' => 'string', 'description' => 'UUID of the server'], 'project_uuid' => ['type' => 'string', 'description' => 'UUID of the project'], - 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment'], + 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.'], 'destination_uuid' => ['type' => 'string', 'description' => 'UUID of the destination if the server has multiple destinations'], 'redis_password' => ['type' => 'string', 'description' => 'Redis password'], 'redis_conf' => ['type' => 'string', 'description' => 'Redis conf'], @@ -774,11 +778,12 @@ public function create_database_redis(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'], properties: [ 'server_uuid' => ['type' => 'string', 'description' => 'UUID of the server'], 'project_uuid' => ['type' => 'string', 'description' => 'UUID of the project'], - 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment'], + 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.'], 'destination_uuid' => ['type' => 'string', 'description' => 'UUID of the destination if the server has multiple destinations'], 'keydb_password' => ['type' => 'string', 'description' => 'KeyDB password'], 'keydb_conf' => ['type' => 'string', 'description' => 'KeyDB conf'], @@ -836,11 +841,12 @@ public function create_database_keydb(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'], properties: [ 'server_uuid' => ['type' => 'string', 'description' => 'UUID of the server'], 'project_uuid' => ['type' => 'string', 'description' => 'UUID of the project'], - 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment'], + 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.'], 'destination_uuid' => ['type' => 'string', 'description' => 'UUID of the destination if the server has multiple destinations'], 'mariadb_conf' => ['type' => 'string', 'description' => 'MariaDB conf'], 'mariadb_root_password' => ['type' => 'string', 'description' => 'MariaDB root password'], @@ -901,11 +907,12 @@ public function create_database_mariadb(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'], properties: [ 'server_uuid' => ['type' => 'string', 'description' => 'UUID of the server'], 'project_uuid' => ['type' => 'string', 'description' => 'UUID of the project'], - 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment'], + 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.'], 'destination_uuid' => ['type' => 'string', 'description' => 'UUID of the destination if the server has multiple destinations'], 'mysql_root_password' => ['type' => 'string', 'description' => 'MySQL root password'], 'mysql_password' => ['type' => 'string', 'description' => 'MySQL password'], @@ -966,11 +973,12 @@ public function create_database_mysql(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid'], properties: [ 'server_uuid' => ['type' => 'string', 'description' => 'UUID of the server'], 'project_uuid' => ['type' => 'string', 'description' => 'UUID of the project'], - 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment'], + 'environment_name' => ['type' => 'string', 'description' => 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.'], 'destination_uuid' => ['type' => 'string', 'description' => 'UUID of the destination if the server has multiple destinations'], 'mongo_conf' => ['type' => 'string', 'description' => 'MongoDB conf'], 'mongo_initdb_root_username' => ['type' => 'string', 'description' => 'MongoDB initdb root username'], @@ -1013,7 +1021,7 @@ public function create_database_mongodb(Request $request) public function create_database(Request $request, NewDatabaseTypes $type) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'postgres_user', 'postgres_password', 'postgres_db', 'postgres_initdb_args', 'postgres_host_auth_method', 'postgres_conf', 'clickhouse_admin_user', 'clickhouse_admin_password', 'dragonfly_password', 'redis_password', 'redis_conf', 'keydb_password', 'keydb_conf', 'mariadb_conf', 'mariadb_root_password', 'mariadb_user', 'mariadb_password', 'mariadb_database', 'mongo_conf', 'mongo_initdb_root_username', 'mongo_initdb_root_password', 'mongo_initdb_database', 'mysql_root_password', 'mysql_password', 'mysql_user', 'mysql_database', 'mysql_conf']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'postgres_user', 'postgres_password', 'postgres_db', 'postgres_initdb_args', 'postgres_host_auth_method', 'postgres_conf', 'clickhouse_admin_user', 'clickhouse_admin_password', 'dragonfly_password', 'redis_password', 'redis_conf', 'keydb_password', 'keydb_conf', 'mariadb_conf', 'mariadb_root_password', 'mariadb_user', 'mariadb_password', 'mariadb_database', 'mongo_conf', 'mongo_initdb_root_username', 'mongo_initdb_root_password', 'mongo_initdb_database', 'mysql_root_password', 'mysql_password', 'mysql_user', 'mysql_database', 'mysql_conf']; $teamId = getTeamIdFromToken(); if (is_null($teamId)) { @@ -1039,6 +1047,11 @@ public function create_database(Request $request, NewDatabaseTypes $type) 'errors' => $errors, ], 422); } + $environmentUuid = $request->environment_uuid; + $environmentName = $request->environment_name; + if (blank($environmentUuid) && blank($environmentName)) { + return response()->json(['message' => 'You need to provide at least one of environment_name or environment_uuid.'], 422); + } $serverUuid = $request->server_uuid; $instantDeploy = $request->instant_deploy ?? false; if ($request->is_public && ! $request->public_port) { @@ -1048,9 +1061,12 @@ public function create_database(Request $request, NewDatabaseTypes $type) if (! $project) { return response()->json(['message' => 'Project not found.'], 404); } - $environment = $project->environments()->where('name', $request->environment_name)->first(); + $environment = $project->environments()->where('name', $environmentName)->first(); + if (! $environment) { + $environment = $project->environments()->where('uuid', $environmentUuid)->first(); + } if (! $environment) { - return response()->json(['message' => 'Environment not found.'], 404); + return response()->json(['message' => 'You need to provide a valid environment_name or environment_uuid.'], 422); } $server = Server::whereTeamId($teamId)->whereUuid($serverUuid)->first(); if (! $server) { @@ -1074,7 +1090,8 @@ public function create_database(Request $request, NewDatabaseTypes $type) 'description' => 'string|nullable', 'image' => 'string', 'project_uuid' => 'string|required', - 'environment_name' => 'string|required', + 'environment_name' => 'string|nullable', + 'environment_uuid' => 'string|nullable', 'server_uuid' => 'string|required', 'destination_uuid' => 'string', 'is_public' => 'boolean', @@ -1105,7 +1122,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) } } if ($type === NewDatabaseTypes::POSTGRESQL) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'postgres_user', 'postgres_password', 'postgres_db', 'postgres_initdb_args', 'postgres_host_auth_method', 'postgres_conf']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'postgres_user', 'postgres_password', 'postgres_db', 'postgres_initdb_args', 'postgres_host_auth_method', 'postgres_conf']; $validator = customApiValidator($request->all(), [ 'postgres_user' => 'string', 'postgres_password' => 'string', @@ -1164,7 +1181,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) return response()->json(serializeApiResponse($payload))->setStatusCode(201); } elseif ($type === NewDatabaseTypes::MARIADB) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'mariadb_conf', 'mariadb_root_password', 'mariadb_user', 'mariadb_password', 'mariadb_database']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'mariadb_conf', 'mariadb_root_password', 'mariadb_user', 'mariadb_password', 'mariadb_database']; $validator = customApiValidator($request->all(), [ 'clickhouse_admin_user' => 'string', 'clickhouse_admin_password' => 'string', @@ -1220,7 +1237,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) return response()->json(serializeApiResponse($payload))->setStatusCode(201); } elseif ($type === NewDatabaseTypes::MYSQL) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'mysql_root_password', 'mysql_password', 'mysql_user', 'mysql_database', 'mysql_conf']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'mysql_root_password', 'mysql_password', 'mysql_user', 'mysql_database', 'mysql_conf']; $validator = customApiValidator($request->all(), [ 'mysql_root_password' => 'string', 'mysql_password' => 'string', @@ -1279,7 +1296,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) return response()->json(serializeApiResponse($payload))->setStatusCode(201); } elseif ($type === NewDatabaseTypes::REDIS) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'redis_password', 'redis_conf']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'redis_password', 'redis_conf']; $validator = customApiValidator($request->all(), [ 'redis_password' => 'string', 'redis_conf' => 'string', @@ -1335,7 +1352,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) return response()->json(serializeApiResponse($payload))->setStatusCode(201); } elseif ($type === NewDatabaseTypes::DRAGONFLY) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'dragonfly_password']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'dragonfly_password']; $validator = customApiValidator($request->all(), [ 'dragonfly_password' => 'string', ]); @@ -1365,7 +1382,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) 'uuid' => $database->uuid, ]))->setStatusCode(201); } elseif ($type === NewDatabaseTypes::KEYDB) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'keydb_password', 'keydb_conf']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'keydb_password', 'keydb_conf']; $validator = customApiValidator($request->all(), [ 'keydb_password' => 'string', 'keydb_conf' => 'string', @@ -1421,7 +1438,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) return response()->json(serializeApiResponse($payload))->setStatusCode(201); } elseif ($type === NewDatabaseTypes::CLICKHOUSE) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'clickhouse_admin_user', 'clickhouse_admin_password']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'clickhouse_admin_user', 'clickhouse_admin_password']; $validator = customApiValidator($request->all(), [ 'clickhouse_admin_user' => 'string', 'clickhouse_admin_password' => 'string', @@ -1457,7 +1474,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) return response()->json(serializeApiResponse($payload))->setStatusCode(201); } elseif ($type === NewDatabaseTypes::MONGODB) { - $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'mongo_conf', 'mongo_initdb_root_username', 'mongo_initdb_root_password', 'mongo_initdb_database']; + $allowedFields = ['name', 'description', 'image', 'public_port', 'is_public', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'mongo_conf', 'mongo_initdb_root_username', 'mongo_initdb_root_password', 'mongo_initdb_database']; $validator = customApiValidator($request->all(), [ 'mongo_conf' => 'string', 'mongo_initdb_root_username' => 'string', diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php index 1d89c82edf..15795e2419 100644 --- a/app/Http/Controllers/Api/ProjectController.php +++ b/app/Http/Controllers/Api/ProjectController.php @@ -102,16 +102,16 @@ public function project_by_uuid(Request $request) #[OA\Get( summary: 'Environment', - description: 'Get environment by name.', - path: '/projects/{uuid}/{environment_name}', - operationId: 'get-environment-by-name', + description: 'Get environment by name or UUID.', + path: '/projects/{uuid}/{environment_name_or_uuid}', + operationId: 'get-environment-by-name-or-uuid', security: [ ['bearerAuth' => []], ], tags: ['Projects'], parameters: [ new OA\Parameter(name: 'uuid', in: 'path', required: true, description: 'Project UUID', schema: new OA\Schema(type: 'string')), - new OA\Parameter(name: 'environment_name', in: 'path', required: true, description: 'Environment name', schema: new OA\Schema(type: 'string')), + new OA\Parameter(name: 'environment_name_or_uuid', in: 'path', required: true, description: 'Environment name or UUID', schema: new OA\Schema(type: 'string')), ], responses: [ new OA\Response( @@ -141,14 +141,17 @@ public function environment_details(Request $request) if (! $request->uuid) { return response()->json(['message' => 'UUID is required.'], 422); } - if (! $request->environment_name) { - return response()->json(['message' => 'Environment name is required.'], 422); + if (! $request->environment_name_or_uuid) { + return response()->json(['message' => 'Environment name or UUID is required.'], 422); } $project = Project::whereTeamId($teamId)->whereUuid($request->uuid)->first(); if (! $project) { return response()->json(['message' => 'Project not found.'], 404); } - $environment = $project->environments()->whereName($request->environment_name)->first(); + $environment = $project->environments()->whereName($request->environment_name_or_uuid)->first(); + if (! $environment) { + $environment = $project->environments()->whereUuid($request->environment_name_or_uuid)->first(); + } if (! $environment) { return response()->json(['message' => 'Environment not found.'], 404); } diff --git a/app/Http/Controllers/Api/ServicesController.php b/app/Http/Controllers/Api/ServicesController.php index f5ecdcf286..03d9d209cc 100644 --- a/app/Http/Controllers/Api/ServicesController.php +++ b/app/Http/Controllers/Api/ServicesController.php @@ -102,7 +102,7 @@ public function services(Request $request) mediaType: 'application/json', schema: new OA\Schema( type: 'object', - required: ['server_uuid', 'project_uuid', 'environment_name', 'type'], + required: ['server_uuid', 'project_uuid', 'environment_name', 'environment_uuid', 'type'], properties: [ 'type' => [ 'description' => 'The one-click service type', @@ -199,7 +199,8 @@ public function services(Request $request) 'name' => ['type' => 'string', 'maxLength' => 255, 'description' => 'Name of the service.'], 'description' => ['type' => 'string', 'nullable' => true, 'description' => 'Description of the service.'], 'project_uuid' => ['type' => 'string', 'description' => 'Project UUID.'], - 'environment_name' => ['type' => 'string', 'description' => 'Environment name.'], + 'environment_name' => ['type' => 'string', 'description' => 'Environment name. You need to provide at least one of environment_name or environment_uuid.'], + 'environment_uuid' => ['type' => 'string', 'description' => 'Environment UUID. You need to provide at least one of environment_name or environment_uuid.'], 'server_uuid' => ['type' => 'string', 'description' => 'Server UUID.'], 'destination_uuid' => ['type' => 'string', 'description' => 'Destination UUID. Required if server has multiple destinations.'], 'instant_deploy' => ['type' => 'boolean', 'default' => false, 'description' => 'Start the service immediately after creation.'], @@ -236,7 +237,7 @@ public function services(Request $request) )] public function create_service(Request $request) { - $allowedFields = ['type', 'name', 'description', 'project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'instant_deploy']; + $allowedFields = ['type', 'name', 'description', 'project_uuid', 'environment_name', 'environment_uuid', 'server_uuid', 'destination_uuid', 'instant_deploy']; $teamId = getTeamIdFromToken(); if (is_null($teamId)) { @@ -250,7 +251,8 @@ public function create_service(Request $request) $validator = customApiValidator($request->all(), [ 'type' => 'string|required', 'project_uuid' => 'string|required', - 'environment_name' => 'string|required', + 'environment_name' => 'string|nullable', + 'environment_uuid' => 'string|nullable', 'server_uuid' => 'string|required', 'destination_uuid' => 'string', 'name' => 'string|max:255', @@ -272,6 +274,11 @@ public function create_service(Request $request) 'errors' => $errors, ], 422); } + $environmentUuid = $request->environment_uuid; + $environmentName = $request->environment_name; + if (blank($environmentUuid) && blank($environmentName)) { + return response()->json(['message' => 'You need to provide at least one of environment_name or environment_uuid.'], 422); + } $serverUuid = $request->server_uuid; $instantDeploy = $request->instant_deploy ?? false; if ($request->is_public && ! $request->public_port) { @@ -281,7 +288,10 @@ public function create_service(Request $request) if (! $project) { return response()->json(['message' => 'Project not found.'], 404); } - $environment = $project->environments()->where('name', $request->environment_name)->first(); + $environment = $project->environments()->where('name', $environmentName)->first(); + if (! $environment) { + $environment = $project->environments()->where('uuid', $environmentUuid)->first(); + } if (! $environment) { return response()->json(['message' => 'Environment not found.'], 404); } @@ -349,7 +359,11 @@ public function create_service(Request $request) } $domains = $service->applications()->get()->pluck('fqdn')->sort(); $domains = $domains->map(function ($domain) { - return str($domain)->beforeLast(':')->value(); + if (count(explode(':', $domain)) > 2) { + return str($domain)->beforeLast(':')->value(); + } + + return $domain; }); return response()->json([ diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 6b677fa0e5..7e4155338d 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1405,7 +1405,7 @@ private function deploy_to_additional_destinations() 'project_uuid' => data_get($this->application, 'environment.project.uuid'), 'application_uuid' => data_get($this->application, 'uuid'), 'deployment_uuid' => $deployment_uuid, - 'environment_name' => data_get($this->application, 'environment.name'), + 'environment_uuid' => data_get($this->application, 'environment.uuid'), ])); } } diff --git a/app/Livewire/Boarding/Index.php b/app/Livewire/Boarding/Index.php index eadabba7c3..15eabfec57 100644 --- a/app/Livewire/Boarding/Index.php +++ b/app/Livewire/Boarding/Index.php @@ -9,6 +9,7 @@ use App\Models\Team; use Illuminate\Support\Collection; use Livewire\Component; +use Visus\Cuid2\Cuid2; class Index extends Component { @@ -334,6 +335,7 @@ public function createNewProject() $this->createdProject = Project::create([ 'name' => 'My first project', 'team_id' => currentTeam()->id, + 'uuid' => (string) new Cuid2, ]); $this->currentState = 'create-resource'; } @@ -346,7 +348,7 @@ public function showNewResource() 'project.resource.create', [ 'project_uuid' => $this->createdProject->uuid, - 'environment_name' => 'production', + 'environment_uuid' => $this->createdProject->environments->first()->uuid, 'server' => $this->createdServer->id, ] ); diff --git a/app/Livewire/Dashboard.php b/app/Livewire/Dashboard.php index 69ba19e401..c3cb797bff 100644 --- a/app/Livewire/Dashboard.php +++ b/app/Livewire/Dashboard.php @@ -8,6 +8,7 @@ use App\Models\Server; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Redirect; use Livewire\Component; class Dashboard extends Component @@ -49,6 +50,20 @@ public function loadDeployments() ])->sortBy('id')->groupBy('server_name')->toArray(); } + public function navigateToProject($projectUuid) + { + $project = Project::where('uuid', $projectUuid)->first(); + + if ($project && $project->environments->count() === 1) { + return Redirect::route('project.resource.index', [ + 'project_uuid' => $projectUuid, + 'environment_uuid' => $project->environments->first()->uuid, + ]); + } + + return Redirect::route('project.show', ['project_uuid' => $projectUuid]); + } + public function render() { return view('livewire.dashboard'); diff --git a/app/Livewire/Project/AddEmpty.php b/app/Livewire/Project/AddEmpty.php index fd976548ab..07873c059d 100644 --- a/app/Livewire/Project/AddEmpty.php +++ b/app/Livewire/Project/AddEmpty.php @@ -5,6 +5,7 @@ use App\Models\Project; use Livewire\Attributes\Validate; use Livewire\Component; +use Visus\Cuid2\Cuid2; class AddEmpty extends Component { @@ -22,6 +23,7 @@ public function submit() '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 792e55e459..56e0caf750 100644 --- a/app/Livewire/Project/Application/Configuration.php +++ b/app/Livewire/Project/Application/Configuration.php @@ -28,8 +28,8 @@ public function mount() ->where('uuid', request()->route('project_uuid')) ->firstOrFail(); $environment = $project->environments() - ->select('id', 'name', 'project_id') - ->where('name', request()->route('environment_name')) + ->select('id', 'uuid', 'name', 'project_id') + ->where('uuid', request()->route('environment_uuid')) ->firstOrFail(); $application = $environment->applications() ->with(['destination']) @@ -39,7 +39,6 @@ public function mount() $this->project = $project; $this->environment = $environment; $this->application = $application; - } public function render() diff --git a/app/Livewire/Project/Application/Deployment/Index.php b/app/Livewire/Project/Application/Deployment/Index.php index 4f761c2cf6..b847c40ef1 100644 --- a/app/Livewire/Project/Application/Deployment/Index.php +++ b/app/Livewire/Project/Application/Deployment/Index.php @@ -34,7 +34,7 @@ public function mount() 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/Show.php b/app/Livewire/Project/Application/Deployment/Show.php index 04170fa280..4e86b5c7e4 100644 --- a/app/Livewire/Project/Application/Deployment/Show.php +++ b/app/Livewire/Project/Application/Deployment/Show.php @@ -26,7 +26,7 @@ public function mount() 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'); } @@ -34,19 +34,11 @@ public function mount() if (! $application) { return redirect()->route('dashboard'); } - // $activity = Activity::where('properties->type_uuid', '=', $deploymentUuid)->first(); - // if (!$activity) { - // return redirect()->route('project.application.deployment.index', [ - // 'project_uuid' => $project->uuid, - // 'environment_name' => $environment->name, - // 'application_uuid' => $application->uuid, - // ]); - // } $application_deployment_queue = ApplicationDeploymentQueue::where('deployment_uuid', $deploymentUuid)->first(); if (! $application_deployment_queue) { return redirect()->route('project.application.deployment.index', [ 'project_uuid' => $project->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'application_uuid' => $application->uuid, ]); } diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php index 19a6145b78..0afc9123a2 100644 --- a/app/Livewire/Project/Application/Heading.php +++ b/app/Livewire/Project/Application/Heading.php @@ -38,7 +38,7 @@ public function mount() { $this->parameters = [ 'project_uuid' => $this->application->project()->uuid, - 'environment_name' => $this->application->environment->name, + 'environment_uuid' => $this->application->environment->uuid, 'application_uuid' => $this->application->uuid, ]; $lastDeployment = $this->application->get_last_successful_deployment(); @@ -94,7 +94,7 @@ public function deploy(bool $force_rebuild = false) 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $this->deploymentUuid, - 'environment_name' => $this->parameters['environment_name'], + 'environment_uuid' => $this->parameters['environment_uuid'], ]); } @@ -136,7 +136,7 @@ public function restart() 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $this->deploymentUuid, - 'environment_name' => $this->parameters['environment_name'], + 'environment_uuid' => $this->parameters['environment_uuid'], ]); } diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php index d42bf03d78..bdf62706c3 100644 --- a/app/Livewire/Project/Application/Previews.php +++ b/app/Livewire/Project/Application/Previews.php @@ -171,7 +171,7 @@ public function deploy(int $pull_request_id, ?string $pull_request_html_url = nu '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 1e58a14586..ff5db1e08c 100644 --- a/app/Livewire/Project/Application/Rollback.php +++ b/app/Livewire/Project/Application/Rollback.php @@ -37,7 +37,7 @@ public function rollbackImage($commit) '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 a8e3e6cab3..593355c443 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 @@ public function mount($project_uuid) { $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 @@ public function clone(string $type) 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 @@ public function clone(string $type) $project = $this->project; $environment = $this->project->environments()->create([ 'name' => $this->newName, + 'uuid' => (string) new Cuid2, ]); } $applications = $this->environment->applications; @@ -174,7 +176,7 @@ public function clone(string $type) 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 5640916595..4ac3b2e2c5 100644 --- a/app/Livewire/Project/Database/Backup/Execution.php +++ b/app/Livewire/Project/Database/Backup/Execution.php @@ -22,7 +22,7 @@ public function mount() 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 9ff2f48d5f..2df32ec7bf 100644 --- a/app/Livewire/Project/Database/Backup/Index.php +++ b/app/Livewire/Project/Database/Backup/Index.php @@ -14,7 +14,7 @@ public function mount() 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 @@ public function mount() ) { 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 4e08f0fee6..938abba549 100644 --- a/app/Livewire/Project/Database/Configuration.php +++ b/app/Livewire/Project/Database/Configuration.php @@ -24,8 +24,8 @@ public function mount() ->where('uuid', request()->route('project_uuid')) ->firstOrFail(); $environment = $project->environments() - ->select('id', 'name', 'project_id') - ->where('name', request()->route('environment_name')) + ->select('id', 'name', 'project_id', 'uuid') + ->where('uuid', request()->route('environment_uuid')) ->firstOrFail(); $database = $environment->databases() ->where('uuid', request()->route('database_uuid')) diff --git a/app/Livewire/Project/EnvironmentEdit.php b/app/Livewire/Project/EnvironmentEdit.php index f48220b3dd..e98b088ecf 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 @@ public function submit() { 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/Index.php b/app/Livewire/Project/Index.php index f8eb838be6..06bf88219b 100644 --- a/app/Livewire/Project/Index.php +++ b/app/Livewire/Project/Index.php @@ -5,6 +5,7 @@ use App\Models\PrivateKey; use App\Models\Project; use App\Models\Server; +use Illuminate\Support\Facades\Redirect; use Livewire\Component; class Index extends Component @@ -30,4 +31,18 @@ public function render() { return view('livewire.project.index'); } + + public function navigateToProject($projectUuid) + { + $project = Project::where('uuid', $projectUuid)->first(); + + if ($project && $project->environments->count() === 1) { + return Redirect::route('project.resource.index', [ + 'project_uuid' => $projectUuid, + 'environment_uuid' => $project->environments->first()->uuid, + ]); + } + + return Redirect::route('project.show', ['project_uuid' => $projectUuid]); + } } diff --git a/app/Livewire/Project/New/DockerCompose.php b/app/Livewire/Project/New/DockerCompose.php index e6667e6f3d..27975eaa2b 100644 --- a/app/Livewire/Project/New/DockerCompose.php +++ b/app/Livewire/Project/New/DockerCompose.php @@ -59,7 +59,7 @@ public function submit() } $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(); @@ -97,7 +97,7 @@ public function submit() 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 417fb2ea02..9429244377 100644 --- a/app/Livewire/Project/New/DockerImage.php +++ b/app/Livewire/Project/New/DockerImage.php @@ -45,7 +45,7 @@ public function submit() $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 @@ public function submit() 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 28249b442a..54cfc4b4d8 100644 --- a/app/Livewire/Project/New/EmptyProject.php +++ b/app/Livewire/Project/New/EmptyProject.php @@ -4,6 +4,7 @@ use App\Models\Project; use Livewire\Component; +use Visus\Cuid2\Cuid2; class EmptyProject extends Component { @@ -12,8 +13,9 @@ public function createEmptyProject() $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 2f4f5a25c5..370d005557 100644 --- a/app/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Livewire/Project/New/GithubPrivateRepository.php @@ -177,7 +177,7 @@ public function submit() $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 @@ public function submit() 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 b46c4a7943..01b0c9ae85 100644 --- a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -136,7 +136,7 @@ public function submit() $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 @@ public function submit() 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 bd35dccef6..2f2331fc00 100644 --- a/app/Livewire/Project/New/PublicGitRepository.php +++ b/app/Livewire/Project/New/PublicGitRepository.php @@ -225,7 +225,7 @@ public function submit() $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 @@ public function submit() $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 @@ public function submit() 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 @@ public function submit() 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 0b6d075a4c..2c098d6bcd 100644 --- a/app/Livewire/Project/New/Select.php +++ b/app/Livewire/Project/New/Select.php @@ -61,7 +61,7 @@ public function mount() } $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 @@ public function updatedSelectedEnvironment() { 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); @@ -308,7 +298,7 @@ public function setPostgresqlType(string $type) 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, @@ -323,7 +313,7 @@ public function whatToDoNext() } 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 3c7f42329e..c3ed6039a0 100644 --- a/app/Livewire/Project/New/SimpleDockerfile.php +++ b/app/Livewire/Project/New/SimpleDockerfile.php @@ -46,7 +46,7 @@ public function submit() $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 @@ public function submit() 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 4fbda22118..0faf0b8da2 100644 --- a/app/Livewire/Project/Resource/Create.php +++ b/app/Livewire/Project/Resource/Create.php @@ -25,7 +25,7 @@ public function mount() 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 @@ public function mount() return redirect()->route('project.database.configuration', [ 'project_uuid' => $project->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid, ]); } @@ -107,7 +107,7 @@ public function mount() 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/EnvironmentSelect.php b/app/Livewire/Project/Resource/EnvironmentSelect.php index efb1b6ca23..a38d750daa 100644 --- a/app/Livewire/Project/Resource/EnvironmentSelect.php +++ b/app/Livewire/Project/Resource/EnvironmentSelect.php @@ -15,7 +15,7 @@ class EnvironmentSelect extends Component public function mount() { - $this->selectedEnvironment = request()->route('environment_name'); + $this->selectedEnvironment = request()->route('environment_uuid'); $this->project_uuid = request()->route('project_uuid'); } @@ -28,7 +28,7 @@ public function updatedSelectedEnvironment($value) } else { return redirect()->route('project.resource.index', [ 'project_uuid' => $this->project_uuid, - 'environment_name' => $value, + 'environment_uuid' => $value, ]); } } diff --git a/app/Livewire/Project/Resource/Index.php b/app/Livewire/Project/Resource/Index.php index 0c2ea802a6..2b199dcfd6 100644 --- a/app/Livewire/Project/Resource/Index.php +++ b/app/Livewire/Project/Resource/Index.php @@ -4,6 +4,7 @@ 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('name', request()->route('environment_name'))->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 @@ public function mount() ])->get()->sortBy('name'); $this->applications = $this->applications->map(function ($application) { $application->hrefLink = route('project.application.configuration', [ - 'project_uuid' => $this->project->uuid, - 'application_uuid' => $application->uuid, - 'environment_name' => $this->environment->name, + '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 @@ public function mount() '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', @@ -106,7 +102,7 @@ public function mount() $db->hrefLink = route('project.database.configuration', [ 'project_uuid' => $this->project->uuid, 'database_uuid' => $db->uuid, - 'environment_name' => $this->environment->name, + 'environment_uuid' => data_get($this->environment, 'uuid'), ]); return $db; @@ -120,9 +116,9 @@ public function mount() ])->get()->sortBy('name'); $this->services = $this->services->map(function ($service) { $service->hrefLink = route('project.service.configuration', [ - 'project_uuid' => $this->project->uuid, - 'service_uuid' => $service->uuid, - 'environment_name' => $this->environment->name, + 'project_uuid' => data_get($service, 'environment.project.uuid'), + 'environment_uuid' => data_get($service, 'environment.uuid'), + 'service_uuid' => data_get($service, 'uuid'), ]); return $service; diff --git a/app/Livewire/Project/Service/Configuration.php b/app/Livewire/Project/Service/Configuration.php index 99a0dea7f8..4a5e8627fa 100644 --- a/app/Livewire/Project/Service/Configuration.php +++ b/app/Livewire/Project/Service/Configuration.php @@ -52,8 +52,8 @@ public function mount() ->where('uuid', request()->route('project_uuid')) ->firstOrFail(); $environment = $project->environments() - ->select('id', 'name', 'project_id') - ->where('name', request()->route('environment_name')) + ->select('id', 'uuid', 'name', 'project_id') + ->where('uuid', request()->route('environment_uuid')) ->firstOrFail(); $this->service = $environment->services()->whereUuid(request()->route('service_uuid'))->firstOrFail(); diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php index a0b4ac2c45..7da48f9fb4 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 @@ public function mount() $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 @@ public function delete($password) 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 61dcab196c..1759fe08ac 100644 --- a/app/Livewire/Project/Shared/Destination.php +++ b/app/Livewire/Project/Shared/Destination.php @@ -92,7 +92,7 @@ public function redeploy(int $network_id, int $server_id) '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'), ]); } catch (\Exception $e) { return handleError($e, $this); diff --git a/app/Livewire/Project/Shared/ResourceOperations.php b/app/Livewire/Project/Shared/ResourceOperations.php index 98b31641a0..c6a32f0c7a 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 @@ public function mount() { $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; } @@ -79,7 +79,7 @@ public function cloneTo($destination_id) } $route = route('project.application.configuration', [ 'project_uuid' => $this->projectUuid, - 'environment_name' => $this->environmentName, + 'environment_uuid' => $this->environmentUuid, 'application_uuid' => $new_resource->uuid, ]).'#resource-operations'; @@ -122,7 +122,7 @@ public function cloneTo($destination_id) } $route = route('project.database.configuration', [ 'project_uuid' => $this->projectUuid, - 'environment_name' => $this->environmentName, + 'environment_uuid' => $this->environmentUuid, 'database_uuid' => $new_resource->uuid, ]).'#resource-operations'; @@ -148,7 +148,7 @@ public function cloneTo($destination_id) $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'; @@ -166,7 +166,7 @@ public function moveTo($environment_id) 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'; @@ -174,7 +174,7 @@ public function moveTo($environment_id) } 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'; @@ -182,7 +182,7 @@ public function moveTo($environment_id) } 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/Project/Shared/ScheduledTask/Show.php b/app/Livewire/Project/Shared/ScheduledTask/Show.php index 0900a1d700..0764ab3b96 100644 --- a/app/Livewire/Project/Shared/ScheduledTask/Show.php +++ b/app/Livewire/Project/Shared/ScheduledTask/Show.php @@ -46,7 +46,7 @@ class Show extends Component #[Locked] public string $task_uuid; - public function mount(string $task_uuid, string $project_uuid, string $environment_name, ?string $application_uuid = null, ?string $service_uuid = null) + public function mount(string $task_uuid, string $project_uuid, string $environment_uuid, ?string $application_uuid = null, ?string $service_uuid = null) { try { $this->task_uuid = $task_uuid; @@ -60,7 +60,7 @@ public function mount(string $task_uuid, string $project_uuid, string $environme $this->resource = Service::ownedByCurrentTeam()->where('uuid', $service_uuid)->firstOrFail(); } $this->parameters = [ - 'environment_name' => $environment_name, + 'environment_uuid' => $environment_uuid, 'project_uuid' => $project_uuid, 'application_uuid' => $application_uuid, 'service_uuid' => $service_uuid, diff --git a/app/Livewire/Project/Show.php b/app/Livewire/Project/Show.php index 2335519c74..886a20218f 100644 --- a/app/Livewire/Project/Show.php +++ b/app/Livewire/Project/Show.php @@ -6,6 +6,7 @@ use App\Models\Project; use Livewire\Attributes\Validate; use Livewire\Component; +use Visus\Cuid2\Cuid2; class Show extends Component { @@ -33,17 +34,26 @@ public function submit() $environment = Environment::create([ 'name' => $this->name, 'project_id' => $this->project->id, + 'uuid' => (string) new Cuid2, ]); return redirect()->route('project.resource.index', [ 'project_uuid' => $this->project->uuid, - 'environment_name' => $environment->name, + 'environment_uuid' => $environment->uuid, ]); } catch (\Throwable $e) { handleError($e, $this); } } + public function navigateToEnvironment($projectUuid, $environmentUuid) + { + return redirect()->route('project.resource.index', [ + 'project_uuid' => $projectUuid, + 'environment_uuid' => $environmentUuid, + ]); + } + public function render() { return view('livewire.project.show'); diff --git a/app/Livewire/SharedVariables/Environment/Show.php b/app/Livewire/SharedVariables/Environment/Show.php index 6a33eb60d6..e88ac5f135 100644 --- a/app/Livewire/SharedVariables/Environment/Show.php +++ b/app/Livewire/SharedVariables/Environment/Show.php @@ -42,8 +42,8 @@ public function saveKey($data) 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 4679274848..8f4f02f70f 100644 --- a/app/Livewire/Source/Github/Change.php +++ b/app/Livewire/Source/Github/Change.php @@ -130,14 +130,14 @@ public function mount() } 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 6413c8fea4..13f15468dc 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -325,7 +325,7 @@ public function link() 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'), ]); } @@ -338,7 +338,7 @@ public function taskLink($task_uuid) 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/Environment.php b/app/Models/Environment.php index 71e8bbd218..b8f1090d8d 100644 --- a/app/Models/Environment.php +++ b/app/Models/Environment.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Model; use OpenApi\Attributes as OA; #[OA\Schema( @@ -18,7 +17,7 @@ 'description' => ['type' => 'string'], ] )] -class Environment extends Model +class Environment extends BaseModel { protected $guarded = []; diff --git a/app/Models/Project.php b/app/Models/Project.php index f27e6c2083..3b50b9b33e 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 @@ protected static function booted() Environment::create([ 'name' => 'production', 'project_id' => $project->id, + 'uuid' => (string) new Cuid2, ]); }); static::deleting(function ($project) { @@ -140,18 +140,4 @@ public function databases() { 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 c605f189be..1df579802d 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -1133,7 +1133,7 @@ public function link() 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'), ]); } @@ -1146,7 +1146,7 @@ public function taskLink($task_uuid) 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 ec56d0fddc..60198115da 100644 --- a/app/Models/StandaloneClickhouse.php +++ b/app/Models/StandaloneClickhouse.php @@ -168,7 +168,7 @@ public function link() 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 683c9acb4a..3c1127d8de 100644 --- a/app/Models/StandaloneDragonfly.php +++ b/app/Models/StandaloneDragonfly.php @@ -173,7 +173,7 @@ public function link() 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 e239020aca..ebf1c22e95 100644 --- a/app/Models/StandaloneKeydb.php +++ b/app/Models/StandaloneKeydb.php @@ -173,7 +173,7 @@ public function link() 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 c010cf4410..004ead4d95 100644 --- a/app/Models/StandaloneMariadb.php +++ b/app/Models/StandaloneMariadb.php @@ -173,7 +173,7 @@ public function link() 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 e18317088f..aba0f6123e 100644 --- a/app/Models/StandaloneMongodb.php +++ b/app/Models/StandaloneMongodb.php @@ -182,7 +182,7 @@ public function link() 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 e6c976a8a7..9ae0fdcaeb 100644 --- a/app/Models/StandaloneMysql.php +++ b/app/Models/StandaloneMysql.php @@ -174,7 +174,7 @@ public function link() 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 141768a7cf..dd92ae7c91 100644 --- a/app/Models/StandalonePostgresql.php +++ b/app/Models/StandalonePostgresql.php @@ -169,7 +169,7 @@ public function link() 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 df1681fc95..ed5cf98708 100644 --- a/app/Models/StandaloneRedis.php +++ b/app/Models/StandaloneRedis.php @@ -169,7 +169,7 @@ public function link() 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/Notifications/Application/DeploymentFailed.php b/app/Notifications/Application/DeploymentFailed.php index 80c1c421c1..0c09b1dbd0 100644 --- a/app/Notifications/Application/DeploymentFailed.php +++ b/app/Notifications/Application/DeploymentFailed.php @@ -22,6 +22,8 @@ class DeploymentFailed extends CustomEmailNotification public string $project_uuid; + public string $environment_uuid; + public string $environment_name; public ?string $deployment_url = null; @@ -36,12 +38,13 @@ public function __construct(Application $application, string $deployment_uuid, ? $this->preview = $preview; $this->application_name = data_get($application, 'name'); $this->project_uuid = data_get($application, 'environment.project.uuid'); + $this->environment_uuid = data_get($application, 'environment.uuid'); $this->environment_name = data_get($application, 'environment.name'); $this->fqdn = data_get($application, 'fqdn'); if (str($this->fqdn)->explode(',')->count() > 1) { $this->fqdn = str($this->fqdn)->explode(',')->first(); } - $this->deployment_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}"; + $this->deployment_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}"; } public function via(object $notifiable): array diff --git a/app/Notifications/Application/DeploymentSuccess.php b/app/Notifications/Application/DeploymentSuccess.php index b1a3d5225d..ac8329132e 100644 --- a/app/Notifications/Application/DeploymentSuccess.php +++ b/app/Notifications/Application/DeploymentSuccess.php @@ -22,6 +22,8 @@ class DeploymentSuccess extends CustomEmailNotification public string $project_uuid; + public string $environment_uuid; + public string $environment_name; public ?string $deployment_url = null; @@ -36,12 +38,13 @@ public function __construct(Application $application, string $deployment_uuid, ? $this->preview = $preview; $this->application_name = data_get($application, 'name'); $this->project_uuid = data_get($application, 'environment.project.uuid'); + $this->environment_uuid = data_get($application, 'environment.uuid'); $this->environment_name = data_get($application, 'environment.name'); $this->fqdn = data_get($application, 'fqdn'); if (str($this->fqdn)->explode(',')->count() > 1) { $this->fqdn = str($this->fqdn)->explode(',')->first(); } - $this->deployment_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}"; + $this->deployment_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}"; } public function via(object $notifiable): array diff --git a/app/Notifications/Application/StatusChanged.php b/app/Notifications/Application/StatusChanged.php index c9c7344c42..669f6e5842 100644 --- a/app/Notifications/Application/StatusChanged.php +++ b/app/Notifications/Application/StatusChanged.php @@ -15,6 +15,8 @@ class StatusChanged extends CustomEmailNotification public string $project_uuid; + public string $environment_uuid; + public string $environment_name; public ?string $resource_url = null; @@ -26,12 +28,13 @@ public function __construct(public Application $resource) $this->onQueue('high'); $this->resource_name = data_get($resource, 'name'); $this->project_uuid = data_get($resource, 'environment.project.uuid'); + $this->environment_uuid = data_get($resource, 'environment.uuid'); $this->environment_name = data_get($resource, 'environment.name'); $this->fqdn = data_get($resource, 'fqdn', null); if (str($this->fqdn)->explode(',')->count() > 1) { $this->fqdn = str($this->fqdn)->explode(',')->first(); } - $this->resource_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->resource->uuid}"; + $this->resource_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->resource->uuid}"; } public function via(object $notifiable): array @@ -80,7 +83,7 @@ public function toTelegram(): array public function toPushover(): PushoverMessage { - $message = $this->resource_name . ' has been stopped.'; + $message = $this->resource_name.' has been stopped.'; return new PushoverMessage( title: 'Application stopped', diff --git a/bootstrap/helpers/api.php b/bootstrap/helpers/api.php index 875866e2ff..307c7ed1b7 100644 --- a/bootstrap/helpers/api.php +++ b/bootstrap/helpers/api.php @@ -166,6 +166,7 @@ function removeUnnecessaryFieldsFromRequest(Request $request) { $request->offsetUnset('project_uuid'); $request->offsetUnset('environment_name'); + $request->offsetUnset('environment_uuid'); $request->offsetUnset('destination_uuid'); $request->offsetUnset('server_uuid'); $request->offsetUnset('type'); diff --git a/database/migrations/2024_11_22_124742_add_uuid_to_environments_table.php b/database/migrations/2024_11_22_124742_add_uuid_to_environments_table.php new file mode 100644 index 0000000000..b106427afe --- /dev/null +++ b/database/migrations/2024_11_22_124742_add_uuid_to_environments_table.php @@ -0,0 +1,38 @@ +string('uuid')->after('id')->nullable()->unique(); + }); + + DB::table('environments') + ->whereNull('uuid') + ->chunkById(100, function ($environments) { + foreach ($environments as $environment) { + DB::table('environments') + ->where('id', $environment->id) + ->update(['uuid' => (string) new Cuid2]); + } + }); + + Schema::table('environments', function (Blueprint $table) { + $table->string('uuid')->nullable(false)->change(); + }); + } + + public function down(): void + { + Schema::table('environments', function (Blueprint $table) { + $table->dropColumn('uuid'); + }); + } +}; diff --git a/openapi.json b/openapi.json index 5d35331ec6..2834e0c8b7 100644 --- a/openapi.json +++ b/openapi.json @@ -65,6 +65,7 @@ "project_uuid", "server_uuid", "environment_name", + "environment_uuid", "git_repository", "git_branch", "build_pack", @@ -81,7 +82,11 @@ }, "environment_name": { "type": "string", - "description": "The environment name." + "description": "The environment name. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "The environment UUID. You need to provide at least one of environment_name or environment_uuid." }, "git_repository": { "type": "string", @@ -377,6 +382,7 @@ "project_uuid", "server_uuid", "environment_name", + "environment_uuid", "github_app_uuid", "git_repository", "git_branch", @@ -394,7 +400,11 @@ }, "environment_name": { "type": "string", - "description": "The environment name." + "description": "The environment name. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "The environment UUID. You need to provide at least one of environment_name or environment_uuid." }, "github_app_uuid": { "type": "string", @@ -694,6 +704,7 @@ "project_uuid", "server_uuid", "environment_name", + "environment_uuid", "private_key_uuid", "git_repository", "git_branch", @@ -711,7 +722,11 @@ }, "environment_name": { "type": "string", - "description": "The environment name." + "description": "The environment name. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "The environment UUID. You need to provide at least one of environment_name or environment_uuid." }, "private_key_uuid": { "type": "string", @@ -1011,6 +1026,7 @@ "project_uuid", "server_uuid", "environment_name", + "environment_uuid", "dockerfile" ], "properties": { @@ -1024,7 +1040,11 @@ }, "environment_name": { "type": "string", - "description": "The environment name." + "description": "The environment name. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "The environment UUID. You need to provide at least one of environment_name or environment_uuid." }, "dockerfile": { "type": "string", @@ -1257,6 +1277,7 @@ "project_uuid", "server_uuid", "environment_name", + "environment_uuid", "docker_registry_image_name", "ports_exposes" ], @@ -1271,7 +1292,11 @@ }, "environment_name": { "type": "string", - "description": "The environment name." + "description": "The environment name. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "The environment UUID. You need to provide at least one of environment_name or environment_uuid." }, "docker_registry_image_name": { "type": "string", @@ -1486,6 +1511,7 @@ "project_uuid", "server_uuid", "environment_name", + "environment_uuid", "docker_compose_raw" ], "properties": { @@ -1499,7 +1525,11 @@ }, "environment_name": { "type": "string", - "description": "The environment name." + "description": "The environment name. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "The environment UUID. You need to provide at least one of environment_name or environment_uuid." }, "docker_compose_raw": { "type": "string", @@ -3079,7 +3109,8 @@ "required": [ "server_uuid", "project_uuid", - "environment_name" + "environment_name", + "environment_uuid" ], "properties": { "server_uuid": { @@ -3092,7 +3123,11 @@ }, "environment_name": { "type": "string", - "description": "Name of the environment" + "description": "Name of the environment. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "UUID of the environment. You need to provide at least one of environment_name or environment_uuid." }, "postgres_user": { "type": "string", @@ -3215,7 +3250,8 @@ "required": [ "server_uuid", "project_uuid", - "environment_name" + "environment_name", + "environment_uuid" ], "properties": { "server_uuid": { @@ -3228,7 +3264,11 @@ }, "environment_name": { "type": "string", - "description": "Name of the environment" + "description": "Name of the environment. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "UUID of the environment. You need to provide at least one of environment_name or environment_uuid." }, "destination_uuid": { "type": "string", @@ -3335,7 +3375,8 @@ "required": [ "server_uuid", "project_uuid", - "environment_name" + "environment_name", + "environment_uuid" ], "properties": { "server_uuid": { @@ -3348,7 +3389,11 @@ }, "environment_name": { "type": "string", - "description": "Name of the environment" + "description": "Name of the environment. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "UUID of the environment. You need to provide at least one of environment_name or environment_uuid." }, "destination_uuid": { "type": "string", @@ -3451,7 +3496,8 @@ "required": [ "server_uuid", "project_uuid", - "environment_name" + "environment_name", + "environment_uuid" ], "properties": { "server_uuid": { @@ -3464,7 +3510,11 @@ }, "environment_name": { "type": "string", - "description": "Name of the environment" + "description": "Name of the environment. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "UUID of the environment. You need to provide at least one of environment_name or environment_uuid." }, "destination_uuid": { "type": "string", @@ -3571,7 +3621,8 @@ "required": [ "server_uuid", "project_uuid", - "environment_name" + "environment_name", + "environment_uuid" ], "properties": { "server_uuid": { @@ -3584,7 +3635,11 @@ }, "environment_name": { "type": "string", - "description": "Name of the environment" + "description": "Name of the environment. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "UUID of the environment. You need to provide at least one of environment_name or environment_uuid." }, "destination_uuid": { "type": "string", @@ -3691,7 +3746,8 @@ "required": [ "server_uuid", "project_uuid", - "environment_name" + "environment_name", + "environment_uuid" ], "properties": { "server_uuid": { @@ -3704,7 +3760,11 @@ }, "environment_name": { "type": "string", - "description": "Name of the environment" + "description": "Name of the environment. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "UUID of the environment. You need to provide at least one of environment_name or environment_uuid." }, "destination_uuid": { "type": "string", @@ -3823,7 +3883,8 @@ "required": [ "server_uuid", "project_uuid", - "environment_name" + "environment_name", + "environment_uuid" ], "properties": { "server_uuid": { @@ -3836,7 +3897,11 @@ }, "environment_name": { "type": "string", - "description": "Name of the environment" + "description": "Name of the environment. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "UUID of the environment. You need to provide at least one of environment_name or environment_uuid." }, "destination_uuid": { "type": "string", @@ -3955,7 +4020,8 @@ "required": [ "server_uuid", "project_uuid", - "environment_name" + "environment_name", + "environment_uuid" ], "properties": { "server_uuid": { @@ -3968,7 +4034,11 @@ }, "environment_name": { "type": "string", - "description": "Name of the environment" + "description": "Name of the environment. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "UUID of the environment. You need to provide at least one of environment_name or environment_uuid." }, "destination_uuid": { "type": "string", @@ -4808,14 +4878,14 @@ ] } }, - "\/projects\/{uuid}\/{environment_name}": { + "\/projects\/{uuid}\/{environment_name_or_uuid}": { "get": { "tags": [ "Projects" ], "summary": "Environment", - "description": "Get environment by name.", - "operationId": "get-environment-by-name", + "description": "Get environment by name or UUID.", + "operationId": "get-environment-by-name-or-uuid", "parameters": [ { "name": "uuid", @@ -4827,9 +4897,9 @@ } }, { - "name": "environment_name", + "name": "environment_name_or_uuid", "in": "path", - "description": "Environment name", + "description": "Environment name or UUID", "required": true, "schema": { "type": "string" @@ -5724,6 +5794,7 @@ "server_uuid", "project_uuid", "environment_name", + "environment_uuid", "type" ], "properties": { @@ -5835,7 +5906,11 @@ }, "environment_name": { "type": "string", - "description": "Environment name." + "description": "Environment name. You need to provide at least one of environment_name or environment_uuid." + }, + "environment_uuid": { + "type": "string", + "description": "Environment UUID. You need to provide at least one of environment_name or environment_uuid." }, "server_uuid": { "type": "string", @@ -7282,13 +7357,10 @@ "uuid": { "type": "string" }, - "application_id": { - "type": "integer" - }, - "service_id": { - "type": "integer" + "resourceable_type": { + "type": "string" }, - "database_id": { + "resourceable_id": { "type": "integer" }, "is_build_time": { @@ -7684,174 +7756,14 @@ "type": "string", "description": "The date and time the team was last updated." }, - "smtp_enabled": { - "type": "boolean", - "description": "Whether SMTP is enabled or not." - }, - "smtp_from_address": { - "type": "string", - "description": "The email address to send emails from." - }, - "smtp_from_name": { - "type": "string", - "description": "The name to send emails from." - }, - "smtp_recipients": { - "type": "string", - "description": "The email addresses to send emails to." - }, - "smtp_host": { - "type": "string", - "description": "The SMTP host." - }, - "smtp_port": { - "type": "string", - "description": "The SMTP port." - }, - "smtp_encryption": { - "type": "string", - "description": "The SMTP encryption." - }, - "smtp_username": { - "type": "string", - "description": "The SMTP username." - }, - "smtp_password": { - "type": "string", - "description": "The SMTP password." - }, - "smtp_timeout": { - "type": "string", - "description": "The SMTP timeout." - }, - "smtp_notifications_test": { - "type": "boolean", - "description": "Whether to send test notifications via SMTP." - }, - "smtp_notifications_deployments": { - "type": "boolean", - "description": "Whether to send deployment notifications via SMTP." - }, - "smtp_notifications_status_changes": { - "type": "boolean", - "description": "Whether to send status change notifications via SMTP." - }, - "smtp_notifications_scheduled_tasks": { - "type": "boolean", - "description": "Whether to send scheduled task notifications via SMTP." - }, - "smtp_notifications_database_backups": { - "type": "boolean", - "description": "Whether to send database backup notifications via SMTP." - }, - "smtp_notifications_server_disk_usage": { - "type": "boolean", - "description": "Whether to send server disk usage notifications via SMTP." - }, - "discord_enabled": { - "type": "boolean", - "description": "Whether Discord is enabled or not." - }, - "discord_webhook_url": { - "type": "string", - "description": "The Discord webhook URL." - }, - "discord_notifications_test": { - "type": "boolean", - "description": "Whether to send test notifications via Discord." - }, - "discord_notifications_deployments": { - "type": "boolean", - "description": "Whether to send deployment notifications via Discord." - }, - "discord_notifications_status_changes": { - "type": "boolean", - "description": "Whether to send status change notifications via Discord." - }, - "discord_notifications_database_backups": { - "type": "boolean", - "description": "Whether to send database backup notifications via Discord." - }, - "discord_notifications_scheduled_tasks": { - "type": "boolean", - "description": "Whether to send scheduled task notifications via Discord." - }, - "discord_notifications_server_disk_usage": { - "type": "boolean", - "description": "Whether to send server disk usage notifications via Discord." - }, "show_boarding": { "type": "boolean", "description": "Whether to show the boarding screen or not." }, - "resend_enabled": { - "type": "boolean", - "description": "Whether to enable resending or not." - }, - "resend_api_key": { - "type": "string", - "description": "The resending API key." - }, - "use_instance_email_settings": { - "type": "boolean", - "description": "Whether to use instance email settings or not." - }, - "telegram_enabled": { - "type": "boolean", - "description": "Whether Telegram is enabled or not." - }, - "telegram_token": { - "type": "string", - "description": "The Telegram token." - }, - "telegram_chat_id": { - "type": "string", - "description": "The Telegram chat ID." - }, - "telegram_notifications_test": { - "type": "boolean", - "description": "Whether to send test notifications via Telegram." - }, - "telegram_notifications_deployments": { - "type": "boolean", - "description": "Whether to send deployment notifications via Telegram." - }, - "telegram_notifications_status_changes": { - "type": "boolean", - "description": "Whether to send status change notifications via Telegram." - }, - "telegram_notifications_database_backups": { - "type": "boolean", - "description": "Whether to send database backup notifications via Telegram." - }, - "telegram_notifications_test_message_thread_id": { - "type": "string", - "description": "The Telegram test message thread ID." - }, - "telegram_notifications_deployments_message_thread_id": { - "type": "string", - "description": "The Telegram deployment message thread ID." - }, - "telegram_notifications_status_changes_message_thread_id": { - "type": "string", - "description": "The Telegram status change message thread ID." - }, - "telegram_notifications_database_backups_message_thread_id": { - "type": "string", - "description": "The Telegram database backup message thread ID." - }, "custom_server_limit": { "type": "string", "description": "The custom server limit." }, - "telegram_notifications_scheduled_tasks": { - "type": "boolean", - "description": "Whether to send scheduled task notifications via Telegram." - }, - "telegram_notifications_scheduled_tasks_thread_id": { - "type": "string", - "description": "The Telegram scheduled task message thread ID." - }, "members": { "description": "The members of the team.", "type": "array", diff --git a/openapi.yaml b/openapi.yaml index 20bf348730..6be1b76f6a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -47,6 +47,7 @@ paths: - project_uuid - server_uuid - environment_name + - environment_uuid - git_repository - git_branch - build_pack @@ -60,7 +61,10 @@ paths: description: 'The server UUID.' environment_name: type: string - description: 'The environment name.' + description: 'The environment name. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.' git_repository: type: string description: 'The git repository URL.' @@ -272,6 +276,7 @@ paths: - project_uuid - server_uuid - environment_name + - environment_uuid - github_app_uuid - git_repository - git_branch @@ -286,7 +291,10 @@ paths: description: 'The server UUID.' environment_name: type: string - description: 'The environment name.' + description: 'The environment name. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.' github_app_uuid: type: string description: 'The Github App UUID.' @@ -501,6 +509,7 @@ paths: - project_uuid - server_uuid - environment_name + - environment_uuid - private_key_uuid - git_repository - git_branch @@ -515,7 +524,10 @@ paths: description: 'The server UUID.' environment_name: type: string - description: 'The environment name.' + description: 'The environment name. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.' private_key_uuid: type: string description: 'The private key UUID.' @@ -730,6 +742,7 @@ paths: - project_uuid - server_uuid - environment_name + - environment_uuid - dockerfile properties: project_uuid: @@ -740,7 +753,10 @@ paths: description: 'The server UUID.' environment_name: type: string - description: 'The environment name.' + description: 'The environment name. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.' dockerfile: type: string description: 'The Dockerfile content.' @@ -906,6 +922,7 @@ paths: - project_uuid - server_uuid - environment_name + - environment_uuid - docker_registry_image_name - ports_exposes properties: @@ -917,7 +934,10 @@ paths: description: 'The server UUID.' environment_name: type: string - description: 'The environment name.' + description: 'The environment name. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.' docker_registry_image_name: type: string description: 'The docker registry image name.' @@ -1073,6 +1093,7 @@ paths: - project_uuid - server_uuid - environment_name + - environment_uuid - docker_compose_raw properties: project_uuid: @@ -1083,7 +1104,10 @@ paths: description: 'The server UUID.' environment_name: type: string - description: 'The environment name.' + description: 'The environment name. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'The environment UUID. You need to provide at least one of environment_name or environment_uuid.' docker_compose_raw: type: string description: 'The Docker Compose raw content.' @@ -2137,6 +2161,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid properties: server_uuid: type: string @@ -2146,7 +2171,10 @@ paths: description: 'UUID of the project' environment_name: type: string - description: 'Name of the environment' + description: 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.' postgres_user: type: string description: 'PostgreSQL user' @@ -2235,6 +2263,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid properties: server_uuid: type: string @@ -2244,7 +2273,10 @@ paths: description: 'UUID of the project' environment_name: type: string - description: 'Name of the environment' + description: 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.' destination_uuid: type: string description: 'UUID of the destination if the server has multiple destinations' @@ -2321,6 +2353,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid properties: server_uuid: type: string @@ -2330,7 +2363,10 @@ paths: description: 'UUID of the project' environment_name: type: string - description: 'Name of the environment' + description: 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.' destination_uuid: type: string description: 'UUID of the destination if the server has multiple destinations' @@ -2404,6 +2440,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid properties: server_uuid: type: string @@ -2413,7 +2450,10 @@ paths: description: 'UUID of the project' environment_name: type: string - description: 'Name of the environment' + description: 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.' destination_uuid: type: string description: 'UUID of the destination if the server has multiple destinations' @@ -2490,6 +2530,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid properties: server_uuid: type: string @@ -2499,7 +2540,10 @@ paths: description: 'UUID of the project' environment_name: type: string - description: 'Name of the environment' + description: 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.' destination_uuid: type: string description: 'UUID of the destination if the server has multiple destinations' @@ -2576,6 +2620,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid properties: server_uuid: type: string @@ -2585,7 +2630,10 @@ paths: description: 'UUID of the project' environment_name: type: string - description: 'Name of the environment' + description: 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.' destination_uuid: type: string description: 'UUID of the destination if the server has multiple destinations' @@ -2671,6 +2719,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid properties: server_uuid: type: string @@ -2680,7 +2729,10 @@ paths: description: 'UUID of the project' environment_name: type: string - description: 'Name of the environment' + description: 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.' destination_uuid: type: string description: 'UUID of the destination if the server has multiple destinations' @@ -2766,6 +2818,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid properties: server_uuid: type: string @@ -2775,7 +2828,10 @@ paths: description: 'UUID of the project' environment_name: type: string - description: 'Name of the environment' + description: 'Name of the environment. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'UUID of the environment. You need to provide at least one of environment_name or environment_uuid.' destination_uuid: type: string description: 'UUID of the destination if the server has multiple destinations' @@ -3293,13 +3349,13 @@ paths: security: - bearerAuth: [] - '/projects/{uuid}/{environment_name}': + '/projects/{uuid}/{environment_name_or_uuid}': get: tags: - Projects summary: Environment - description: 'Get environment by name.' - operationId: get-environment-by-name + description: 'Get environment by name or UUID.' + operationId: get-environment-by-name-or-uuid parameters: - name: uuid @@ -3309,9 +3365,9 @@ paths: schema: type: string - - name: environment_name + name: environment_name_or_uuid in: path - description: 'Environment name' + description: 'Environment name or UUID' required: true schema: type: string @@ -3872,6 +3928,7 @@ paths: - server_uuid - project_uuid - environment_name + - environment_uuid - type properties: type: @@ -3891,7 +3948,10 @@ paths: description: 'Project UUID.' environment_name: type: string - description: 'Environment name.' + description: 'Environment name. You need to provide at least one of environment_name or environment_uuid.' + environment_uuid: + type: string + description: 'Environment UUID. You need to provide at least one of environment_name or environment_uuid.' server_uuid: type: string description: 'Server UUID.' @@ -4856,11 +4916,9 @@ components: type: integer uuid: type: string - application_id: - type: integer - service_id: - type: integer - database_id: + resourceable_type: + type: string + resourceable_id: type: integer is_build_time: type: boolean @@ -5139,132 +5197,12 @@ components: updated_at: type: string description: 'The date and time the team was last updated.' - smtp_enabled: - type: boolean - description: 'Whether SMTP is enabled or not.' - smtp_from_address: - type: string - description: 'The email address to send emails from.' - smtp_from_name: - type: string - description: 'The name to send emails from.' - smtp_recipients: - type: string - description: 'The email addresses to send emails to.' - smtp_host: - type: string - description: 'The SMTP host.' - smtp_port: - type: string - description: 'The SMTP port.' - smtp_encryption: - type: string - description: 'The SMTP encryption.' - smtp_username: - type: string - description: 'The SMTP username.' - smtp_password: - type: string - description: 'The SMTP password.' - smtp_timeout: - type: string - description: 'The SMTP timeout.' - smtp_notifications_test: - type: boolean - description: 'Whether to send test notifications via SMTP.' - smtp_notifications_deployments: - type: boolean - description: 'Whether to send deployment notifications via SMTP.' - smtp_notifications_status_changes: - type: boolean - description: 'Whether to send status change notifications via SMTP.' - smtp_notifications_scheduled_tasks: - type: boolean - description: 'Whether to send scheduled task notifications via SMTP.' - smtp_notifications_database_backups: - type: boolean - description: 'Whether to send database backup notifications via SMTP.' - smtp_notifications_server_disk_usage: - type: boolean - description: 'Whether to send server disk usage notifications via SMTP.' - discord_enabled: - type: boolean - description: 'Whether Discord is enabled or not.' - discord_webhook_url: - type: string - description: 'The Discord webhook URL.' - discord_notifications_test: - type: boolean - description: 'Whether to send test notifications via Discord.' - discord_notifications_deployments: - type: boolean - description: 'Whether to send deployment notifications via Discord.' - discord_notifications_status_changes: - type: boolean - description: 'Whether to send status change notifications via Discord.' - discord_notifications_database_backups: - type: boolean - description: 'Whether to send database backup notifications via Discord.' - discord_notifications_scheduled_tasks: - type: boolean - description: 'Whether to send scheduled task notifications via Discord.' - discord_notifications_server_disk_usage: - type: boolean - description: 'Whether to send server disk usage notifications via Discord.' show_boarding: type: boolean description: 'Whether to show the boarding screen or not.' - resend_enabled: - type: boolean - description: 'Whether to enable resending or not.' - resend_api_key: - type: string - description: 'The resending API key.' - use_instance_email_settings: - type: boolean - description: 'Whether to use instance email settings or not.' - telegram_enabled: - type: boolean - description: 'Whether Telegram is enabled or not.' - telegram_token: - type: string - description: 'The Telegram token.' - telegram_chat_id: - type: string - description: 'The Telegram chat ID.' - telegram_notifications_test: - type: boolean - description: 'Whether to send test notifications via Telegram.' - telegram_notifications_deployments: - type: boolean - description: 'Whether to send deployment notifications via Telegram.' - telegram_notifications_status_changes: - type: boolean - description: 'Whether to send status change notifications via Telegram.' - telegram_notifications_database_backups: - type: boolean - description: 'Whether to send database backup notifications via Telegram.' - telegram_notifications_test_message_thread_id: - type: string - description: 'The Telegram test message thread ID.' - telegram_notifications_deployments_message_thread_id: - type: string - description: 'The Telegram deployment message thread ID.' - telegram_notifications_status_changes_message_thread_id: - type: string - description: 'The Telegram status change message thread ID.' - telegram_notifications_database_backups_message_thread_id: - type: string - description: 'The Telegram database backup message thread ID.' custom_server_limit: type: string description: 'The custom server limit.' - telegram_notifications_scheduled_tasks: - type: boolean - description: 'Whether to send scheduled task notifications via Telegram.' - telegram_notifications_scheduled_tasks_thread_id: - type: string - description: 'The Telegram scheduled task message thread ID.' members: description: 'The members of the team.' type: array diff --git a/resources/css/app.css b/resources/css/app.css index 32d476c1ab..6e7704eb7d 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -6,11 +6,11 @@ html, body { - @apply h-full bg-neutral-50 text-neutral-800 dark:bg-base dark:text-neutral-400 w-full; + @apply min-h-full bg-neutral-50 dark:bg-base dark:text-neutral-400 w-full; } body { - @apply text-sm antialiased scrollbar; + @apply text-sm antialiased scrollbar min-h-screen; } .apexcharts-tooltip { diff --git a/resources/views/components/resources/breadcrumbs.blade.php b/resources/views/components/resources/breadcrumbs.blade.php index f91e04037a..5f7029fd0b 100644 --- a/resources/views/components/resources/breadcrumbs.blade.php +++ b/resources/views/components/resources/breadcrumbs.blade.php @@ -21,7 +21,10 @@
  • {{ data_get($resource, 'environment.name') }} + href="{{ route('project.resource.index', [ + 'environment_uuid' => data_get($resource, 'environment.uuid'), + 'project_uuid' => data_get($resource, 'environment.project.uuid'), + ]) }}">{{ data_get($resource, 'environment.name') }} diff --git a/resources/views/livewire/project/application/configuration.blade.php b/resources/views/livewire/project/application/configuration.blade.php index 7827476d8f..b8f4b96f6e 100644 --- a/resources/views/livewire/project/application/configuration.blade.php +++ b/resources/views/livewire/project/application/configuration.blade.php @@ -9,31 +9,31 @@
    diff --git a/resources/views/livewire/project/database/configuration.blade.php b/resources/views/livewire/project/database/configuration.blade.php index b0702c24ae..8575f34b6f 100644 --- a/resources/views/livewire/project/database/configuration.blade.php +++ b/resources/views/livewire/project/database/configuration.blade.php @@ -8,38 +8,37 @@
    diff --git a/resources/views/livewire/project/environment-edit.blade.php b/resources/views/livewire/project/environment-edit.blade.php index af5e686c48..bdea09ced3 100644 --- a/resources/views/livewire/project/environment-edit.blade.php +++ b/resources/views/livewire/project/environment-edit.blade.php @@ -26,7 +26,7 @@
  • + href="{{ route('project.resource.index', ['environment_uuid' => $environment->uuid, 'project_uuid' => $project->uuid]) }}"> {{ $environment->name }}
    diff --git a/resources/views/livewire/project/index.blade.php b/resources/views/livewire/project/index.blade.php index cb8e1bbede..3e2849e5ea 100644 --- a/resources/views/livewire/project/index.blade.php +++ b/resources/views/livewire/project/index.blade.php @@ -12,21 +12,21 @@
    -