import { useMemo } from 'react'; import { SelectableValue } from '@grafana/data'; import { EditorField, EditorFieldGroup } from '@grafana/plugin-ui'; import { ALIGNMENT_PERIODS } from '../constants'; import CloudMonitoringDatasource from '../datasource'; import { alignmentPeriodLabel } from '../functions'; import { PreprocessorType, TimeSeriesList } from '../types/query'; import { CustomMetaData, MetricDescriptor } from '../types/types'; import { AlignmentFunction } from './AlignmentFunction'; import { PeriodSelect } from './PeriodSelect'; export interface Props { refId: string; onChange: (query: TimeSeriesList) => void; query: TimeSeriesList; templateVariableOptions: Array>; customMetaData: CustomMetaData; datasource: CloudMonitoringDatasource; metricDescriptor?: MetricDescriptor; preprocessor?: PreprocessorType; } export const Alignment = ({ refId, templateVariableOptions, onChange, query, customMetaData, datasource, metricDescriptor, preprocessor, }: Props) => { const alignmentLabel = useMemo(() => alignmentPeriodLabel(customMetaData, datasource), [customMetaData, datasource]); return ( onChange({ ...query, ...q })} metricDescriptor={metricDescriptor} preprocessor={preprocessor} /> onChange({ ...query, alignmentPeriod: period })} aligmentPeriods={ALIGNMENT_PERIODS} /> ); };