diff --git a/superset-frontend/spec/fixtures/mockChartQueries.js b/superset-frontend/spec/fixtures/mockChartQueries.js index e4fa224ad8263..d25267392a0db 100644 --- a/superset-frontend/spec/fixtures/mockChartQueries.js +++ b/superset-frontend/spec/fixtures/mockChartQueries.js @@ -33,23 +33,6 @@ export default { triggerQuery: false, lastRendered: 0, form_data: { - slice_id: sliceId, - viz_type: 'pie', - row_limit: 50000, - metric: 'sum__num', - since: '100 years ago', - groupby: ['gender'], - metrics: ['sum__num'], - compare_lag: '10', - limit: '25', - until: 'now', - granularity: 'ds', - markup_type: 'markdown', - where: '', - compare_suffix: 'o10Y', - datasource: datasourceId, - }, - formData: { datasource: datasourceId, viz_type: 'pie', slice_id: sliceId, diff --git a/superset-frontend/src/dashboard/actions/dashboardState.js b/superset-frontend/src/dashboard/actions/dashboardState.js index f96b3ebadf28b..1b9224a3da37f 100644 --- a/superset-frontend/src/dashboard/actions/dashboardState.js +++ b/superset-frontend/src/dashboard/actions/dashboardState.js @@ -489,8 +489,7 @@ export function addSliceToDashboard(id, component) { const newChart = { ...initChart, id, - form_data, - formData: applyDefaultFormData(form_data), + form_data: applyDefaultFormData(form_data), }; return Promise.all([ diff --git a/superset-frontend/src/dashboard/actions/hydrate.js b/superset-frontend/src/dashboard/actions/hydrate.js index 6c98f701fc93d..7f393f3bc276d 100644 --- a/superset-frontend/src/dashboard/actions/hydrate.js +++ b/superset-frontend/src/dashboard/actions/hydrate.js @@ -138,8 +138,7 @@ export const hydrateDashboard = chartQueries[key] = { ...chart, id: key, - form_data, - formData: applyDefaultFormData(form_data), + form_data: applyDefaultFormData(form_data), }; slices[key] = { @@ -316,7 +315,7 @@ export const hydrateDashboard = const behaviors = ( getChartMetadataRegistry().get( - chartQueries[chartId]?.formData?.viz_type, + chartQueries[chartId]?.form_data?.viz_type, ) ?? {} )?.behaviors ?? []; diff --git a/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx b/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx index 59cbce2090354..6ace923c0f827 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx @@ -40,7 +40,7 @@ describe('Chart', () => { // from redux maxRows: 666, chart: chartQueries[queryId], - formData: chartQueries[queryId].formData, + formData: chartQueries[queryId].form_data, datasource: mockDatasource[sliceEntities.slices[queryId].datasource], slice: { ...sliceEntities.slices[queryId], diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts index 4e1b2eda1271e..425029bb86872 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts @@ -111,7 +111,7 @@ export const useInitialization = () => { // do not load filter_box in reviewing if (filterboxMigrationState === FILTER_BOX_MIGRATION_STATES.REVIEWING) { charts = keyBy( - filter(charts, chart => chart.formData?.viz_type !== 'filter_box'), + filter(charts, chart => chart.form_data?.viz_type !== 'filter_box'), 'id', ); const numberOfFilterbox = document.querySelectorAll( diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.ts b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.ts index 4bf04c7e957bf..6dad6d4b3a751 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.ts +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.ts @@ -28,7 +28,7 @@ import { BuildTreeLeafTitle, TreeItem } from './types'; export const isShowTypeInTree = ({ type, meta }: LayoutItem, charts?: Charts) => (type === TAB_TYPE || type === CHART_TYPE || type === DASHBOARD_ROOT_TYPE) && - (!charts || charts[meta?.chartId]?.formData?.viz_type !== 'filter_box'); + (!charts || charts[meta?.chartId]?.form_data?.viz_type !== 'filter_box'); export const buildTree = ( node: LayoutItem, diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx index 266ac2a779dfe..43901ddec2914 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx @@ -688,7 +688,7 @@ const FiltersConfigForm = ( } Object.values(charts).forEach((chart: Chart) => { - const chartDatasetUid = chart.formData?.datasource; + const chartDatasetUid = chart.form_data?.datasource; if (chartDatasetUid === undefined) { return; } diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts index 8fdb3b0325997..2a0b7fcad857b 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.ts @@ -111,7 +111,7 @@ export const mostUsedDataset = ( let maxCount = 0; Object.values(charts).forEach(chart => { - const { formData } = chart; + const { form_data: formData } = chart; if (formData) { const { datasource } = formData; const count = (map.get(datasource) || 0) + 1; diff --git a/superset-frontend/src/dashboard/types.ts b/superset-frontend/src/dashboard/types.ts index aabc2e5c2e773..160d62564de0b 100644 --- a/superset-frontend/src/dashboard/types.ts +++ b/superset-frontend/src/dashboard/types.ts @@ -40,14 +40,13 @@ export type ChartReducerInitialState = typeof chart; // Ref: https://github.com/apache/superset/blob/dcac860f3e5528ecbc39e58f045c7388adb5c3d0/superset-frontend/src/dashboard/reducers/getInitialState.js#L120 export interface ChartQueryPayload extends Partial { id: number; - formData: ChartProps['formData']; form_data?: ChartProps['rawFormData']; [key: string]: unknown; } /** Chart state of redux */ export type Chart = ChartState & { - formData: { + form_data: { viz_type: string; datasource: string; }; diff --git a/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts b/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts index 0bbabfcde52d1..3ca003fd0aecf 100644 --- a/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts +++ b/superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts @@ -116,7 +116,7 @@ export default function getFormDataWithExtraFilters({ } const formData = { - ...chart.formData, + ...chart.form_data, label_colors: labelColors, shared_label_colors: sharedLabelColors, ...(colorScheme && { color_scheme: colorScheme }), diff --git a/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts b/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts index 021a488e37794..ce2cff6886f9d 100644 --- a/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts +++ b/superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts @@ -35,7 +35,7 @@ describe('getFormDataWithExtraFilters', () => { queryController: null, queriesResponse: null, triggerQuery: false, - formData: { + form_data: { viz_type: 'filter_select', filters: [ { @@ -45,6 +45,7 @@ describe('getFormDataWithExtraFilters', () => { }, ], datasource: '123', + url_params: {}, }, }; const mockArgs: GetFormDataWithExtraFiltersArguments = { diff --git a/superset-frontend/src/dashboard/util/logging/childChartsDidLoad.js b/superset-frontend/src/dashboard/util/logging/childChartsDidLoad.js index fc6fa68fbd5d1..7cef9ae6dc521 100644 --- a/superset-frontend/src/dashboard/util/logging/childChartsDidLoad.js +++ b/superset-frontend/src/dashboard/util/logging/childChartsDidLoad.js @@ -26,7 +26,7 @@ export default function childChartsDidLoad({ chartQueries, layout, id }) { const query = chartQueries[chartId] || {}; // filterbox's don't re-render, don't use stale update time - if (query.formData && query.formData.viz_type !== 'filter_box') { + if (query.form_data && query.form_data.viz_type !== 'filter_box') { minQueryStartTime = Math.min( query.chartUpdateStartTime, minQueryStartTime,