From 0670e6c1d632c2e0d936cd346a53d000367c8852 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 30 Nov 2023 12:21:53 +0100 Subject: [PATCH] fix: server view for link() --- app/Models/Application.php | 13 ++++---- app/Models/Service.php | 13 ++++---- app/Models/StandaloneMariadb.php | 13 ++++---- app/Models/StandaloneMongodb.php | 13 ++++---- app/Models/StandaloneMysql.php | 13 ++++---- app/Models/StandalonePostgresql.php | 13 ++++---- app/Models/StandaloneRedis.php | 13 ++++---- .../views/livewire/server/delete.blade.php | 30 ++++++++++++++----- 8 files changed, 78 insertions(+), 43 deletions(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index e2d93c7a1..0a9c8fac8 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -50,11 +50,14 @@ class Application extends BaseModel } public function link() { - return route('project.application.configuration', [ - 'project_uuid' => $this->environment->project->uuid, - 'environment_name' => $this->environment->name, - 'application_uuid' => $this->uuid - ]); + 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'), + 'application_uuid' => data_get($this, 'uuid') + ]); + } + return null; } public function settings() { diff --git a/app/Models/Service.php b/app/Models/Service.php index 3a02ed560..b5842bb88 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -363,11 +363,14 @@ class Service extends BaseModel } public function link() { - return route('project.service.configuration', [ - 'project_uuid' => $this->environment->project->uuid, - 'environment_name' => $this->environment->name, - 'service_uuid' => $this->uuid - ]); + 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'), + 'service_uuid' => data_get($this, 'uuid') + ]); + } + return null; } public function documentation() { diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php index ca7221d7c..8893632d3 100644 --- a/app/Models/StandaloneMariadb.php +++ b/app/Models/StandaloneMariadb.php @@ -43,11 +43,14 @@ class StandaloneMariadb extends BaseModel } public function link() { - return route('project.database.configuration', [ - 'project_uuid' => $this->environment->project->uuid, - 'environment_name' => $this->environment->name, - 'database_uuid' => $this->uuid - ]); + 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'), + 'database_uuid' => data_get($this, 'uuid') + ]); + } + return null; } public function isLogDrainEnabled() { diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php index 598719acf..c041c9407 100644 --- a/app/Models/StandaloneMongodb.php +++ b/app/Models/StandaloneMongodb.php @@ -50,11 +50,14 @@ class StandaloneMongodb extends BaseModel } public function link() { - return route('project.database.configuration', [ - 'project_uuid' => $this->environment->project->uuid, - 'environment_name' => $this->environment->name, - 'database_uuid' => $this->uuid - ]); + 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'), + 'database_uuid' => data_get($this, 'uuid') + ]); + } + return null; } public function mongoInitdbRootPassword(): Attribute { diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php index 4cbee006e..a4691b9b2 100644 --- a/app/Models/StandaloneMysql.php +++ b/app/Models/StandaloneMysql.php @@ -43,11 +43,14 @@ class StandaloneMysql extends BaseModel } public function link() { - return route('project.database.configuration', [ - 'project_uuid' => $this->environment->project->uuid, - 'environment_name' => $this->environment->name, - 'database_uuid' => $this->uuid - ]); + 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'), + 'database_uuid' => data_get($this, 'uuid') + ]); + } + return null; } public function type(): string { diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php index 0056f9b51..e0db00d76 100644 --- a/app/Models/StandalonePostgresql.php +++ b/app/Models/StandalonePostgresql.php @@ -43,11 +43,14 @@ class StandalonePostgresql extends BaseModel } public function link() { - return route('project.database.configuration', [ - 'project_uuid' => $this->environment->project->uuid, - 'environment_name' => $this->environment->name, - 'database_uuid' => $this->uuid - ]); + 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'), + 'database_uuid' => data_get($this, 'uuid') + ]); + } + return null; } public function isLogDrainEnabled() { diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php index b2038d8af..95add8315 100644 --- a/app/Models/StandaloneRedis.php +++ b/app/Models/StandaloneRedis.php @@ -38,11 +38,14 @@ class StandaloneRedis extends BaseModel } public function link() { - return route('project.database.configuration', [ - 'project_uuid' => $this->environment->project->uuid, - 'environment_name' => $this->environment->name, - 'database_uuid' => $this->uuid - ]); + 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'), + 'database_uuid' => data_get($this, 'uuid') + ]); + } + return null; } public function isLogDrainEnabled() { diff --git a/resources/views/livewire/server/delete.blade.php b/resources/views/livewire/server/delete.blade.php index b1855ea15..e85fe37e5 100644 --- a/resources/views/livewire/server/delete.blade.php +++ b/resources/views/livewire/server/delete.blade.php @@ -25,10 +25,17 @@ @if ($loop->first)

Defined resources

@endif - -
{{ str($resource->type())->headline() }}
-
{{ $resource->name }}
-
+ @if ($resource->link()) + +
{{ str($resource->type())->headline() }}
+
{{ $resource->name }}
+
+ @else +
+
{{ str($resource->type())->headline() }}
+
{{ $resource->name }}
+
+ @endif @empty @endforelse @@ -38,10 +45,17 @@ @if ($loop->first)

Defined resources

@endif - -
{{ str($resource->type())->headline() }}
-
{{ $resource->name }}
-
+ @if ($resource->link()) + +
{{ str($resource->type())->headline() }}
+
{{ $resource->name }}
+
+ @else +
+
{{ str($resource->type())->headline() }}
+
{{ $resource->name }}
+
+ @endif @empty @endforelse