destination and dashboard confirmation
This commit is contained in:
@@ -30,10 +30,10 @@ class Dashboard extends Component
|
||||
|
||||
public function cleanup_queue()
|
||||
{
|
||||
$this->dispatch('success', 'Cleanup started.');
|
||||
Artisan::queue('cleanup:application-deployment-queue', [
|
||||
'--team-id' => currentTeam()->id,
|
||||
]);
|
||||
return redirect()->route('dashboard')->with('success', 'Cleanup started.');
|
||||
}
|
||||
|
||||
public function get_deployments()
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Destination;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Livewire\Component;
|
||||
|
||||
class Form extends Component
|
||||
@@ -26,8 +27,13 @@ class Form extends Component
|
||||
$this->destination->save();
|
||||
}
|
||||
|
||||
public function delete()
|
||||
public function delete($password)
|
||||
{
|
||||
if (!Hash::check($password, Auth::user()->password)) {
|
||||
$this->addError('password', 'The provided password is incorrect.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') {
|
||||
if ($this->destination->attachedTo()) {
|
||||
|
@@ -10,7 +10,7 @@
|
||||
'checkboxes' => [],
|
||||
'actions' => [],
|
||||
'confirmWithText' => true,
|
||||
'confirmText' => 'Confirm Deletion',
|
||||
'confirmationText' => 'Confirm Deletion',
|
||||
'confirmationLabel' => 'Please confirm the execution of the actions by entering the Name below',
|
||||
'shortConfirmationLabel' => 'Name',
|
||||
'confirmWithPassword' => true,
|
||||
@@ -27,8 +27,8 @@
|
||||
deleteText: '',
|
||||
password: '',
|
||||
actions: @js($actions),
|
||||
confirmText: @js($confirmText),
|
||||
userConfirmText: '',
|
||||
confirmationText: @js($confirmationText),
|
||||
userConfirmationText: '',
|
||||
confirmWithText: @js($confirmWithText),
|
||||
confirmWithPassword: @js($confirmWithPassword),
|
||||
copied: false,
|
||||
@@ -39,7 +39,7 @@
|
||||
this.step = this.initialStep;
|
||||
this.deleteText = '';
|
||||
this.password = '';
|
||||
this.userConfirmText = '';
|
||||
this.userConfirmationText = '';
|
||||
this.selectedActions = @js(collect($checkboxes)->pluck('id')->all());
|
||||
$wire.$refresh();
|
||||
},
|
||||
@@ -69,8 +69,8 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
copyConfirmText() {
|
||||
navigator.clipboard.writeText(this.confirmText);
|
||||
copyConfirmationText() {
|
||||
navigator.clipboard.writeText(this.confirmationText);
|
||||
this.copied = true;
|
||||
setTimeout(() => {
|
||||
this.copied = false;
|
||||
@@ -199,8 +199,8 @@
|
||||
<p class="text-sm mb-2">{{ $confirmationLabel }}</p>
|
||||
|
||||
<div class="relative mb-2">
|
||||
<input type="text" x-model="confirmText" class="w-full p-2 pr-10 rounded text-black input cursor-text" readonly>
|
||||
<button @click="copyConfirmText()" class="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-500 hover:text-gray-700" title="Copy confirmation text" x-ref="copyButton">
|
||||
<input type="text" x-model="confirmationText" class="w-full p-2 pr-10 rounded text-black input cursor-text" readonly>
|
||||
<button @click="copyConfirmationText()" class="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-500 hover:text-gray-700" title="Copy confirmation text" x-ref="copyButton">
|
||||
<template x-if="!copied">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path d="M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z" />
|
||||
@@ -215,17 +215,16 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<label for="userConfirmText" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mt-4">
|
||||
<label for="userConfirmationText" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mt-4">
|
||||
{{ $shortConfirmationLabel }}
|
||||
</label>
|
||||
<input type="text" x-model="userConfirmText" class="w-full p-2 rounded text-black input mt-1" placeholder="Type the Resource Name here">
|
||||
<input type="text" x-model="userConfirmationText" class="w-full p-2 rounded text-black input mt-1">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Step 3: Password confirmation -->
|
||||
@if($confirmWithPassword)
|
||||
<div x-show="step === 3">
|
||||
<div x-show="step === 3 && confirmWithPassword">
|
||||
<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>
|
||||
@@ -241,7 +240,6 @@
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<!-- Navigation buttons -->
|
||||
<div class="flex flex-row justify-between mt-4">
|
||||
@@ -263,7 +261,7 @@
|
||||
</template>
|
||||
|
||||
<template x-if="step === 2">
|
||||
<x-forms.button @click="step === finalStep ? executeAction() : step++" x-bind:disabled="confirmWithText && userConfirmText !== confirmText" class="w-auto" isError>
|
||||
<x-forms.button @click="step === finalStep ? executeAction() : step++" x-bind:disabled="confirmWithText && userConfirmationText !== confirmationText" class="w-auto" isError>
|
||||
<span x-text="step === finalStep ? step3ButtonText : step2ButtonText"></span>
|
||||
</x-forms.button>
|
||||
</template>
|
||||
|
@@ -122,9 +122,24 @@
|
||||
@if (count($deployments_per_server) > 0)
|
||||
<x-loading />
|
||||
@endif
|
||||
<x-modal-confirmation isErrorButton action="cleanup_queue" buttonTitle="Cleanup Queues">
|
||||
This will clean up the deployment queue. <br>Please think again.
|
||||
</x-modal-confirmation>
|
||||
<x-modal-confirmation
|
||||
title="Confirm Queues Cleanup"
|
||||
buttonTitle="Cleanup Queues"
|
||||
isErrorButton
|
||||
submitAction="cleanup_queue"
|
||||
:actions="['Cleanup all running Deployment Queues']"
|
||||
buttonTitle="Cleanup Queues"
|
||||
:confirmWithText="false"
|
||||
:confirmWithPassword="false"
|
||||
step3ButtonText="Cleanup Deployment Queues"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
@if (session('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div wire:poll.3000ms="get_deployments" class="grid grid-cols-1">
|
||||
@forelse ($deployments_per_server as $server_name => $deployments)
|
||||
@@ -168,4 +183,6 @@
|
||||
}
|
||||
</script>
|
||||
{{-- <x-forms.button wire:click='getIptables'>Get IPTABLES</x-forms.button> --}}
|
||||
|
||||
|
||||
</div>
|
||||
|
@@ -6,9 +6,19 @@
|
||||
Save
|
||||
</x-forms.button>
|
||||
@if ($destination->network !== 'coolify')
|
||||
<x-modal-confirmation isErrorButton buttonTitle="Delete Destination">
|
||||
This destination will be deleted. It is not reversible. <br>Please think again.
|
||||
</x-modal-confirmation>
|
||||
<x-modal-confirmation
|
||||
title="Confirm Destination Deletion?"
|
||||
buttonTitle="Delete Destination"
|
||||
isErrorButton
|
||||
submitAction="delete"
|
||||
:actions="['This will delete the selected destination/network.']"
|
||||
confirmationText="{{ $destination->name }}"
|
||||
confirmationLabel="Please confirm the execution of the actions by entering the Destination Name below"
|
||||
shortConfirmationLabel="Destination Name"
|
||||
buttonTitle="Delete Destination"
|
||||
step3ButtonText="Permanently Delete Destination"
|
||||
:confirmWithPassword="true"
|
||||
/>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user