Skip to content

Commit

Permalink
[Snapshot & Restore] Added incremental search back to snapshots list …
Browse files Browse the repository at this point in the history
…and a debounce of 500ms
  • Loading branch information
yuliacech committed Oct 14, 2021
1 parent cfd5f04 commit 61d21d4
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import React, { useState } from 'react';
import useDebounce from 'react-use/lib/useDebounce';

import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -56,6 +57,15 @@ export const SnapshotSearchBar: React.FunctionComponent<Props> = ({
onSnapshotDeleted,
repositories,
}) => {
const [debouncedValue, setDebouncedValue] = useState<SnapshotListParams>(listParams);
useDebounce(
() => {
setListParams(debouncedValue);
},
500,
[debouncedValue]
);

const deleteButton = selectedItems.length ? (
<SnapshotDeleteProvider>
{(
Expand Down Expand Up @@ -126,7 +136,7 @@ export const SnapshotSearchBar: React.FunctionComponent<Props> = ({
if (changedQuery.ast.clauses.length > 1) {
setError({ name: onlyOneClauseMessage, message: onlyOneClauseMessage });
} else {
setListParams(getListParams(listParams, changedQuery));
setDebouncedValue(getListParams(listParams, changedQuery));
}
}
};
Expand All @@ -139,7 +149,7 @@ export const SnapshotSearchBar: React.FunctionComponent<Props> = ({
onChange={onSearchBarChange}
toolsLeft={deleteButton}
toolsRight={reloadButton}
box={{ schema: searchSchema }}
box={{ schema: searchSchema, incremental: true }}
/>
<EuiSpacer />
{error ? (
Expand Down

0 comments on commit 61d21d4

Please sign in to comment.