Skip to content

Commit

Permalink
Do not override MetricFindValue type
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Sep 23, 2021
1 parent 8d231af commit b24adea
Showing 3 changed files with 6 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/Component/QueryEditor.tsx
Original file line number Diff line number Diff line change
@@ -16,12 +16,12 @@ interface LastQuery {
}

export const QueryEditor: ComponentType<Props> = ({ datasource, onChange, onRunQuery, query }) => {
const [metric, setMetric] = React.useState<SelectableValue<string>>();
const [metric, setMetric] = React.useState<SelectableValue<string | number>>();
const [payload, setPayload] = React.useState(query.payload ?? '');

const [lastQuery, setLastQuery] = React.useState<LastQuery | null>(null);

const [metricOptions, setMetricOptions] = React.useState<Array<SelectableValue<string>>>([]);
const [metricOptions, setMetricOptions] = React.useState<Array<SelectableValue<string | number>>>([]);
const [isMetricOptionsLoading, setIsMetricOptionsLoading] = React.useState<boolean>(false);

const loadMetrics = React.useCallback(
@@ -69,9 +69,9 @@ export const QueryEditor: ComponentType<Props> = ({ datasource, onChange, onRunQ
return;
}

setLastQuery({ payload, metric: metric.value });
setLastQuery({ payload, metric: metric.value.toString() });

onChange({ ...query, payload, target: metric.value });
onChange({ ...query, payload, target: metric.value.toString() });

onRunQuery();
}, [payload, metric]);
2 changes: 1 addition & 1 deletion src/DataSource.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import {
DataQueryResponse,
DataSourceApi,
DataSourceInstanceSettings,
MetricFindValue,
toDataFrame,
} from '@grafana/data';
import { AnnotationQueryRequest } from '@grafana/data/types/datasource';
@@ -13,7 +14,6 @@ import {
GrafanaQuery,
MetricFindTagKeys,
MetricFindTagValues,
MetricFindValue,
MultiValueVariable,
QueryRequest,
TextValuePair,
7 changes: 1 addition & 6 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataQuery, DataQueryRequest, DataSourceJsonData, VariableModel } from '@grafana/data';
import { DataQuery, DataQueryRequest, DataSourceJsonData, MetricFindValue, VariableModel } from '@grafana/data';
import { TemplateSrv as GrafanaTemplateSrv } from '@grafana/runtime';

declare module '@grafana/runtime' {
@@ -26,11 +26,6 @@ export interface VariableQuery {
format: 'string' | 'json';
}

export interface MetricFindValue extends MetricFindValue {
value: any;
text: string;
}

export interface MetricFindTagKeys extends MetricFindValue {
key: string;
type: string;

0 comments on commit b24adea

Please sign in to comment.