Feat: confirm server deletion
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Livewire\Server;
|
|||||||
|
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class Delete extends Component
|
class Delete extends Component
|
||||||
{
|
{
|
||||||
@@ -11,8 +13,12 @@ class Delete extends Component
|
|||||||
|
|
||||||
public $server;
|
public $server;
|
||||||
|
|
||||||
public function delete()
|
public function delete($password)
|
||||||
{
|
{
|
||||||
|
if (!Hash::check($password, Auth::user()->password)) {
|
||||||
|
$this->addError('password', 'The provided password is incorrect.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$this->authorize('delete', $this->server);
|
$this->authorize('delete', $this->server);
|
||||||
if ($this->server->hasDefinedResources()) {
|
if ($this->server->hasDefinedResources()) {
|
||||||
|
|||||||
@@ -8,13 +8,29 @@
|
|||||||
</div>
|
</div>
|
||||||
@if ($server->definedResources()->count() > 0)
|
@if ($server->definedResources()->count() > 0)
|
||||||
<div class="pb-2 text-red-500">You need to delete all resources before deleting this server.</div>
|
<div class="pb-2 text-red-500">You need to delete all resources before deleting this server.</div>
|
||||||
<x-modal-confirmation disabled isErrorButton buttonTitle="Delete">
|
<x-modal-confirmation
|
||||||
This server will be deleted. It is not reversible. <br>Please think again.
|
title="Confirm Server Deletion?"
|
||||||
</x-modal-confirmation>
|
isErrorButton
|
||||||
|
buttonTitle="Delete"
|
||||||
|
submitAction="delete"
|
||||||
|
:actions="['This server will be permanently deleted.']"
|
||||||
|
confirmationText="{{ $server->name }}"
|
||||||
|
confirmationLabel="Please confirm the execution of the actions by entering the Server Name below"
|
||||||
|
shortConfirmationLabel="Server Name"
|
||||||
|
step3ButtonText="Permanently Delete Server"
|
||||||
|
/>
|
||||||
@else
|
@else
|
||||||
<x-modal-confirmation isErrorButton buttonTitle="Delete">
|
<x-modal-confirmation
|
||||||
This server will be deleted. It is not reversible. <br>Please think again.
|
title="Confirm Server Deletion?"
|
||||||
</x-modal-confirmation>
|
isErrorButton
|
||||||
|
buttonTitle="Delete"
|
||||||
|
submitAction="delete"
|
||||||
|
:actions="['This server will be permanently deleted.']"
|
||||||
|
confirmationText="{{ $server->name }}"
|
||||||
|
confirmationLabel="Please confirm the execution of the actions by entering the Server Name below"
|
||||||
|
shortConfirmationLabel="Server Name"
|
||||||
|
step2ButtonText="Permanently Delete Server"
|
||||||
|
/>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user