Skip to content

Add run_id_pattern search for Dag Run API. #52437

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

Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
40a8982
Add run_id filter for dag runs
noeunkim Jun 29, 2025
b5411bf
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jun 29, 2025
d0afa38
Update i18n support for run_id filter in Dag Runs page
noeunkim Jun 29, 2025
97ddb24
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jun 29, 2025
361e695
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jun 29, 2025
f164c25
Apply param dependency injection and update i18n key structure
noeunkim Jun 29, 2025
47eed2f
Apply _SearchParam to support pattern search
noeunkim Jul 1, 2025
d2e8c9a
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 1, 2025
6b75074
Rename run_id to run_id_pattern and refactor DagRuns ui to use SearchBar
noeunkim Jul 2, 2025
38dfe34
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 2, 2025
d39c3da
Resolve merge conflict
noeunkim Jul 2, 2025
e26b625
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 2, 2025
41e4b63
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 2, 2025
f63a60a
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 3, 2025
3a12950
Merge branch 'apache:main' into feature/issue-52363-add-run-id-filter…
noeunkim Jul 3, 2025
1ece0de
Improve test cases
noeunkim Jul 3, 2025
ebf43e8
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 3, 2025
e6720e9
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 3, 2025
29ca35c
Resolve test failure
noeunkim Jul 4, 2025
958416d
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 5, 2025
d22c187
Fix: resolve Advanced Search button visibility
noeunkim Jul 5, 2025
5462b2f
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 7, 2025
8c3ef85
Improve filter layout and variable consistency
noeunkim Jul 7, 2025
2a24ca2
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 7, 2025
f383fea
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 7, 2025
b1fd488
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 8, 2025
9ac90f3
Merge branch 'main' into feature/issue-52363-add-run-id-filter-to-ui-…
noeunkim Jul 8, 2025
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 @@ -2041,6 +2041,18 @@ paths:
type: string
default: id
title: Order By
- name: run_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: "SQL LIKE expression \u2014 use `%` / `_` wildcards (e.g. `%customer_%`).\
\ Regular expressions are **not** supported."
title: Run Id
description: "SQL LIKE expression \u2014 use `%` / `_` wildcards (e.g. `%customer_%`).\
\ Regular expressions are **not** supported."
responses:
'200':
description: Successful Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
Range,
RangeFilter,
SortParam,
_SearchParam,
datetime_range_filter_factory,
search_param_factory,
)
from airflow.api_fastapi.common.router import AirflowRouter
from airflow.api_fastapi.core_api.datamodels.assets import AssetEventCollectionResponse
Expand Down Expand Up @@ -334,6 +336,7 @@ def get_dag_runs(
readable_dag_runs_filter: ReadableDagRunsFilterDep,
session: SessionDep,
dag_bag: DagBagDep,
run_id_pattern: Annotated[_SearchParam, Depends(search_param_factory(DagRun.run_id, "run_id"))],
) -> DAGRunCollectionResponse:
"""
Get all DAG Runs.
Expand All @@ -360,6 +363,7 @@ def get_dag_runs(
state,
run_type,
readable_dag_runs_filter,
run_id_pattern,
],
order_by=order_by,
offset=offset,
Expand Down
5 changes: 3 additions & 2 deletions airflow-core/src/airflow/ui/openapi-gen/queries/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const UseDagRunServiceGetUpstreamAssetEventsKeyFn = ({ dagId, dagRunId }:
export type DagRunServiceGetDagRunsDefaultResponse = Awaited<ReturnType<typeof DagRunService.getDagRuns>>;
export type DagRunServiceGetDagRunsQueryResult<TData = DagRunServiceGetDagRunsDefaultResponse, TError = unknown> = UseQueryResult<TData, TError>;
export const useDagRunServiceGetDagRunsKey = "DagRunServiceGetDagRuns";
export const UseDagRunServiceGetDagRunsKeyFn = ({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
export const UseDagRunServiceGetDagRunsKeyFn = ({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
dagId: string;
endDateGte?: string;
endDateLte?: string;
Expand All @@ -151,13 +151,14 @@ export const UseDagRunServiceGetDagRunsKeyFn = ({ dagId, endDateGte, endDateLte,
orderBy?: string;
runAfterGte?: string;
runAfterLte?: string;
runId?: string;
runType?: string[];
startDateGte?: string;
startDateLte?: string;
state?: string[];
updatedAtGte?: string;
updatedAtLte?: string;
}, queryKey?: Array<unknown>) => [useDagRunServiceGetDagRunsKey, ...(queryKey ?? [{ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }])];
}, queryKey?: Array<unknown>) => [useDagRunServiceGetDagRunsKey, ...(queryKey ?? [{ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }])];
export type DagSourceServiceGetDagSourceDefaultResponse = Awaited<ReturnType<typeof DagSourceService.getDagSource>>;
export type DagSourceServiceGetDagSourceQueryResult<TData = DagSourceServiceGetDagSourceDefaultResponse, TError = unknown> = UseQueryResult<TData, TError>;
export const useDagSourceServiceGetDagSourceKey = "DagSourceServiceGetDagSource";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ export const ensureUseDagRunServiceGetUpstreamAssetEventsData = (queryClient: Qu
* @param data.runType
* @param data.state
* @param data.orderBy
* @param data.runId SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
* @returns DAGRunCollectionResponse Successful Response
* @throws ApiError
*/
export const ensureUseDagRunServiceGetDagRunsData = (queryClient: QueryClient, { dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
export const ensureUseDagRunServiceGetDagRunsData = (queryClient: QueryClient, { dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
dagId: string;
endDateGte?: string;
endDateLte?: string;
Expand All @@ -286,13 +287,14 @@ export const ensureUseDagRunServiceGetDagRunsData = (queryClient: QueryClient, {
orderBy?: string;
runAfterGte?: string;
runAfterLte?: string;
runId?: string;
runType?: string[];
startDateGte?: string;
startDateLte?: string;
state?: string[];
updatedAtGte?: string;
updatedAtLte?: string;
}) => queryClient.ensureQueryData({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) });
}) => queryClient.ensureQueryData({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) });
/**
* Get Dag Source
* Get source code using file token.
Expand Down
6 changes: 4 additions & 2 deletions airflow-core/src/airflow/ui/openapi-gen/queries/prefetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ export const prefetchUseDagRunServiceGetUpstreamAssetEvents = (queryClient: Quer
* @param data.runType
* @param data.state
* @param data.orderBy
* @param data.runId SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
* @returns DAGRunCollectionResponse Successful Response
* @throws ApiError
*/
export const prefetchUseDagRunServiceGetDagRuns = (queryClient: QueryClient, { dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
export const prefetchUseDagRunServiceGetDagRuns = (queryClient: QueryClient, { dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
dagId: string;
endDateGte?: string;
endDateLte?: string;
Expand All @@ -286,13 +287,14 @@ export const prefetchUseDagRunServiceGetDagRuns = (queryClient: QueryClient, { d
orderBy?: string;
runAfterGte?: string;
runAfterLte?: string;
runId?: string;
runType?: string[];
startDateGte?: string;
startDateLte?: string;
state?: string[];
updatedAtGte?: string;
updatedAtLte?: string;
}) => queryClient.prefetchQuery({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) });
}) => queryClient.prefetchQuery({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) });
/**
* Get Dag Source
* Get source code using file token.
Expand Down
6 changes: 4 additions & 2 deletions airflow-core/src/airflow/ui/openapi-gen/queries/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ export const useDagRunServiceGetUpstreamAssetEvents = <TData = Common.DagRunServ
* @param data.runType
* @param data.state
* @param data.orderBy
* @param data.runId SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
* @returns DAGRunCollectionResponse Successful Response
* @throws ApiError
*/
export const useDagRunServiceGetDagRuns = <TData = Common.DagRunServiceGetDagRunsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
export const useDagRunServiceGetDagRuns = <TData = Common.DagRunServiceGetDagRunsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
dagId: string;
endDateGte?: string;
endDateLte?: string;
Expand All @@ -286,13 +287,14 @@ export const useDagRunServiceGetDagRuns = <TData = Common.DagRunServiceGetDagRun
orderBy?: string;
runAfterGte?: string;
runAfterLte?: string;
runId?: string;
runType?: string[];
startDateGte?: string;
startDateLte?: string;
state?: string[];
updatedAtGte?: string;
updatedAtLte?: string;
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useQuery<TData, TError>({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }, queryKey), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) as TData, ...options });
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useQuery<TData, TError>({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }, queryKey), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) as TData, ...options });
/**
* Get Dag Source
* Get source code using file token.
Expand Down
6 changes: 4 additions & 2 deletions airflow-core/src/airflow/ui/openapi-gen/queries/suspense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ export const useDagRunServiceGetUpstreamAssetEventsSuspense = <TData = Common.Da
* @param data.runType
* @param data.state
* @param data.orderBy
* @param data.runId SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
* @returns DAGRunCollectionResponse Successful Response
* @throws ApiError
*/
export const useDagRunServiceGetDagRunsSuspense = <TData = Common.DagRunServiceGetDagRunsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
export const useDagRunServiceGetDagRunsSuspense = <TData = Common.DagRunServiceGetDagRunsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
dagId: string;
endDateGte?: string;
endDateLte?: string;
Expand All @@ -286,13 +287,14 @@ export const useDagRunServiceGetDagRunsSuspense = <TData = Common.DagRunServiceG
orderBy?: string;
runAfterGte?: string;
runAfterLte?: string;
runId?: string;
runType?: string[];
startDateGte?: string;
startDateLte?: string;
state?: string[];
updatedAtGte?: string;
updatedAtLte?: string;
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useSuspenseQuery<TData, TError>({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }, queryKey), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) as TData, ...options });
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useSuspenseQuery<TData, TError>({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }, queryKey), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runId, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) as TData, ...options });
/**
* Get Dag Source
* Get source code using file token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ export class DagRunService {
* @param data.runType
* @param data.state
* @param data.orderBy
* @param data.runId SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
* @returns DAGRunCollectionResponse Successful Response
* @throws ApiError
*/
Expand All @@ -1008,7 +1009,8 @@ export class DagRunService {
updated_at_lte: data.updatedAtLte,
run_type: data.runType,
state: data.state,
order_by: data.orderBy
order_by: data.orderBy,
run_id: data.runId
},
errors: {
401: 'Unauthorized',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,10 @@ export type GetDagRunsData = {
orderBy?: string;
runAfterGte?: string | null;
runAfterLte?: string | null;
/**
* SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
*/
runId?: string | null;
runType?: Array<(string)>;
startDateGte?: string | null;
startDateLte?: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"active": "Active",
"all": "All",
"paused": "Paused"
}
},
"runIdPatternFilter": "Add run_id filter"
},
"ownerLink": "Owner link for {{owner}}",
"runAndTaskActions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum SearchParamsKeys {
OFFSET = "offset",
PAUSED = "paused",
POOL = "pool",
RUN_ID_PATTERN = "run_id_pattern",
RUN_TYPE = "run_type",
SORT = "sort",
SOURCE = "log_source",
Expand Down
44 changes: 38 additions & 6 deletions airflow-core/src/airflow/ui/src/pages/DagRuns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Flex, HStack, Link, type SelectValueChangeDetails, Text } from "@chakra-ui/react";
import { Flex, HStack, Link, type SelectValueChangeDetails, Text, Box } from "@chakra-ui/react";
import type { ColumnDef } from "@tanstack/react-table";
import type { TFunction } from "i18next";
import { useCallback } from "react";
Expand All @@ -37,6 +37,7 @@ import { LimitedItemsList } from "src/components/LimitedItemsList";
import { MarkRunAsButton } from "src/components/MarkAs";
import RenderedJsonField from "src/components/RenderedJsonField";
import { RunTypeIcon } from "src/components/RunTypeIcon";
import { SearchBar } from "src/components/SearchBar";
import { StateBadge } from "src/components/StateBadge";
import Time from "src/components/Time";
import { Select } from "src/components/ui";
Expand All @@ -48,6 +49,7 @@ import { renderDuration, useAutoRefresh, isStatePending } from "src/utils";
type DagRunRow = { row: { original: DAGRunResponse } };
const {
END_DATE: END_DATE_PARAM,
RUN_ID_PATTERN: RUN_ID_PATTERN_PARAM,
RUN_TYPE: RUN_TYPE_PARAM,
START_DATE: START_DATE_PARAM,
STATE: STATE_PARAM,
Expand Down Expand Up @@ -157,8 +159,10 @@ export const DagRuns = () => {
const [sort] = sorting;
const orderBy = sort ? `${sort.desc ? "-" : ""}${sort.id}` : "-run_after";

const { pageIndex, pageSize } = pagination;
const filteredState = searchParams.get(STATE_PARAM);
const filteredType = searchParams.get(RUN_TYPE_PARAM);
const filteredRunIdPattern = searchParams.get(RUN_ID_PATTERN_PARAM);
const startDate = searchParams.get(START_DATE_PARAM);
const endDate = searchParams.get(END_DATE_PARAM);

Expand All @@ -170,15 +174,16 @@ export const DagRuns = () => {
dagId: dagId ?? "~",
endDateLte: endDate ?? undefined,
limit,
offset: pagination.pageIndex * pagination.pageSize,
offset: pageIndex * pageSize,
orderBy,
runId: filteredRunIdPattern ?? undefined,
runType: filteredType === null ? undefined : [filteredType],
startDateGte: startDate ?? undefined,
state: filteredState === null ? undefined : [filteredState],
},
undefined,
{
enabled: !isNaN(pagination.pageSize),
enabled: !isNaN(pageSize),
refetchInterval: (query) =>
query.state.data?.dag_runs.some((run) => isStatePending(run.state)) ? refetchInterval : false,
},
Expand Down Expand Up @@ -220,9 +225,25 @@ export const DagRuns = () => {
[pagination, searchParams, setSearchParams, setTableURLState, sorting],
);

const handleRunIdPatternChange = useCallback(
(value: string) => {
if (value === "") {
searchParams.delete(RUN_ID_PATTERN_PARAM);
} else {
searchParams.set(RUN_ID_PATTERN_PARAM, value);
}
setTableURLState({
pagination: { ...pagination, pageIndex: 0 },
sorting,
});
setSearchParams(searchParams);
},
[pagination, searchParams, setSearchParams, setTableURLState, sorting],
);

return (
<>
<Flex gap={1}>
<HStack paddingY="4px">
<Select.Root
collection={stateOptions}
maxW="200px"
Expand Down Expand Up @@ -254,13 +275,14 @@ export const DagRuns = () => {
))}
</Select.Content>
</Select.Root>

<Select.Root
collection={dagRunTypeOptions}
maxW="200px"
onValueChange={handleTypeChange}
value={[filteredType ?? "all"]}
>
<Select.Trigger colorPalette="blue" isActive={Boolean(filteredState)} minW="max-content">
<Select.Trigger colorPalette="blue" isActive={Boolean(filteredType)} minW="max-content">
<Select.ValueText width="auto">
{() =>
filteredType === null ? (
Expand Down Expand Up @@ -289,7 +311,17 @@ export const DagRuns = () => {
))}
</Select.Content>
</Select.Root>
</Flex>

<Box flex="1" maxW="200px">
<SearchBar
defaultValue={filteredRunIdPattern ?? ""}
hideAdvanced={true}
hotkeyDisabled={false}
onChange={handleRunIdPatternChange}
placeHolder={translate("dags:filters.runIdPatternFilter")}
/>
</Box>
</HStack>
<DataTable
columns={runColumns(translate, dagId)}
data={data?.dag_runs ?? []}
Expand Down
Loading