mirror of
https://github.com/grafana/grafana.git
synced 2025-09-28 06:14:07 +08:00
24 lines
553 B
TypeScript
24 lines
553 B
TypeScript
import React from 'react';
|
|
import { SelectableValue } from '@grafana/data';
|
|
import { Seg } from './Seg';
|
|
import { unwrap } from './unwrap';
|
|
|
|
type Props = {
|
|
loadOptions: () => Promise<SelectableValue[]>;
|
|
allowCustomValue?: boolean;
|
|
onAdd: (v: string) => void;
|
|
};
|
|
|
|
export const AddButton = ({ loadOptions, allowCustomValue, onAdd }: Props): JSX.Element => {
|
|
return (
|
|
<Seg
|
|
value="+"
|
|
loadOptions={loadOptions}
|
|
allowCustomValue={allowCustomValue}
|
|
onChange={(v) => {
|
|
onAdd(unwrap(v.value));
|
|
}}
|
|
/>
|
|
);
|
|
};
|