mirror of
https://github.com/apache/superset.git
synced 2026-06-01 05:39:17 +00:00
feat(explore): default aggregate for string/numeric columns when creating metric (#15798)
* feat(explore): default aggregate for string/numeric columns when creating metric * Fix for editing items with the same label * Replace componentDidUpdate with getDerivedStateFromProps * Wrap changes in feature flag
This commit is contained in:
committed by
GitHub
parent
040b94119b
commit
5e1c469f42
@@ -43,6 +43,7 @@ export type AdhocMetricPopoverTriggerProps = {
|
||||
};
|
||||
|
||||
export type AdhocMetricPopoverTriggerState = {
|
||||
adhocMetric: AdhocMetric;
|
||||
popoverVisible: boolean;
|
||||
title: { label: string; hasCustomLabel: boolean };
|
||||
currentLabel: string;
|
||||
@@ -65,6 +66,7 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
||||
this.onChange = this.onChange.bind(this);
|
||||
|
||||
this.state = {
|
||||
adhocMetric: props.adhocMetric,
|
||||
popoverVisible: false,
|
||||
title: {
|
||||
label: props.adhocMetric.label,
|
||||
@@ -76,6 +78,26 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
||||
};
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(
|
||||
nextProps: AdhocMetricPopoverTriggerProps,
|
||||
prevState: AdhocMetricPopoverTriggerState,
|
||||
) {
|
||||
if (prevState.adhocMetric.optionName !== nextProps.adhocMetric.optionName) {
|
||||
return {
|
||||
adhocMetric: nextProps.adhocMetric,
|
||||
title: {
|
||||
label: nextProps.adhocMetric.label,
|
||||
hasCustomLabel: nextProps.adhocMetric.hasCustomLabel,
|
||||
},
|
||||
currentLabel: '',
|
||||
labelModified: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
adhocMetric: nextProps.adhocMetric,
|
||||
};
|
||||
}
|
||||
|
||||
onLabelChange(e: any) {
|
||||
const { verbose_name, metric_name } = this.props.savedMetric;
|
||||
const defaultMetricLabel = this.props.adhocMetric?.getDefaultLabel();
|
||||
|
||||
Reference in New Issue
Block a user