bbovenzi commented on code in PR #64878:
URL: https://github.com/apache/airflow/pull/64878#discussion_r3053747178
##########
airflow-core/src/airflow/ui/public/i18n/locales/en/dashboard.json:
##########
@@ -1,4 +1,9 @@
{
+ "deadlines": {
+ "deadlines": "Deadlines",
+ "pending": "Pending",
+ "recentlyMissed": "Recently Missed"
+ },
Review Comment:
We are reimplementing these translations a lot here and in your other PR.
Let's try to consolidate them as much as possible.
##########
airflow-core/src/airflow/ui/src/pages/Dashboard/Deadlines/Deadlines.tsx:
##########
@@ -0,0 +1,179 @@
+/*!
+ * 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 { Badge, Box, Flex, Heading, HStack, Link, Separator, Skeleton, Text,
VStack } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { useTranslation } from "react-i18next";
+import { FiAlertTriangle, FiClock } from "react-icons/fi";
+import { Link as RouterLink } from "react-router-dom";
+
+import { useDeadlinesServiceGetDeadlines } from "openapi/queries";
+import type { DeadlineResponse } from "openapi/requests/types.gen";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import Time from "src/components/Time";
+import { useAutoRefresh } from "src/utils";
+
+const LIMIT = 5;
+
+const DeadlineRow = ({ deadline }: { readonly deadline: DeadlineResponse }) =>
(
+ <HStack justifyContent="space-between" px={2} py={1.5} width="100%">
+ <VStack alignItems="flex-start" gap={0}>
+ <HStack>
+ <Link asChild color="fg.info" fontSize="sm" fontWeight="bold">
+ <RouterLink
to={`/dags/${deadline.dag_id}`}>{deadline.dag_id}</RouterLink>
+ </Link>
+ <Text color="fg.muted" fontSize="xs">
+ /
+ </Text>
+ <Link asChild color="fg.info" fontSize="sm">
+ <RouterLink
to={`/dags/${deadline.dag_id}/runs/${deadline.dag_run_id}`}>
+ {deadline.dag_run_id}
+ </RouterLink>
+ </Link>
+ </HStack>
+ {deadline.alert_name !== undefined && deadline.alert_name !== "" ? (
+ <Text color="fg.muted" fontSize="xs">
+ {deadline.alert_name}
+ </Text>
+ ) : undefined}
+ </VStack>
+ <Time datetime={deadline.deadline_time} fontSize="sm" />
+ </HStack>
+);
+
+export const Deadlines = () => {
+ const { t: translate } = useTranslation("dashboard");
+ const refetchInterval = useAutoRefresh({ checkPendingRuns: true });
+ const now = dayjs().toISOString();
Review Comment:
With the refetchInterval, we will calculate a new `now` and `last24h`
constantly.
It would be better to move this under the "History" section and use the
start and end date provided just like you did with the Overview page. But
again, we don't want to do any of this yet.
##########
airflow-core/src/airflow/ui/src/pages/Deadlines/index.tsx:
##########
@@ -0,0 +1,150 @@
+/*!
+ * 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 { Badge, Box, Heading, Link, VStack } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import type { TFunction } from "i18next";
+import { useTranslation } from "react-i18next";
+import { Link as RouterLink, useSearchParams } from "react-router-dom";
+
+import { useDeadlinesServiceGetDeadlines } from "openapi/queries";
+import type { DeadlineResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import { FilterBar } from "src/components/FilterBar";
+import Time from "src/components/Time";
+import { TruncatedText } from "src/components/TruncatedText";
+import { SearchParamsKeys } from "src/constants/searchParams";
+import { useFiltersHandler, type FilterableSearchParamsKeys } from "src/utils";
+
+type DeadlineRow = { row: { original: DeadlineResponse } };
+
+const createColumns = (translate: TFunction):
Array<ColumnDef<DeadlineResponse>> => [
+ {
+ accessorKey: "dag_id",
+ cell: ({ row: { original } }: DeadlineRow) => (
+ <Link asChild color="fg.info">
+ <RouterLink to={`/dags/${original.dag_id}`}>
+ <TruncatedText text={original.dag_id} />
+ </RouterLink>
+ </Link>
+ ),
+ header: translate("common:dagId"),
+ },
+ {
+ accessorKey: "dag_run_id",
+ cell: ({ row: { original } }: DeadlineRow) => (
+ <Link asChild color="fg.info">
+ <RouterLink
to={`/dags/${original.dag_id}/runs/${original.dag_run_id}`}>
+ <TruncatedText text={original.dag_run_id} />
+ </RouterLink>
+ </Link>
+ ),
+ enableSorting: false,
+ header: translate("common:dagRunId"),
+ },
+ {
+ accessorKey: "deadline_time",
+ cell: ({ row: { original } }: DeadlineRow) => <Time
datetime={original.deadline_time} />,
+ header: translate("browse:deadlines.columns.deadlineTime"),
+ },
+ {
+ accessorKey: "missed",
+ cell: ({
+ row: {
+ original: { missed },
+ },
+ }) => (
+ <Badge colorPalette={missed ? "red" : "blue"} size="sm" variant="solid">
+ {missed
+ ? translate("browse:deadlines.filters.statusOptions.missed")
+ : translate("browse:deadlines.filters.statusOptions.pending")}
+ </Badge>
+ ),
+ header: translate("browse:deadlines.columns.status"),
+ },
+ {
+ accessorKey: "alert_name",
+ cell: ({ row: { original } }) => original.alert_name ?? "",
+ enableSorting: false,
+ header: translate("browse:deadlines.columns.alertName"),
+ },
+ {
+ accessorKey: "created_at",
+ cell: ({ row: { original } }: DeadlineRow) => <Time
datetime={original.created_at} />,
+ header: translate("common:table.createdAt"),
+ },
+];
+
+const deadlinesFilterKeys: Array<FilterableSearchParamsKeys> = [
+ SearchParamsKeys.DAG_ID,
+ SearchParamsKeys.MISSED,
+];
+
+export const Deadlines = () => {
+ const { t: translate } = useTranslation(["browse", "common"]);
+ const { setTableURLState, tableURLState } = useTableURLState();
+ const [searchParams] = useSearchParams();
+
+ const { filterConfigs, handleFiltersChange, initialValues } =
useFiltersHandler(deadlinesFilterKeys);
+
+ const columns = createColumns(translate);
+
+ const { pagination, sorting } = tableURLState;
+ const [sort] = sorting;
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] :
["deadline_time"];
Review Comment:
```suggestion
const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] :
["-deadline_time"];
```
We need to do deadline time in descending order
##########
airflow-core/src/airflow/ui/src/pages/Deadlines/index.tsx:
##########
@@ -0,0 +1,150 @@
+/*!
+ * 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 { Badge, Box, Heading, Link, VStack } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import type { TFunction } from "i18next";
+import { useTranslation } from "react-i18next";
+import { Link as RouterLink, useSearchParams } from "react-router-dom";
+
+import { useDeadlinesServiceGetDeadlines } from "openapi/queries";
+import type { DeadlineResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import { FilterBar } from "src/components/FilterBar";
+import Time from "src/components/Time";
+import { TruncatedText } from "src/components/TruncatedText";
+import { SearchParamsKeys } from "src/constants/searchParams";
+import { useFiltersHandler, type FilterableSearchParamsKeys } from "src/utils";
+
+type DeadlineRow = { row: { original: DeadlineResponse } };
+
+const createColumns = (translate: TFunction):
Array<ColumnDef<DeadlineResponse>> => [
+ {
+ accessorKey: "dag_id",
+ cell: ({ row: { original } }: DeadlineRow) => (
+ <Link asChild color="fg.info">
+ <RouterLink to={`/dags/${original.dag_id}`}>
+ <TruncatedText text={original.dag_id} />
+ </RouterLink>
+ </Link>
+ ),
+ header: translate("common:dagId"),
+ },
+ {
+ accessorKey: "dag_run_id",
+ cell: ({ row: { original } }: DeadlineRow) => (
+ <Link asChild color="fg.info">
+ <RouterLink
to={`/dags/${original.dag_id}/runs/${original.dag_run_id}`}>
+ <TruncatedText text={original.dag_run_id} />
+ </RouterLink>
+ </Link>
+ ),
+ enableSorting: false,
+ header: translate("common:dagRunId"),
+ },
+ {
+ accessorKey: "deadline_time",
+ cell: ({ row: { original } }: DeadlineRow) => <Time
datetime={original.deadline_time} />,
+ header: translate("browse:deadlines.columns.deadlineTime"),
+ },
+ {
+ accessorKey: "missed",
+ cell: ({
+ row: {
+ original: { missed },
+ },
+ }) => (
+ <Badge colorPalette={missed ? "red" : "blue"} size="sm" variant="solid">
+ {missed
+ ? translate("browse:deadlines.filters.statusOptions.missed")
+ : translate("browse:deadlines.filters.statusOptions.pending")}
+ </Badge>
+ ),
+ header: translate("browse:deadlines.columns.status"),
+ },
+ {
+ accessorKey: "alert_name",
+ cell: ({ row: { original } }) => original.alert_name ?? "",
+ enableSorting: false,
+ header: translate("browse:deadlines.columns.alertName"),
+ },
+ {
+ accessorKey: "created_at",
+ cell: ({ row: { original } }: DeadlineRow) => <Time
datetime={original.created_at} />,
+ header: translate("common:table.createdAt"),
+ },
Review Comment:
Where's description?
##########
airflow-core/src/airflow/ui/src/pages/Deadlines/index.tsx:
##########
@@ -0,0 +1,150 @@
+/*!
+ * 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 { Badge, Box, Heading, Link, VStack } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import type { TFunction } from "i18next";
+import { useTranslation } from "react-i18next";
+import { Link as RouterLink, useSearchParams } from "react-router-dom";
+
+import { useDeadlinesServiceGetDeadlines } from "openapi/queries";
+import type { DeadlineResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import { FilterBar } from "src/components/FilterBar";
+import Time from "src/components/Time";
+import { TruncatedText } from "src/components/TruncatedText";
+import { SearchParamsKeys } from "src/constants/searchParams";
+import { useFiltersHandler, type FilterableSearchParamsKeys } from "src/utils";
+
+type DeadlineRow = { row: { original: DeadlineResponse } };
+
+const createColumns = (translate: TFunction):
Array<ColumnDef<DeadlineResponse>> => [
+ {
+ accessorKey: "dag_id",
+ cell: ({ row: { original } }: DeadlineRow) => (
+ <Link asChild color="fg.info">
+ <RouterLink to={`/dags/${original.dag_id}`}>
+ <TruncatedText text={original.dag_id} />
+ </RouterLink>
+ </Link>
+ ),
+ header: translate("common:dagId"),
+ },
+ {
+ accessorKey: "dag_run_id",
+ cell: ({ row: { original } }: DeadlineRow) => (
+ <Link asChild color="fg.info">
+ <RouterLink
to={`/dags/${original.dag_id}/runs/${original.dag_run_id}`}>
+ <TruncatedText text={original.dag_run_id} />
+ </RouterLink>
+ </Link>
+ ),
+ enableSorting: false,
+ header: translate("common:dagRunId"),
+ },
+ {
+ accessorKey: "deadline_time",
+ cell: ({ row: { original } }: DeadlineRow) => <Time
datetime={original.deadline_time} />,
+ header: translate("browse:deadlines.columns.deadlineTime"),
+ },
+ {
+ accessorKey: "missed",
+ cell: ({
+ row: {
+ original: { missed },
+ },
+ }) => (
+ <Badge colorPalette={missed ? "red" : "blue"} size="sm" variant="solid">
+ {missed
+ ? translate("browse:deadlines.filters.statusOptions.missed")
+ : translate("browse:deadlines.filters.statusOptions.pending")}
+ </Badge>
+ ),
+ header: translate("browse:deadlines.columns.status"),
+ },
+ {
+ accessorKey: "alert_name",
+ cell: ({ row: { original } }) => original.alert_name ?? "",
+ enableSorting: false,
+ header: translate("browse:deadlines.columns.alertName"),
+ },
+ {
+ accessorKey: "created_at",
+ cell: ({ row: { original } }: DeadlineRow) => <Time
datetime={original.created_at} />,
+ header: translate("common:table.createdAt"),
+ },
+];
+
+const deadlinesFilterKeys: Array<FilterableSearchParamsKeys> = [
+ SearchParamsKeys.DAG_ID,
+ SearchParamsKeys.MISSED,
+];
+
+export const Deadlines = () => {
+ const { t: translate } = useTranslation(["browse", "common"]);
+ const { setTableURLState, tableURLState } = useTableURLState();
+ const [searchParams] = useSearchParams();
+
+ const { filterConfigs, handleFiltersChange, initialValues } =
useFiltersHandler(deadlinesFilterKeys);
+
+ const columns = createColumns(translate);
+
+ const { pagination, sorting } = tableURLState;
+ const [sort] = sorting;
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] :
["deadline_time"];
+
+ const filteredDagId = searchParams.get(SearchParamsKeys.DAG_ID);
+ const filteredMissed = searchParams.get(SearchParamsKeys.MISSED);
+
+ const missedFilter = filteredMissed === "true" ? true : filteredMissed ===
"false" ? false : undefined;
+
+ const { data, error, isFetching, isLoading } =
useDeadlinesServiceGetDeadlines({
Review Comment:
I would ideally like to include the alert reference and the dag run's
end_date plus state to give much more context here, but that can be a custom UI
endpoint later.
##########
airflow-core/src/airflow/ui/src/pages/Deadlines/index.tsx:
##########
@@ -0,0 +1,150 @@
+/*!
+ * 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 { Badge, Box, Heading, Link, VStack } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import type { TFunction } from "i18next";
+import { useTranslation } from "react-i18next";
+import { Link as RouterLink, useSearchParams } from "react-router-dom";
+
+import { useDeadlinesServiceGetDeadlines } from "openapi/queries";
+import type { DeadlineResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import { FilterBar } from "src/components/FilterBar";
+import Time from "src/components/Time";
+import { TruncatedText } from "src/components/TruncatedText";
+import { SearchParamsKeys } from "src/constants/searchParams";
+import { useFiltersHandler, type FilterableSearchParamsKeys } from "src/utils";
+
+type DeadlineRow = { row: { original: DeadlineResponse } };
+
+const createColumns = (translate: TFunction):
Array<ColumnDef<DeadlineResponse>> => [
+ {
+ accessorKey: "dag_id",
+ cell: ({ row: { original } }: DeadlineRow) => (
+ <Link asChild color="fg.info">
+ <RouterLink to={`/dags/${original.dag_id}`}>
+ <TruncatedText text={original.dag_id} />
+ </RouterLink>
+ </Link>
+ ),
+ header: translate("common:dagId"),
+ },
+ {
+ accessorKey: "dag_run_id",
+ cell: ({ row: { original } }: DeadlineRow) => (
+ <Link asChild color="fg.info">
+ <RouterLink
to={`/dags/${original.dag_id}/runs/${original.dag_run_id}`}>
+ <TruncatedText text={original.dag_run_id} />
+ </RouterLink>
+ </Link>
+ ),
+ enableSorting: false,
+ header: translate("common:dagRunId"),
+ },
+ {
+ accessorKey: "deadline_time",
+ cell: ({ row: { original } }: DeadlineRow) => <Time
datetime={original.deadline_time} />,
+ header: translate("browse:deadlines.columns.deadlineTime"),
+ },
+ {
+ accessorKey: "missed",
+ cell: ({
+ row: {
+ original: { missed },
+ },
+ }) => (
+ <Badge colorPalette={missed ? "red" : "blue"} size="sm" variant="solid">
+ {missed
+ ? translate("browse:deadlines.filters.statusOptions.missed")
+ : translate("browse:deadlines.filters.statusOptions.pending")}
+ </Badge>
+ ),
+ header: translate("browse:deadlines.columns.status"),
+ },
+ {
+ accessorKey: "alert_name",
+ cell: ({ row: { original } }) => original.alert_name ?? "",
+ enableSorting: false,
+ header: translate("browse:deadlines.columns.alertName"),
+ },
+ {
+ accessorKey: "created_at",
+ cell: ({ row: { original } }: DeadlineRow) => <Time
datetime={original.created_at} />,
+ header: translate("common:table.createdAt"),
+ },
+];
+
+const deadlinesFilterKeys: Array<FilterableSearchParamsKeys> = [
+ SearchParamsKeys.DAG_ID,
+ SearchParamsKeys.MISSED,
+];
+
+export const Deadlines = () => {
+ const { t: translate } = useTranslation(["browse", "common"]);
+ const { setTableURLState, tableURLState } = useTableURLState();
+ const [searchParams] = useSearchParams();
+
+ const { filterConfigs, handleFiltersChange, initialValues } =
useFiltersHandler(deadlinesFilterKeys);
+
+ const columns = createColumns(translate);
+
+ const { pagination, sorting } = tableURLState;
+ const [sort] = sorting;
+ const orderBy = sort ? [`${sort.desc ? "-" : ""}${sort.id}`] :
["deadline_time"];
+
+ const filteredDagId = searchParams.get(SearchParamsKeys.DAG_ID);
+ const filteredMissed = searchParams.get(SearchParamsKeys.MISSED);
Review Comment:
You can look at our other time range filters to add filters for deadlineTime
Lte and Gte
--
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]