1 import * as _ from 'lodash';
3 import { ActionLabelsI18n } from '../../../shared/constants/app.constants';
4 import { Icons } from '../../../shared/enum/icons.enum';
5 import { CdTableAction } from '../../../shared/models/cd-table-action';
6 import { CdTableSelection } from '../../../shared/models/cd-table-selection';
8 export class RbdSnapshotActionsModel {
10 rename: CdTableAction;
11 protect: CdTableAction;
12 unprotect: CdTableAction;
15 rollback: CdTableAction;
16 deleteSnap: CdTableAction;
17 ordering: CdTableAction[];
19 constructor(actionLabels: ActionLabelsI18n, featuresName: string[]) {
23 name: actionLabels.CREATE
28 name: actionLabels.RENAME
33 visible: (selection: CdTableSelection) =>
34 selection.hasSingleSelection && !selection.first().is_protected,
35 name: actionLabels.PROTECT
40 visible: (selection: CdTableSelection) =>
41 selection.hasSingleSelection && selection.first().is_protected,
42 name: actionLabels.UNPROTECT
46 canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
47 disable: (selection: CdTableSelection) =>
48 !selection.hasSingleSelection ||
49 selection.first().cdExecuting ||
50 !_.isUndefined(this.getCloneDisableDesc(featuresName)),
51 disableDesc: () => this.getCloneDisableDesc(featuresName),
53 name: actionLabels.CLONE
57 canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
58 disable: (selection: CdTableSelection) =>
59 !selection.hasSingleSelection || selection.first().cdExecuting,
61 name: actionLabels.COPY
66 name: actionLabels.ROLLBACK
71 disable: (selection: CdTableSelection) => {
72 const first = selection.first();
73 return !selection.hasSingleSelection || first.cdExecuting || first.is_protected;
75 name: actionLabels.DELETE
90 getCloneDisableDesc(featuresName: string[]): string | undefined {
91 if (!featuresName?.includes('layering')) {
92 return $localize`Parent image must support Layering`;