Skip to content

Commit

Permalink
set default value for percentile and deletes percentile value when pe…
Browse files Browse the repository at this point in the history
…rcentile is deselected
  • Loading branch information
MGJamJam committed Jul 24, 2024
1 parent 4cedeb6 commit 82762c2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,19 @@ export function QueryEditor(props: Props) {
};

const handleAggregationChange = (item: SelectableValue) => {
props.onChange({ ...query, metric: item.value });
// set a default value when percentile is selected and delete percentileValue when percentile is deselected
// to not pollute the dashboard.json file
let percentile = undefined;
if (item.value === 'percentile' && percentileValue == null) {
setPercentileValue(95);
percentile = 95;
} else {
if (percentileValue != null) {
setPercentileValue(undefined);
}
}

props.onChange({ ...query, metric: item.value, percentileValue: percentile });
props.onRunQuery();
};

Expand Down

0 comments on commit 82762c2

Please sign in to comment.