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`,
name: actionLabels.PROTECT,
disable: (selection: CdTableSelection) =>
this.disableForMirrorSnapshot(selection) ||
- this.getDisableDesc(selection, this.featuresName)
+ this.getProtectDisableDesc(selection, this.featuresName)
};
this.unprotect = {
permission: 'update',
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
};
];
}
- 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;
}
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.');
});
])('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);
});
});
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');
});
});