]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-table-action.ts
9af10625ae65bd3226dfeec3ff4cf6b5cee5660e
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / models / cd-table-action.ts
1 import { CdTableSelection } from './cd-table-selection';
2
3 export class CdTableAction {
4 // It's possible to assign a string
5 // or a function that returns the link if it has to be dynamic
6 // or none if it's not needed
7 routerLink?: string | Function;
8
9 preserveFragment? = false;
10
11 // This is the function that will be triggered on a click event if defined
12 click?: Function;
13
14 permission: 'create' | 'update' | 'delete' | 'read';
15
16 // The name of the action
17 name: string;
18
19 // The font awesome icon that will be used
20 icon: string;
21
22 // You can define the condition to disable the action.
23 // By default all 'update' and 'delete' actions will only be enabled
24 // if one selection is made and no task is running on the selected item.
25 disable?: (_: CdTableSelection) => boolean;
26
27 /**
28 * In some cases you might want to give the user a hint why a button is
29 * disabled. The specified message will be shown to the user as a button
30 * tooltip.
31 */
32 disableDesc?: (_: CdTableSelection) => string | undefined;
33
34 /**
35 * Defines if the button can become 'primary' (displayed as button and not
36 * 'hidden' in the menu). Only one button can be primary at a time. By
37 * default all 'create' actions can be the action button if no or multiple
38 * items are selected. Also, all 'update' and 'delete' actions can be the
39 * action button by default, provided only one item is selected.
40 */
41 canBePrimary?: (_: CdTableSelection) => boolean;
42
43 // In some rare cases you want to hide a action that can be used by the user for example
44 // if one action can lock the item and another action unlocks it
45 visible?: (_: CdTableSelection) => boolean;
46 }