Skip to content

Commit

Permalink
add default value for percentileValue (#95)
Browse files Browse the repository at this point in the history
* set default value for percentile and deletes percentile value when percentile is deselected

* update changelog

* delete unnecessary if statement

* fmt
  • Loading branch information
MGJamJam authored Jul 25, 2024
1 parent 078153e commit 18b3cc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Development

### Added

- Default Percentile Value when percentile metric is selected

## 1.1.1

### Added
Expand Down
12 changes: 11 additions & 1 deletion src/components/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ 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 {
setPercentileValue(undefined);
}

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

Expand Down

0 comments on commit 18b3cc1

Please sign in to comment.