mirror of https://github.com/apache/superset.git
fix(explore): add current savedMetric to dropdown (#12835)
This commit is contained in:
parent
9c5ec3d72a
commit
61e56b5027
|
@ -63,11 +63,16 @@ const defaultProps = {
|
||||||
columns: [],
|
columns: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
function getOptionsForSavedMetrics(savedMetrics, currentMetricValues) {
|
function getOptionsForSavedMetrics(
|
||||||
|
savedMetrics,
|
||||||
|
currentMetricValues,
|
||||||
|
currentMetric,
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
savedMetrics?.filter(savedMetric =>
|
savedMetrics?.filter(savedMetric =>
|
||||||
Array.isArray(currentMetricValues)
|
Array.isArray(currentMetricValues)
|
||||||
? !currentMetricValues.includes(savedMetric.metric_name)
|
? !currentMetricValues.includes(savedMetric.metric_name) ||
|
||||||
|
savedMetric.metric_name === currentMetric
|
||||||
: savedMetric,
|
: savedMetric,
|
||||||
) ?? []
|
) ?? []
|
||||||
);
|
);
|
||||||
|
@ -143,6 +148,7 @@ class MetricsControl extends React.PureComponent {
|
||||||
savedMetricsOptions={getOptionsForSavedMetrics(
|
savedMetricsOptions={getOptionsForSavedMetrics(
|
||||||
this.props.savedMetrics,
|
this.props.savedMetrics,
|
||||||
this.props.value,
|
this.props.value,
|
||||||
|
this.props.value?.[index],
|
||||||
)}
|
)}
|
||||||
datasourceType={this.props.datasourceType}
|
datasourceType={this.props.datasourceType}
|
||||||
onMoveLabel={this.moveLabel}
|
onMoveLabel={this.moveLabel}
|
||||||
|
@ -284,6 +290,7 @@ class MetricsControl extends React.PureComponent {
|
||||||
savedMetricsOptions={getOptionsForSavedMetrics(
|
savedMetricsOptions={getOptionsForSavedMetrics(
|
||||||
this.props.savedMetrics,
|
this.props.savedMetrics,
|
||||||
this.props.value,
|
this.props.value,
|
||||||
|
null,
|
||||||
)}
|
)}
|
||||||
savedMetric={{}}
|
savedMetric={{}}
|
||||||
datasourceType={this.props.datasourceType}
|
datasourceType={this.props.datasourceType}
|
||||||
|
|
Loading…
Reference in New Issue