diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx index c01b4052d1..eaf0f172b4 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx @@ -362,6 +362,14 @@ const temporal_columns_lookup: SharedControlConfig<'HiddenControl'> = { ), }; +const sort_by_metric: SharedControlConfig<'CheckboxControl'> = { + type: 'CheckboxControl', + label: t('Sort by metric'), + description: t( + 'Whether to sort results by the selected metric in descending order.', + ), +}; + export default { metrics: dndAdhocMetricsControl, metric: dndAdhocMetricControl, @@ -400,4 +408,5 @@ export default { show_empty_columns, temporal_columns_lookup, currency_format, + sort_by_metric, }; diff --git a/superset-frontend/plugins/legacy-plugin-chart-chord/src/controlPanel.ts b/superset-frontend/plugins/legacy-plugin-chart-chord/src/controlPanel.ts index 679e959707..031382a45e 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-chord/src/controlPanel.ts +++ b/superset-frontend/plugins/legacy-plugin-chart-chord/src/controlPanel.ts @@ -33,18 +33,7 @@ const config: ControlPanelConfig = { ['metric'], ['adhoc_filters'], ['row_limit'], - [ - { - name: 'sort_by_metric', - config: { - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), - }, - }, - ], + ['sort_by_metric'], ], }, { diff --git a/superset-frontend/plugins/legacy-plugin-chart-heatmap/src/controlPanel.tsx b/superset-frontend/plugins/legacy-plugin-chart-heatmap/src/controlPanel.tsx index 53394c99eb..d22428e1ea 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-heatmap/src/controlPanel.tsx +++ b/superset-frontend/plugins/legacy-plugin-chart-heatmap/src/controlPanel.tsx @@ -64,18 +64,7 @@ const config: ControlPanelConfig = { ['metric'], ['adhoc_filters'], ['row_limit'], - [ - { - name: 'sort_by_metric', - config: { - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), - }, - }, - ], + ['sort_by_metric'], ], }, { diff --git a/superset-frontend/plugins/legacy-plugin-chart-sankey/src/controlPanel.ts b/superset-frontend/plugins/legacy-plugin-chart-sankey/src/controlPanel.ts index ef9f0394d9..7505f1a4a0 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-sankey/src/controlPanel.ts +++ b/superset-frontend/plugins/legacy-plugin-chart-sankey/src/controlPanel.ts @@ -49,18 +49,7 @@ const config: ControlPanelConfig = { }, }, ], - [ - { - name: 'sort_by_metric', - config: { - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), - }, - }, - ], + ['sort_by_metric'], ], }, { diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts index 82d8dcb1e2..f75764e9f5 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts @@ -54,18 +54,7 @@ const config: ControlPanelConfig = { ['metric'], ['adhoc_filters'], ['row_limit'], - [ - { - name: 'sort_by_metric', - config: { - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), - }, - }, - ], + ['sort_by_metric'], ], }, { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx index a8e4f01644..df2b23c599 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx @@ -62,12 +62,8 @@ const config: ControlPanelConfig = { { name: 'sort_by_metric', config: { + ...sharedControls.sort_by_metric, default: true, - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), }, }, ], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/controlPanel.tsx index 8727a23c72..5d6df447ac 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/controlPanel.tsx @@ -53,18 +53,7 @@ const config: ControlPanelConfig = { }, }, ], - [ - { - name: 'sort_by_metric', - config: { - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), - }, - }, - ], + ['sort_by_metric'], ], }, { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx index 7e700c18c9..583444508d 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx @@ -26,6 +26,7 @@ import { D3_FORMAT_OPTIONS, D3_TIME_FORMAT_OPTIONS, getStandardizedControls, + sharedControls, } from '@superset-ui/chart-controls'; import { DEFAULT_FORM_DATA } from './types'; import { legendSection } from '../controls'; @@ -56,12 +57,8 @@ const config: ControlPanelConfig = { { name: 'sort_by_metric', config: { + ...sharedControls.sort_by_metric, default: true, - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), }, }, ], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/controlPanel.tsx index 532b19b410..2a64a8f965 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/controlPanel.tsx @@ -42,18 +42,7 @@ const config: ControlPanelConfig = { ['secondary_metric'], ['adhoc_filters'], ['row_limit'], - [ - { - name: 'sort_by_metric', - config: { - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), - }, - }, - ], + ['sort_by_metric'], ], }, { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/controlPanel.tsx index 2e09f25d1e..1e1dc47576 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/controlPanel.tsx @@ -40,18 +40,7 @@ const config: ControlPanelConfig = { ['groupby'], ['metric'], ['row_limit'], - [ - { - name: 'sort_by_metric', - config: { - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), - }, - }, - ], + ['sort_by_metric'], ['adhoc_filters'], ], }, diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controlPanel.ts b/superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controlPanel.ts index 3ba153d246..9425f12117 100644 --- a/superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controlPanel.ts +++ b/superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controlPanel.ts @@ -32,18 +32,7 @@ const config: ControlPanelConfig = { ['metric'], ['adhoc_filters'], ['row_limit'], - [ - { - name: 'sort_by_metric', - config: { - type: 'CheckboxControl', - label: t('Sort by metric'), - description: t( - 'Whether to sort results by the selected metric in descending order.', - ), - }, - }, - ], + ['sort_by_metric'], ], }, {