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) => this.getCloneDisableDesc(selection, featuresName),
49 name: actionLabels.CLONE
53 canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
54 disable: (selection: CdTableSelection) =>
55 !selection.hasSingleSelection || selection.first().cdExecuting,
57 name: actionLabels.COPY
62 name: actionLabels.ROLLBACK
67 disable: (selection: CdTableSelection) => {
68 const first = selection.first();
69 return !selection.hasSingleSelection || first.cdExecuting || first.is_protected;
71 name: actionLabels.DELETE
86 getCloneDisableDesc(selection: CdTableSelection, featuresName: string[]): boolean | string {
87 if (selection.hasSingleSelection && !selection.first().cdExecuting) {
88 if (!featuresName?.includes('layering')) {
89 return $localize`Parent image must support Layering`;