mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
[Feature] Dashboard filter indicators (#7908)
* dashboard filter indicators * add/fix unit tests
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { filterId } from './mockSliceEntities';
|
||||
|
||||
export const emptyFilters = {};
|
||||
|
||||
export const dashboardFilters = {
|
||||
[filterId]: {
|
||||
chartId: filterId,
|
||||
componentId: 'CHART-rwDfbGqeEn',
|
||||
directPathToFilter: [
|
||||
'ROOT_ID',
|
||||
'TABS-VPEX_c476g',
|
||||
'TAB-PMJyKM1yB',
|
||||
'TABS-YdylzDMTMQ',
|
||||
'TAB-O9AaU9FT0',
|
||||
'ROW-l6PrlhwSjh',
|
||||
'CHART-rwDfbGqeEn',
|
||||
],
|
||||
scope: 'ROOT_ID',
|
||||
isDateFilter: false,
|
||||
isInstantFilter: true,
|
||||
columns: {
|
||||
region: ['a', 'b'],
|
||||
},
|
||||
labels: {
|
||||
region: 'region',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -20,8 +20,8 @@ export default {
|
||||
id: 1234,
|
||||
slug: 'dashboardSlug',
|
||||
metadata: {
|
||||
filter_immune_slices: [],
|
||||
filter_immune_slice_fields: {},
|
||||
filterImmuneSlices: [],
|
||||
filterImmuneSliceFields: {},
|
||||
},
|
||||
userId: 'mock_user_id',
|
||||
dash_edit_perm: true,
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
import newComponentFactory from '../../../../src/dashboard/util/newComponentFactory';
|
||||
|
||||
import { sliceId as chartId } from './mockChartQueries';
|
||||
import { filterId } from './mockDashboardFilters';
|
||||
|
||||
export const sliceId = chartId;
|
||||
|
||||
@@ -187,3 +188,22 @@ export const dashboardLayoutWithTabs = {
|
||||
},
|
||||
future: [],
|
||||
};
|
||||
|
||||
export const filterComponent = {
|
||||
...newComponentFactory(CHART_TYPE),
|
||||
id: 'CHART-rwDfbGqeEn',
|
||||
parents: [
|
||||
'ROOT_ID',
|
||||
'TABS-VPEX_c476g',
|
||||
'TAB-PMJyKM1yB',
|
||||
'TABS-YdylzDMTMQ',
|
||||
'TAB-O9AaU9FT0',
|
||||
'ROW-l6PrlhwSjh',
|
||||
],
|
||||
meta: {
|
||||
chartId: filterId,
|
||||
width: 3,
|
||||
height: 10,
|
||||
chartName: 'Filter',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -21,13 +21,12 @@ import { BUILDER_PANE_TYPE } from '../../../../src/dashboard/util/constants';
|
||||
|
||||
export default {
|
||||
sliceIds: [sliceId],
|
||||
refresh: false,
|
||||
filters: {},
|
||||
expandedSlices: {},
|
||||
editMode: false,
|
||||
builderPaneType: BUILDER_PANE_TYPE.NONE,
|
||||
hasUnsavedChanges: false,
|
||||
maxUndoHistoryExceeded: false,
|
||||
isStarred: true,
|
||||
isPublished: true,
|
||||
css: '',
|
||||
};
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { sliceId as id } from './mockChartQueries';
|
||||
import { datasourceId } from '../../../fixtures/mockDatasource';
|
||||
import { sliceId } from './mockChartQueries';
|
||||
|
||||
export const sliceId = id;
|
||||
export const filterId = 127;
|
||||
export const column = 'region';
|
||||
|
||||
export const sliceEntitiesForChart = {
|
||||
slices: {
|
||||
@@ -49,6 +50,8 @@ export const sliceEntitiesForChart = {
|
||||
datasource: datasourceId,
|
||||
description: null,
|
||||
description_markeddown: '',
|
||||
modified: '23 hours ago',
|
||||
changed_on: 1529453332615,
|
||||
},
|
||||
},
|
||||
isLoading: false,
|
||||
@@ -58,11 +61,23 @@ export const sliceEntitiesForChart = {
|
||||
|
||||
export const sliceEntitiesForDashboard = {
|
||||
slices: {
|
||||
127: {
|
||||
slice_id: 127,
|
||||
[filterId]: {
|
||||
slice_id: filterId,
|
||||
slice_url: '/superset/explore/?form_data=%7B%22slice_id%22%3A%20127%7D',
|
||||
slice_name: 'Region Filter',
|
||||
form_data: {},
|
||||
form_data: {
|
||||
instant_filtering: true,
|
||||
filter_configs: [
|
||||
{
|
||||
asc: true,
|
||||
clearable: true,
|
||||
column,
|
||||
key: 'JknLrSlNL',
|
||||
multiple: true,
|
||||
label: column,
|
||||
},
|
||||
],
|
||||
},
|
||||
edit_url: '/chart/edit/127',
|
||||
viz_type: 'filter_box',
|
||||
datasource: '2__table',
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import chartQueries from './mockChartQueries';
|
||||
import { dashboardLayout } from './mockDashboardLayout';
|
||||
import dashboardInfo from './mockDashboardInfo';
|
||||
import { emptyFilters } from './mockDashboardFilters';
|
||||
import dashboardState from './mockDashboardState';
|
||||
import messageToasts from '../../messageToasts/mockMessageToasts';
|
||||
import datasources from '../../../fixtures/mockDatasource';
|
||||
@@ -29,6 +30,7 @@ export default {
|
||||
sliceEntities,
|
||||
charts: chartQueries,
|
||||
dashboardInfo,
|
||||
dashboardFilters: emptyFilters,
|
||||
dashboardState,
|
||||
dashboardLayout,
|
||||
messageToasts,
|
||||
|
||||
@@ -35,6 +35,7 @@ export const mockStoreWithTabs = createStore(
|
||||
{
|
||||
...mockState,
|
||||
dashboardLayout: dashboardLayoutWithTabs,
|
||||
dashboardFilters: {},
|
||||
},
|
||||
compose(applyMiddleware(thunk)),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user