|
|
|
|
@ -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> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|