minyeamer commented on code in PR #71558:
URL: https://github.com/apache/airflow/pull/71558#discussion_r4184062268


##########
airflow-core/src/airflow/ui/src/pages/TimeSchedule/TimeSchedule.tsx:
##########
@@ -0,0 +1,178 @@
+/*!
+ * 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 { useState } from "react";
+
+import { Box, Flex, Text, VStack } from "@chakra-ui/react";
+import { useTranslation } from "react-i18next";
+import { useLocalStorage } from "usehooks-ts";
+
+import { ErrorAlert } from "src/components/ErrorAlert";
+
+import {
+  TIME_SCHEDULE_AGGREGATION_MODE_KEY,
+  TIME_SCHEDULE_DAG_RUN_LIMIT_KEY,
+  TIME_SCHEDULE_SCHEDULED_ONLY_KEY,
+  TIME_SCHEDULE_VIEW_MODE_KEY,
+} from "src/constants/localStorage";
+import { useTimezone } from "src/context/timezone";
+import { useDocumentTitle } from "src/utils";
+
+import { DayTimeline } from "./DayTimeline";
+import { TimeScheduleControls, TimeScheduleViewControls } from 
"./TimeScheduleControls";
+import { TimelineTooltip } from "./TimelineTooltip";
+import { WeekTimeline } from "./WeekTimeline";
+import { TIMELINE_HORIZONTAL_PADDING } from "./constants";
+import { buildDayRowLayouts } from "./timelineUtils";
+import type { AggregationMode, DagRunLimit, RowSortMode, ViewMode } from 
"./types";
+import { useTimeScheduleData } from "./useTimeScheduleData";
+import { useTimelineZoom } from "./useTimelineZoom";
+
+const CHART_VIEWPORT_HEIGHT = "calc(100dvh - 160px)";
+
+export const TimeSchedule = () => {
+  const { t: translate } = useTranslation();
+  const { selectedTimezone } = useTimezone();
+  const [viewMode, setViewMode] = 
useLocalStorage<ViewMode>(TIME_SCHEDULE_VIEW_MODE_KEY, "day");
+  const [aggregationMode, setAggregationMode] = 
useLocalStorage<AggregationMode>(
+    TIME_SCHEDULE_AGGREGATION_MODE_KEY,
+    "mean",
+  );
+  const [showScheduledOnly, setShowScheduledOnly] = useLocalStorage<boolean>(
+    TIME_SCHEDULE_SCHEDULED_ONLY_KEY,
+    true,
+  );
+  const [dagRunLimit, setDagRunLimit] = 
useLocalStorage<DagRunLimit>(TIME_SCHEDULE_DAG_RUN_LIMIT_KEY, 200);
+  const [rowSortMode, setRowSortMode] = 
useState<RowSortMode>("dagIdAscending");
+  const zoom = useTimelineZoom(viewMode);
+
+  useDocumentTitle(translate("timeSchedule.title"));
+
+  const { controls, dagRunCount, dayRows, error, isLoading, timelineItems } = 
useTimeScheduleData({
+    aggregationMode,
+    dagRunLimit,
+    rowSortMode,
+    selectedTimezone,
+    showScheduledOnly,
+    timeScale: zoom.timeScale,
+    viewMode,
+  });
+  const dayRowLayouts = buildDayRowLayouts({
+    rows: dayRows,
+    selectedTimezone,
+    timelineWidth: zoom.chartWidth - TIMELINE_HORIZONTAL_PADDING,
+  });
+  const dayGridHeight = Math.max(480, dayRowLayouts.reduce((height, row) => 
height + row.height, 0) + 32);
+  const chartContentHeight = Math.max(320, dayGridHeight - 48);
+  const chartMinWidth = zoom.timeScale === 60 ? undefined : 
`${zoom.chartWidth}px`;
+  const timelineMinWidth =
+    zoom.timeScale === 60 ? undefined : `${zoom.chartWidth - 
TIMELINE_HORIZONTAL_PADDING}px`;
+  const cycleRowSortMode = () => {
+    setRowSortMode((current) =>
+      current === "dagIdAscending"
+        ? "dagIdDescending"
+        : current === "dagIdDescending"
+          ? "startTime"
+          : "dagIdAscending",
+    );
+  };
+  const renderTimelineTooltip = (item: (typeof timelineItems)[number]) => (
+    <TimelineTooltip item={item} selectedTimezone={selectedTimezone} />
+  );
+
+  return (
+    <VStack align="stretch" gap={4}>
+      <TimeScheduleControls {...controls} onViewModeChange={setViewMode} 
viewMode={viewMode} />
+
+      <Box
+        bg="bg.panel"
+        borderColor="border.subtle"
+        borderRadius="md"
+        borderWidth="1px"
+        data-testid="time-schedule-chart"
+        onMouseLeave={zoom.onChartMouseLeave}
+        onMouseMove={zoom.onChartMouseMove}
+        overscrollBehavior="auto"
+        p={4}
+        ref={zoom.chartRootRef}
+        tabIndex={0}
+      >
+        <VStack align="stretch" gap={3} height="100%" minHeight={0}>
+          <Flex align="center" gap={4} justify="space-between" wrap="wrap">
+            <Text color="fg.muted" fontSize="sm">
+              {isLoading
+                ? translate("timeSchedule.loading")
+                : translate("timeSchedule.dagRunsRendered", { count: 
dagRunCount })}
+            </Text>

Review Comment:
   ```suggestion
               <Text color="fg.muted" fontSize="sm">
                 {isLoading ? null : `${dagRunCount} ${translate("dagRun", { 
count: dagRunCount })}`}
               </Text>
   ```



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