2019-01-17 02:27:43 -06:00
|
|
|
import React, { FC } from 'react';
|
2018-12-19 10:12:50 -06:00
|
|
|
|
2019-07-16 13:40:23 -05:00
|
|
|
import { SelectableValue } from '@grafana/data';
|
2020-01-17 05:25:47 -06:00
|
|
|
import { Segment } from '@grafana/ui';
|
2018-12-19 10:12:50 -06:00
|
|
|
|
|
|
|
export interface Props {
|
2020-03-02 08:31:09 -06:00
|
|
|
onChange: (perSeriesAligner: string) => void;
|
2020-01-17 05:25:47 -06:00
|
|
|
templateVariableOptions: Array<SelectableValue<string>>;
|
2019-07-16 13:40:23 -05:00
|
|
|
alignOptions: Array<SelectableValue<string>>;
|
2018-12-19 10:12:50 -06:00
|
|
|
perSeriesAligner: string;
|
|
|
|
}
|
|
|
|
|
2020-01-17 05:25:47 -06:00
|
|
|
export const Alignments: FC<Props> = ({ perSeriesAligner, templateVariableOptions, onChange, alignOptions }) => {
|
2018-12-20 04:26:05 -06:00
|
|
|
return (
|
2019-01-08 06:00:31 -06:00
|
|
|
<>
|
2020-01-17 05:25:47 -06:00
|
|
|
<div className="gf-form-inline">
|
2018-12-20 04:26:05 -06:00
|
|
|
<div className="gf-form offset-width-9">
|
|
|
|
<label className="gf-form-label query-keyword width-15">Aligner</label>
|
2020-01-17 05:25:47 -06:00
|
|
|
<Segment
|
2020-03-27 06:01:16 -05:00
|
|
|
onChange={({ value }) => onChange(value!)}
|
2021-01-20 00:59:48 -06:00
|
|
|
value={[...alignOptions, ...templateVariableOptions].find((s) => s.value === perSeriesAligner)}
|
2020-01-17 05:25:47 -06:00
|
|
|
options={[
|
|
|
|
{
|
|
|
|
label: 'Template Variables',
|
|
|
|
options: templateVariableOptions,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Alignment options',
|
|
|
|
expanded: true,
|
|
|
|
options: alignOptions,
|
|
|
|
},
|
|
|
|
]}
|
2018-12-20 04:26:05 -06:00
|
|
|
placeholder="Select Alignment"
|
2020-01-17 05:25:47 -06:00
|
|
|
></Segment>
|
2018-12-19 10:12:50 -06:00
|
|
|
</div>
|
2018-12-20 04:26:05 -06:00
|
|
|
</div>
|
2019-01-08 06:00:31 -06:00
|
|
|
</>
|
2018-12-20 04:26:05 -06:00
|
|
|
);
|
|
|
|
};
|