make things more clear

This commit is contained in:
ayntk-ai
2024-08-27 14:19:37 +02:00
parent 9040f5d2a1
commit 4726676248
5 changed files with 29 additions and 25 deletions

View File

@@ -10,7 +10,7 @@ class DeleteService
{
use AsAction;
public function handle(Service $service, bool $deleteConfigurations, bool $deleteVolumes, bool $deleteImages, bool $deleteConnectedNetworks)
public function handle(Service $service, bool $deleteConfigurations, bool $deleteVolumes, bool $dockerCleanup, bool $deleteConnectedNetworks)
{
try {
$server = data_get($service, 'server');
@@ -69,7 +69,7 @@ class DeleteService
$service->tags()->detach();
$service->forceDelete();
if ($deleteImages) {
if ($dockerCleanup) {
CleanupDocker::run($server, true);
}
}

View File

@@ -33,7 +33,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
public bool $deleteConfigurations,
public bool $deleteVolumes,
public bool $deleteImages,
public bool $dockerCleanup,
public bool $deleteConnectedNetworks
) {
}
@@ -60,7 +60,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
break;
case 'service':
StopService::run($this->resource, true);
DeleteService::run($this->resource, $this->deleteConfigurations, $this->deleteVolumes, $this->deleteImages, $this->deleteConnectedNetworks);
DeleteService::run($this->resource, $this->deleteConfigurations, $this->deleteVolumes, $this->dockerCleanup, $this->deleteConnectedNetworks);
break;
}
@@ -80,7 +80,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
|| $this->resource instanceof StandaloneDragonfly
|| $this->resource instanceof StandaloneClickhouse;
$server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server');
if (($this->deleteImages || $isDatabase) && $server) {
if (($this->dockerCleanup || $isDatabase) && $server) {
CleanupDocker::run($server, true);
}

View File

@@ -20,7 +20,7 @@ class Danger extends Component
public bool $delete_volumes = true;
public bool $delete_images = true;
public bool $docker_cleanup = true;
public bool $delete_connected_networks = true;
@@ -48,7 +48,7 @@ class Danger extends Component
$this->resource,
$this->delete_configurations,
$this->delete_volumes,
$this->delete_images,
$this->docker_cleanup,
$this->delete_connected_networks
);

View File

@@ -8,15 +8,7 @@
'action' => 'delete',
'content' => null,
])
<div x-data="{ modalOpen: false, step: 1, deleteText: '', selectedActions: [], getActionText(action) {
const actionTexts = {
'delete_volumes': 'Delete associated volumes',
'delete_connected_networks': 'Delete connected networks',
'delete_configurations': 'Delete configuration files',
'delete_images': 'Delete associated unused images'
};
return actionTexts[action] || action;
} }" @keydown.escape.window="modalOpen = false; step = 1" :class="{ 'z-40': modalOpen }"
<div x-data="{ modalOpen: false }" @keydown.escape.window="modalOpen = false" :class="{ 'z-40': modalOpen }"
class="relative w-auto h-auto">
@if ($customButton)
<x-forms.button @click="modalOpen=true" class="{{ $buttonFullWidth ? 'w-full' : '' }}">
@@ -32,7 +24,6 @@
@click="modalOpen=true"
class="{{ $buttonFullWidth ? 'w-full' : '' }} {{ $isErrorButton ? 'bg-red-500 hover:bg-red-600 text-white' : '' }}"
:disabled="$disabled"
wire:target
>
{{ $buttonTitle }}
</x-forms.button>
@@ -43,7 +34,7 @@
class="fixed top-0 lg:pt-10 left-0 z-[99] flex items-start justify-center w-screen h-screen" x-cloak>
<div x-show="modalOpen" x-transition:enter="ease-out duration-100" x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100" x-transition:leave="ease-in duration-100"
x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" @click="modalOpen=false; step=1"
x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" @click="modalOpen=false"
class="absolute inset-0 w-full h-full bg-black bg-opacity-20 backdrop-blur-sm"></div>
<div x-show="modalOpen" x-trap.inert.noscroll="modalOpen" x-transition:enter="ease-out duration-100"
x-transition:enter-start="opacity-0 -translate-y-2 sm:scale-95"
@@ -54,6 +45,11 @@
class="relative w-full py-6 border rounded min-w-full lg:min-w-[36rem] max-w-fit bg-neutral-100 border-neutral-400 dark:bg-base px-7 dark:border-coolgray-300">
<div class="flex items-center justify-between pb-3">
<h3 class="text-2xl font-bold">{{ $title }}</h3>
<button @click="modalOpen=false" class="absolute top-4 right-4 text-gray-600 hover:text-gray-800">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<div class="relative w-auto pb-8">
{{ $slot }}

View File

@@ -14,23 +14,25 @@
>
<div x-data="{ step: 1, deleteText: '', password: '', selectedActions: [], getActionText(action) {
const actionTexts = {
'delete_volumes': 'Delete associated volumes',
'delete_connected_networks': 'Delete connected networks',
'delete_configurations': 'Delete configuration files',
'delete_images': 'Delete associated unused images'
'delete_volumes': 'All associated volumes of this resource will be deleted.',
'delete_connected_networks': 'All connected networks of this resource will be deleted (predefined networks are not deleted).',
'delete_configurations': 'All configuration files of this resource will be deleted on the server.',
'docker_cleanup': 'Docker cleanup will be executed which removes builder cache and unused images.'
};
return actionTexts[action] || action;
} }">
<!-- Step 1: Select actions -->
<div x-show="step === 1">
<div class="px-2 mb-4">Select the actions you want to perform:</div>
<div class="flex justify-between items-center mb-4">
<div class="px-2">Select the actions you want to perform:</div>
</div>
<x-forms.checkbox id="delete_volumes" wire:model="delete_volumes" label="Permanently delete associated volumes?"></x-forms.checkbox>
<x-forms.checkbox id="delete_connected_networks" wire:model="delete_connected_networks" label="Permanently delete connected networks, predefined networks are not deleted?"></x-forms.checkbox>
<x-forms.checkbox id="delete_configurations" wire:model="delete_configurations" label="Permanently delete configuration files from the server?"></x-forms.checkbox>
<x-forms.checkbox id="delete_images" wire:model="delete_images" label="Permanently delete associated unused images?"></x-forms.checkbox>
<x-forms.checkbox id="docker_cleanup" wire:model="docker_cleanup" label="Run Docker cleanup (remove builder cache and unused images)?"></x-forms.checkbox>
<div class="flex justify-between mt-4">
<x-forms.button @click="$dispatch('close-modal')">Cancel</x-forms.button>
<x-forms.button isError x-show="step === 1" @click="step = 2; selectedActions = [$wire.delete_volumes ? 'delete_volumes' : null, $wire.delete_connected_networks ? 'delete_connected_networks' : null, $wire.delete_configurations ? 'delete_configurations' : null, $wire.delete_images ? 'delete_images' : null].filter(Boolean)" x-bind:disabled="!($wire.delete_volumes || $wire.delete_connected_networks || $wire.delete_configurations || $wire.delete_images)" type="button">
<x-forms.button isError x-show="step === 1" @click="step = 2; selectedActions = [$wire.delete_volumes ? 'delete_volumes' : null, $wire.delete_connected_networks ? 'delete_connected_networks' : null, $wire.delete_configurations ? 'delete_configurations' : null, $wire.docker_cleanup ? 'docker_cleanup' : null].filter(Boolean)" type="button">
Continue
</x-forms.button>
</div>
@@ -44,6 +46,12 @@
</div>
<div class="px-2 mb-4">The following actions will be performed:</div>
<ul class="mb-4 space-y-2">
<li class="flex items-center text-red-500">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
<span class="font-bold">All containers of this resource will be stopped and permanently deleted.</span>
</li>
<template x-for="action in selectedActions" :key="action">
<li class="flex items-center text-red-500">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">