mgr/dashboard: fix disable action for MGR modules

Fixes: https://tracker.ceph.com/issues/47947
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
This commit is contained in:
Kiefer Chang 2020-10-22 14:39:46 +08:00
parent 0acdb82146
commit d8c393bafa
No known key found for this signature in database
GPG Key ID: 038321232249E246
2 changed files with 10 additions and 6 deletions

View File

@ -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.');
});
});
});

View File

@ -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.`;
}