An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Refactor: Integrate tow step process in the modal component WIP
ayntk-ai73068aaa7509
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.phpindex 5859a2f001..eefb7d547c 100644--- a/resources/views/components/modal-confirmation.blade.php+++ b/resources/views/components/modal-confirmation.blade.php@@ -1,58 +1,161 @@@props([- 'title' => null,- 'isErrorButton' => false,- 'buttonTitle' => 'Confirm Action',- 'buttonFullWidth' => false,- 'customButton' => null,- 'disabled' => false,- 'action' => 'delete',- 'content' => null,+'title' => 'Are you sure?',+'isErrorButton' => false,+'buttonTitle' => 'Confirm Action',+'buttonFullWidth' => false,+'customButton' => null,+'disabled' => false,+'action' => 'delete',+'content' => null,+'checkboxes' => [],+'checkboxActions' => [],+'actions' => [],+'confirmWithText' => true,+'confirmWithPassword' => true,])-<div x-data="{ modalOpen: false }" @keydown.escape.window="modalOpen = false" :class="{ 'z-40': modalOpen }"- class="relative w-auto h-auto">++<div x-data="{+ modalOpen: false,+ step: {{ !empty($checkboxes) ? 1 : 2 }},+ selectedActions: [],+ deleteText: '',+ password: '',+ checkboxActions: @js($checkboxActions),+ getActionText(action) {+ return this.checkboxActions[action] || action;+ }+}" @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' : '' }}">- {{ $customButton }}- </x-forms.button>+ @if ($buttonFullWidth)+ <x-forms.button @click="modalOpen=true" class="w-full">+ {{ $customButton }}+ </x-forms.button>@else- @if ($content)- <div @click="modalOpen=true">- {{ $content }}- </div>- @else- <x-forms.button- @click="modalOpen=true"- class="{{ $buttonFullWidth ? 'w-full' : '' }} {{ $isErrorButton ? 'bg-red-500 hover:bg-red-600 text-white' : '' }}"- :disabled="$disabled"- >- {{ $buttonTitle }}- </x-forms.button>- @endif+ <x-forms.button @click="modalOpen=true">+ {{ $customButton }}+ </x-forms.button>+ @endif+ @else+ @if ($content)+ <div @click="modalOpen=true">+ {{ $content }}+ </div>+ @else+ @if ($disabled)+ @if ($buttonFullWidth)+ <x-forms.button class="w-full" isError disabled wire:target>+ {{ $buttonTitle }}+ </x-forms.button>+ @else+ <x-forms.button isError disabled wire:target>+ {{ $buttonTitle }}+ </x-forms.button>+ @endif+ @elseif ($isErrorButton)+ @if ($buttonFullWidth)+ <x-forms.button class="w-full" isError @click="modalOpen=true">+ {{ $buttonTitle }}+ </x-forms.button>+ @else+ <x-forms.button isError @click="modalOpen=true">+ {{ $buttonTitle }}+ </x-forms.button>+ @endif+ @else+ @if ($buttonFullWidth)+ <x-forms.button @click="modalOpen=true" class="flex w-full gap-2" wire:target>+ {{ $buttonTitle }}+ </x-forms.button>+ @else+ <x-forms.button @click="modalOpen=true" class="flex gap-2" wire:target>+ {{ $buttonTitle }}+ </x-forms.button>+ @endif+ @endif+ @endif@endif<template x-teleport="body">- <div x-show="modalOpen"- 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"- 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"- x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"- x-transition:leave="ease-in duration-100"- x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"- x-transition:leave-end="opacity-0 -translate-y-2 sm:scale-95"- 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 x-show="modalOpen" 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" 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" x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100" x-transition:leave="ease-in duration-100" x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100" x-transition:leave-end="opacity-0 -translate-y-2 sm:scale-95" 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>+ {{-- <button @click="modalOpen=false"+ class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 rounded-full dark:text-white hover:bg-coolgray-300">+ <svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"+ stroke-width="1.5" stroke="currentColor">+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>- </button>+ </button> --}}</div><div class="relative w-auto pb-8">- {{ $slot }}+ @if(!empty($checkboxes))+ <!-- Step 1: Select actions -->+ <div x-show="step === 1">+ <div class="flex justify-between items-center mb-4">+ <div class="px-2">Select the actions you want to perform:</div>+ </div>+ @foreach($checkboxes as $index => $checkbox)+ <x-forms.checkbox :id="$checkbox['id']" :wire:model="$checkbox['model']" :label="$checkbox['label']" x-on:change="$event.target.checked ? selectedActions.push('{{ $checkbox['id'] }}') : selectedActions = selectedActions.filter(a => a !== '{{ $checkbox['id'] }}')"></x-forms.checkbox>+ @endforeach+ {{-- <x-forms.button isError x-show="step === 1" @click="step = 2; selectedActions = Object.keys(checkboxActions).filter(action => $wire[action])" type="button">+ Continue+ </x-forms.button> --}}+ </div>+ @else+ <div x-init="step = 2"></div>+ @endif++ <!-- Step 2: Confirm deletion -->+ <div x-show="step === 2">+ <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4" role="alert">+ <p class="font-bold">Warning</p>+ <p>This operation is not reversible. Please proceed with caution.</p>+ </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">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>+ </svg>+ <span x-text="checkboxActions[action]" class="font-bold"></span>+ </li>+ </template>+ </ul>+ <div class="text-black dark:text-white mb-4">Please type <span class="text-red-500 font-bold">DELETE</span> to confirm this destructive action:</div>+ <input type="text" x-model="deleteText" class="w-full p-2 rounded mb-6 text-black input">+ </div>++ <!-- Step 3: Password confirmation -->+ <div x-show="step === 3">+ <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4" role="alert">+ <p class="font-bold">Final Confirmation</p>+ <p>Please enter your password to confirm this destructive action.</p>+ </div>+ <div class="mb-4">+ <label for="password-confirm" class="block text-sm font-medium text-gray-700 dark:text-gray-300">+ Your Password+ </label>+ <input type="password" id="password-confirm" x-model="password" class="input" placeholder="Enter your password">+ </div>+ </div>+ </div>+ <!-- Navigation buttons -->+ <div class="flex flex-row justify-between mt-4">+ <x-forms.button @click="step > 1 ? step-- : modalOpen = false" x-text="step > 1 ? 'Back' : 'Cancel'" class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300"></x-forms.button>+ <x-forms.button x-show="step < 3" {{-- :class="{'w-24': true, 'bg-red-500 hover:bg-red-600': isErrorButton}" --}} @click="step++" {{-- x-bind:disabled="step === 1 && selectedActions.length === 0" --}}>+ Continue+ </x-forms.button>+ <x-forms.button x-show="step === 3" {{-- :class="{'w-24': true, 'bg-red-500 hover:bg-red-600': isErrorButton}" --}} @click="$wire.{{ $action }}(selectedActions, password); modalOpen = false" x-bind:disabled="!password">+ Confirm+ </x-forms.button></div></div></div>diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.phpindex cae7c1dd90..c9bbc2ed01 100644--- a/resources/views/livewire/project/shared/danger.blade.php+++ b/resources/views/livewire/project/shared/danger.blade.php@@ -1,100 +1,27 @@-<div class="border border-red-600 rounded-md p-6 mt-8">- <h2 class="text-3xl font-bold mb-4">Danger Zone</h2>-- <div class="space-y-6">- <div class="flex items-center justify-between">- <div>- <h4 class="text-lg font-semibold">Delete Resource</h4>- <p class="text-gray-600 dark:text-gray-400">Once you delete a resource, there is no going back. Please be certain.</p>- </div>- <x-modal-confirmation- isError- type="button"- buttonTitle="Delete this resource"- title="Resource Deletion"- >- <div x-data="{ step: 1, deleteText: '', password: '', selectedActions: [], getActionText(action) {- const actionTexts = {- '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="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="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.docker_cleanup ? 'docker_cleanup' : null].filter(Boolean)" type="button">- Continue- </x-forms.button>- </div>- </div>-- <!-- Step 2: Confirm deletion -->- <div x-show="step === 2">- <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4" role="alert">- <p class="font-bold">Warning</p>- <p>This operation is not reversible. Please proceed with caution.</p>- </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">- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>- </svg>- <span x-text="getActionText(action)" class="font-bold"></span>- </li>- </template>- </ul>- <div class="text-black dark:text-white mb-4">Please type <span class="text-red-500 font-bold">DELETE</span> to confirm this destructive action:</div>- <input type="text" x-model="deleteText" class="w-full p-2 rounded mb-6 text-black input">- <div class="flex justify-between">- <x-forms.button @click="step = 1">Back</x-forms.button>- <x-forms.button isError type="button" @click="step = 3" x-bind:disabled="deleteText !== 'DELETE'">- Permanently Delete- </x-forms.button>- </div>- </div>-- <!-- Step 3: Password confirmation -->- <div x-show="step === 3">- <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4" role="alert">- <p class="font-bold">Final Confirmation</p>- <p>Please enter your password to confirm this destructive action.</p>- </div>- <div class="mb-4">- <label for="password-confirm" class="block text-sm font-medium text-gray-700 dark:text-gray-300">- Your Password- </label>- <input type="password" id="password-confirm" x-model="password"- class="input"- placeholder="Enter your password">- </div>- <div class="flex justify-between">- <x-forms.button @click="step = 2">Back</x-forms.button>- <x-forms.button isError type="button" @click="$wire.delete(selectedActions, password)" x-bind:disabled="!password">- Confirm Deletion- </x-forms.button>- </div>- </div>- </div>- </x-modal-confirmation>- </div>+<div>+ <h2>Danger Zone</h2>+ <div class="">Woah. I hope you know what are you doing.</div>+ <h4 class="pt-4">Delete Resource</h4>+ <div class="pb-4">This will stop your containers, delete all related data, etc. Beware! There is no coming+ back!</div>+ <x-modal-confirmation+ isError+ type="button"+ buttonTitle="Delete this resource"+ :checkboxes="[+ ['id' => 'delete_volumes', 'model' => 'delete_volumes', 'label' => 'Permanently delete associated volumes?'],+ ['id' => 'delete_connected_networks', 'model' => 'delete_connected_networks', 'label' => 'Permanently delete connected networks, predefined networks are not deleted?'],+ ['id' => 'delete_configurations', 'model' => 'delete_configurations', 'label' => 'Permanently delete configuration files from the server?'],+ ['id' => 'docker_cleanup', 'model' => 'docker_cleanup', 'label' => 'Run Docker cleanup (remove builder cache and unused images)?']+ ]"+ :checkboxActions="[+ 'delete_volumes' => $delete_volumes ? 'All associated volumes of this resource will be deleted.' : null,+ 'delete_connected_networks' => $delete_connected_networks ? 'All connected networks of this resource will be deleted (predefined networks are not deleted).' : null,+ 'delete_configurations' => $delete_configurations ? 'All configuration files of this resource will be deleted on the server.' : null,+ 'docker_cleanup' => $docker_cleanup ? 'Docker cleanup will be executed which removes builder cache and unused images.' : null+ ]"+ >+ This resource will be deleted. It is not reversible. <strong class="text-error">Please think again.</strong><br><br>+ </x-modal-confirmation></div>