From: Patrick Nawracay Date: Mon, 15 Oct 2018 13:24:48 +0000 (+0200) Subject: mgr/dashboard: TableActionsComponent cleanup X-Git-Tag: v14.1.0~1083^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=061704080c9cff36b015b9ff5c3233a87ba77bbd;p=ceph.git mgr/dashboard: TableActionsComponent cleanup Rename `buttonCondition` to `canBePrimary` Signed-off-by: Patrick Nawracay --- 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 346bdb40ef26..a3ce598536a0 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 0aeb84283770..1494bc625491 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 cdd1cee67ace..fef1b2fcd836 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 0d66c58de668..a6fb9fe5355d 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 cb5a2c4eb4ae..ad9f4c14387e 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