import { I18n } from '@ngx-translate/i18n-polyfill';
+import * as _ from 'lodash';
import { ActionLabelsI18n } from '../../../shared/constants/app.constants';
import { Icons } from '../../../shared/enum/icons.enum';
deleteSnap: CdTableAction;
ordering: CdTableAction[];
- constructor(i18n: I18n, actionLabels: ActionLabelsI18n) {
+ constructor(i18n: I18n, actionLabels: ActionLabelsI18n, featuresName: string[]) {
this.i18n = i18n;
this.create = {
permission: 'create',
canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
disable: (selection: CdTableSelection) =>
- !selection.hasSingleSelection || selection.first().cdExecuting,
+ !selection.hasSingleSelection ||
+ selection.first().cdExecuting ||
+ !_.isUndefined(this.getCloneDisableDesc(featuresName)),
+ disableDesc: () => this.getCloneDisableDesc(featuresName),
icon: Icons.clone,
name: actionLabels.CLONE
};
this.deleteSnap
];
}
+
+ getCloneDisableDesc(featuresName: string[]): string | undefined {
+ if (!featuresName.includes('layering')) {
+ return this.i18n('Parent image must support Layering');
+ }
+ }
}
@Input()
snapshots: RbdSnapshotModel[] = [];
@Input()
+ featuresName: string[];
+ @Input()
poolName: string;
@Input()
rbdName: string;
private actionLabels: ActionLabelsI18n
) {
this.permission = this.authStorageService.getPermissions().rbdImage;
- const actions = new RbdSnapshotActionsModel(this.i18n, this.actionLabels);
- actions.create.click = () => this.openCreateSnapshotModal();
- actions.rename.click = () => this.openEditSnapshotModal();
- actions.protect.click = () => this.toggleProtection();
- actions.unprotect.click = () => this.toggleProtection();
- const getImageUri = () =>
- this.selection.first() &&
- `${encodeURIComponent(this.poolName)}/${encodeURIComponent(
- this.rbdName
- )}/${encodeURIComponent(this.selection.first().name)}`;
- actions.clone.routerLink = () => `/block/rbd/clone/${getImageUri()}`;
- actions.copy.routerLink = () => `/block/rbd/copy/${getImageUri()}`;
- actions.rollback.click = () => this.rollbackModal();
- actions.deleteSnap.click = () => this.deleteSnapshotModal();
- this.tableActions = actions.ordering;
}
ngOnInit() {
}
ngOnChanges() {
+ const actions = new RbdSnapshotActionsModel(this.i18n, this.actionLabels, this.featuresName);
+ actions.create.click = () => this.openCreateSnapshotModal();
+ actions.rename.click = () => this.openEditSnapshotModal();
+ actions.protect.click = () => this.toggleProtection();
+ actions.unprotect.click = () => this.toggleProtection();
+ const getImageUri = () =>
+ this.selection.first() &&
+ `${encodeURIComponent(this.poolName)}/${encodeURIComponent(
+ this.rbdName
+ )}/${encodeURIComponent(this.selection.first().name)}`;
+ actions.clone.routerLink = () => `/block/rbd/clone/${getImageUri()}`;
+ actions.copy.routerLink = () => `/block/rbd/copy/${getImageUri()}`;
+ actions.rollback.click = () => this.rollbackModal();
+ actions.deleteSnap.click = () => this.deleteSnapshotModal();
+ this.tableActions = actions.ordering;
+
const itemFilter = (entry, task) => {
return entry.name === task.metadata['snapshot_name'];
};