2024-06-25 06:43:47 -05:00
|
|
|
import { useCallback } from 'react';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2023-12-07 05:03:18 -06:00
|
|
|
import { StandardEditorProps, SelectableValue } from '@grafana/data';
|
2024-02-06 10:20:42 -06:00
|
|
|
import { GraphThresholdsStyleMode } from '@grafana/schema';
|
2021-08-24 10:22:34 -05:00
|
|
|
import { Select } from '@grafana/ui';
|
2021-06-21 01:51:39 -05:00
|
|
|
|
2023-12-07 05:03:18 -06:00
|
|
|
type Props = StandardEditorProps<
|
2024-02-06 10:20:42 -06:00
|
|
|
SelectableValue<{ mode: GraphThresholdsStyleMode }>,
|
|
|
|
{ options: Array<SelectableValue<GraphThresholdsStyleMode>> }
|
2023-12-07 05:03:18 -06:00
|
|
|
>;
|
2023-02-06 15:53:56 -06:00
|
|
|
|
|
|
|
export const ThresholdsStyleEditor = ({ item, value, onChange, id }: Props) => {
|
2021-06-21 01:51:39 -05:00
|
|
|
const onChangeCb = useCallback(
|
2024-02-06 10:20:42 -06:00
|
|
|
(v: SelectableValue<GraphThresholdsStyleMode>) => {
|
2021-06-21 01:51:39 -05:00
|
|
|
onChange({
|
|
|
|
mode: v.value,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
[onChange]
|
|
|
|
);
|
2023-12-07 05:03:18 -06:00
|
|
|
return <Select inputId={id} value={value.mode} options={item.settings?.options ?? []} onChange={onChangeCb} />;
|
2021-06-21 01:51:39 -05:00
|
|
|
};
|