From 061704080c9cff36b015b9ff5c3233a87ba77bbd Mon Sep 17 00:00:00 2001 From: Patrick Nawracay Date: Mon, 15 Oct 2018 15:24:48 +0200 Subject: [PATCH] mgr/dashboard: TableActionsComponent cleanup Rename `buttonCondition` to `canBePrimary` Signed-off-by: Patrick Nawracay --- .../src/app/ceph/block/rbd-list/rbd-list.component.ts | 4 ++-- .../rbd-snapshot-list/rbd-snapshot-actions.model.ts | 4 ++-- .../table-actions/table-actions.component.spec.ts | 10 +++++----- .../datatable/table-actions/table-actions.component.ts | 2 +- .../frontend/src/app/shared/models/cd-table-action.ts | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts index 346bdb40ef2..a3ce598536a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts @@ -85,7 +85,7 @@ export class RbdListComponent implements OnInit { permission: 'create', icon: 'fa-plus', routerLink: () => '/block/rbd/add', - buttonCondition: (selection: CdTableSelection) => !selection.hasSingleSelection, + canBePrimary: (selection: CdTableSelection) => !selection.hasSingleSelection, name: 'Add' }; const editAction: CdTableAction = { @@ -102,7 +102,7 @@ export class RbdListComponent implements OnInit { }; const copyAction: CdTableAction = { permission: 'create', - buttonCondition: (selection: CdTableSelection) => selection.hasSingleSelection, + canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, disable: (selection: CdTableSelection) => !selection.hasSingleSelection || selection.first().cdExecuting, icon: 'fa-copy', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts index 0aeb8428377..1494bc62549 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts @@ -28,7 +28,7 @@ export class RbdSnapshotActionsModel { }; clone: CdTableAction = { permission: 'create', - buttonCondition: (selection: CdTableSelection) => selection.hasSingleSelection, + canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, disable: (selection: CdTableSelection) => !selection.hasSingleSelection || selection.first().cdExecuting, icon: 'fa-clone', @@ -36,7 +36,7 @@ export class RbdSnapshotActionsModel { }; copy: CdTableAction = { permission: 'create', - buttonCondition: (selection: CdTableSelection) => selection.hasSingleSelection, + canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, disable: (selection: CdTableSelection) => !selection.hasSingleSelection || selection.first().cdExecuting, icon: 'fa-copy', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.spec.ts index cdd1cee67ac..fef1b2fcd83 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.spec.ts @@ -46,7 +46,7 @@ describe('TableActionsComponent', () => { addAction = { permission: 'create', icon: 'fa-plus', - buttonCondition: (selection: CdTableSelection) => !selection.hasSelection, + canBePrimary: (selection: CdTableSelection) => !selection.hasSelection, name: 'Add' }; editAction = { @@ -57,7 +57,7 @@ describe('TableActionsComponent', () => { copyAction = { permission: 'create', icon: 'fa-copy', - buttonCondition: (selection: CdTableSelection) => selection.hasSingleSelection, + canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, disable: (selection: CdTableSelection) => !selection.hasSingleSelection || selection.first().cdExecuting, name: 'Copy' @@ -65,7 +65,7 @@ describe('TableActionsComponent', () => { deleteAction = { permission: 'delete', icon: 'fa-times', - buttonCondition: (selection: CdTableSelection) => selection.hasSelection, + canBePrimary: (selection: CdTableSelection) => selection.hasSelection, disable: (selection: CdTableSelection) => !selection.hasSelection || selection.first().cdExecuting, name: 'Delete' @@ -73,14 +73,14 @@ describe('TableActionsComponent', () => { protectAction = { permission: 'update', icon: 'fa-lock', - buttonCondition: () => false, + canBePrimary: () => false, visible: (selection: CdTableSelection) => selection.hasSingleSelection, name: 'Protect' }; unprotectAction = { permission: 'update', icon: 'fa-unlock', - buttonCondition: () => false, + canBePrimary: () => false, visible: (selection: CdTableSelection) => !selection.hasSingleSelection, name: 'Unprotect' }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts index 0d66c58de66..a6fb9fe5355 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts @@ -84,7 +84,7 @@ export class TableActionsComponent implements OnInit { * @returns {boolean} */ private showableAction(action: CdTableAction): boolean { - const condition = action.buttonCondition; + const condition = action.canBePrimary; const singleSelection = this.selection.hasSingleSelection; const defaultCase = action.permission === 'create' ? !singleSelection : singleSelection; return (condition && condition(this.selection)) || (!condition && defaultCase); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-table-action.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-table-action.ts index cb5a2c4eb4a..ad9f4c14387 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-table-action.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-table-action.ts @@ -26,7 +26,7 @@ export class CdTableAction { // You can define the condition to disable the action. // By default all 'create' actions can be the action button if no or multiple items are selected // By default all 'update' and 'delete' actions can be the action button if one item is selected - buttonCondition?: (_: CdTableSelection) => boolean; + canBePrimary?: (_: CdTableSelection) => boolean; // In some rare cases you want to hide a action that can be used by the user for example // if one action can lock the item and another action unlocks it -- 2.39.5