Skip to content

Commit

Permalink
Improve reusability of QueryInput and StreamsFilter. (#20723)
Browse files Browse the repository at this point in the history
  • Loading branch information
linuspahl authored Oct 22, 2024
1 parent 921b34f commit a38614f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ type Props = {
streams: Array<{ key: string, value: string }>,
onChange: (newStreamIds: Array<string>) => void,
multi?: boolean,
clearable?: boolean
};

const StreamsFilter = ({ disabled = false, value = [], streams, onChange, multi = true }: Props) => {
const StreamsFilter = ({
disabled = false, value = [], streams, onChange, multi = true,
clearable = true,
}: Props) => {
const sendTelemetry = useSendTelemetry();
const selectedStreams = value.join(',');
const placeholder = 'Select streams the search should include. Searches in all streams if empty.';
Expand All @@ -58,6 +62,7 @@ const StreamsFilter = ({ disabled = false, value = [], streams, onChange, multi
<Container data-testid="streams-filter" title={placeholder}>
<Select placeholder={placeholder}
disabled={disabled}
clearable={clearable}
inputProps={{ 'aria-label': placeholder }}
displayKey="key"
inputId="streams-filter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ const _updateEditorConfiguration = (node: { editor: Editor; }, completer: AutoCo
});

commands.forEach((command) => editor.commands.addCommand(command));
editor.completers = [completer];

if (completer) {
editor.completers = [completer];
}
}
};

Expand All @@ -186,7 +189,7 @@ const useCompleter = ({ streams, timeRange, completerFactory, view }: Pick<Props
return { all: allFieldsByName, query: queryFieldsByName };
}, [allFields, queryFields]);

return useMemo(() => completerFactory(completers ?? [], timeRange, streams, fieldTypes, userTimezone, view),
return useMemo(() => completerFactory?.(completers ?? [], timeRange, streams, fieldTypes, userTimezone, view),
[completerFactory, completers, timeRange, streams, fieldTypes, userTimezone, view]);
};

Expand Down

0 comments on commit a38614f

Please sign in to comment.