pierrejeambrun commented on code in PR #53216:
URL: https://github.com/apache/airflow/pull/53216#discussion_r2556369958


##########
airflow-core/src/airflow/ui/src/constants/showVersionIndicatorOptions.ts:
##########
@@ -0,0 +1,44 @@
+/*!
+ * 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 { createListCollection } from "@chakra-ui/react";
+
+export const VersionIndicatorDisplayOptions = {
+  ALL: "all",
+  BUNDLE: "bundle",
+  DAG: "dag",
+  NONE: "none",
+} as const;

Review Comment:
   why `as const` ? 



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/common.py:
##########
@@ -79,6 +79,9 @@ class GridRunsResponse(BaseModel):
     run_after: datetime
     state: DagRunState | None
     run_type: DagRunType
+    dag_version_number: int | None = None
+    bundle_version: str | None = None
+    has_mixed_versions: bool = False

Review Comment:
   Removing that will also simplify the backend code.



##########
airflow-core/src/airflow/ui/src/components/ui/VersionIndicator.tsx:
##########
@@ -0,0 +1,111 @@
+/*!
+ * 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 } from "@chakra-ui/react";
+import { useTranslation } from "react-i18next";
+import { FiGitCommit } from "react-icons/fi";
+
+import { Tooltip } from "src/components/ui";
+
+export const BundleVersionIndicator = ({ bundleVersion }: { readonly 
bundleVersion: string | null }) => {
+  const { t: translate } = useTranslation("components");
+
+  return (
+    <Tooltip content={`${translate("versionDetails.bundleVersion")}: 
${bundleVersion}`}>
+      <Box color="orange.fg" left={-2} position="absolute" top={93} zIndex={1}>
+        <FiGitCommit size="15px" />
+      </Box>
+    </Tooltip>
+  );
+};
+
+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} />
+
+          <Tooltip
+            content={`v${dagVersionNumber ?? ""}`}
+            positioning={{
+              placement: "top",
+            }}
+          >
+            <Box
+              _hover={{
+                bg: "orange.emphasis",
+                cursor: "pointer",
+              }}
+              bg="orange.focusRing"
+              borderRadius="full"
+              height={2}
+              left="50%"
+              position="absolute"
+              top={-2}
+              transform="translateX(-50%)"
+              transition="all 0.2s"
+              width={2}
+            />
+          </Tooltip>
+        </>
+      ) : (
+        <Tooltip
+          content={`v${dagVersionNumber ?? ""}`}
+          positioning={{
+            placement: "right",
+          }}
+        >
+          <Box
+            _hover={{
+              cursor: "pointer",
+            }}
+            alignItems="center"
+            color="orange.fg"
+            display="flex"
+            justifyContent="center"
+            left="50%"
+            position="absolute"
+            top={-1.5}
+            transform="translateX(-50%)"
+            transition="all 0.2s"
+          >
+            <FiGitCommit size="15px" />

Review Comment:
   I don't think Horizontal `DagVersionIndicator` and `BundleVersionIndicator` 
should use the same icon.
   
   I would keep the `gitcommit` one for BundleVersions. And I would leave the 
DagVersions as a contained 'chip'. 



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/common.py:
##########
@@ -79,6 +79,9 @@ class GridRunsResponse(BaseModel):
     run_after: datetime
     state: DagRunState | None
     run_type: DagRunType
+    dag_version_number: int | None = None
+    bundle_version: str | None = None
+    has_mixed_versions: bool = False

Review Comment:
   Same for this. You don't need to compute it. We have the `get_dag_run` query 
in the context of the grid, that returns `dag_versions` already, if the list is 
bigger than 1 we have mixed version. (only thing is that this list consider TIH 
too, which might or might not be appropriate depending on how we want to 
visualize things)



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/ui/common.py:
##########
@@ -79,6 +79,9 @@ class GridRunsResponse(BaseModel):
     run_after: datetime
     state: DagRunState | None
     run_type: DagRunType
+    dag_version_number: int | None = None

Review Comment:
   I don't think you need to pass this down, because the grid is calling 
`get_dag_details` and the latest `dag_version` is already there in the payload.
   
   So you might get it in the front-end from there. same for the bundle name 
and bundle version.



##########
airflow-core/src/airflow/ui/src/layouts/Details/PanelButtons.tsx:
##########
@@ -479,6 +493,44 @@ export const PanelButtons = ({
                         ) : undefined}
                       </>
                     )}
+                    {/* eslint-disable react/jsx-max-depth */}
+                    <VStack alignItems="flex-start" px={1}>
+                      <Select.Root
+                        // @ts-expect-error option type
+                        collection={showVersionIndicatorOptions}
+                        onValueChange={handleshowVersionIndicatorChange}
+                        size="sm"
+                        value={[showVersionIndicatorMode]}
+                      >
+                        <Select.Label fontSize="xs">
+                          {translate("dag:panel.showVersionIndicator.label")}
+                        </Select.Label>
+                        <Select.Control>
+                          <Select.Trigger>
+                            <Select.ValueText>
+                              {translate(
+                                showVersionIndicatorOptions.items.find(
+                                  (item) => item.value === 
showVersionIndicatorMode,
+                                )?.label ?? "",
+                              )}
+                            </Select.ValueText>
+                          </Select.Trigger>
+                          <Select.IndicatorGroup>

Review Comment:
   If it's possible to inline in the dropdown the relevant icon (git commit or 
chip) to act as a 'legent', so it's clearer what we will filter on.



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