fix: show defined resources in server tab, so you will know what you need to delete before you can delete the server.

This commit is contained in:
Andras Bacsai 2023-11-27 09:39:43 +01:00
parent ec21155c9e
commit d396f649df
16 changed files with 85 additions and 14 deletions

View File

@ -137,7 +137,7 @@ public function new()
}
$service->parse(isNew: true);
return redirect()->route('project.service', [
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,

View File

@ -129,7 +129,7 @@ public function submit()
$service->parse(isNew: true);
return redirect()->route('project.service', [
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,

View File

@ -41,7 +41,7 @@ public function delete()
try {
$this->application->delete();
$this->emit('success', 'Application deleted successfully.');
return redirect()->route('project.service', $this->parameters);
return redirect()->route('project.service.configuration', $this->parameters);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@ -47,7 +47,14 @@ protected static function booted()
$application->environment_variables_preview()->delete();
});
}
public function link()
{
return route('project.application.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'application_uuid' => $this->uuid
]);
}
public function settings()
{
return $this->hasOne(ApplicationSetting::class);

View File

@ -194,6 +194,12 @@ public function getDiskUsage()
{
return instant_remote_process(["df /| tail -1 | awk '{ print $5}' | sed 's/%//g'"], $this, false);
}
public function definedResources() {
$applications = $this->applications();
$databases = $this->databases();
$services = $this->services();
return $applications->concat($databases)->concat($services->get());
}
public function hasDefinedResources()
{
$applications = $this->applications()->count() > 0;

View File

@ -361,6 +361,14 @@ public function saveExtraFields($fields)
}
}
}
public function link()
{
return route('project.service.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'service_uuid' => $this->uuid
]);
}
public function documentation()
{
$services = getServiceTemplates();

View File

@ -41,6 +41,14 @@ protected static function booted()
$database->environment_variables()->delete();
});
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function isLogDrainEnabled()
{
return data_get($this, 'is_log_drain_enabled', false);

View File

@ -48,6 +48,14 @@ public function isLogDrainEnabled()
{
return data_get($this, 'is_log_drain_enabled', false);
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function mongoInitdbRootPassword(): Attribute
{
return Attribute::make(

View File

@ -41,6 +41,14 @@ protected static function booted()
$database->environment_variables()->delete();
});
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function type(): string
{
return 'standalone-mysql';

View File

@ -41,7 +41,14 @@ protected static function booted()
$database->environment_variables()->delete();
});
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function isLogDrainEnabled()
{
return data_get($this, 'is_log_drain_enabled', false);

View File

@ -36,7 +36,14 @@ protected static function booted()
$database->environment_variables()->delete();
});
}
public function link()
{
return route('project.database.configuration', [
'project_uuid' => $this->environment->project->uuid,
'environment_name' => $this->environment->name,
'database_uuid' => $this->uuid
]);
}
public function isLogDrainEnabled()
{
return data_get($this, 'is_log_drain_enabled', false);

View File

@ -1,6 +1,6 @@
<div class="navbar-main">
<a class="{{ request()->routeIs('project.service') ? 'text-white' : '' }}"
href="{{ route('project.service', $parameters) }}">
<a class="{{ request()->routeIs('project.service.configuration') ? 'text-white' : '' }}"
href="{{ route('project.service.configuration', $parameters) }}">
<button>Configuration</button>
</a>
<x-services.links />

View File

@ -2,8 +2,8 @@
<livewire:project.service.navbar :service="$service" :parameters="$parameters" :query="$query" />
<div class="flex h-full pt-6">
<div class="flex flex-col gap-4 min-w-fit">
<a class="{{ request()->routeIs('project.service') ? 'text-white' : '' }}"
href="{{ route('project.service', [...$parameters, 'service_name' => null]) }}">
<a class="{{ request()->routeIs('project.service.configuration') ? 'text-white' : '' }}"
href="{{ route('project.service.configuration', [...$parameters, 'service_name' => null]) }}">
<button><- Back</button>
</a>
<a :class="activeTab === 'general' && 'text-white'"

View File

@ -11,12 +11,24 @@
<div class="pb-4">This will remove this server from Coolify. Beware! There is no coming
back!
</div>
@if ($server->hasDefinedResources())
<div class="text-warning">Please delete all resources before deleting this server.</div>
@if ($server->definedResources()->count() > 0)
<x-forms.button disabled isError isModal modalId="deleteServer">
Delete
</x-forms.button>
@else
<x-forms.button isError isModal modalId="deleteServer">
Delete
</x-forms.button>
@endif
@forelse ($server->definedResources() as $resource)
@if ($loop->first)
<div class="text-warning">Please delete all resources before deleting this server.</div>
@endif
<div class="flex gap-2">
<div class="w-64">{{ str($resource->type())->headline() }}</div>
<a class="text-white underline" href="{{ $resource->link() }}">{{ $resource->name }}</a>
</div>
@empty
@endforelse
@endif
</div>

View File

@ -79,7 +79,7 @@ class="items-center justify-center box">+ Add New Resource</a>
@endforeach
@foreach ($environment->services->sortBy('name') as $service)
<a class="relative box group"
href="{{ route('project.service', [$project->uuid, $environment->name, $service->uuid]) }}">
href="{{ route('project.service.configuration', [$project->uuid, $environment->name, $service->uuid]) }}">
<div class="flex flex-col mx-6">
<div class="font-bold text-white">{{ $service->name }}</div>
<div class="description">{{ $service->description }}</div>

View File

@ -120,7 +120,7 @@
// Services
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', ServiceIndex::class)->name('project.service');
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', ServiceIndex::class)->name('project.service.configuration');
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}', ServiceShow::class)->name('project.service.show');
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}/logs', Logs::class)->name('project.service.logs');
});