From 4a428b8b996e55211b1a48ba603e8971f0e90ad7 Mon Sep 17 00:00:00 2001 From: avanthakkar Date: Tue, 26 Sep 2023 16:34:08 +0530 Subject: [PATCH] mgr/dashboard: enable protect option if layering enabled Fixes: https://tracker.ceph.com/issues/63076 Signed-off-by: avanthakkar (cherry picked from commit 91be9ecdf519df18e564c79681f6275376f786e6) --- .../app/ceph/block/rbd-form/rbd-form.component.ts | 2 +- .../rbd-snapshot-actions.model.ts | 15 +++++++++------ .../rbd-snapshot-list.component.spec.ts | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts index 6b71d263e5092..3d5f0f452df08 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts @@ -141,7 +141,7 @@ export class RbdFormComponent extends CdForm implements OnInit { requires: null, allowEnable: false, allowDisable: false, - helperHtml: $localize`Feature can't be manipulated after the image is created` + helperHtml: $localize`Feature flag can't be manipulated after the image is created. Disabling this option will also disable the Protect and Clone actions on Snapshot` }, 'exclusive-lock': { desc: $localize`Exclusive lock`, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts index 345d47e7421d1..9b3b7d1d6cdd0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts @@ -46,7 +46,7 @@ export class RbdSnapshotActionsModel { name: actionLabels.PROTECT, disable: (selection: CdTableSelection) => this.disableForMirrorSnapshot(selection) || - this.getDisableDesc(selection, this.featuresName) + this.getProtectDisableDesc(selection, this.featuresName) }; this.unprotect = { permission: 'update', @@ -60,8 +60,7 @@ export class RbdSnapshotActionsModel { permission: 'create', canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, disable: (selection: CdTableSelection) => - this.getDisableDesc(selection, this.featuresName) || - this.disableForMirrorSnapshot(selection), + this.getCloneDisableDesc(selection) || this.disableForMirrorSnapshot(selection), icon: Icons.clone, name: actionLabels.CLONE }; @@ -109,19 +108,23 @@ export class RbdSnapshotActionsModel { ]; } - getDisableDesc(selection: CdTableSelection, featuresName: string[]): boolean | string { + getProtectDisableDesc(selection: CdTableSelection, featuresName: string[]): boolean | string { if (selection.hasSingleSelection && !selection.first().cdExecuting) { if (!featuresName?.includes('layering')) { return $localize`The layering feature needs to be enabled on parent image`; } + return false; + } + return true; + } + getCloneDisableDesc(selection: CdTableSelection): boolean | string { + if (selection.hasSingleSelection && !selection.first().cdExecuting) { if (this.cloneFormatVersion === 1 && !selection.first().is_protected) { return $localize`Snapshot must be protected in order to clone.`; } - return false; } - return true; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts index d2fb9b067e012..1b9b385466510 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts @@ -288,7 +288,7 @@ describe('RbdSnapshotListComponent', () => { it('should be disabled with version 1 and protected false', () => { const selection = new CdTableSelection([{ name: 'someName', is_protected: false }]); - const disableDesc = actions.getDisableDesc(selection, ['layering']); + const disableDesc = actions.getCloneDisableDesc(selection); expect(disableDesc).toBe('Snapshot must be protected in order to clone.'); }); @@ -299,7 +299,7 @@ describe('RbdSnapshotListComponent', () => { ])('should be enabled with version %d and protected %s', (version, is_protected) => { actions.cloneFormatVersion = version; const selection = new CdTableSelection([{ name: 'someName', is_protected: is_protected }]); - const disableDesc = actions.getDisableDesc(selection, ['layering']); + const disableDesc = actions.getCloneDisableDesc(selection); expect(disableDesc).toBe(false); }); }); @@ -316,7 +316,7 @@ describe('RbdSnapshotListComponent', () => { it('should be disabled if layering not supported', () => { const selection = new CdTableSelection([{ name: 'someName', is_protected: false }]); - const disableDesc = actions.getDisableDesc(selection, ['deep-flatten', 'fast-diff']); + const disableDesc = actions.getProtectDisableDesc(selection, ['deep-flatten', 'fast-diff']); expect(disableDesc).toBe('The layering feature needs to be enabled on parent image'); }); }); -- 2.39.5