pierrejeambrun commented on code in PR #50732:
URL: https://github.com/apache/airflow/pull/50732#discussion_r2123960094
##########
airflow-core/src/airflow/ui/openapi-gen/queries/customInfiniteQueries.ts:
##########
Review Comment:
I think we should rename that file `customInfiniteQueries.ts`. Maybe
`useDagsInfinite`
##########
airflow-core/src/airflow/ui/openapi-gen/queries/customInfiniteQueries.ts:
##########
@@ -0,0 +1,38 @@
+import { InfiniteData, useInfiniteQuery, UseInfiniteQueryOptions } from
"@tanstack/react-query";
+
+import { DagService } from "openapi/requests/services.gen";
+
+import * as Common from "./common";
+
+export const useDagServiceGetDagTagsInfinite = <
+ TData = InfiniteData<Common.DagServiceGetDagTagsDefaultResponse>,
+ TError = unknown,
+ TQueryKey extends Array<unknown> = unknown[],
+>(
+ {
+ limit,
+ orderBy,
+ tagNamePattern,
+ }: {
+ limit?: number;
+ orderBy?: string;
+ tagNamePattern?: string;
+ } = {},
+ queryKey?: TQueryKey,
+ options?: Omit<UseInfiniteQueryOptions<TData, TError>, "queryKey" |
"queryFn">,
+) =>
+ useInfiniteQuery({
+ queryKey: Common.UseDagServiceGetDagTagsKeyFn({ limit, orderBy,
tagNamePattern }, queryKey),
+ queryFn: ({ pageParam }) =>
+ DagService.getDagTags({ limit, offset: pageParam as number, orderBy,
tagNamePattern }) as TData,
+ initialPageParam: 0,
+ getNextPageParam: (lastPage, _allPages, lastPageParam, _allPageParams) =>
+ (lastPageParam as number) < (lastPage as
Common.DagServiceGetDagTagsDefaultResponse).total_entries
+ ? (lastPage as Common.DagServiceGetDagTagsDefaultResponse).tags.length
+ (lastPageParam as number)
+ : undefined,
+ getPreviousPageParam: (firstPage, _allPages, firstPageParam,
_allPageParams) =>
+ (firstPageParam as number) > 0
+ ? -(firstPage as
Common.DagServiceGetDagTagsDefaultResponse).tags.length + (firstPageParam as
number)
+ : undefined,
Review Comment:
There is too much hard casting here. We should try to remove as many `as` as
possible.
##########
airflow-core/src/airflow/ui/src/pages/DagsList/DagsFilters/DagsFilters.tsx:
##########
@@ -166,11 +171,18 @@ export const DagsFilters = () => {
showPaused={showPaused}
/>
<TagFilter
+ onMenuScrollToBottom={() => {
+ void fetchNextPage();
+ }}
Review Comment:
```suggestion
onMenuScrollToBottom={async () => {
await fetchNextPage();
}}
```
##########
airflow-core/src/airflow/ui/openapi-gen/queries/customInfiniteQueries.ts:
##########
@@ -0,0 +1,38 @@
+import { InfiniteData, useInfiniteQuery, UseInfiniteQueryOptions } from
"@tanstack/react-query";
+
+import { DagService } from "openapi/requests/services.gen";
+
+import * as Common from "./common";
+
+export const useDagServiceGetDagTagsInfinite = <
+ TData = InfiniteData<Common.DagServiceGetDagTagsDefaultResponse>,
+ TError = unknown,
+ TQueryKey extends Array<unknown> = unknown[],
+>(
+ {
+ limit,
+ orderBy,
+ tagNamePattern,
+ }: {
+ limit?: number;
+ orderBy?: string;
+ tagNamePattern?: string;
+ } = {},
+ queryKey?: TQueryKey,
+ options?: Omit<UseInfiniteQueryOptions<TData, TError>, "queryKey" |
"queryFn">,
+) =>
+ useInfiniteQuery({
+ queryKey: Common.UseDagServiceGetDagTagsKeyFn({ limit, orderBy,
tagNamePattern }, queryKey),
+ queryFn: ({ pageParam }) =>
+ DagService.getDagTags({ limit, offset: pageParam as number, orderBy,
tagNamePattern }) as TData,
+ initialPageParam: 0,
+ getNextPageParam: (lastPage, _allPages, lastPageParam, _allPageParams) =>
+ (lastPageParam as number) < (lastPage as
Common.DagServiceGetDagTagsDefaultResponse).total_entries
+ ? (lastPage as Common.DagServiceGetDagTagsDefaultResponse).tags.length
+ (lastPageParam as number)
+ : undefined,
+ getPreviousPageParam: (firstPage, _allPages, firstPageParam,
_allPageParams) =>
+ (firstPageParam as number) > 0
+ ? -(firstPage as
Common.DagServiceGetDagTagsDefaultResponse).tags.length + (firstPageParam as
number)
+ : undefined,
Review Comment:
I think it means handling the `undefined` cases
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]