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

Add debounce on search on ingestion listing page #9516

Merged
merged 2 commits into from
Dec 26, 2023
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 @@ -16,5 +16,6 @@ export const DEFAULT_MAX_RECENT_QUERIES = 9;
*/
export const MAX_ROWS_BEFORE_DEBOUNCE = 50;
export const HALF_SECOND_IN_MS = 500;
export const ONE_SECOND_IN_MS = 1000;

export const ADD_UNAUTHORIZED_MESSAGE = 'You are not authorized to add Queries to this entity.';
8 changes: 7 additions & 1 deletion datahub-web-react/src/app/ingest/secret/SecretsList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useState } from 'react';
import { Button, Empty, message, Modal, Pagination, Typography } from 'antd';
import { debounce } from 'lodash';
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
import * as QueryString from 'query-string';
import { useLocation } from 'react-router';
Expand All @@ -18,6 +19,7 @@ import { SearchBar } from '../../search/SearchBar';
import { useEntityRegistry } from '../../useEntityRegistry';
import { scrollToTop } from '../../shared/searchUtils';
import { addSecretToListSecretsCache, removeSecretFromListSecretsCache } from './cacheUtils';
import { ONE_SECOND_IN_MS } from '../../entity/shared/tabs/Dataset/Queries/utils/constants';

const DeleteButtonContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -84,6 +86,10 @@ export const SecretsList = () => {
setPage(newPage);
};

const debouncedSetQuery = debounce((newQuery: string | undefined) => {
setQuery(newQuery);
}, ONE_SECOND_IN_MS);

const onSubmit = (state: SecretBuilderState, resetBuilderState: () => void) => {
createSecretMutation({
variables: {
Expand Down Expand Up @@ -199,7 +205,7 @@ export const SecretsList = () => {
onSearch={() => null}
onQueryChange={(q) => {
setPage(1);
setQuery(q);
debouncedSetQuery(q);
}}
entityRegistry={entityRegistry}
hideRecommendations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PlusOutlined, RedoOutlined } from '@ant-design/icons';
import React, { useCallback, useEffect, useState } from 'react';
import { debounce } from 'lodash';
import * as QueryString from 'query-string';
import { useLocation } from 'react-router';
import { Button, message, Modal, Pagination, Select } from 'antd';
Expand Down Expand Up @@ -30,6 +31,7 @@ import {
INGESTION_CREATE_SOURCE_ID,
INGESTION_REFRESH_SOURCES_ID,
} from '../../onboarding/config/IngestionOnboardingConfig';
import { ONE_SECOND_IN_MS } from '../../entity/shared/tabs/Dataset/Queries/utils/constants';

const PLACEHOLDER_URN = 'placeholder-urn';

Expand Down Expand Up @@ -133,6 +135,10 @@ export const IngestionSourceList = () => {
setLastRefresh(new Date().getTime());
}, [refetch]);

const debouncedSetQuery = debounce((newQuery: string | undefined) => {
setQuery(newQuery);
}, ONE_SECOND_IN_MS);

function hasActiveExecution() {
return !!filteredSources.find((source) =>
source.executions?.executionRequests.find((request) => isExecutionRequestActive(request)),
Expand Down Expand Up @@ -401,7 +407,7 @@ export const IngestionSourceList = () => {
onSearch={() => null}
onQueryChange={(q) => {
setPage(1);
setQuery(q);
debouncedSetQuery(q);
}}
entityRegistry={entityRegistry}
hideRecommendations
Expand Down
Loading