Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reusability of QueryInput and StreamsFilter. #20723

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
});

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

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

Expand All @@ -186,7 +189,7 @@
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 Expand Up @@ -225,25 +228,25 @@
};

type Props = BaseProps & {
commands?: Array<Command>,

Check warning on line 231 in graylog2-web-interface/src/views/components/searchbar/queryinput/QueryInput.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "commands" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
completerFactory?: (
completers: Array<Completer>,
timeRange: TimeRange | NoTimeRangeOverride | undefined,
streams: Array<string>,
fieldTypes: FieldTypes,
userTimezone: string,
view: View | undefined,
) => AutoCompleter,

Check warning on line 239 in graylog2-web-interface/src/views/components/searchbar/queryinput/QueryInput.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "completerFactory" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
disableExecution?: boolean,

Check warning on line 240 in graylog2-web-interface/src/views/components/searchbar/queryinput/QueryInput.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "disableExecution" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
isValidating?: boolean,

Check warning on line 241 in graylog2-web-interface/src/views/components/searchbar/queryinput/QueryInput.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "isValidating" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
name: string,
onBlur?: (query: string) => void,

Check warning on line 243 in graylog2-web-interface/src/views/components/searchbar/queryinput/QueryInput.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "onBlur" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
onChange: (changeEvent: { target: { value: string, name: string } }) => Promise<string>,
onExecute: (query: string) => void,
streams?: Array<string> | undefined,

Check warning on line 246 in graylog2-web-interface/src/views/components/searchbar/queryinput/QueryInput.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "streams" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
timeRange?: TimeRange | NoTimeRangeOverride | undefined,

Check warning on line 247 in graylog2-web-interface/src/views/components/searchbar/queryinput/QueryInput.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "timeRange" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
validate: () => Promise<FormikErrors<{}>>,
view?: View

Check warning on line 249 in graylog2-web-interface/src/views/components/searchbar/queryinput/QueryInput.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

propType "view" is not required, but has no corresponding defaultProps declaration.

No further rule information available.
};

const QueryInput = React.forwardRef<Editor, Props>(({
Expand Down
Loading