Skip to content

Commit

Permalink
Remove unused fields from Get property value query editor (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwysiu authored Jul 30, 2024
1 parent 4a3bdbe commit 3849be1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
7 changes: 0 additions & 7 deletions src/components/query/QueryEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,8 @@ describe('QueryEditor', () => {
expect(screen.getByText('Property Alias')).toBeInTheDocument();
expect(screen.getByText('Asset')).toBeInTheDocument();
expect(screen.getByText('Property')).toBeInTheDocument();
expect(screen.getByText('Quality')).toBeInTheDocument();
expect(screen.getByText('Format L4E Anomaly Result')).toBeInTheDocument();
expect(screen.getByText('Client cache')).toBeInTheDocument();
expect(screen.getByText('Time')).toBeInTheDocument();
expect(screen.getByText('Format')).toBeInTheDocument();
});
});

Expand All @@ -174,10 +171,6 @@ describe('QueryEditor', () => {
});
await waitFor(() => {
expect(screen.getByText('Property Alias')).toBeInTheDocument();
// temporary condition - in the old form version, the following fields are not displayed, but they should be in the new one
expect(screen.getByText('Quality')).toBeInTheDocument();
expect(screen.getByText('Time')).toBeInTheDocument();
expect(screen.getByText('Format')).toBeInTheDocument();
});
});

Expand Down
7 changes: 5 additions & 2 deletions src/components/query/QueryOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SitewiseQuery, shouldShowL4eOptions, shouldShowLastObserved } from 'types';
import { SitewiseQuery, shouldShowL4eOptions, shouldShowLastObserved, shouldShowQualityAndOrderComponent } from 'types';
import { CollapsableSection, Switch, useTheme2 } from '@grafana/ui';
import React from 'react';
import { EditorField, EditorFieldGroup } from '@grafana/experimental';
Expand Down Expand Up @@ -55,7 +55,10 @@ export function QueryOptions({
<Switch value={query.flattenL4e} onChange={onFlattenL4eChange} />
</EditorField>
)}
{(showProp || query.propertyAlias) && showQuality && qualityAndOrderComponent}
{shouldShowQualityAndOrderComponent(query.queryType) &&
(showProp || query.propertyAlias) &&
showQuality &&
qualityAndOrderComponent}
</EditorFieldGroup>
</CollapsableSection>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export enum QueryType {
PropertyValueHistory = 'PropertyValueHistory',
PropertyAggregate = 'PropertyAggregate',
PropertyInterpolated = 'PropertyInterpolated',
ListTimeSeries = "ListTimeSeries"
ListTimeSeries = 'ListTimeSeries',
}

export enum SiteWiseQuality {
Expand Down Expand Up @@ -202,7 +202,7 @@ export interface ListTimeSeriesQuery extends SitewiseQuery {
queryType: QueryType.ListTimeSeries;
aliasPrefix?: string;
assetId?: string;
timeSeriesType?: "ASSOCIATED" | "DISASSOCIATED" | "ALL";
timeSeriesType?: 'ASSOCIATED' | 'DISASSOCIATED' | 'ALL';
}

export function isListTimeSeriesQuery(q?: SitewiseQuery): q is ListTimeSeriesQuery {
Expand Down Expand Up @@ -235,6 +235,10 @@ export function shouldShowL4eOptions(queryType?: QueryType): boolean {
return queryType === QueryType.PropertyValue || queryType === QueryType.PropertyValueHistory;
}

export function shouldShowQualityAndOrderComponent(queryType?: QueryType): boolean {
return queryType !== QueryType.PropertyValue;
}

// matches native sitewise API with capitals
export interface AssetPropertyInfo extends SelectableValue<string> {
Id: string;
Expand Down
6 changes: 0 additions & 6 deletions tests/queryEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ test.describe('Query Editor', () => {

await queryEditor.selectProperty('Total Average Power');

await queryEditor.openQueryOptions();

await expect(queryEditor.qualitySelect).toBeVisible();
await expect(queryEditor.timeSelect).toBeVisible();
await expect(queryEditor.formatSelect).toBeVisible();

await queryEditor.runQuery();

await expect(page.getByText('No data')).not.toBeVisible();
Expand Down

0 comments on commit 3849be1

Please sign in to comment.