= {};
- for (const frame of input) {
- if (frame.refId) {
- let v = byName[frame.refId];
- if (!v) {
- v = byName[frame.refId] = {
- refId: frame.refId,
- count: 0,
- };
- allNames.push(v);
- }
- v.count++;
- }
- }
-
- if (configuredOptions.length) {
- const options: RefIdInfo[] = [];
- const selected: RefIdInfo[] = [];
- for (const v of allNames) {
- if (configuredOptions.includes(v.refId)) {
- selected.push(v);
- }
- options.push(v);
- }
-
- this.setState({
- options,
- selected: selected.map((s) => s.refId),
- });
- } else {
- this.setState({ options: allNames, selected: [] });
- }
- }
-
- onFieldToggle = (fieldName: string) => {
- const { selected } = this.state;
- if (selected.indexOf(fieldName) > -1) {
- this.onChange(selected.filter((s) => s !== fieldName));
- } else {
- this.onChange([...selected, fieldName]);
- }
- };
-
- onChange = (selected: string[]) => {
- this.setState({ selected });
- this.props.onChange({
- ...this.props.options,
- include: selected.join('|'),
- });
- };
-
- render() {
- const { options, selected } = this.state;
- const { input } = this.props;
- return (
- <>
- {input.length <= 1 && (
-
- Filter data by query expects multiple queries in the input.
-
- )}
-
-
- {options.map((o, i) => {
- const label = `${o.refId}${o.count > 1 ? ' (' + o.count + ')' : ''}`;
- const isSelected = selected.indexOf(o.refId) > -1;
- return (
- {
- this.onFieldToggle(o.refId);
- }}
- label={label}
- selected={isSelected}
- />
- );
- })}
-
-
- >
- );
- }
-}
+export const FilterByRefIdTransformerEditor = (props: TransformerUIProps) => {
+ return (
+ {
+ props.onChange({
+ ...props.options,
+ include: value?.options || '',
+ });
+ }}
+ context={{ data: props.input }}
+ />
+ );
+};
export const filterFramesByRefIdTransformRegistryItem: TransformerRegistryItem =
{