Feat: delete volume confirmation

This commit is contained in:
ayntk-ai
2024-09-04 22:33:47 +02:00
parent a7b78dcf41
commit 08df814408
2 changed files with 20 additions and 8 deletions

View File

@@ -3,6 +3,8 @@
namespace App\Livewire\Project\Shared\Storages; namespace App\Livewire\Project\Shared\Storages;
use App\Models\LocalPersistentVolume; use App\Models\LocalPersistentVolume;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
use Livewire\Component; use Livewire\Component;
class Show extends Component class Show extends Component
@@ -36,8 +38,14 @@ class Show extends Component
$this->dispatch('success', 'Storage updated successfully'); $this->dispatch('success', 'Storage updated successfully');
} }
public function delete() public function delete($password)
{ {
if (!Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return;
}
// Test deletion in more detail
$this->storage->delete(); $this->storage->delete();
$this->dispatch('refreshStorages'); $this->dispatch('refreshStorages');
} }

View File

@@ -46,13 +46,17 @@
<x-forms.button type="submit"> <x-forms.button type="submit">
Update Update
</x-forms.button> </x-forms.button>
<x-modal-confirmation isErrorButton buttonTitle="Delete"> <x-modal-confirmation
This storage will be deleted <span class="font-bold dark:text-warning">{{ $storage->name }}</span>. title="Confirm persistent storage deletion?"
It isErrorButton
is buttonTitle="Delete"
not submitAction="delete"
reversible. <br>Please think again. :actions="['The selected persistent storage/volume will be permanently deleted.', 'If the persistent storage/volume is actvily used by a resource data will be lost.']"
</x-modal-confirmation> confirmationText="{{ $storage->name }}"
confirmationLabel="Please confirm the execution of the actions by entering the Storage Name below"
shortConfirmationLabel="Storage Name"
step3ButtonText="Permanently Delete Persistent Storage/Volume"
/>
</div> </div>
@endif @endif
</form> </form>