visible: (selection: CdTableSelection) =>
selection.hasSingleSelection && !selection.first().is_protected,
name: actionLabels.PROTECT,
- disable: (selection: CdTableSelection) => this.disableForMirrorSnapshot(selection)
+ disable: (selection: CdTableSelection) =>
+ this.disableForMirrorSnapshot(selection) ||
+ this.getDisableDesc(selection, this.featuresName)
};
this.unprotect = {
permission: 'update',
permission: 'create',
canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
disable: (selection: CdTableSelection) =>
- this.getCloneDisableDesc(selection, this.featuresName) ||
+ this.getDisableDesc(selection, this.featuresName) ||
this.disableForMirrorSnapshot(selection),
icon: Icons.clone,
name: actionLabels.CLONE
];
}
- getCloneDisableDesc(selection: CdTableSelection, featuresName: string[]): boolean | string {
+ getDisableDesc(selection: CdTableSelection, featuresName: string[]): boolean | string {
if (selection.hasSingleSelection && !selection.first().cdExecuting) {
if (!featuresName?.includes('layering')) {
- return $localize`Parent image must support Layering`;
+ return $localize`The layering feature needs to be enabled on parent image`;
}
if (this.cloneFormatVersion === 1 && !selection.first().is_protected) {
it('should be disabled with version 1 and protected false', () => {
const selection = new CdTableSelection([{ name: 'someName', is_protected: false }]);
- const disableDesc = actions.getCloneDisableDesc(selection, ['layering']);
+ const disableDesc = actions.getDisableDesc(selection, ['layering']);
expect(disableDesc).toBe('Snapshot must be protected in order to clone.');
});
])('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.getCloneDisableDesc(selection, ['layering']);
+ const disableDesc = actions.getDisableDesc(selection, ['layering']);
expect(disableDesc).toBe(false);
});
});
+
+ describe('protect button disable state', () => {
+ let actions: RbdSnapshotActionsModel;
+
+ beforeEach(() => {
+ fixture.detectChanges();
+ const rbdService = TestBed.inject(RbdService);
+ const actionLabelsI18n = TestBed.inject(ActionLabelsI18n);
+ actions = new RbdSnapshotActionsModel(actionLabelsI18n, [], rbdService);
+ });
+
+ 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']);
+ expect(disableDesc).toBe('The layering feature needs to be enabled on parent image');
+ });
+ });
});