]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / datatable / table-actions / table-actions.component.ts
index 62f33acac186621c976a35fae134054c25491df3..57714dbae6b14d48eb90cc59084e1592deeb68a9 100644 (file)
@@ -2,6 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
 
 import * as _ from 'lodash';
 
+import { Icons } from '../../../shared/enum/icons.enum';
 import { CdTableAction } from '../../models/cd-table-action';
 import { CdTableSelection } from '../../models/cd-table-selection';
 import { Permission } from '../../models/permissions';
@@ -18,16 +19,20 @@ export class TableActionsComponent implements OnInit {
   selection: CdTableSelection;
   @Input()
   tableActions: CdTableAction[];
+  @Input()
+  btnColor = 'secondary';
 
   // Use this if you just want to display a drop down button,
   // labeled with the given text, with all actions in it.
   // This disables the main action button.
   @Input()
-  onlyDropDown?: string;
+  dropDownOnly?: string;
 
   // Array with all visible actions
   dropDownActions: CdTableAction[] = [];
 
+  icons = Icons;
+
   constructor() {}
 
   ngOnInit() {
@@ -74,8 +79,8 @@ export class TableActionsComponent implements OnInit {
    * @returns {CdTableAction}
    */
   getCurrentButton(): CdTableAction {
-    if (this.onlyDropDown) {
-      return;
+    if (this.dropDownOnly) {
+      return undefined;
     }
     let buttonAction = this.dropDownActions.find((tableAction) => this.showableAction(tableAction));
     if (!buttonAction && this.dropDownActions.length > 0) {
@@ -99,7 +104,7 @@ export class TableActionsComponent implements OnInit {
 
   useRouterLink(action: CdTableAction): string {
     if (!action.routerLink || this.disableSelectionAction(action)) {
-      return;
+      return undefined;
     }
     return _.isString(action.routerLink) ? action.routerLink : action.routerLink();
   }
@@ -115,11 +120,11 @@ export class TableActionsComponent implements OnInit {
    * @returns {Boolean}
    */
   disableSelectionAction(action: CdTableAction): Boolean {
-    const permission = action.permission;
     const disable = action.disable;
     if (disable) {
       return Boolean(disable(this.selection));
     }
+    const permission = action.permission;
     const selected = this.selection.hasSingleSelection && this.selection.first();
     return Boolean(
       ['update', 'delete'].includes(permission) && (!selected || selected.cdExecuting)