grafana/public/app/plugins/panel/geomap/editor/FrameSelectionEditor.tsx
2023-04-10 17:02:20 -07:00

27 lines
738 B
TypeScript

import React, { useCallback } from 'react';
import { FrameMatcherID, MatcherConfig, StandardEditorProps } from '@grafana/data';
import { RefIDPicker } from '@grafana/ui/src/components/MatchersUI/FieldsByFrameRefIdMatcher';
type Props = StandardEditorProps<MatcherConfig>;
export const FrameSelectionEditor = ({ value, context, onChange }: Props) => {
const onFilterChange = useCallback(
(v: string) => {
onChange(
v?.length
? {
id: FrameMatcherID.byRefId,
options: v,
}
: undefined
);
},
[onChange]
);
return (
<RefIDPicker value={value?.options} onChange={onFilterChange} data={context.data} placeholder="Change filter" />
);
};