2023-06-21 19:26:15 -07:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
|
|
import { FieldOverrideEditorProps, SelectableValue } from '@grafana/data';
|
|
|
|
|
import { HorizontalGroup, RadioButtonGroup } from '@grafana/ui';
|
|
|
|
|
|
|
|
|
|
import { InputPrefix, NullsThresholdInput } from './NullsThresholdInput';
|
|
|
|
|
|
|
|
|
|
const DISCONNECT_OPTIONS: Array<SelectableValue<boolean | number>> = [
|
|
|
|
|
{
|
|
|
|
|
label: 'Never',
|
|
|
|
|
value: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Threshold',
|
|
|
|
|
value: 3600000, // 1h
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
type Props = FieldOverrideEditorProps<boolean | number, unknown>;
|
|
|
|
|
|
2023-07-13 19:28:58 -07:00
|
|
|
export const InsertNullsEditor = ({ value, onChange, item }: Props) => {
|
2023-06-21 19:26:15 -07:00
|
|
|
const isThreshold = typeof value === 'number';
|
|
|
|
|
DISCONNECT_OPTIONS[1].value = isThreshold ? value : 3600000; // 1h
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<HorizontalGroup>
|
|
|
|
|
<RadioButtonGroup value={value} options={DISCONNECT_OPTIONS} onChange={onChange} />
|
2023-07-13 19:28:58 -07:00
|
|
|
{isThreshold && (
|
|
|
|
|
<NullsThresholdInput
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
inputPrefix={InputPrefix.GreaterThan}
|
|
|
|
|
isTime={item.settings.isTime}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2023-06-21 19:26:15 -07:00
|
|
|
</HorizontalGroup>
|
|
|
|
|
);
|
|
|
|
|
};
|