shivaam commented on code in PR #70159: URL: https://github.com/apache/airflow/pull/70159#discussion_r3669457593
########## airflow-core/src/airflow/ui/src/pages/Dag/Backfills/BackfillDagRunsModal.tsx: ########## @@ -0,0 +1,192 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { Heading, Text } from "@chakra-ui/react"; +import type { ColumnDef } from "@tanstack/react-table"; +import { useState } from "react"; +import { useTranslation } from "react-i18next"; + +import { useBackfillServiceListBackfillDagRuns } from "openapi/queries"; +import type { BackfillDagRunResponse, BackfillResponse } from "openapi/requests/types.gen"; +import { DataTable } from "src/components/DataTable"; +import type { TableState } from "src/components/DataTable/types"; +import { ErrorAlert } from "src/components/ErrorAlert"; +import { StateBadge } from "src/components/StateBadge"; +import Time from "src/components/Time"; +import { Dialog, RouterLink } from "src/components/ui"; +import { useConfig } from "src/queries/useConfig"; +import { useAutoRefresh } from "src/utils"; + +type BackfillDagRunsModalProps = { + readonly backfill: BackfillResponse | undefined; + readonly onClose: () => void; + readonly open: boolean; +}; + +const translateExceptionReason = (reason: string, translate: (key: string) => string) => { + // Keep this mapping in sync with BackfillDagRunExceptionReason in airflow.models.backfill. + switch (reason) { + case "already exists": + return translate("components:backfill.exceptionReason.alreadyExists"); + case "in flight": + return translate("components:backfill.exceptionReason.inFlight"); + default: + return translate("components:backfill.exceptionReason.unknown"); + } +}; + +const getColumns = (translate: (key: string) => string): Array<ColumnDef<BackfillDagRunResponse>> => [ + { + accessorKey: "logical_date", + cell: ({ row }) => { + if (row.original.partition_key !== null && row.original.partition_key !== "") { + return <Text>{row.original.partition_key}</Text>; + } + + if (row.original.logical_date !== null && row.original.logical_date !== "") { + return ( + <Text> + <Time datetime={row.original.logical_date} /> + </Text> + ); + } + + return <Text color="fg.muted">—</Text>; + }, + enableSorting: false, + header: translate("slot"), + }, + { + accessorKey: "dag_run_state", + cell: ({ row }) => { + const state = row.original.dag_run_state; + + if (state === null || state === undefined) { + return <Text color="fg.muted">—</Text>; + } + + return <StateBadge state={state}>{translate(`states.${state}`)}</StateBadge>; + }, + enableSorting: false, + header: translate("dagRunState"), + }, + { + accessorKey: "exception_reason", + cell: ({ row }) => { + const reason = row.original.exception_reason; + + if (reason === null || reason === "") { + return <Text color="fg.muted">—</Text>; + } + + return <Text>{translateExceptionReason(reason, translate)}</Text>; + }, + enableSorting: false, + header: translate("components:backfill.notCreatedReason"), + }, + { + accessorKey: "dag_run_id", + cell: ({ row }) => { + const runId = row.original.dag_run_id; + + if (runId === null || runId === undefined || runId === "") { + return <Text color="fg.muted">—</Text>; + } + + return ( + <RouterLink fontWeight="bold" to={`/dags/${row.original.dag_id}/runs/${runId}`}> + {runId} + </RouterLink> + ); + }, + enableSorting: false, + header: translate("runId"), + }, + { + accessorKey: "sort_ordinal", + enableSorting: false, + header: "#", + }, +]; + +export const BackfillDagRunsModal = ({ backfill, onClose, open }: BackfillDagRunsModalProps) => { + const { t: translate } = useTranslation(); + const pageSize = (useConfig("fallback_page_limit") as number | undefined) ?? 100; + const [pageIndex, setPageIndex] = useState(0); + const tableState = { + pagination: { + pageIndex, + pageSize, + }, + sorting: [], + } satisfies TableState; + const refetchInterval = useAutoRefresh({ dagId: backfill?.dag_id }); + const shouldPoll = backfill?.completed_at === null && !backfill.is_paused; Review Comment: Addressed in 9a965b6a92. The modal now fetches the selected backfill by URL ID and polls its metadata while unfinished. The visible slot page also keeps polling until any stale queued or running rows reach a terminal state, then both queries stop; closing the modal disables them. ########## airflow-core/src/airflow/ui/public/i18n/locales/en/components.json: ########## @@ -7,9 +7,15 @@ "backwards": "Run Backwards", "dateRange": "Date Range", "errorStartDateBeforeEndDate": "Start Date must be before the End Date", + "exceptionReason": { + "alreadyExists": "Already exists", + "inFlight": "In flight", + "unknown": "Unknown" Review Comment: Updated. Known enum values remain translated (already exists, in flight, and unknown), while any unfamiliar backend value is displayed verbatim instead of being collapsed to Unknown. ########## airflow-core/src/airflow/ui/src/pages/Dag/Backfills/Backfills.tsx: ########## @@ -106,18 +117,18 @@ const getColumns = (translate: (key: string) => string): Array<ColumnDef<Backfil export const Backfills = () => { const { t: translate } = useTranslation(); const { setTableURLState, tableURLState } = useTableURLState(); + const [selectedBackfill, setSelectedBackfill] = useState<BackfillResponse>(); Review Comment: Implemented in 9a965b6a92. Opening a backfill now navigates to /dags/{dag_id}/backfills/{backfill_id}, which opens the cover dialog and supports direct links and browser navigation. The modal fetches that backfill directly, so deep links do not depend on the currently paginated Backfills row. -- 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]
