You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by kg...@apache.org on 2023/07/11 15:15:02 UTC
[superset] branch master updated: fix: Incorrect initial global scoping of cross filters (#24642)
This is an automated email from the ASF dual-hosted git repository.
kgabryje pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new bbffc4c1f8 fix: Incorrect initial global scoping of cross filters (#24642)
bbffc4c1f8 is described below
commit bbffc4c1f8f4eda13517f16ea5e467153c282d4c
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Tue Jul 11 17:14:55 2023 +0200
fix: Incorrect initial global scoping of cross filters (#24642)
---
.../src/dashboard/util/crossFilters.test.ts | 84 +++++++++++++++++++++-
.../src/dashboard/util/crossFilters.ts | 9 ++-
2 files changed, 90 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/src/dashboard/util/crossFilters.test.ts b/superset-frontend/src/dashboard/util/crossFilters.test.ts
index 45bcaaf0b6..0e9fc00de8 100644
--- a/superset-frontend/src/dashboard/util/crossFilters.test.ts
+++ b/superset-frontend/src/dashboard/util/crossFilters.test.ts
@@ -175,7 +175,6 @@ test('Generate correct cross filters configuration without initial configuration
chartsInScope: [1, 2],
},
});
- metadataRegistryStub.restore();
});
test('Generate correct cross filters configuration with initial configuration', () => {
@@ -218,7 +217,6 @@ test('Generate correct cross filters configuration with initial configuration',
chartsInScope: [1, 2],
},
});
- metadataRegistryStub.restore();
});
test('Return undefined if DASHBOARD_CROSS_FILTERS feature flag is disabled', () => {
@@ -234,3 +232,85 @@ test('Return undefined if DASHBOARD_CROSS_FILTERS feature flag is disabled', ()
),
).toEqual(undefined);
});
+
+test('Recalculate charts in global filter scope when charts change', () => {
+ // @ts-ignore
+ global.featureFlags = {
+ [FeatureFlag.DASHBOARD_CROSS_FILTERS]: true,
+ };
+ expect(
+ getCrossFiltersConfiguration(
+ {
+ ...DASHBOARD_LAYOUT,
+ 'CHART-3': {
+ children: [],
+ id: 'CHART-3',
+ meta: {
+ chartId: 3,
+ sliceName: 'Test chart 3',
+ height: 1,
+ width: 1,
+ uuid: '3',
+ },
+ parents: ['ROOT_ID', 'GRID_ID', 'ROW-6XUMf1rV76'],
+ type: 'CHART',
+ },
+ },
+ CHART_CONFIG_METADATA,
+ {
+ ...CHARTS,
+ '3': {
+ id: 3,
+ form_data: {
+ datasource: '3__table',
+ viz_type: 'echarts_timeseries_line',
+ },
+ chartAlert: null,
+ chartStatus: 'rendered' as const,
+ chartUpdateEndTime: 0,
+ chartUpdateStartTime: 0,
+ lastRendered: 0,
+ latestQueryFormData: {},
+ sliceFormData: {
+ datasource: '3__table',
+ viz_type: 'echarts_timeseries_line',
+ },
+ queryController: null,
+ queriesResponse: [{}],
+ triggerQuery: false,
+ },
+ },
+ ),
+ ).toEqual({
+ chartConfiguration: {
+ '1': {
+ id: 1,
+ crossFilters: {
+ scope: { rootPath: ['ROOT_ID'], excluded: [1, 2] },
+ chartsInScope: [3],
+ },
+ },
+ '2': {
+ id: 2,
+ crossFilters: {
+ scope: 'global',
+ chartsInScope: [1, 3],
+ },
+ },
+ '3': {
+ id: 3,
+ crossFilters: {
+ scope: 'global',
+ chartsInScope: [1, 2],
+ },
+ },
+ },
+ globalChartConfiguration: {
+ scope: {
+ excluded: [],
+ rootPath: ['ROOT_ID'],
+ },
+ chartsInScope: [1, 2, 3],
+ },
+ });
+});
diff --git a/superset-frontend/src/dashboard/util/crossFilters.ts b/superset-frontend/src/dashboard/util/crossFilters.ts
index 77b2b36f35..425c725989 100644
--- a/superset-frontend/src/dashboard/util/crossFilters.ts
+++ b/superset-frontend/src/dashboard/util/crossFilters.ts
@@ -53,7 +53,14 @@ export const getCrossFiltersConfiguration = (
}
const globalChartConfiguration = metadata.global_chart_configuration
- ? cloneDeep(metadata.global_chart_configuration)
+ ? {
+ scope: metadata.global_chart_configuration.scope,
+ chartsInScope: getChartIdsInFilterScope(
+ metadata.global_chart_configuration.scope,
+ Object.values(charts).map(chart => chart.id),
+ dashboardLayout,
+ ),
+ }
: {
scope: DEFAULT_CROSS_FILTER_SCOPING,
chartsInScope: Object.values(charts).map(chart => chart.id),