feat(dashboard/native-filters): Hide filters out of scope of current tab (#14933)

* Optimize finding charts and tabs in scope

* Put filters out of scope in Collapse

* Use lastFocusedTabId instead of directPathToChild

* Fix tests

* Fix cypress test

* Uncomment e2e test
This commit is contained in:
Kamil Gabryjelski
2021-06-02 20:38:18 +02:00
committed by GitHub
parent 723a67156c
commit 405f95b6af
20 changed files with 329 additions and 105 deletions

View File

@@ -50,16 +50,21 @@ jest.mock('src/dashboard/actions/dashboardState');
describe('DashboardBuilder', () => {
let favStarStub;
let focusedTabStub;
beforeAll(() => {
// this is invoked on mount, so we stub it instead of making a request
favStarStub = sinon
.stub(dashboardStateActions, 'fetchFaveStar')
.returns({ type: 'mock-action' });
focusedTabStub = sinon
.stub(dashboardStateActions, 'setLastFocusedTab')
.returns({ type: 'mock-action' });
});
afterAll(() => {
favStarStub.restore();
focusedTabStub.restore();
});
function setup(overrideState = {}, overrideStore) {

View File

@@ -36,6 +36,7 @@ import { sliceId } from 'spec/fixtures/mockChartQueries';
import dashboardInfo from 'spec/fixtures/mockDashboardInfo';
import { dashboardLayout as mockLayout } from 'spec/fixtures/mockDashboardLayout';
import { sliceEntitiesForChart } from 'spec/fixtures/mockSliceEntities';
import { nativeFiltersInfo } from '../../fixtures/mockNativeFilters';
describe('ChartHolder', () => {
const props = {
@@ -55,6 +56,7 @@ describe('ChartHolder', () => {
handleComponentDrop() {},
updateComponents() {},
deleteComponent() {},
nativeFilters: nativeFiltersInfo.filters,
};
function setup(overrideProps) {

View File

@@ -33,8 +33,10 @@ import HoverMenu from 'src/dashboard/components/menu/HoverMenu';
import DragDroppable from 'src/dashboard/components/dnd/DragDroppable';
import Tabs from 'src/dashboard/components/gridComponents/Tabs';
import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants';
import emptyDashboardLayout from 'src/dashboard/fixtures/emptyDashboardLayout';
import { dashboardLayoutWithTabs } from 'spec/fixtures/mockDashboardLayout';
import { mockStoreWithTabs } from 'spec/fixtures/mockStore';
import { nativeFilters } from 'spec/fixtures/mockNativeFilters';
describe('Tabs', () => {
fetchMock.post('glob:*/r/shortner/', {});
@@ -59,6 +61,8 @@ describe('Tabs', () => {
deleteComponent() {},
updateComponents() {},
logEvent() {},
dashboardLayout: emptyDashboardLayout,
nativeFilters: nativeFilters.filters,
};
function setup(overrideProps) {