mirror of
https://github.com/apache/superset.git
synced 2026-05-07 08:54:23 +00:00
Major refactor to modernize control panel system:
## Changes Made
### Core Infrastructure
- Created InlineControls.tsx with helper functions for all control types
- Added SharedControlComponents for replacing string control references
- Fixed TypeScript types and imports across all control panels
- Added proper exports and type definitions
### Control Panel Migrations
- Converted 20+ control panel files from inline configurations to React components
- Eliminated all string control references (e.g., ['metric'] → MetricControl())
- Updated all legacy-plugin-chart-* plugins
- Updated all legacy-preset-chart-deckgl layers
- Fixed chord diagram control panel (was prematurely using JSON Forms)
### Type Safety Improvements
- Fixed choice array type mismatches (now supports mixed types)
- Resolved import conflicts by renaming inline control helpers
- Added proper TypeScript types for all control configurations
- Reduced TypeScript errors by 57% (44 → 19)
### Pattern Conversion
Before: { name: 'control', config: { type: 'SelectControl', ... } }
After: SelectControl({ name: 'control', ... })
This sets the foundation for the next phase: migrating to JSON Forms format.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
205 lines
5.8 KiB
TypeScript
205 lines
5.8 KiB
TypeScript
/**
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
* or more contributor license agreements. See the NOTICE file
|
|
* distributed with this work for additional information
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
* to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance
|
|
* with the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
import { t } from '@superset-ui/core';
|
|
import {
|
|
ColorSchemeControl,
|
|
ControlPanelConfig,
|
|
ControlPanelsContainerProps,
|
|
ControlSubSectionHeader,
|
|
CurrencyFormatControl,
|
|
D3_TIME_FORMAT_DOCS,
|
|
TimeShiftColorControl,
|
|
YAxisFormatControl,
|
|
ZoomableControl,
|
|
getStandardizedControls,
|
|
sections,
|
|
sharedControls,
|
|
} from '@superset-ui/chart-controls';
|
|
|
|
import {
|
|
DEFAULT_FORM_DATA,
|
|
TIME_SERIES_DESCRIPTION_TEXT,
|
|
} from '../../constants';
|
|
import {
|
|
legendSection,
|
|
minorTicks,
|
|
richTooltipSection,
|
|
seriesOrderSection,
|
|
showValueSection,
|
|
truncateXAxis,
|
|
xAxisBounds,
|
|
xAxisLabelRotation,
|
|
xAxisLabelInterval,
|
|
} from '../../../controls';
|
|
|
|
const {
|
|
logAxis,
|
|
markerEnabled,
|
|
markerSize,
|
|
minorSplitLine,
|
|
rowLimit,
|
|
truncateYAxis,
|
|
yAxisBounds,
|
|
} = DEFAULT_FORM_DATA;
|
|
const config: ControlPanelConfig = {
|
|
controlPanelSections: [
|
|
sections.echartsTimeSeriesQueryWithXAxisSort,
|
|
sections.advancedAnalyticsControls,
|
|
sections.annotationsAndLayersControls,
|
|
sections.forecastIntervalControls,
|
|
sections.titleControls,
|
|
{
|
|
label: t('Chart Options'),
|
|
expanded: true,
|
|
controlSetRows: [
|
|
...seriesOrderSection,
|
|
[ColorSchemeControl()],
|
|
[TimeShiftColorControl()],
|
|
...showValueSection,
|
|
[
|
|
{
|
|
name: 'markerEnabled',
|
|
config: {
|
|
type: 'CheckboxControl',
|
|
label: t('Marker'),
|
|
renderTrigger: true,
|
|
default: markerEnabled,
|
|
description: t(
|
|
'Draw a marker on data points. Only applicable for line types.',
|
|
),
|
|
},
|
|
},
|
|
],
|
|
[
|
|
{
|
|
name: 'markerSize',
|
|
config: {
|
|
type: 'SliderControl',
|
|
label: t('Marker Size'),
|
|
renderTrigger: true,
|
|
min: 0,
|
|
max: 100,
|
|
default: markerSize,
|
|
description: t(
|
|
'Size of marker. Also applies to forecast observations.',
|
|
),
|
|
visibility: ({ controls }: ControlPanelsContainerProps) =>
|
|
Boolean(controls?.markerEnabled?.value),
|
|
},
|
|
},
|
|
],
|
|
[ZoomableControl()],
|
|
[minorTicks],
|
|
...legendSection,
|
|
[<ControlSubSectionHeader>{t('X Axis')}</ControlSubSectionHeader>],
|
|
|
|
[
|
|
{
|
|
name: 'x_axis_time_format',
|
|
config: {
|
|
...sharedControls.x_axis_time_format,
|
|
default: 'smart_date',
|
|
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
|
|
},
|
|
},
|
|
],
|
|
[xAxisLabelRotation],
|
|
[xAxisLabelInterval],
|
|
// eslint-disable-next-line react/jsx-key
|
|
...richTooltipSection,
|
|
// eslint-disable-next-line react/jsx-key
|
|
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
|
|
[YAxisFormatControl()],
|
|
[CurrencyFormatControl()],
|
|
[
|
|
{
|
|
name: 'logAxis',
|
|
config: {
|
|
type: 'CheckboxControl',
|
|
label: t('Logarithmic y-axis'),
|
|
renderTrigger: true,
|
|
default: logAxis,
|
|
description: t('Logarithmic y-axis'),
|
|
},
|
|
},
|
|
],
|
|
[
|
|
{
|
|
name: 'minorSplitLine',
|
|
config: {
|
|
type: 'CheckboxControl',
|
|
label: t('Minor Split Line'),
|
|
renderTrigger: true,
|
|
default: minorSplitLine,
|
|
description: t('Draw split lines for minor y-axis ticks'),
|
|
},
|
|
},
|
|
],
|
|
[truncateXAxis],
|
|
[xAxisBounds],
|
|
[
|
|
{
|
|
name: 'truncateYAxis',
|
|
config: {
|
|
type: 'CheckboxControl',
|
|
label: t('Truncate Y Axis'),
|
|
default: truncateYAxis,
|
|
renderTrigger: true,
|
|
description: t(
|
|
'Truncate Y Axis. Can be overridden by specifying a min or max bound.',
|
|
),
|
|
},
|
|
},
|
|
],
|
|
[
|
|
{
|
|
name: 'y_axis_bounds',
|
|
config: {
|
|
type: 'BoundsControl',
|
|
label: t('Y Axis Bounds'),
|
|
renderTrigger: true,
|
|
default: yAxisBounds,
|
|
description: t(
|
|
'Bounds for the Y-axis. When left empty, the bounds are ' +
|
|
'dynamically defined based on the min/max of the data. Note that ' +
|
|
"this feature will only expand the axis range. It won't " +
|
|
"narrow the data's extent.",
|
|
),
|
|
visibility: ({ controls }: ControlPanelsContainerProps) =>
|
|
Boolean(controls?.truncateYAxis?.value),
|
|
},
|
|
},
|
|
],
|
|
],
|
|
},
|
|
],
|
|
controlOverrides: {
|
|
row_limit: {
|
|
default: rowLimit,
|
|
},
|
|
},
|
|
formDataOverrides: formData => ({
|
|
...formData,
|
|
metrics: getStandardizedControls().popAllMetrics(),
|
|
groupby: getStandardizedControls().popAllColumns(),
|
|
}),
|
|
};
|
|
|
|
export default config;
|