Skip to content

Commit ed222df

Browse files
author
Naman Munet
committed
mgr/dashboard: Add confirmation textbox for resource name on delete action
Before: ===== User was able to delete a single or multiple critical resources like ( images, snapshots, subvolumes, subvolume-groups, pools, hosts , OSDs, buckets, file system, services ) by just clicking on a checkbox. After: ===== User now has to type the resource name that they are deleting in the textbox on the delete modal, and then only they will be able to delete the critical resource. Also from now onwards multiple selection for deletions of critical resources is not possible. Hence, user can delete only single resource at a time. On the other side, non-critical resources can be deleted in one go. fixes: https://tracker.ceph.com/issues/69628 Signed-off-by: Naman Munet <[email protected]>
1 parent 98fc589 commit ed222df

25 files changed

+164
-41
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/pool-list/pool-list.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
1616
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
1717
import { PoolEditPeerModalComponent } from '../pool-edit-peer-modal/pool-edit-peer-modal.component';
1818
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
19+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
1920

2021
const BASE_URL = '/block/mirroring';
2122
@Component({
@@ -147,6 +148,7 @@ export class PoolListComponent implements OnInit, OnDestroy {
147148
const peerUUID = this.getPeerUUID();
148149

149150
this.modalService.show(CriticalConfirmationModalComponent, {
151+
impact: DeletionImpact.high,
150152
itemDescription: $localize`mirror peer`,
151153
itemNames: [`${poolName} (${peerUUID})`],
152154
submitActionObservable: () =>

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { RbdTrashMoveModalComponent } from '../rbd-trash-move-modal/rbd-trash-mo
3232
import { RBDImageFormat, RbdModel } from './rbd-model';
3333
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
3434
import { RBDActionHelpers } from '../rbd-contants';
35+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
3536
const BASE_URL = 'block/rbd';
3637

3738
@Component({
@@ -426,8 +427,9 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
426427
const imageSpec = new ImageSpec(poolName, namespace, imageName);
427428

428429
this.cdsModalService.show(CriticalConfirmationModalComponent, {
430+
impact: DeletionImpact.high,
429431
itemDescription: 'RBD',
430-
itemNames: [imageSpec],
432+
itemNames: [imageSpec.imageName],
431433
bodyTemplate: this.deleteTpl,
432434
bodyContext: {
433435
hasSnapshots: this.hasSnapshots(),

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { RbdSnapshotFormModalComponent } from '../rbd-snapshot-form/rbd-snapshot
3737
import { RbdSnapshotActionsModel } from './rbd-snapshot-actions.model';
3838
import { RbdSnapshotModel } from './rbd-snapshot.model';
3939
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
40+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
4041

4142
@Component({
4243
selector: 'cd-rbd-snapshot-list',
@@ -325,6 +326,7 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges {
325326
deleteSnapshotModal() {
326327
const snapshotName = this.selection.selected[0].name;
327328
this.modalRef = this.cdsModalService.show(CriticalConfirmationModalComponent, {
329+
impact: DeletionImpact.high,
328330
itemDescription: $localize`RBD snapshot`,
329331
itemNames: [snapshotName],
330332
submitAction: () => this._asyncTask('deleteSnapshot', 'rbd/snap/delete', snapshotName)

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
[columns]="snapshot.columns"
5454
identifier="name"
5555
forceIdentifier="true"
56-
selectionType="multiClick"
56+
selectionType="single"
5757
(updateSelection)="snapshot.updateSelection($event)">
5858
<cd-table-actions class="table-actions"
5959
[permission]="permission"

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CriticalConfirmationModalComponent } from '~/app/shared/components/crit
1212
import { FormModalComponent } from '~/app/shared/components/form-modal/form-modal.component';
1313
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
1414
import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
15+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
1516
import { Icons } from '~/app/shared/enum/icons.enum';
1617
import { NotificationType } from '~/app/shared/enum/notification-type.enum';
1718
import { CdValidators } from '~/app/shared/forms/cd-validators';
@@ -208,9 +209,7 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges {
208209
name: this.actionLabels.DELETE,
209210
icon: Icons.destroy,
210211
permission: 'delete',
211-
click: () => this.deleteSnapshotModal(),
212-
canBePrimary: (selection) => selection.hasSelection,
213-
disable: (selection) => !selection.hasSelection
212+
click: () => this.deleteSnapshotModal()
214213
}
215214
]
216215
};
@@ -684,6 +683,7 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges {
684683

685684
deleteSnapshotModal() {
686685
this.modalService.show(CriticalConfirmationModalComponent, {
686+
impact: DeletionImpact.high,
687687
itemDescription: $localize`CephFs Snapshot`,
688688
itemNames: this.snapshot.selection.selected.map((snapshot: CephfsSnapshot) => snapshot.name),
689689
submitAction: () => this.deleteSnapshot()

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { map, switchMap } from 'rxjs/operators';
2626
import { HealthService } from '~/app/shared/api/health.service';
2727
import { CephfsAuthModalComponent } from '~/app/ceph/cephfs/cephfs-auth-modal/cephfs-auth-modal.component';
2828
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
29+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
2930

3031
const BASE_URL = 'cephfs/fs';
3132

@@ -173,6 +174,7 @@ export class CephfsListComponent extends ListWithDetails implements OnInit {
173174
removeVolumeModal() {
174175
const volName = this.selection.first().mdsmap['fs_name'];
175176
this.cdsModalService.show(CriticalConfirmationModalComponent, {
177+
impact: DeletionImpact.high,
176178
itemDescription: 'File System',
177179
itemNames: [volName],
178180
actionDescription: 'remove',

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-subvolume-group/cephfs-subvolume-group.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { CephfsSubvolumeGroup } from '~/app/shared/models/cephfs-subvolume-group
2020
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
2121
import _ from 'lodash';
2222
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
23+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
2324

2425
@Component({
2526
selector: 'cd-cephfs-subvolume-group',
@@ -175,6 +176,7 @@ export class CephfsSubvolumeGroupComponent implements OnInit, OnChanges {
175176
removeSubVolumeModal() {
176177
const name = this.selection.first().name;
177178
this.cdsModalService.show(CriticalConfirmationModalComponent, {
179+
impact: DeletionImpact.high,
178180
itemDescription: 'subvolume group',
179181
itemNames: [name],
180182
actionDescription: 'remove',

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-subvolume-list/cephfs-subvolume-list.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { HealthService } from '~/app/shared/api/health.service';
3535
import _ from 'lodash';
3636
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
3737
import { DEFAULT_SUBVOLUME_GROUP } from '~/app/shared/constants/cephfs.constant';
38+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
3839

3940
@Component({
4041
selector: 'cd-cephfs-subvolume-list',
@@ -246,7 +247,8 @@ export class CephfsSubvolumeListComponent extends CdForm implements OnInit, OnCh
246247
this.errorMessage = '';
247248
this.selectedName = this.selection.first().name;
248249
this.modalService.show(CriticalConfirmationModalComponent, {
249-
actionDescription: 'Remove',
250+
impact: DeletionImpact.high,
251+
actionDescription: 'remove',
250252
itemNames: [this.selectedName],
251253
itemDescription: 'Subvolume',
252254
childFormGroup: this.removeForm,

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-subvolume-snapshots-list/cephfs-subvolume-snapshots-list.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { Validators } from '@angular/forms';
2727
import { CdValidators } from '~/app/shared/forms/cd-validators';
2828
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
2929
import { DEFAULT_SUBVOLUME_GROUP } from '~/app/shared/constants/cephfs.constant';
30+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
3031

3132
@Component({
3233
selector: 'cd-cephfs-subvolume-snapshots-list',
@@ -228,7 +229,8 @@ export class CephfsSubvolumeSnapshotsListComponent implements OnInit, OnChanges
228229
const subVolumeGroupName = this.activeGroupName;
229230
const fsName = this.fsName;
230231
this.modalRef = this.modalService.show(CriticalConfirmationModalComponent, {
231-
actionDescription: this.actionLabels.REMOVE,
232+
impact: DeletionImpact.high,
233+
actionDescription: 'remove',
232234
itemNames: [snapshotName],
233235
itemDescription: 'Snapshot',
234236
submitAction: () =>

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
3434
import { URLBuilderService } from '~/app/shared/services/url-builder.service';
3535
import { HostFormComponent } from './host-form/host-form.component';
3636
import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
37+
import { DeletionImpact } from '~/app/shared/enum/critical-confirmation-modal-impact.enum';
3738

3839
const BASE_URL = 'hosts';
3940

@@ -470,6 +471,7 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
470471
deleteAction() {
471472
const hostname = this.selection.first().hostname;
472473
this.modalRef = this.cdsModalService.show(CriticalConfirmationModalComponent, {
474+
impact: DeletionImpact.high,
473475
itemDescription: 'Host',
474476
itemNames: [hostname],
475477
actionDescription: 'remove',

0 commit comments

Comments
 (0)