fix(explore): dnd error when dragging metric if multi: false (#16088)

* fix(explore): dnd error when dragging metric if multi: false

* Fix error for non-dnd controls
This commit is contained in:
Kamil Gabryjelski
2021-08-09 18:15:50 +02:00
committed by GitHub
parent 578a9e9d53
commit b7cc89c6d4
5 changed files with 20 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ const propTypes = {
onDropLabel: PropTypes.func,
index: PropTypes.number,
type: PropTypes.string,
multi: PropTypes.bool,
};
class AdhocMetricOption extends React.PureComponent {
@@ -62,6 +63,7 @@ class AdhocMetricOption extends React.PureComponent {
onDropLabel,
index,
type,
multi,
} = this.props;
return (
@@ -84,6 +86,7 @@ class AdhocMetricOption extends React.PureComponent {
type={type ?? DndItemType.AdhocMetricOption}
withCaret
isFunction
multi={multi}
/>
</AdhocMetricPopoverTrigger>
);

View File

@@ -49,6 +49,7 @@ export default function MetricDefinitionValue({
onDropLabel,
index,
type,
multi,
}) {
const getSavedMetricByName = metricName =>
savedMetrics.find(metric => metric.metric_name === metricName);
@@ -76,6 +77,7 @@ export default function MetricDefinitionValue({
index,
savedMetric: savedMetric ?? {},
type,
multi,
};
return <AdhocMetricOption {...metricOptionProps} />;

View File

@@ -154,6 +154,7 @@ class MetricsControl extends React.PureComponent {
datasourceType={this.props.datasourceType}
onMoveLabel={this.moveLabel}
onDropLabel={() => this.props.onChange(this.state.value)}
multi={this.props.multi}
/>
);
this.select = null;