bbovenzi commented on code in PR #53216: URL: https://github.com/apache/airflow/pull/53216#discussion_r2479336398
########## airflow-core/src/airflow/ui/src/components/ui/VersionIndicator.tsx: ########## @@ -0,0 +1,155 @@ +/*! + * 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, Text } from "@chakra-ui/react"; +import { FiGitCommit } from "react-icons/fi"; + +export const BundleVersionIndicator = ({ bundleVersion }: { readonly bundleVersion: string | null }) => ( + <Box + color="orange.fg" + left={-2} + position="absolute" + title={`Bundle Version: ${bundleVersion}`} Review Comment: Let's add this as a translation. ########## airflow-core/src/airflow/ui/src/layouts/Details/PanelButtons.tsx: ########## @@ -100,6 +102,16 @@ const getWidthBasedConfig = (width: number, enableResponsiveOptions: boolean) => }; }; +const getVersionDisplayOptions = (translate: (key: string) => string) => + createListCollection({ + items: [ + { label: translate("dag:panel.versionDisplay.options.showAll"), value: "all" }, + { label: translate("dag:panel.versionDisplay.options.showDagVersion"), value: "dag" }, + { label: translate("dag:panel.versionDisplay.options.showBundleVersion"), value: "bundle" }, + { label: translate("dag:panel.versionDisplay.options.hideAll"), value: "none" }, Review Comment: Let's make the values an enum const we can import in many places so we avoid future spelling mistakes? ########## airflow-core/src/airflow/ui/src/layouts/Details/Grid/Bar.tsx: ########## @@ -34,17 +35,25 @@ type Props = { readonly nodes: Array<GridTask>; readonly onCellClick?: () => void; readonly onColumnClick?: () => void; - readonly run: GridRunsResponse; + readonly run: { + has_mixed_versions?: boolean; Review Comment: This line should already be included in GridRunsResponse, no? ########## airflow-core/src/airflow/ui/src/components/ui/VersionIndicator.tsx: ########## @@ -0,0 +1,155 @@ +/*! + * 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, Text } from "@chakra-ui/react"; +import { FiGitCommit } from "react-icons/fi"; + +export const BundleVersionIndicator = ({ bundleVersion }: { readonly bundleVersion: string | null }) => ( + <Box + color="orange.fg" + left={-2} + position="absolute" + title={`Bundle Version: ${bundleVersion}`} + top={93} + zIndex={1} + > + <FiGitCommit size="15px" /> + </Box> +); + +export const DagVersionIndicator = ({ + dagVersionNumber, + orientation = "vertical", +}: { + readonly dagVersionNumber: number | null; + readonly orientation?: "horizontal" | "vertical"; +}) => { + const isVertical = orientation === "vertical"; + + return ( + <Box + aria-label={`Version ${dagVersionNumber} indicator`} + as="output" + height={isVertical ? 104 : 0.5} + left={isVertical ? -1.25 : 0} + position="absolute" + top={isVertical ? -1.5 : -0.5} + width={isVertical ? 0.5 : 4.5} + zIndex={1} + > + {isVertical ? ( + <> + <Box bg="orange.focusRing" height="full" position="absolute" width={0.5} /> + + <Box + _hover={{ "& > .version-tooltip": { opacity: 1, visibility: "visible" } }} + left="50%" + position="absolute" + top={-2} + transform="translateX(-50%)" + zIndex="tooltip" + > + <Box + _hover={{ + bg: "orange.emphasis", + cursor: "pointer", + }} + bg="orange.focusRing" + borderRadius="full" + height={2} + transition="all 0.2s" + width={2} + /> + <Box Review Comment: Why did we make a custom tooltip instead of the one from chakra? I know there were performance issues with it before, but now it seems much better. ########## airflow-core/src/airflow/ui/src/layouts/Details/Grid/TaskInstancesColumn.tsx: ########## @@ -20,41 +20,75 @@ import { Box } from "@chakra-ui/react"; import { useParams } from "react-router-dom"; import type { LightGridTaskInstanceSummary } from "openapi/requests/types.gen"; +import { DagVersionIndicator } from "src/components/ui/VersionIndicator"; import { GridTI } from "./GridTI"; import type { GridTask } from "./utils"; type Props = { readonly depth?: number; + readonly hasMixedVersions?: boolean; readonly nodes: Array<GridTask>; readonly onCellClick?: () => void; readonly runId: string; readonly taskInstances: Array<LightGridTaskInstanceSummary>; + readonly versionDisplayMode?: string; }; -export const TaskInstancesColumn = ({ nodes, onCellClick, runId, taskInstances }: Props) => { +export const TaskInstancesColumn = ({ + hasMixedVersions, + nodes, + onCellClick, + runId, + taskInstances, + versionDisplayMode, +}: Props) => { const { dagId = "" } = useParams(); - return nodes.map((node) => { + const taskInstanceMap = new Map(taskInstances.map((ti) => [ti.task_id, ti])); Review Comment: What's the reason to change this to a map and then make `hasVersionChangeFlag` an immediately invoked function expression? ########## airflow-core/src/airflow/ui/src/components/ui/VersionIndicator.tsx: ########## @@ -0,0 +1,155 @@ +/*! + * 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, Text } from "@chakra-ui/react"; +import { FiGitCommit } from "react-icons/fi"; + +export const BundleVersionIndicator = ({ bundleVersion }: { readonly bundleVersion: string | null }) => ( + <Box + color="orange.fg" + left={-2} + position="absolute" + title={`Bundle Version: ${bundleVersion}`} + top={93} + zIndex={1} + > + <FiGitCommit size="15px" /> + </Box> +); + +export const DagVersionIndicator = ({ + dagVersionNumber, + orientation = "vertical", +}: { + readonly dagVersionNumber: number | null; + readonly orientation?: "horizontal" | "vertical"; +}) => { + const isVertical = orientation === "vertical"; + + return ( + <Box + aria-label={`Version ${dagVersionNumber} indicator`} + as="output" + height={isVertical ? 104 : 0.5} + left={isVertical ? -1.25 : 0} + position="absolute" + top={isVertical ? -1.5 : -0.5} + width={isVertical ? 0.5 : 4.5} + zIndex={1} + > + {isVertical ? ( + <> + <Box bg="orange.focusRing" height="full" position="absolute" width={0.5} /> + + <Box + _hover={{ "& > .version-tooltip": { opacity: 1, visibility: "visible" } }} + left="50%" + position="absolute" + top={-2} + transform="translateX(-50%)" + zIndex="tooltip" + > + <Box + _hover={{ + bg: "orange.emphasis", + cursor: "pointer", + }} + bg="orange.focusRing" + borderRadius="full" + height={2} + transition="all 0.2s" + width={2} + /> + <Box + bg="orange.focusRing" + borderRadius="full" + className="version-tooltip" + left="50%" + opacity={0} + pointerEvents="none" + position="absolute" + px={0.5} + py={0.5} + top={-0.5} + transform="translateX(-50%)" + transition="all 0.2s" + visibility="hidden" + > + <Text + color={{ _dark: "black", _light: "white" }} Review Comment: Why not use `fg.inverted` here? -- 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]
