minyeamer commented on code in PR #71558: URL: https://github.com/apache/airflow/pull/71558#discussion_r4192014167
########## 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); Review Comment: ```typescript // airflow-core/src/airflow/ui/src/pages/TimeSchedule/constants.ts export const DAY_HEADER_HEIGHT_PX = 48; export const DAY_GRID_MIN_HEIGHT_PX = 480; export const DAY_CONTENT_MIN_HEIGHT_PX = 320; export const DAY_GRID_BOTTOM_PADDING_PX = 32; ``` ```suggestion const dayGridHeight = Math.max( DAY_GRID_MIN_HEIGHT_PX, dayRowLayouts.reduce((height, row) => height + row.height, 0) + DAY_GRID_BOTTOM_PADDING_PX, ); const chartContentHeight = Math.max(DAY_CONTENT_MIN_HEIGHT_PX, dayGridHeight - DAY_HEADER_HEIGHT_PX); ``` -- 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]
