Skip to content

Commit

Permalink
Remove ANY option for interpolated property quality (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwysiu authored Jul 22, 2024
1 parent be97a5f commit 4a3bdbe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
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 @@ -43,6 +43,8 @@ const qualities: Array<SelectableValue<SiteWiseQuality>> = [
{ value: SiteWiseQuality.UNCERTAIN, label: 'UNCERTAIN' },
];

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

const ordering: Array<SelectableValue<SiteWiseTimeOrder>> = [
{ value: SiteWiseTimeOrder.ASCENDING, label: 'ASCENDING' },
{ value: SiteWiseTimeOrder.DESCENDING, label: 'DESCENDING' },
Expand Down Expand Up @@ -104,14 +106,16 @@ export class QualityAndOrderRow extends PureComponent<Props> {

render() {
const { query } = this.props;
const currQualities =
query.queryType === QueryType.PropertyInterpolated ? interpolatedPropertyQualities : qualities;
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

0 comments on commit 4a3bdbe

Please sign in to comment.