From 7e99fcc4302e5072a9ed895e0be78e237e968476 Mon Sep 17 00:00:00 2001 From: Cody Leff Date: Wed, 13 Jul 2022 19:09:57 -0600 Subject: [PATCH 1/3] Fix chart refresh on save as. --- superset-frontend/src/datasource/reducer.ts | 9 ++++++++- .../src/explore/actions/hydrateExplore.ts | 12 ++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/superset-frontend/src/datasource/reducer.ts b/superset-frontend/src/datasource/reducer.ts index 476ed750bedef..6db0e8d47454d 100644 --- a/superset-frontend/src/datasource/reducer.ts +++ b/superset-frontend/src/datasource/reducer.ts @@ -23,10 +23,14 @@ import { DatasourcesActionType, } from 'src/datasource/actions'; import { Dataset } from '@superset-ui/chart-controls'; +import { + HydrateExplore, + HYDRATE_EXPLORE, +} from 'src/explore/actions/hydrateExplore'; export default function datasourcesReducer( datasources: { [key: string]: Dataset } | undefined, - action: DatasourcesAction, + action: DatasourcesAction | HydrateExplore, ) { if (action.type === DatasourcesActionType.INIT_DATASOURCES) { return { ...action.datasources }; @@ -43,5 +47,8 @@ export default function datasourcesReducer( [getDatasourceUid(action.datasource)]: action.datasource, }; } + if (action.type === HYDRATE_EXPLORE) { + return { ...(action as HydrateExplore).data.datasources }; + } return datasources || {}; } diff --git a/superset-frontend/src/explore/actions/hydrateExplore.ts b/superset-frontend/src/explore/actions/hydrateExplore.ts index b16ac30a7bc10..2479a8c978734 100644 --- a/superset-frontend/src/explore/actions/hydrateExplore.ts +++ b/superset-frontend/src/explore/actions/hydrateExplore.ts @@ -35,7 +35,6 @@ import { getDatasourceUid } from 'src/utils/getDatasourceUid'; import { getUrlParam } from 'src/utils/urlUtils'; import { URL_PARAMS } from 'src/constants'; import { findPermission } from 'src/utils/findPermission'; -import { initDatasources } from 'src/datasource/actions'; export const HYDRATE_EXPLORE = 'HYDRATE_EXPLORE'; export const hydrateExplore = @@ -121,13 +120,6 @@ export const hydrateExplore = lastRendered: 0, }; - dispatch( - initDatasources({ - ...datasources, - [getDatasourceUid(initialDatasource)]: initialDatasource, - }), - ); - return dispatch({ type: HYDRATE_EXPLORE, data: { @@ -135,6 +127,10 @@ export const hydrateExplore = ...charts, [chartKey]: chart, }, + datasources: { + ...datasources, + [getDatasourceUid(initialDatasource)]: initialDatasource, + }, saveModal: { dashboards: [], saveModalAlert: null, From f68083d1238d148cf89460175e929811bf1680ff Mon Sep 17 00:00:00 2001 From: Cody Leff Date: Thu, 14 Jul 2022 06:58:07 -0600 Subject: [PATCH 2/3] Fix Jest test. --- .../src/explore/actions/hydrateExplore.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/superset-frontend/src/explore/actions/hydrateExplore.test.ts b/superset-frontend/src/explore/actions/hydrateExplore.test.ts index 3b3963f9f5117..ad28120bdfa92 100644 --- a/superset-frontend/src/explore/actions/hydrateExplore.test.ts +++ b/superset-frontend/src/explore/actions/hydrateExplore.test.ts @@ -64,6 +64,19 @@ test('creates hydrate action from initial data', () => { lastRendered: 0, }, }, + datasources: { + '8__table': { + column_format: {}, + columns: [{ column_name: 'a' }], + datasource_name: '8__table', + description: null, + id: 8, + main_dttm_col: '', + metrics: [{ metric_name: 'first' }, { metric_name: 'second' }], + type: 'table', + verbose_map: {}, + }, + }, saveModal: { dashboards: [], saveModalAlert: null, From 95dc1d7acb3022d795dbdd5b0d3bfec25e955afd Mon Sep 17 00:00:00 2001 From: Cody Leff Date: Thu, 14 Jul 2022 07:01:50 -0600 Subject: [PATCH 3/3] Re-enable skipped Cypress test. --- .../cypress-base/cypress/integration/explore/link.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/cypress-base/cypress/integration/explore/link.test.ts b/superset-frontend/cypress-base/cypress/integration/explore/link.test.ts index bc18f2c410f2c..fb3445fc6366f 100644 --- a/superset-frontend/cypress-base/cypress/integration/explore/link.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/explore/link.test.ts @@ -28,7 +28,7 @@ import { HEALTH_POP_FORM_DATA_DEFAULTS } from './visualizations/shared.helper'; const apiURL = (endpoint: string, queryObject: Record) => `${endpoint}?q=${rison.encode(queryObject)}`; -describe.skip('Test explore links', () => { +describe('Test explore links', () => { beforeEach(() => { cy.login(); interceptChart({ legacy: true }).as('chartData');