import React, { FunctionComponent } from 'react'; import { SelectableValue } from '@grafana/data'; import { Segment } from '@grafana/ui'; import { QueryType } from '../types'; import { QUERY_TYPES } from '../constants'; export interface Props { value: QueryType; onChange: (slo: QueryType) => void; templateVariableOptions: Array>; } function asQueryType(input: Array>) { const res: Array> = []; 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 = ({ onChange, value, templateVariableOptions }) => { return (
qt.value === value)} options={[ ...QUERY_TYPES, { label: 'Template Variables', options: templateVariableOptions, }, ]} onChange={({ value }: SelectableValue) => onChange(value!)} />
); };