From 2dcfdcab3bc071fe26d97a17647b718188e801ab Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:09:21 +0200 Subject: [PATCH 001/136] fix init scripts for postgres --- .../Project/Database/Postgresql/General.php | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.php index c12fa49f34..642aa793db 100644 --- a/app/Livewire/Project/Database/Postgresql/General.php +++ b/app/Livewire/Project/Database/Postgresql/General.php @@ -9,8 +9,6 @@ use Exception; use Livewire\Component; -use function Aws\filter; - class General extends Component { public StandalonePostgresql $database; @@ -126,8 +124,31 @@ public function instantSave() public function save_init_script($script) { - $this->database->init_scripts = filter($this->database->init_scripts, fn ($s) => $s['filename'] !== $script['filename']); - $this->database->init_scripts = array_merge($this->database->init_scripts, [$script]); + $initScripts = collect($this->database->init_scripts ?? []); + + $existingScript = $initScripts->firstWhere('filename', $script['filename']); + if ($existingScript && $existingScript['index'] !== $script['index']) { + $this->dispatch('error', 'A script with this filename already exists.'); + + return; + } + + $index = $initScripts->search(function ($item) use ($script) { + return $item['index'] === $script['index']; + }); + + if ($index !== false) { + $initScripts[$index] = $script; + } else { + $initScripts->push($script); + } + + $this->database->init_scripts = $initScripts->values()->map(function ($item, $index) { + $item['index'] = $index; + + return $item; + })->all(); + $this->database->save(); $this->dispatch('success', 'Init script saved.'); } From 66b458d807bc0ff9cc8acae47f57aef17359d15c Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:14:13 +0200 Subject: [PATCH 002/136] aws filter still used From 907c6cc4e54f6b82e0d0f1d35c2c1d56eaf84ace Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:16:06 +0200 Subject: [PATCH 003/136] format --- app/Livewire/Project/Database/Postgresql/General.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.php index 642aa793db..3abdcc22e2 100644 --- a/app/Livewire/Project/Database/Postgresql/General.php +++ b/app/Livewire/Project/Database/Postgresql/General.php @@ -127,6 +127,7 @@ public function save_init_script($script) $initScripts = collect($this->database->init_scripts ?? []); $existingScript = $initScripts->firstWhere('filename', $script['filename']); + if ($existingScript && $existingScript['index'] !== $script['index']) { $this->dispatch('error', 'A script with this filename already exists.'); From 7f393eb2c26c470cdf1a86820ed40a8cf33bea01 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:51:51 +0200 Subject: [PATCH 004/136] fix indexing after deletion and make sure init script is removed form the server --- .../Project/Database/Postgresql/General.php | 38 +++++++++++++++---- .../project/database/init-script.blade.php | 2 +- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.php index 3abdcc22e2..0180279120 100644 --- a/app/Livewire/Project/Database/Postgresql/General.php +++ b/app/Livewire/Project/Database/Postgresql/General.php @@ -144,11 +144,13 @@ public function save_init_script($script) $initScripts->push($script); } - $this->database->init_scripts = $initScripts->values()->map(function ($item, $index) { - $item['index'] = $index; + $this->database->init_scripts = $initScripts->values() + ->map(function ($item, $index) { + $item['index'] = $index; - return $item; - })->all(); + return $item; + }) + ->all(); $this->database->save(); $this->dispatch('success', 'Init script saved.'); @@ -159,12 +161,32 @@ public function delete_init_script($script) $collection = collect($this->database->init_scripts); $found = $collection->firstWhere('filename', $script['filename']); if ($found) { - $this->database->init_scripts = $collection->filter(fn ($s) => $s['filename'] !== $script['filename'])->toArray(); + $container_name = $this->database->uuid; + $configuration_dir = database_configuration_dir().'/'.$container_name; + $file_path = "$configuration_dir/docker-entrypoint-initdb.d/{$script['filename']}"; + + $command = "rm -f $file_path"; + try { + instant_remote_process([$command], $this->server); + } catch (\Exception $e) { + $this->dispatch('error', 'Failed to remove init script from server: '.$e->getMessage()); + + return; + } + + $updatedScripts = $collection->filter(fn ($s) => $s['filename'] !== $script['filename']) + ->values() + ->map(function ($item, $index) { + $item['index'] = $index; + + return $item; + }) + ->all(); + + $this->database->init_scripts = $updatedScripts; $this->database->save(); $this->refresh(); - $this->dispatch('success', 'Init script deleted.'); - - return; + $this->dispatch('success', 'Init script deleted from the database and the server.'); } } diff --git a/resources/views/livewire/project/database/init-script.blade.php b/resources/views/livewire/project/database/init-script.blade.php index 8ba0db23c8..1580e41cca 100644 --- a/resources/views/livewire/project/database/init-script.blade.php +++ b/resources/views/livewire/project/database/init-script.blade.php @@ -4,7 +4,7 @@ Save Date: Fri, 18 Oct 2024 21:07:23 +0200 Subject: [PATCH 005/136] fix: if an init script is renamed the old version is still on the server --- app/Actions/Database/StartPostgresql.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index 2a8e5476c9..3a2f9ce109 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -197,9 +197,12 @@ private function generate_environment_variables() private function generate_init_scripts() { + $this->commands[] = "rm -rf $this->configuration_dir/docker-entrypoint-initdb.d/*"; + if (is_null($this->database->init_scripts) || count($this->database->init_scripts) === 0) { return; } + foreach ($this->database->init_scripts as $init_script) { $filename = data_get($init_script, 'filename'); $content = data_get($init_script, 'content'); From 159c4aa7ac02fdae6849d8c6db7a7a837dd8f01a Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:08:45 +0200 Subject: [PATCH 006/136] remove old init script on server if it is renamed --- .../Project/Database/Postgresql/General.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.php index 0180279120..88dd5c1a86 100644 --- a/app/Livewire/Project/Database/Postgresql/General.php +++ b/app/Livewire/Project/Database/Postgresql/General.php @@ -127,6 +127,7 @@ public function save_init_script($script) $initScripts = collect($this->database->init_scripts ?? []); $existingScript = $initScripts->firstWhere('filename', $script['filename']); + $oldScript = $initScripts->firstWhere('index', $script['index']); if ($existingScript && $existingScript['index'] !== $script['index']) { $this->dispatch('error', 'A script with this filename already exists.'); @@ -134,6 +135,21 @@ public function save_init_script($script) return; } + $container_name = $this->database->uuid; + $configuration_dir = database_configuration_dir().'/'.$container_name; + + if ($oldScript && $oldScript['filename'] !== $script['filename']) { + $old_file_path = "$configuration_dir/docker-entrypoint-initdb.d/{$oldScript['filename']}"; + $delete_command = "rm -f $old_file_path"; + try { + instant_remote_process([$delete_command], $this->server); + } catch (\Exception $e) { + $this->dispatch('error', 'Failed to remove old init script from server: '.$e->getMessage()); + + return; + } + } + $index = $initScripts->search(function ($item) use ($script) { return $item['index'] === $script['index']; }); @@ -153,7 +169,7 @@ public function save_init_script($script) ->all(); $this->database->save(); - $this->dispatch('success', 'Init script saved.'); + $this->dispatch('success', 'Init script saved and updated.'); } public function delete_init_script($script) From 18201ece00132da40d51bf0ec4ee4bcba8ae4633 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:17:57 +0200 Subject: [PATCH 007/136] fix remove postgres config if it is null or not set --- app/Actions/Database/StartPostgresql.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index 3a2f9ce109..17cd6171f6 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -214,10 +214,15 @@ private function generate_init_scripts() private function add_custom_conf() { + $filename = 'custom-postgres.conf'; + $config_file_path = "$this->configuration_dir/$filename"; + if (is_null($this->database->postgres_conf) || empty($this->database->postgres_conf)) { + $this->commands[] = "rm -f $config_file_path"; + return; } - $filename = 'custom-postgres.conf'; + $content = $this->database->postgres_conf; if (! str($content)->contains('listen_addresses')) { $content .= "\nlisten_addresses = '*'"; @@ -225,6 +230,6 @@ private function add_custom_conf() $this->database->save(); } $content_base64 = base64_encode($content); - $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/{$filename} > /dev/null"; + $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $config_file_path > /dev/null"; } } From 8b30123add289c4e169692c79a36be5af611b352 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 17 Nov 2024 22:49:44 +0100 Subject: [PATCH 008/136] feat: add service/resource/project labels --- app/Actions/Database/StartClickhouse.php | 6 +--- app/Actions/Database/StartDragonfly.php | 6 +--- app/Actions/Database/StartKeydb.php | 6 +--- app/Actions/Database/StartMariadb.php | 6 +--- app/Actions/Database/StartMongodb.php | 6 +--- app/Actions/Database/StartMysql.php | 6 +--- app/Actions/Database/StartPostgresql.php | 6 +--- app/Actions/Database/StartRedis.php | 6 +--- app/Jobs/ApplicationDeploymentJob.php | 2 +- bootstrap/helpers/docker.php | 19 ++++++++++++- bootstrap/helpers/shared.php | 35 ++++++++++++++++++++++-- 11 files changed, 59 insertions(+), 45 deletions(-) diff --git a/app/Actions/Database/StartClickhouse.php b/app/Actions/Database/StartClickhouse.php index 13667e8297..ca850d4366 100644 --- a/app/Actions/Database/StartClickhouse.php +++ b/app/Actions/Database/StartClickhouse.php @@ -49,11 +49,7 @@ public function handle(StandaloneClickhouse $database) 'hard' => 262144, ], ], - 'labels' => [ - 'coolify.managed' => 'true', - 'coolify.type' => 'database', - 'coolify.databaseId' => $this->database->id, - ], + 'labels' => defaultDatabaseLabels($this->database)->toArray(), 'healthcheck' => [ 'test' => "clickhouse-client --password {$this->database->clickhouse_admin_password} --query 'SELECT 1'", 'interval' => '5s', diff --git a/app/Actions/Database/StartDragonfly.php b/app/Actions/Database/StartDragonfly.php index c72714e1cd..a7ee6c9949 100644 --- a/app/Actions/Database/StartDragonfly.php +++ b/app/Actions/Database/StartDragonfly.php @@ -46,11 +46,7 @@ public function handle(StandaloneDragonfly $database) 'networks' => [ $this->database->destination->network, ], - 'labels' => [ - 'coolify.managed' => 'true', - 'coolify.type' => 'database', - 'coolify.databaseId' => $this->database->id, - ], + 'labels' => defaultDatabaseLabels($this->database)->toArray(), 'healthcheck' => [ 'test' => "redis-cli -a {$this->database->dragonfly_password} ping", 'interval' => '5s', diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.php index bd98258ab6..b41abaf5ea 100644 --- a/app/Actions/Database/StartKeydb.php +++ b/app/Actions/Database/StartKeydb.php @@ -48,11 +48,7 @@ public function handle(StandaloneKeydb $database) 'networks' => [ $this->database->destination->network, ], - 'labels' => [ - 'coolify.managed' => 'true', - 'coolify.type' => 'database', - 'coolify.databaseId' => $this->database->id, - ], + 'labels' => defaultDatabaseLabels($this->database)->toArray(), 'healthcheck' => [ 'test' => "keydb-cli --pass {$this->database->keydb_password} ping", 'interval' => '5s', diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php index 696dd7ff4b..c47bf82cc5 100644 --- a/app/Actions/Database/StartMariadb.php +++ b/app/Actions/Database/StartMariadb.php @@ -43,11 +43,7 @@ public function handle(StandaloneMariadb $database) 'networks' => [ $this->database->destination->network, ], - 'labels' => [ - 'coolify.managed' => 'true', - 'coolify.type' => 'database', - 'coolify.databaseId' => $this->database->id, - ], + 'labels' => defaultDatabaseLabels($this->database)->toArray(), 'healthcheck' => [ 'test' => ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized'], 'interval' => '5s', diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php index 26a0f82d0a..20b722a6e5 100644 --- a/app/Actions/Database/StartMongodb.php +++ b/app/Actions/Database/StartMongodb.php @@ -51,11 +51,7 @@ public function handle(StandaloneMongodb $database) 'networks' => [ $this->database->destination->network, ], - 'labels' => [ - 'coolify.managed' => 'true', - 'coolify.type' => 'database', - 'coolify.databaseId' => $this->database->id, - ], + 'labels' => defaultDatabaseLabels($this->database)->toArray(), 'healthcheck' => [ 'test' => [ 'CMD', diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php index a3694648f9..33272b37e4 100644 --- a/app/Actions/Database/StartMysql.php +++ b/app/Actions/Database/StartMysql.php @@ -43,11 +43,7 @@ public function handle(StandaloneMysql $database) 'networks' => [ $this->database->destination->network, ], - 'labels' => [ - 'coolify.managed' => 'true', - 'coolify.type' => 'database', - 'coolify.databaseId' => $this->database->id, - ], + 'labels' => defaultDatabaseLabels($this->database)->toArray(), 'healthcheck' => [ 'test' => ['CMD', 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', "-p{$this->database->mysql_root_password}"], 'interval' => '5s', diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index f5e85087ff..0cd35e20bc 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -47,11 +47,7 @@ public function handle(StandalonePostgresql $database) 'networks' => [ $this->database->destination->network, ], - 'labels' => [ - 'coolify.managed' => 'true', - 'coolify.type' => 'database', - 'coolify.databaseId' => $this->database->id, - ], + 'labels' => defaultDatabaseLabels($this->database)->toArray(), 'healthcheck' => [ 'test' => [ 'CMD-SHELL', diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php index 7a2d2b34d5..6f12408471 100644 --- a/app/Actions/Database/StartRedis.php +++ b/app/Actions/Database/StartRedis.php @@ -48,11 +48,7 @@ public function handle(StandaloneRedis $database) 'networks' => [ $this->database->destination->network, ], - 'labels' => [ - 'coolify.managed' => 'true', - 'coolify.type' => 'database', - 'coolify.databaseId' => $this->database->id, - ], + 'labels' => defaultDatabaseLabels($this->database)->toArray(), 'healthcheck' => [ 'test' => [ 'CMD-SHELL', diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index cd89f55f37..7177b27f35 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1683,7 +1683,7 @@ private function generate_compose_file() return escapeDollarSign($value); }); } - $labels = $labels->merge(defaultLabels($this->application->id, $this->application->uuid, $this->pull_request_id))->toArray(); + $labels = $labels->merge(defaultLabels($this->application->id, $this->application->uuid, $this->application->project()->name, $this->application->name, $this->pull_request_id))->toArray(); // Check for custom HEALTHCHECK if ($this->application->build_pack === 'dockerfile' || $this->application->dockerfile) { diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index da99c5cbdb..f80f7a69cc 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -188,7 +188,19 @@ function get_port_from_dockerfile($dockerfile): ?int return null; } -function defaultLabels($id, $name, $pull_request_id = 0, string $type = 'application', $subType = null, $subId = null) +function defaultDatabaseLabels($database) { + $labels = collect([]); + $labels->push('coolify.managed=true'); + $labels->push('coolify.type=database'); + $labels->push('coolify.databaseId='.$database->id); + $labels->push('coolify.resourceName='.Str::slug($database->name)); + $labels->push('coolify.serviceName='.Str::slug($database->name)); + $labels->push('coolify.projectName='.Str::slug($database->project()->name)); + + return $labels; +} + +function defaultLabels($id, $name, string $projectName, string $resourceName, $pull_request_id = 0, string $type = 'application', $subType = null, $subId = null, $subName = null) { $labels = collect([]); $labels->push('coolify.managed=true'); @@ -196,14 +208,19 @@ function defaultLabels($id, $name, $pull_request_id = 0, string $type = 'applica $labels->push('coolify.'.$type.'Id='.$id); $labels->push("coolify.type=$type"); $labels->push('coolify.name='.$name); + $labels->push('coolify.resourceName='.Str::slug($resourceName)); + $labels->push('coolify.projectName='.Str::slug($projectName)); + $labels->push('coolify.serviceName='.Str::slug($subName ?? $resourceName)); $labels->push('coolify.pullRequestId='.$pull_request_id); if ($type === 'service') { $subId && $labels->push('coolify.service.subId='.$subId); $subType && $labels->push('coolify.service.subType='.$subType); + $subName && $labels->push('coolify.service.subName='.Str::slug($subName)); } return $labels; } + function generateServiceSpecificFqdns(ServiceApplication|Application $resource) { if ($resource->getMorphClass() === \App\Models\ServiceApplication::class) { diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index dc49247892..fe01e046e9 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -2059,7 +2059,16 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal } else { $fqdns = collect(data_get($savedService, 'fqdns'))->filter(); } - $defaultLabels = defaultLabels($resource->id, $containerName, type: 'service', subType: $isDatabase ? 'database' : 'application', subId: $savedService->id); + $defaultLabels = defaultLabels( + id: $resource->id, + name: $containerName, + projectName: $resource->project()->name, + resourceName: $resource->name, + type: 'service', + subType: $isDatabase ? 'database' : 'application', + subId: $savedService->id, + subName: $savedService->name, + ); $serviceLabels = $serviceLabels->merge($defaultLabels); if (! $isDatabase && $fqdns->count() > 0) { if ($fqdns) { @@ -2887,7 +2896,15 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal } } } - $defaultLabels = defaultLabels($resource->id, $containerName, $pull_request_id, type: 'application'); + + $defaultLabels = defaultLabels( + id: $resource->id, + name: $containerName, + projectName: $resource->project()->name, + resourceName: $resource->name, + pull_request_id: $pull_request_id, + type: 'application' + ); $serviceLabels = $serviceLabels->merge($defaultLabels); if ($server->isLogDrainEnabled()) { @@ -3673,6 +3690,8 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $defaultLabels = defaultLabels( id: $resource->id, name: $containerName, + projectName: $resource->project()->name, + resourceName: $resource->name, pull_request_id: $pullRequestId, type: 'application' ); @@ -3682,7 +3701,17 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int } else { $fqdns = collect(data_get($savedService, 'fqdns'))->filter(); } - $defaultLabels = defaultLabels($resource->id, $containerName, type: 'service', subType: $isDatabase ? 'database' : 'application', subId: $savedService->id); + + $defaultLabels = defaultLabels( + id: $resource->id, + name: $containerName, + projectName: $resource->project()->name, + resourceName: $resource->name, + type: 'service', + subType: $isDatabase ? 'database' : 'application', + subId: $savedService->id, + subName: $savedService->human_name ?? $savedService->name, + ); } // Add COOLIFY_FQDN & COOLIFY_URL to environment if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { From 3e2e24dcca0e7222feb86fa3960189a6a7195828 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:04:08 +0100 Subject: [PATCH 009/136] feat add uuid to environments --- ..._124742_add_uuid_to_environments_table.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 database/migrations/2024_11_22_124742_add_uuid_to_environments_table.php 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'); + }); + } +}; From e776302a25a4edeedbc882ff64286be279b6fc6e Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:28:06 +0100 Subject: [PATCH 010/136] use new route for dash and project --- app/Livewire/Dashboard.php | 6 +++ app/Livewire/Project/Index.php | 6 +++ resources/views/livewire/dashboard.blade.php | 26 +++++------ .../views/livewire/project/index.blade.php | 45 ++++++------------- 4 files changed, 36 insertions(+), 47 deletions(-) diff --git a/app/Livewire/Dashboard.php b/app/Livewire/Dashboard.php index 69ba19e401..0dc69087b6 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,11 @@ public function loadDeployments() ])->sortBy('id')->groupBy('server_name')->toArray(); } + public function navigateToProject($projectUuid) + { + return Redirect::route('project.show', ['project_uuid' => $projectUuid]); + } + public function render() { return view('livewire.dashboard'); diff --git a/app/Livewire/Project/Index.php b/app/Livewire/Project/Index.php index f8eb838be6..8808037b79 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,9 @@ public function render() { return view('livewire.project.index'); } + + public function navigateToProject($projectUuid) + { + return Redirect::route('project.show', ['project_uuid' => $projectUuid]); + } } diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php index decd75c462..50a5e020f7 100644 --- a/resources/views/livewire/dashboard.blade.php +++ b/resources/views/livewire/dashboard.blade.php @@ -25,7 +25,7 @@