mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: remove strict errors for cloud-monitoring (#40620)
This commit is contained in:
committed by
GitHub
parent
026006290b
commit
7f8a01aa7d
@@ -1,12 +1,12 @@
|
||||
import React, { FC } from 'react';
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
import { SELECT_WIDTH } from '../constants';
|
||||
import { CustomMetaData, MetricQuery } from '../types';
|
||||
import { CustomMetaData, MetricQuery, SLOQuery } from '../types';
|
||||
import { AlignmentFunction, AlignmentPeriod, AlignmentPeriodLabel, QueryEditorField, QueryEditorRow } from '.';
|
||||
import CloudMonitoringDatasource from '../datasource';
|
||||
|
||||
export interface Props {
|
||||
onChange: (query: MetricQuery) => void;
|
||||
onChange: (query: MetricQuery | SLOQuery) => void;
|
||||
query: MetricQuery;
|
||||
templateVariableOptions: Array<SelectableValue<string>>;
|
||||
customMetaData: CustomMetaData;
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
import React, { FC, useMemo } from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
import { Select } from '@grafana/ui';
|
||||
import { ALIGNMENT_PERIODS } from '../constants';
|
||||
import { BaseQuery } from '../types';
|
||||
import { MetricQuery, SLOQuery } from '../types';
|
||||
|
||||
export interface Props {
|
||||
onChange: (query: BaseQuery) => void;
|
||||
query: BaseQuery;
|
||||
export interface Props<TQuery> {
|
||||
onChange(query: TQuery): void;
|
||||
query: TQuery;
|
||||
templateVariableOptions: Array<SelectableValue<string>>;
|
||||
selectWidth?: number;
|
||||
}
|
||||
|
||||
export const AlignmentPeriod: FC<Props> = ({ templateVariableOptions, onChange, query, selectWidth }) => {
|
||||
export function AlignmentPeriod<TQuery extends MetricQuery | SLOQuery>({
|
||||
templateVariableOptions,
|
||||
onChange,
|
||||
query,
|
||||
selectWidth,
|
||||
}: Props<TQuery>) {
|
||||
const options = useMemo(
|
||||
() =>
|
||||
ALIGNMENT_PERIODS.map((ap) => ({
|
||||
@@ -42,4 +47,4 @@ export const AlignmentPeriod: FC<Props> = ({ templateVariableOptions, onChange,
|
||||
placeholder="Select Alignment"
|
||||
></Select>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
AlignmentTypes,
|
||||
CustomMetaData,
|
||||
ValueTypes,
|
||||
SLOQuery,
|
||||
} from '../types';
|
||||
import { getAlignmentPickerData } from '../functions';
|
||||
import CloudMonitoringDatasource from '../datasource';
|
||||
@@ -71,7 +72,7 @@ function Editor({
|
||||
}, [datasource, groupBys, metricType, projectName, refId]);
|
||||
|
||||
const onChange = useCallback(
|
||||
(metricQuery: MetricQuery) => {
|
||||
(metricQuery: MetricQuery | SLOQuery) => {
|
||||
onQueryChange({ ...query, ...metricQuery });
|
||||
onRunQuery();
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ export class QueryEditor extends PureComponent<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
onQueryChange(prop: string, value: any) {
|
||||
onQueryChange(prop: string, value: MetricQuery | SLOQuery) {
|
||||
this.props.onChange({ ...this.props.query, [prop]: value });
|
||||
this.props.onRunQuery();
|
||||
}
|
||||
|
||||
@@ -10,12 +10,25 @@ export interface Props {
|
||||
templateVariableOptions: Array<SelectableValue<string>>;
|
||||
}
|
||||
|
||||
function asQueryType(input: Array<SelectableValue<string>>) {
|
||||
const res: Array<SelectableValue<QueryType>> = [];
|
||||
input.forEach((v) => {
|
||||
if (v.value === QueryType.METRICS) {
|
||||
res.push({ ...v, value: QueryType.METRICS });
|
||||
}
|
||||
if (v.value === QueryType.SLO) {
|
||||
res.push({ ...v, value: QueryType.SLO });
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
export const QueryTypeSelector: FunctionComponent<Props> = ({ onChange, value, templateVariableOptions }) => {
|
||||
return (
|
||||
<div className="gf-form-inline">
|
||||
<label className="gf-form-label query-keyword width-9">Query Type</label>
|
||||
<Segment
|
||||
value={[...QUERY_TYPES, ...templateVariableOptions].find((qt) => qt.value === value)}
|
||||
value={[...QUERY_TYPES, ...asQueryType(templateVariableOptions)].find((qt) => qt.value === value)}
|
||||
options={[
|
||||
...QUERY_TYPES,
|
||||
{
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React from 'react';
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
import { Metrics, LabelFilter, GroupBy, Preprocessor, Alignment } from '.';
|
||||
import { MetricQuery, MetricDescriptor, CustomMetaData } from '../types';
|
||||
import { MetricQuery, MetricDescriptor, CustomMetaData, SLOQuery } from '../types';
|
||||
import CloudMonitoringDatasource from '../datasource';
|
||||
|
||||
export interface Props {
|
||||
customMetaData: CustomMetaData;
|
||||
variableOptionGroup: SelectableValue<string>;
|
||||
onMetricTypeChange: (query: MetricDescriptor) => void;
|
||||
onChange: (query: MetricQuery) => void;
|
||||
onChange: (query: MetricQuery | SLOQuery) => void;
|
||||
query: MetricQuery;
|
||||
datasource: CloudMonitoringDatasource;
|
||||
labels: any;
|
||||
|
||||
Reference in New Issue
Block a user