choo121600 commented on code in PR #77455:
URL: https://github.com/apache/airflow/pull/77455#discussion_r4692949252


##########
airflow-core/src/airflow/ui/src/components/AltClickExtraLinks.tsx:
##########
@@ -0,0 +1,126 @@
+/*!
+ * 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 type { MouseEvent, ReactElement } from "react";
+import { useEffect, useRef, useState } from "react";
+
+import { Box, Button, Portal, VStack } from "@chakra-ui/react";
+import { useNavigate, type To } from "react-router-dom";
+
+import type { ExtraLink } from "src/hooks/useTaskInstanceExtraLinks";
+
+type Props = {
+  readonly children: ReactElement;
+  readonly links: ReadonlyArray<ExtraLink>;
+  readonly navigateTo: To;
+  readonly replace?: boolean;
+};
+
+type MenuPosition = {
+  readonly x: number;
+  readonly y: number;
+};
+
+const ExtraLinksMenu = ({
+  links,
+  onClose,
+  position,
+}: {
+  readonly links: ReadonlyArray<ExtraLink>;
+  readonly onClose: () => void;
+  readonly position: MenuPosition;
+}) => {
+  const firstItemRef = useRef<HTMLAnchorElement | null>(null);
+
+  useEffect(() => {
+    firstItemRef.current?.focus();
+  }, []);
+
+  return (
+    <Portal>
+      <Box data-testid="extra-links-backdrop" inset={0} onClick={onClose} 
position="fixed" zIndex="modal" />
+      <Box

Review Comment:
   **Hand-rolled menu**
   
   This custom menu has no arrow-key navigation, Escape only works while focus 
is inside it, and it can render off-screen near the viewport edge. Could we use 
Chakra's `Menu` (already used in e.g. `FilterMenuButton.tsx`) instead?



##########
airflow-core/src/airflow/ui/src/layouts/Details/Grid/GridTI.tsx:
##########
@@ -68,10 +72,29 @@ export const GridTI = ({
   const { groupId: selectedGroupId, runId: selectedRunId, taskId: 
selectedTaskId } = useParams();
   const { colorMode = "light" } = useColorMode();
   const location = useLocation();
+  const { t: translate } = useTranslation("components");
 
   const [searchParams] = useSearchParams();
+  const [isHovered, setIsHovered] = useState(false);
 
   const hasTaskInstance = instance.dag_version_number !== null && 
instance.dag_version_number !== undefined;
+  const tryNumberParam = searchParams.get(SearchParamsKeys.TRY_NUMBER);
+
+  const links = useTaskInstanceExtraLinks({
+    dagId,
+    dagRunId: runId,
+    enabled: isHovered && hasTaskInstance,
+    regionId: instance.latest_region_id,
+    regionIndex: instance.latest_region_index,
+    taskId,
+    tryNumber: tryNumberParam === null ? undefined : parseInt(tryNumberParam, 
10),

Review Comment:
   **Wrong try number for other cells**
   
   `try_number` in the URL belongs to the selected task instance, but here it 
is applied to every hovered cell, so other cells fetch links for a try they may 
not have (wrong links or a 404). Could we drop it here and in `TaskNode.tsx` so 
the latest try is used?



##########
airflow-core/src/airflow/ui/src/layouts/Details/Grid/GridTI.tsx:
##########
@@ -68,10 +72,29 @@ export const GridTI = ({
   const { groupId: selectedGroupId, runId: selectedRunId, taskId: 
selectedTaskId } = useParams();
   const { colorMode = "light" } = useColorMode();
   const location = useLocation();
+  const { t: translate } = useTranslation("components");
 
   const [searchParams] = useSearchParams();
+  const [isHovered, setIsHovered] = useState(false);
 
   const hasTaskInstance = instance.dag_version_number !== null && 
instance.dag_version_number !== undefined;
+  const tryNumberParam = searchParams.get(SearchParamsKeys.TRY_NUMBER);
+
+  const links = useTaskInstanceExtraLinks({
+    dagId,
+    dagRunId: runId,
+    enabled: isHovered && hasTaskInstance,

Review Comment:
   **One request per hovered cell**
   
   Moving the mouse across the grid fires an extra-links request for every cell 
it passes over. Could this be enabled only once the tooltip actually opens (it 
already has a 500ms delay), or fetched on Alt+click?



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