imrichardwu commented on code in PR #62195:
URL: https://github.com/apache/airflow/pull/62195#discussion_r3053859442


##########
airflow-core/src/airflow/ui/src/pages/Dag/DeadlineAlertsBadge.tsx:
##########
@@ -0,0 +1,110 @@
+/*!
+ * 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 { Box, Button, HStack, Separator, Text, VStack } from 
"@chakra-ui/react";
+import dayjs from "dayjs";
+import { useTranslation } from "react-i18next";
+import { FiClock } from "react-icons/fi";
+
+import { useDeadlinesServiceGetDeadlines, 
useDeadlinesServiceGetDagDeadlineAlerts } from "openapi/queries";
+import type { DeadlineAlertResponse } from "openapi/requests/types.gen";
+import { Popover } from "src/components/ui";
+import { renderDuration } from "src/utils";
+
+const referenceTypeLabels: Record<string, string> = {
+  AverageRuntimeDeadline: "Average Runtime",
+  DagRunLogicalDateDeadline: "Logical Date",
+  DagRunQueuedAtDeadline: "Queued At",
+  FixedDatetimeDeadline: "Fixed Datetime",
+};
+
+const formatReferenceType = (referenceType: string): string =>
+  referenceTypeLabels[referenceType] ?? referenceType;
+
+const AlertRow = ({ alert }: { readonly alert: DeadlineAlertResponse }) => {
+  const { t: translate } = useTranslation("dag");
+
+  return (
+    <Box py={2} width="100%">
+      <Text fontWeight="bold">
+        {alert.name !== undefined && alert.name !== null && alert.name !== ""
+          ? alert.name
+          : translate("deadlineAlerts.unnamed")}
+      </Text>
+      {alert.description !== undefined && alert.description !== null && 
alert.description !== "" ? (
+        <Text color="fg.muted" fontSize="xs">
+          {alert.description}
+        </Text>
+      ) : undefined}
+      <HStack fontSize="xs" gap={3} mt={1}>
+        <Text color="fg.muted">
+          {translate("deadlineAlerts.referenceType")}: 
{formatReferenceType(alert.reference_type)}
+        </Text>

Review Comment:
   Since name and description are both optional and may not always be set, 
would it be better to replace the "Calculated from: Interval" fields with a 
human-readable sentence like "Run to complete within 1 hour of logical date"? 
That way every alert always has meaningful display text regardless of whether 
name/description are provided. Or should we keep name/description as the 
primary display and only fall back to the generated sentence when they're 
absent?



-- 
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]

Reply via email to