Skip to content

Commit b55d097

Browse files
authored
[v3-1-test] Remove redundant debounce-promise dependency from UI (#61832) (#61938)
(cherry picked from commit 721b0ed) Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
1 parent 407ae0c commit b55d097

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

airflow-core/src/airflow/ui/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"chartjs-adapter-dayjs-4": "^1.0.4",
3838
"chartjs-plugin-annotation": "^3.1.0",
3939
"dayjs": "^1.11.13",
40-
"debounce-promise": "^3.1.2",
4140
"elkjs": "^0.10.0",
4241
"html-to-image": "^1.11.13",
4342
"i18next": "^25.1.2",

airflow-core/src/airflow/ui/pnpm-lock.yaml

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

airflow-core/src/airflow/ui/src/components/SearchDags/SearchDags.tsx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import { Field } from "@chakra-ui/react";
2020
import { useQueryClient } from "@tanstack/react-query";
2121
import { AsyncSelect } from "chakra-react-select";
2222
import type { OptionsOrGroups, GroupBase, SingleValue } from "chakra-react-select";
23-
import debounce from "debounce-promise";
2423
import React from "react";
2524
import { useTranslation } from "react-i18next";
2625
import { useNavigate } from "react-router-dom";
26+
import { useDebouncedCallback } from "use-debounce";
2727

2828
import { UseDagServiceGetDagsKeyFn } from "openapi/queries";
2929
import { DagService } from "openapi/requests/services.gen";
@@ -49,32 +49,31 @@ export const SearchDags = ({
4949
}
5050
};
5151

52-
const searchDag = (
53-
inputValue: string,
54-
callback: (options: OptionsOrGroups<Option, GroupBase<Option>>) => void,
55-
): Promise<OptionsOrGroups<Option, GroupBase<Option>>> =>
56-
queryClient.fetchQuery({
57-
queryFn: () =>
58-
DagService.getDags({
59-
dagDisplayNamePattern: inputValue,
60-
limit: SEARCH_LIMIT,
61-
}).then((data: DAGCollectionResponse) => {
62-
const options = data.dags.map((dag: DAGResponse) => ({
63-
label: dag.dag_display_name || dag.dag_id,
64-
value: dag.dag_id,
65-
}));
52+
const searchDagDebounced = useDebouncedCallback(
53+
(inputValue: string, callback: (options: OptionsOrGroups<Option, GroupBase<Option>>) => void) => {
54+
void queryClient.fetchQuery({
55+
queryFn: () =>
56+
DagService.getDags({
57+
dagDisplayNamePattern: inputValue,
58+
limit: SEARCH_LIMIT,
59+
}).then((data: DAGCollectionResponse) => {
60+
const options = data.dags.map((dag: DAGResponse) => ({
61+
label: dag.dag_display_name || dag.dag_id,
62+
value: dag.dag_id,
63+
}));
6664

67-
callback(options);
65+
callback(options);
6866

69-
return options;
67+
return options;
68+
}),
69+
queryKey: UseDagServiceGetDagsKeyFn({
70+
dagDisplayNamePattern: inputValue,
7071
}),
71-
queryKey: UseDagServiceGetDagsKeyFn({
72-
dagDisplayNamePattern: inputValue,
73-
}),
74-
staleTime: 0,
75-
});
76-
77-
const searchDagDebounced = debounce(searchDag, 300);
72+
staleTime: 0,
73+
});
74+
},
75+
300,
76+
);
7877

7978
return (
8079
<Field.Root>

0 commit comments

Comments
 (0)