From 68c16e3b593c4801dcf3ebfdaad2c3378239925e Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 21 Sep 2022 17:47:58 +0800 Subject: [PATCH 1/9] feat: support multiple columns with time grain in Pivot Table v2 --- .../src/plugin/buildQuery.ts | 30 +++++++-- .../src/plugin/controlPanel.tsx | 62 ++++++++++++++++++- 2 files changed, 86 insertions(+), 6 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts index 677902b796800..902aad4e35377 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts @@ -17,8 +17,10 @@ * under the License. */ import { + AdhocColumn, buildQueryContext, ensureIsArray, + isPhysicalColumn, QueryFormColumn, QueryFormOrderBy, } from '@superset-ui/core'; @@ -27,10 +29,28 @@ import { PivotTableQueryFormData } from '../types'; export default function buildQuery(formData: PivotTableQueryFormData) { const { groupbyColumns = [], groupbyRows = [] } = formData; // TODO: add deduping of AdhocColumns - const groupbySet = new Set([ - ...ensureIsArray(groupbyColumns), - ...ensureIsArray(groupbyRows), - ]); + const groupbySet = Array.from( + new Set([ + ...ensureIsArray(groupbyColumns), + ...ensureIsArray(groupbyRows), + ]), + ).map(col => { + if ( + isPhysicalColumn(col) && + formData.time_grain_sqla && + formData?.isDTTMLookup[col] + ) { + return { + timeGrain: formData.time_grain_sqla, + columnType: 'BASE_AXIS', + sqlExpression: col, + label: col, + expressionType: 'SQL', + } as AdhocColumn; + } + return col; + }); + return buildQueryContext(formData, baseQueryObject => { const { series_limit_metric, metrics, order_desc } = baseQueryObject; let orderBy: QueryFormOrderBy[] | undefined; @@ -43,7 +63,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) { { ...baseQueryObject, orderby: orderBy, - columns: [...groupbySet], + columns: groupbySet, }, ]; }); diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx index 5427410b162a8..5a7fa1a5168a6 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx @@ -19,6 +19,10 @@ import React from 'react'; import { ensureIsArray, + FeatureFlag, + isAdhocColumn, + isFeatureEnabled, + isPhysicalColumn, QueryFormMetric, smartDateFormatter, t, @@ -33,12 +37,14 @@ import { emitFilterControl, Dataset, getStandardizedControls, + ControlState, + ControlPanelState, } from '@superset-ui/chart-controls'; import { MetricsLayoutEnum } from '../types'; const config: ControlPanelConfig = { controlPanelSections: [ - { ...sections.legacyTimeseriesTime, expanded: false }, + { ...sections.genericTime, expanded: false }, { label: t('Query'), expanded: true, @@ -63,6 +69,60 @@ const config: ControlPanelConfig = { }, }, ], + [ + isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) + ? { + name: 'time_grain_sqla', + config: { + ...sharedControls.time_grain_sqla, + visibility: ({ controls }) => { + if (!isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES)) { + return true; + } + + const isDTTMLookup = Object.fromEntries( + ensureIsArray(controls?.groupbyColumns?.options).map( + option => [option.column_name, option.is_dttm], + ), + ); + const selections = [ + ...ensureIsArray(controls?.groupbyColumns.value), + ...ensureIsArray(controls?.groupbyRows.value), + ]; + return selections + .map(selection => { + if (isAdhocColumn(selection)) { + return true; + } + if (isPhysicalColumn(selection)) { + return !!isDTTMLookup[selection]; + } + return false; + }) + .some(Boolean); + }, + }, + } + : null, + isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) + ? { + name: 'isDTTMLookup', + config: { + type: 'HiddenControl', + initialValue: ( + control: ControlState, + state: ControlPanelState, + ) => + Object.fromEntries( + ensureIsArray(state?.datasource?.columns).map(option => [ + option.column_name ?? option.name, + option.is_dttm, + ]), + ), + }, + } + : null, + ], [ { name: 'metrics', From 11f0e9e76d767a6c024382f48320a44933ea4a50 Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 21 Sep 2022 19:03:16 +0800 Subject: [PATCH 2/9] switch --- .../plugins/plugin-chart-pivot-table/package.json | 4 +++- .../plugin-chart-pivot-table/src/plugin/buildQuery.ts | 9 ++++++++- .../plugin-chart-pivot-table/src/plugin/controlPanel.tsx | 8 +++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/package.json b/superset-frontend/plugins/plugin-chart-pivot-table/package.json index a796b90836e96..9d65b2f0bb8fe 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/package.json +++ b/superset-frontend/plugins/plugin-chart-pivot-table/package.json @@ -25,7 +25,9 @@ "publishConfig": { "access": "public" }, - "dependencies": {}, + "dependencies": { + "lodash": "^4.17.11" + }, "peerDependencies": { "@superset-ui/chart-controls": "*", "@superset-ui/core": "*", diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts index 902aad4e35377..b4cf1e3ead069 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts @@ -16,10 +16,14 @@ * specific language governing permissions and limitations * under the License. */ +import omit from 'lodash/omit'; + import { AdhocColumn, buildQueryContext, ensureIsArray, + FeatureFlag, + isFeatureEnabled, isPhysicalColumn, QueryFormColumn, QueryFormOrderBy, @@ -38,6 +42,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) { if ( isPhysicalColumn(col) && formData.time_grain_sqla && + isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) && formData?.isDTTMLookup[col] ) { return { @@ -61,7 +66,9 @@ export default function buildQuery(formData: PivotTableQueryFormData) { } return [ { - ...baseQueryObject, + ...(isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) + ? omit(baseQueryObject, ['extras.time_grain_sqla']) + : baseQueryObject), orderby: orderBy, columns: groupbySet, }, diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx index 5a7fa1a5168a6..dc9c455391d79 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx @@ -76,10 +76,6 @@ const config: ControlPanelConfig = { config: { ...sharedControls.time_grain_sqla, visibility: ({ controls }) => { - if (!isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES)) { - return true; - } - const isDTTMLookup = Object.fromEntries( ensureIsArray(controls?.groupbyColumns?.options).map( option => [option.column_name, option.is_dttm], @@ -114,7 +110,9 @@ const config: ControlPanelConfig = { state: ControlPanelState, ) => Object.fromEntries( - ensureIsArray(state?.datasource?.columns).map(option => [ + ensureIsArray>( + state?.datasource?.columns, + ).map(option => [ option.column_name ?? option.name, option.is_dttm, ]), From 817a5a1822fe966ec6a704a52a0314036f8e9caa Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 21 Sep 2022 19:07:41 +0800 Subject: [PATCH 3/9] rename --- .../plugin-chart-pivot-table/src/plugin/buildQuery.ts | 2 +- .../plugin-chart-pivot-table/src/plugin/controlPanel.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts index b4cf1e3ead069..629db2c18fd0d 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts @@ -43,7 +43,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) { isPhysicalColumn(col) && formData.time_grain_sqla && isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) && - formData?.isDTTMLookup[col] + formData?.DTTMLookup[col] ) { return { timeGrain: formData.time_grain_sqla, diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx index dc9c455391d79..c8b0518f208d5 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx @@ -76,7 +76,7 @@ const config: ControlPanelConfig = { config: { ...sharedControls.time_grain_sqla, visibility: ({ controls }) => { - const isDTTMLookup = Object.fromEntries( + const DTTMLookup = Object.fromEntries( ensureIsArray(controls?.groupbyColumns?.options).map( option => [option.column_name, option.is_dttm], ), @@ -91,7 +91,7 @@ const config: ControlPanelConfig = { return true; } if (isPhysicalColumn(selection)) { - return !!isDTTMLookup[selection]; + return !!DTTMLookup[selection]; } return false; }) @@ -102,7 +102,7 @@ const config: ControlPanelConfig = { : null, isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? { - name: 'isDTTMLookup', + name: 'DTTMLookup', config: { type: 'HiddenControl', initialValue: ( From b73d31bb5f03d1e11e98558a97aa62931d54282d Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 21 Sep 2022 21:51:19 +0800 Subject: [PATCH 4/9] improve structure --- .../src/plugin/buildQuery.ts | 2 +- .../src/plugin/controlPanel.tsx | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts index 629db2c18fd0d..acb43c9f54f83 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts @@ -43,7 +43,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) { isPhysicalColumn(col) && formData.time_grain_sqla && isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) && - formData?.DTTMLookup[col] + formData?.datetimeLookup[col] ) { return { timeGrain: formData.time_grain_sqla, diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx index c8b0518f208d5..ae61b5e6814f7 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx @@ -102,20 +102,19 @@ const config: ControlPanelConfig = { : null, isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? { - name: 'DTTMLookup', + name: 'datetimeLookup', config: { type: 'HiddenControl', - initialValue: ( - control: ControlState, - state: ControlPanelState, - ) => + default: (control: ControlState, state: ControlPanelState) => Object.fromEntries( ensureIsArray>( state?.datasource?.columns, - ).map(option => [ - option.column_name ?? option.name, - option.is_dttm, - ]), + ) + .filter(option => option.is_dttm) + .map(option => [ + option.column_name ?? option.name, + option.is_dttm, + ]), ), }, } From 951a7b93d48aca774a815a09dbc0bfedf9e39b61 Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 21 Sep 2022 21:56:33 +0800 Subject: [PATCH 5/9] rename --- .../plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts | 2 +- .../plugin-chart-pivot-table/src/plugin/controlPanel.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts index acb43c9f54f83..396863449227e 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts @@ -43,7 +43,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) { isPhysicalColumn(col) && formData.time_grain_sqla && isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) && - formData?.datetimeLookup[col] + formData?.datetimeColumnLookup[col] ) { return { timeGrain: formData.time_grain_sqla, diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx index ae61b5e6814f7..5b51f5f9274c1 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx @@ -102,7 +102,7 @@ const config: ControlPanelConfig = { : null, isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? { - name: 'datetimeLookup', + name: 'datetimeColumnLookup', config: { type: 'HiddenControl', default: (control: ControlState, state: ControlPanelState) => From e014935d1aa06e7c81f0db811c0ef0a383effd60 Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 21 Sep 2022 22:27:30 +0800 Subject: [PATCH 6/9] address comments --- .../plugins/plugin-chart-pivot-table/package.json | 7 +++---- .../plugin-chart-pivot-table/src/plugin/buildQuery.ts | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/package.json b/superset-frontend/plugins/plugin-chart-pivot-table/package.json index 9d65b2f0bb8fe..bed12a2e7250e 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/package.json +++ b/superset-frontend/plugins/plugin-chart-pivot-table/package.json @@ -25,16 +25,15 @@ "publishConfig": { "access": "public" }, - "dependencies": { - "lodash": "^4.17.11" - }, + "dependencies": {}, "peerDependencies": { "@superset-ui/chart-controls": "*", "@superset-ui/core": "*", "@ant-design/icons": "^4.2.2", "react": "^16.13.1", "react-dom": "^16.13.1", - "prop-types": "*" + "prop-types": "*", + "lodash": "^4.17.11" }, "devDependencies": { "@babel/types": "^7.13.12", diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts index 396863449227e..e1a5af17ff227 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts @@ -33,7 +33,7 @@ import { PivotTableQueryFormData } from '../types'; export default function buildQuery(formData: PivotTableQueryFormData) { const { groupbyColumns = [], groupbyRows = [] } = formData; // TODO: add deduping of AdhocColumns - const groupbySet = Array.from( + const columns = Array.from( new Set([ ...ensureIsArray(groupbyColumns), ...ensureIsArray(groupbyRows), @@ -70,7 +70,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) { ? omit(baseQueryObject, ['extras.time_grain_sqla']) : baseQueryObject), orderby: orderBy, - columns: groupbySet, + columns, }, ]; }); From 1804dfe157ffbff7dccc89b71075511be06fe28d Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 21 Sep 2022 22:28:34 +0800 Subject: [PATCH 7/9] addressing comments --- .../plugin-chart-pivot-table/src/plugin/controlPanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx index 5b51f5f9274c1..77c57ff2b2b82 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx @@ -76,7 +76,7 @@ const config: ControlPanelConfig = { config: { ...sharedControls.time_grain_sqla, visibility: ({ controls }) => { - const DTTMLookup = Object.fromEntries( + const dttmLookup = Object.fromEntries( ensureIsArray(controls?.groupbyColumns?.options).map( option => [option.column_name, option.is_dttm], ), @@ -91,7 +91,7 @@ const config: ControlPanelConfig = { return true; } if (isPhysicalColumn(selection)) { - return !!DTTMLookup[selection]; + return !!dttmLookup[selection]; } return false; }) From ba735cc1a9d9925dddc1e5c596ff9ce6a3117a08 Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 21 Sep 2022 22:30:35 +0800 Subject: [PATCH 8/9] updates --- .../plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts index e1a5af17ff227..7cf3cd11bef3c 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts @@ -43,7 +43,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) { isPhysicalColumn(col) && formData.time_grain_sqla && isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) && - formData?.datetimeColumnLookup[col] + formData?.datetimeColumnLookup?.[col] ) { return { timeGrain: formData.time_grain_sqla, From 8f64fe52c39ba494c58d230d9c717d3fe370da9d Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Thu, 22 Sep 2022 10:17:07 +0800 Subject: [PATCH 9/9] move datatime columns lookup into sharedControls --- .../src/shared-controls/index.tsx | 20 +++++++++++++- .../src/plugin/buildQuery.ts | 2 +- .../src/plugin/controlPanel.tsx | 26 +++---------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/index.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/index.tsx index 9b06bb3b9b075..9577cd9656c34 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/index.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/index.tsx @@ -45,6 +45,7 @@ import { ComparisionType, isAdhocColumn, isPhysicalColumn, + ensureIsArray, } from '@superset-ui/core'; import { @@ -57,7 +58,13 @@ import { DEFAULT_NUMBER_FORMAT, } from '../utils'; import { TIME_FILTER_LABELS } from '../constants'; -import { SharedControlConfig, Dataset, ColumnMeta } from '../types'; +import { + SharedControlConfig, + Dataset, + ColumnMeta, + ControlState, + ControlPanelState, +} from '../types'; import { dndAdhocFilterControl, @@ -340,6 +347,16 @@ const show_empty_columns: SharedControlConfig<'CheckboxControl'> = { description: t('Show empty columns'), }; +const datetime_columns_lookup: SharedControlConfig<'HiddenControl'> = { + type: 'HiddenControl', + initialValue: (control: ControlState, state: ControlPanelState) => + Object.fromEntries( + ensureIsArray>(state?.datasource?.columns) + .filter(option => option.is_dttm) + .map(option => [option.column_name ?? option.name, option.is_dttm]), + ), +}; + export default { metrics: dndAdhocMetricsControl, metric: dndAdhocMetricControl, @@ -376,4 +393,5 @@ export default { truncate_metric, x_axis: dndXAxisControl, show_empty_columns, + datetime_columns_lookup, }; diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts index 7cf3cd11bef3c..8068ace2fdd74 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts @@ -43,7 +43,7 @@ export default function buildQuery(formData: PivotTableQueryFormData) { isPhysicalColumn(col) && formData.time_grain_sqla && isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) && - formData?.datetimeColumnLookup?.[col] + formData?.datetime_columns_lookup?.[col] ) { return { timeGrain: formData.time_grain_sqla, diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx index 77c57ff2b2b82..fe69188b253ba 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx @@ -37,8 +37,6 @@ import { emitFilterControl, Dataset, getStandardizedControls, - ControlState, - ControlPanelState, } from '@superset-ui/chart-controls'; import { MetricsLayoutEnum } from '../types'; @@ -81,11 +79,11 @@ const config: ControlPanelConfig = { option => [option.column_name, option.is_dttm], ), ); - const selections = [ + + return [ ...ensureIsArray(controls?.groupbyColumns.value), ...ensureIsArray(controls?.groupbyRows.value), - ]; - return selections + ] .map(selection => { if (isAdhocColumn(selection)) { return true; @@ -101,23 +99,7 @@ const config: ControlPanelConfig = { } : null, isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) - ? { - name: 'datetimeColumnLookup', - config: { - type: 'HiddenControl', - default: (control: ControlState, state: ControlPanelState) => - Object.fromEntries( - ensureIsArray>( - state?.datasource?.columns, - ) - .filter(option => option.is_dttm) - .map(option => [ - option.column_name ?? option.name, - option.is_dttm, - ]), - ), - }, - } + ? 'datetime_columns_lookup' : null, ], [