Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default value for percentileValue #95

Merged
merged 5 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Development

### Added
- Default Percentile Value when percentile metric is selected

## 1.1.1

### Added
Expand Down
14 changes: 13 additions & 1 deletion src/components/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

type Props = QueryEditorProps<
DataSource,
BitmovinAnalyticsDataQuery | OldBitmovinAnalyticsDataQuery,

Check warning on line 34 in src/components/QueryEditor.tsx

View workflow job for this annotation

GitHub Actions / build

'OldBitmovinAnalyticsDataQuery' is deprecated. These are the options query options of the old Angular based plugin
BitmovinDataSourceOptions
>;

Expand Down Expand Up @@ -69,7 +69,19 @@
};

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);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not simple else , why is there another if ?

Suggested change
} else {
if (percentileValue != null) {
setPercentileValue(undefined);
}
}
} else {
setPercentileValue(undefined);
}

Copy link
Contributor Author

@MGJamJam MGJamJam Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that if the percentileValue is already null we do not need to update the state because it already would be null/undefined. 🤔 But I guess it would make the code more readable to delete the if as it is really not necessary.


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

Expand Down
Loading