From d8c393bafa85b9da7fc7ab2eb2c86d83da80dd20 Mon Sep 17 00:00:00 2001 From: Kiefer Chang Date: Thu, 22 Oct 2020 14:39:46 +0800 Subject: [PATCH] mgr/dashboard: fix disable action for MGR modules Fixes: https://tracker.ceph.com/issues/47947 Signed-off-by: Kiefer Chang --- .../mgr-module-list.component.spec.ts | 12 ++++++++---- .../mgr-module-list/mgr-module-list.component.ts | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.spec.ts index f340bd83264..46f633487ac 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.spec.ts @@ -129,23 +129,27 @@ describe('MgrModuleListComponent', () => { expect(component.table.refreshBtn).toHaveBeenCalled(); })); - it('should not disable module (1)', () => { + it.only('should not disable module without selecting one', () => { + expect(component.getTableActionDisabledDesc()).toBeTruthy(); + }); + + it('should not disable dashboard module', () => { component.selection.selected = [ { name: 'dashboard' } ]; - expect(component.isTableActionDisabled('enabled')).toBeTruthy(); + expect(component.getTableActionDisabledDesc()).toBeTruthy(); }); - it('should not disable module (2)', () => { + it('should not disable an always-on module', () => { component.selection.selected = [ { name: 'bar', always_on: true } ]; - expect(component.isTableActionDisabled('enabled')).toBeTruthy(); + expect(component.getTableActionDisabledDesc()).toBe('This Manager module is always on.'); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.ts index 3e75ab9792b..636f1317041 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component.ts @@ -88,7 +88,7 @@ export class MgrModuleListComponent extends ListWithDetails { name: $localize`Disable`, permission: 'update', click: () => this.updateModuleState(), - disable: () => () => this.getTableActionDisabledDesc(), + disable: () => this.getTableActionDisabledDesc(), icon: Icons.stop } ]; @@ -139,7 +139,7 @@ export class MgrModuleListComponent extends ListWithDetails { } getTableActionDisabledDesc(): string | boolean { - if (this.selection.first().always_on) { + if (this.selection.first()?.always_on) { return $localize`This Manager module is always on.`; } -- 2.47.3