From a2fdd5af49be86915d1eee6ecc5b3096b3b847dd Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Wed, 24 Jun 2020 15:19:43 +0200 Subject: [PATCH] mgr/dashboard: Action button is not reset after switching tabs Fixes: https://tracker.ceph.com/issues/46145 Signed-off-by: Volker Theile --- .../shared/datatable/table/table.component.spec.ts | 11 +++++++++++ .../src/app/shared/datatable/table/table.component.ts | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts index bfb53a6cb2f..e27be89ed31 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts @@ -11,6 +11,7 @@ import { configureTestBed } from '../../../../testing/unit-test-helper'; import { ComponentsModule } from '../../components/components.module'; import { CdTableColumnFilter } from '../../models/cd-table-column-filter'; import { CdTableFetchDataContext } from '../../models/cd-table-fetch-data-context'; +import { CdTableSelection } from '../../models/cd-table-selection'; import { PipesModule } from '../../pipes/pipes.module'; import { TableComponent } from './table.component'; @@ -106,6 +107,16 @@ describe('TableComponent', () => { component.ngOnInit(); }); + it('should call updateSelection on init', () => { + component.updateSelection.subscribe((selection: CdTableSelection) => { + expect(selection.hasSelection).toBeFalsy(); + expect(selection.hasSingleSelection).toBeFalsy(); + expect(selection.hasMultiSelection).toBeFalsy(); + expect(selection.selected.length).toBe(0); + }); + component.ngOnInit(); + }); + describe('test column filtering', () => { let filterIndex: CdTableColumnFilter; let filterOdd: CdTableColumnFilter; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts index 6c4d171e23b..c177cc994fc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts @@ -282,6 +282,8 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O this.filterHiddenColumns(); this.initColumnFilters(); this.updateColumnFilterOptions(); + // Notify all subscribers to reset their current selection. + this.updateSelection.emit(new CdTableSelection()); // Load the data table content every N ms or at least once. // Force showing the loading indicator if there are subscribers to the fetchData // event. This is necessary because it has been set to False in useData() when -- 2.39.5