mirror of
https://github.com/apache/superset.git
synced 2026-05-31 13:19:23 +00:00
refactor(explore): convert ControlPanelsContainer to typescript (#13221)
This commit is contained in:
@@ -123,9 +123,6 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
|
||||
adhocMetricLabel: this.state.adhocMetric?.getDefaultLabel(),
|
||||
});
|
||||
}
|
||||
if (prevProps.datasource !== this.props.datasource) {
|
||||
this.props.onChange(null);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -60,7 +60,6 @@ class AdhocMetricOption extends React.PureComponent {
|
||||
onMoveLabel,
|
||||
onDropLabel,
|
||||
index,
|
||||
datasource,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@@ -70,7 +69,6 @@ class AdhocMetricOption extends React.PureComponent {
|
||||
columns={columns}
|
||||
savedMetricsOptions={savedMetricsOptions}
|
||||
savedMetric={savedMetric}
|
||||
datasource={datasource}
|
||||
datasourceType={datasourceType}
|
||||
>
|
||||
<OptionControlLabel
|
||||
|
||||
@@ -33,7 +33,6 @@ export type AdhocMetricPopoverTriggerProps = {
|
||||
savedMetricsOptions: savedMetricType[];
|
||||
savedMetric: savedMetricType;
|
||||
datasourceType: string;
|
||||
datasource: string;
|
||||
children: ReactNode;
|
||||
createNew?: boolean;
|
||||
};
|
||||
@@ -160,7 +159,6 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
||||
columns={this.props.columns}
|
||||
savedMetricsOptions={this.props.savedMetricsOptions}
|
||||
savedMetric={this.props.savedMetric}
|
||||
datasource={this.props.datasource}
|
||||
datasourceType={this.props.datasourceType}
|
||||
onResize={this.onPopoverResize}
|
||||
onClose={this.closePopover}
|
||||
|
||||
@@ -38,7 +38,6 @@ const propTypes = {
|
||||
savedMetricsOptions: PropTypes.arrayOf(savedMetricType),
|
||||
multi: PropTypes.bool,
|
||||
datasourceType: PropTypes.string,
|
||||
datasource: PropTypes.string,
|
||||
};
|
||||
|
||||
export default function MetricDefinitionValue({
|
||||
@@ -52,16 +51,15 @@ export default function MetricDefinitionValue({
|
||||
onMoveLabel,
|
||||
onDropLabel,
|
||||
index,
|
||||
datasource,
|
||||
}) {
|
||||
const getSavedMetricByName = metricName =>
|
||||
savedMetrics.find(metric => metric.metric_name === metricName);
|
||||
|
||||
let savedMetric;
|
||||
if (option.metric_name) {
|
||||
savedMetric = option;
|
||||
} else if (typeof option === 'string') {
|
||||
if (typeof option === 'string') {
|
||||
savedMetric = getSavedMetricByName(option);
|
||||
} else if (option.metric_name) {
|
||||
savedMetric = option;
|
||||
}
|
||||
|
||||
if (option instanceof AdhocMetric || savedMetric) {
|
||||
@@ -79,7 +77,6 @@ export default function MetricDefinitionValue({
|
||||
onDropLabel,
|
||||
index,
|
||||
savedMetric: savedMetric ?? {},
|
||||
datasource,
|
||||
};
|
||||
|
||||
return <AdhocMetricOption {...metricOptionProps} />;
|
||||
|
||||
@@ -179,10 +179,10 @@ class MetricsControl extends React.PureComponent {
|
||||
) {
|
||||
this.setState({ options: this.optionsForSelect(nextProps) });
|
||||
|
||||
// Remove metrics if selected value no longer a column
|
||||
const containsAllMetrics = columnsContainAllMetrics(value, nextProps);
|
||||
|
||||
if (!containsAllMetrics) {
|
||||
// Remove all metrics if selected value no longer a valid column
|
||||
// in the dataset. Must use `nextProps` here because Redux reducers may
|
||||
// have already updated the value for this control.
|
||||
if (!columnsContainAllMetrics(nextProps.value, nextProps)) {
|
||||
this.props.onChange([]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user