From: Volker Theile Date: Tue, 23 Jun 2020 10:19:54 +0000 (+0200) Subject: mgr/dashboard: Bypass current selection when calling CdTableAction::disableDesc(). X-Git-Tag: wip-pdonnell-testing-20200918.022351~863^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a92baa8523279f663644837304f1e6c71787a63e;p=ceph-ci.git mgr/dashboard: Bypass current selection when calling CdTableAction::disableDesc(). Signed-off-by: Volker Theile --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts index 9cc62f48b3d..591b0f189fd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts @@ -103,7 +103,7 @@ describe('HostsComponent', () => { }); it('should return undefined (no selection)', () => { - expect(component.getEditDisableDesc()).toBeUndefined(); + expect(component.getEditDisableDesc(component.selection)).toBeUndefined(); }); it('should return undefined (managed by Orchestrator)', () => { @@ -113,7 +113,7 @@ describe('HostsComponent', () => { orchestrator: true } }); - expect(component.getEditDisableDesc()).toBeUndefined(); + expect(component.getEditDisableDesc(component.selection)).toBeUndefined(); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts index 50b04947c0d..41594c1f55e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts @@ -94,7 +94,7 @@ export class HostsComponent extends ListWithDetails implements OnInit { }, disable: (selection: CdTableSelection) => !selection.hasSingleSelection || !selection.first().sources.orchestrator, - disableDesc: () => this.getEditDisableDesc() + disableDesc: this.getEditDisableDesc.bind(this) }, { name: this.actionLabels.DELETE, @@ -189,12 +189,8 @@ export class HostsComponent extends ListWithDetails implements OnInit { }); } - getEditDisableDesc(): string | undefined { - if ( - this.selection && - this.selection.hasSingleSelection && - !this.selection.first().sources.orchestrator - ) { + getEditDisableDesc(selection: CdTableSelection): string | undefined { + if (selection && selection.hasSingleSelection && !selection.first().sources.orchestrator) { return this.i18n('Host editing is disabled because the host is not managed by Orchestrator.'); } return undefined; 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 4f34fc574be..f494ae19f55 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 @@ -146,6 +146,6 @@ export class TableActionsComponent implements OnInit { } useDisableDesc(action: CdTableAction) { - return action.disableDesc && action.disableDesc(); + return action.disableDesc && action.disableDesc(this.selection); } } 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 ac8dcb61a98..9af10625ae6 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 @@ -29,7 +29,7 @@ export class CdTableAction { * disabled. The specified message will be shown to the user as a button * tooltip. */ - disableDesc?: Function; + disableDesc?: (_: CdTableSelection) => string | undefined; /** * Defines if the button can become 'primary' (displayed as button and not