Skip to content

Commit

Permalink
Fix Table chart, trigger CI, trigger CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
codyml committed Sep 12, 2022
1 parent 5964987 commit ad0b10a
Showing 1 changed file with 6 additions and 44 deletions.
50 changes: 6 additions & 44 deletions superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
sections,
sharedControls,
ControlPanelState,
ExtraControlProps,
ControlState,
emitFilterControl,
Dataset,
Expand Down Expand Up @@ -96,15 +95,14 @@ const queryMode: ControlConfig<'RadioButtonControl'> = {
rerender: ['all_columns', 'groupby', 'metrics', 'percent_metrics'],
};

const all_columns: typeof sharedControls.groupby = {
type: 'SelectControl',
const allColumnsControl: typeof sharedControls.groupby = {
...sharedControls.groupby,
label: t('Columns'),
description: t('Columns to display'),
multi: true,
freeForm: true,
allowAll: true,
commaChoosesOption: false,
default: [],
optionRenderer: c => <ColumnOption showType column={c} />,
valueRenderer: c => <ColumnOption column={c} />,
valueKey: 'column_name',
Expand All @@ -120,37 +118,12 @@ const all_columns: typeof sharedControls.groupby = {
resetOnHide: false,
};

const dnd_all_columns: typeof sharedControls.groupby = {
type: 'DndColumnSelect',
label: t('Columns'),
description: t('Columns to display'),
default: [],
mapStateToProps({ datasource, controls }, controlState) {
const newState: ExtraControlProps = {};
if (datasource?.columns[0]?.hasOwnProperty('column_name')) {
const options = (datasource as Dataset).columns;
newState.options = Object.fromEntries(
options.map((option: ColumnMeta) => [option.column_name, option]),
);
} else newState.options = datasource?.columns;
newState.queryMode = getQueryMode(controls);
newState.externalValidationErrors =
isRawMode({ controls }) && ensureIsArray(controlState?.value).length === 0
? [t('must have a value')]
: [];
return newState;
},
visibility: isRawMode,
resetOnHide: false,
};

const percent_metrics: typeof sharedControls.metrics = {
type: 'MetricsControl',
const percentMetricsControl: typeof sharedControls.metrics = {
...sharedControls.metrics,
label: t('Percentage metrics'),
description: t(
'Metrics for which percentage of total are to be displayed. Calculated from only data within the row limit.',
),
multi: true,
visibility: isAggMode,
resetOnHide: false,
mapStateToProps: ({ datasource, controls }, controlState) => ({
Expand All @@ -170,11 +143,6 @@ const percent_metrics: typeof sharedControls.metrics = {
validators: [],
};

const dnd_percent_metrics = {
...percent_metrics,
type: 'DndMetricSelect',
};

const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyTimeseriesTime,
Expand Down Expand Up @@ -251,19 +219,13 @@ const config: ControlPanelConfig = {
},
{
name: 'all_columns',
config: isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dnd_all_columns
: all_columns,
config: allColumnsControl,
},
],
[
{
name: 'percent_metrics',
config: {
...(isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dnd_percent_metrics
: percent_metrics),
},
config: percentMetricsControl,
},
],
['adhoc_filters'],
Expand Down

0 comments on commit ad0b10a

Please sign in to comment.