feat: add confirmation modals for detaching and deleting drives to enhance user experience

This commit is contained in:
2025-12-05 04:21:36 -05:00
parent 940c97da9f
commit e37165e06e
2 changed files with 240 additions and 22 deletions

View File

@@ -109,6 +109,18 @@ class Storage extends Component
public ?string $movingDriveKey = null;
public string $moveDriveTargetBus = 'scsi';
/**
* Form state for detach confirmation modal.
*/
public bool $showDetachModal = false;
public ?string $detachingDriveKey = null;
/**
* Form state for delete confirmation modal.
*/
public bool $showDeleteModal = false;
public ?string $deletingDriveKey = null;
/**
* Storage name for cephpool.
*/
@@ -619,15 +631,40 @@ class Storage extends Component
}
/**
* Detach a drive (move to unused).
* Open the detach confirmation modal.
*/
public function detachDrive(string $driveKey): void
public function openDetachModal(string $driveKey): void
{
if (!isset($this->drives[$driveKey])) {
$this->notify('Drive not found.', 'error');
return;
}
$this->detachingDriveKey = $driveKey;
$this->showDetachModal = true;
}
/**
* Close the detach confirmation modal.
*/
public function closeDetachModal(): void
{
$this->showDetachModal = false;
$this->detachingDriveKey = null;
}
/**
* Detach a drive (move to unused).
*/
public function detachDrive(): void
{
if (!$this->detachingDriveKey || !isset($this->drives[$this->detachingDriveKey])) {
$this->notify('Drive not found.', 'error');
return;
}
$driveKey = $this->detachingDriveKey;
// Check VM status - must be stopped to detach
if ($this->status && $this->status->status !== 'stopped') {
$this->notify('VM must be stopped to detach drives.', 'error');
@@ -647,6 +684,7 @@ class Storage extends Component
);
$this->notify("Drive {$driveKey} detached successfully.", 'success');
$this->closeDetachModal();
$this->loadStorageConfiguration(false);
} catch (\Exception $e) {
$this->notify('Failed to detach drive: ' . $e->getMessage(), 'error');
@@ -704,15 +742,40 @@ class Storage extends Component
}
/**
* Delete a drive permanently.
* Open the delete confirmation modal.
*/
public function deleteDrive(string $driveKey): void
public function openDeleteModal(string $driveKey): void
{
if (!isset($this->drives[$driveKey])) {
$this->notify('Drive not found.', 'error');
return;
}
$this->deletingDriveKey = $driveKey;
$this->showDeleteModal = true;
}
/**
* Close the delete confirmation modal.
*/
public function closeDeleteModal(): void
{
$this->showDeleteModal = false;
$this->deletingDriveKey = null;
}
/**
* Delete a drive permanently.
*/
public function deleteDrive(): void
{
if (!$this->deletingDriveKey || !isset($this->drives[$this->deletingDriveKey])) {
$this->notify('Drive not found.', 'error');
return;
}
$driveKey = $this->deletingDriveKey;
// Check VM status
if ($this->status && $this->status->status !== 'stopped') {
$this->notify('VM must be stopped to delete drives.', 'error');
@@ -752,6 +815,7 @@ class Storage extends Component
}
$this->notify("Drive {$driveKey} deleted successfully.", 'success');
$this->closeDeleteModal();
$this->loadStorageConfiguration(false);
} catch (\Exception $e) {
$this->notify('Failed to delete drive: ' . $e->getMessage(), 'error');