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

Remove ANY option for interpolated property quality #342

Merged
merged 3 commits into from
Jul 22, 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
2 changes: 1 addition & 1 deletion pkg/sitewise/api/property_interpolated.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func interpolatedQueryToInputs(query models.AssetPropertyValueQuery) []*iotsitew
endTimeInSeconds := to.Unix()

quality := query.Quality
if quality == "" {
if quality == "" || query.Quality == "ANY" {
quality = "GOOD"
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/query/QualityAndOrderRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,18 @@ export class QualityAndOrderRow extends PureComponent<Props> {

render() {
const { query } = this.props;
let currQualities = qualities;
if (query.queryType === QueryType.PropertyInterpolated) {
currQualities = qualities.slice(1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

add this to the top of the file underneath where const qualities is defined so it's only created once.

const interpolatedPropertyQualities: Array<SelectableValue<SiteWiseQuality>> = qualities.slice(1);

and change this here to

Suggested change
let currQualities = qualities;
if (query.queryType === QueryType.PropertyInterpolated) {
currQualities = qualities.slice(1);
}
const currQualities = query.queryType === QueryType.PropertyInterpolated ? interpolatedPropertyQualities : qualities;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return (
<>
<EditorField label="Quality" width={15} htmlFor="quality">
<Select
id="quality"
aria-label="Quality"
options={qualities}
value={qualities.find((v) => v.value === query.quality) ?? qualities[0]}
options={currQualities}
value={currQualities.find((v) => v.value === query.quality) ?? currQualities[0]}
onChange={this.onQualityChange}
isSearchable={true}
menuPlacement="auto"
Expand Down
4 changes: 4 additions & 0 deletions src/components/query/QueryEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ describe('QueryEditor', () => {
expect(screen.getByText('Quality')).toBeInTheDocument();
expect(screen.getByText('Resolution')).toBeInTheDocument();
expect(screen.getByText('Format')).toBeInTheDocument();

// Interpolated Property queries should not have ANY as the quality default
expect(screen.getByText('GOOD')).toBeInTheDocument();
expect(screen.queryByText('ANY')).not.toBeInTheDocument();
});
});

Expand Down
Loading