]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: enable protect option if layering enabled 53671/head
authoravanthakkar <avanjohn@gmail.com>
Tue, 26 Sep 2023 11:04:08 +0000 (16:34 +0530)
committeravanthakkar <avanjohn@gmail.com>
Tue, 3 Oct 2023 10:20:52 +0000 (15:50 +0530)
Fixes: https://tracker.ceph.com/issues/63076
Signed-off-by: avanthakkar <avanjohn@gmail.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts

index 168be1f6400ac0b8b47b6f0de95eb3d41fe8497d..33e67b09bbf76c2a3a7390f72caeaad5f629da80 100644 (file)
@@ -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`,
index 345d47e7421d1508be01c2a226252afbf3d21cec..9b3b7d1d6cdd0d1ce849876c58076c57da9e03f3 100644 (file)
@@ -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;
   }
 
index d2fb9b067e0122fcb900d643f940626e384b495c..1b9b3854665109dd580b1bb428b03dd3527c4728 100644 (file)
@@ -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');
     });
   });