Skip to content

Commit 297ca51

Browse files
authored
Merge pull request ceph#53671 from rhcs-dashboard/fix-protect-if-layering-enabled
mgr/dashboard: enable protect option if layering enabled Reviewed-by: Ankush Behl <[email protected]> Reviewed-by: Sunil Angadi <[email protected]>
2 parents 2a8afa6 + 91be9ec commit 297ca51

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
141141
requires: null,
142142
allowEnable: false,
143143
allowDisable: false,
144-
helperHtml: $localize`Feature can't be manipulated after the image is created`
144+
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`
145145
},
146146
'exclusive-lock': {
147147
desc: $localize`Exclusive lock`,

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class RbdSnapshotActionsModel {
4646
name: actionLabels.PROTECT,
4747
disable: (selection: CdTableSelection) =>
4848
this.disableForMirrorSnapshot(selection) ||
49-
this.getDisableDesc(selection, this.featuresName)
49+
this.getProtectDisableDesc(selection, this.featuresName)
5050
};
5151
this.unprotect = {
5252
permission: 'update',
@@ -60,8 +60,7 @@ export class RbdSnapshotActionsModel {
6060
permission: 'create',
6161
canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
6262
disable: (selection: CdTableSelection) =>
63-
this.getDisableDesc(selection, this.featuresName) ||
64-
this.disableForMirrorSnapshot(selection),
63+
this.getCloneDisableDesc(selection) || this.disableForMirrorSnapshot(selection),
6564
icon: Icons.clone,
6665
name: actionLabels.CLONE
6766
};
@@ -109,19 +108,23 @@ export class RbdSnapshotActionsModel {
109108
];
110109
}
111110

112-
getDisableDesc(selection: CdTableSelection, featuresName: string[]): boolean | string {
111+
getProtectDisableDesc(selection: CdTableSelection, featuresName: string[]): boolean | string {
113112
if (selection.hasSingleSelection && !selection.first().cdExecuting) {
114113
if (!featuresName?.includes('layering')) {
115114
return $localize`The layering feature needs to be enabled on parent image`;
116115
}
116+
return false;
117+
}
118+
return true;
119+
}
117120

121+
getCloneDisableDesc(selection: CdTableSelection): boolean | string {
122+
if (selection.hasSingleSelection && !selection.first().cdExecuting) {
118123
if (this.cloneFormatVersion === 1 && !selection.first().is_protected) {
119124
return $localize`Snapshot must be protected in order to clone.`;
120125
}
121-
122126
return false;
123127
}
124-
125128
return true;
126129
}
127130

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ describe('RbdSnapshotListComponent', () => {
288288

289289
it('should be disabled with version 1 and protected false', () => {
290290
const selection = new CdTableSelection([{ name: 'someName', is_protected: false }]);
291-
const disableDesc = actions.getDisableDesc(selection, ['layering']);
291+
const disableDesc = actions.getCloneDisableDesc(selection);
292292
expect(disableDesc).toBe('Snapshot must be protected in order to clone.');
293293
});
294294

@@ -299,7 +299,7 @@ describe('RbdSnapshotListComponent', () => {
299299
])('should be enabled with version %d and protected %s', (version, is_protected) => {
300300
actions.cloneFormatVersion = version;
301301
const selection = new CdTableSelection([{ name: 'someName', is_protected: is_protected }]);
302-
const disableDesc = actions.getDisableDesc(selection, ['layering']);
302+
const disableDesc = actions.getCloneDisableDesc(selection);
303303
expect(disableDesc).toBe(false);
304304
});
305305
});
@@ -316,7 +316,7 @@ describe('RbdSnapshotListComponent', () => {
316316

317317
it('should be disabled if layering not supported', () => {
318318
const selection = new CdTableSelection([{ name: 'someName', is_protected: false }]);
319-
const disableDesc = actions.getDisableDesc(selection, ['deep-flatten', 'fast-diff']);
319+
const disableDesc = actions.getProtectDisableDesc(selection, ['deep-flatten', 'fast-diff']);
320320
expect(disableDesc).toBe('The layering feature needs to be enabled on parent image');
321321
});
322322
});

0 commit comments

Comments
 (0)