]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / rbd-snapshot-list / rbd-snapshot-actions.model.ts
1 import { I18n } from '@ngx-translate/i18n-polyfill';
2
3 import { CdTableAction } from '../../../shared/models/cd-table-action';
4 import { CdTableSelection } from '../../../shared/models/cd-table-selection';
5
6 export class RbdSnapshotActionsModel {
7 i18n: I18n;
8
9 create: CdTableAction;
10 rename: CdTableAction;
11 protect: CdTableAction;
12 unprotect: CdTableAction;
13 clone: CdTableAction;
14 copy: CdTableAction;
15 rollback: CdTableAction;
16 deleteSnap: CdTableAction;
17 ordering: CdTableAction[];
18
19 constructor(i18n: I18n) {
20 this.i18n = i18n;
21
22 this.create = {
23 permission: 'create',
24 icon: 'fa-plus',
25 name: this.i18n('Create')
26 };
27 this.rename = {
28 permission: 'update',
29 icon: 'fa-pencil',
30 name: this.i18n('Rename')
31 };
32 this.protect = {
33 permission: 'update',
34 icon: 'fa-lock',
35 visible: (selection: CdTableSelection) =>
36 selection.hasSingleSelection && !selection.first().is_protected,
37 name: this.i18n('Protect')
38 };
39 this.unprotect = {
40 permission: 'update',
41 icon: 'fa-unlock',
42 visible: (selection: CdTableSelection) =>
43 selection.hasSingleSelection && selection.first().is_protected,
44 name: this.i18n('Unprotect')
45 };
46 this.clone = {
47 permission: 'create',
48 canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
49 disable: (selection: CdTableSelection) =>
50 !selection.hasSingleSelection || selection.first().cdExecuting,
51 icon: 'fa-clone',
52 name: this.i18n('Clone')
53 };
54 this.copy = {
55 permission: 'create',
56 canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
57 disable: (selection: CdTableSelection) =>
58 !selection.hasSingleSelection || selection.first().cdExecuting,
59 icon: 'fa-copy',
60 name: this.i18n('Copy')
61 };
62 this.rollback = {
63 permission: 'update',
64 icon: 'fa-undo',
65 name: this.i18n('Rollback')
66 };
67 this.deleteSnap = {
68 permission: 'delete',
69 icon: 'fa-times',
70 disable: (selection: CdTableSelection) => {
71 const first = selection.first();
72 return !selection.hasSingleSelection || first.cdExecuting || first.is_protected;
73 },
74 name: this.i18n('Delete')
75 };
76
77 this.ordering = [
78 this.create,
79 this.rename,
80 this.protect,
81 this.unprotect,
82 this.clone,
83 this.copy,
84 this.rollback,
85 this.deleteSnap
86 ];
87 }
88 }