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


##########
airflow-core/src/airflow/ui/src/hooks/useLineageFilter.ts:
##########
@@ -0,0 +1,89 @@
+/*!
+ * 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 { useEffect, useRef } from "react";
+import { useLocalStorage } from "usehooks-ts";
+
+import type { FilterMode } from "src/layouts/Details/LineageFilter";
+
+type UseLineageFilterProps = {
+  readonly dagId: string;
+  readonly taskId?: string;
+};
+
+type UseLineageFilterReturn = {
+  readonly handleClearLineageFilter: () => void;
+  readonly handleLineageFilterModeChange: (mode: FilterMode) => void;
+  readonly lineageFilterMode: FilterMode;
+  readonly lineageFilterRoot: string | undefined;
+  readonly setLineageFilterRoot: (root: string | undefined) => void;
+};
+
+/**
+ * Custom hook to manage lineage filter state for the DAG views (Graph and 
Grid).
+ *
+ * This hook handles:
+ * - Persisting filter state in localStorage
+ * - Clearing filter on initial mount when no task is selected
+ * - Managing filter state when tasks are clicked
+ */
+export const useLineageFilter = ({ dagId, taskId }: UseLineageFilterProps): 
UseLineageFilterReturn => {
+  // Use localStorage for lineage filter state so it persists across navigation

Review Comment:
   I would remove most of those comments, they are not super useful to me.



##########
airflow-core/src/airflow/ui/src/layouts/Details/Graph/Graph.tsx:
##########
@@ -58,12 +59,29 @@ const nodeColor = (
   return "";
 };
 
-export const Graph = () => {
+type GraphProps = {
+  readonly filterMode: FilterMode;
+  readonly filterRoot: string | undefined;
+  readonly setFilterRoot: (root: string | undefined) => void;
+};
+
+export const Graph = ({ filterMode, filterRoot, setFilterRoot }: GraphProps) 
=> {
   const { colorMode = "light" } = useColorMode();
   const { dagId = "", runId = "", taskId } = useParams();
 
   const selectedVersion = useSelectedVersion();
 
+  const handleNodeClick = (_event: React.MouseEvent, node: 
ReactFlowNode<CustomNodeProps>) => {
+    if (filterMode !== "none") {
+      return;
+    }
+    // Only set filter root for actual tasks, not DAGs or other node types
+    // This just stores which task was clicked - it doesn't activate the filter
+    if (!node.id.startsWith("dag:") && !node.id.startsWith("asset")) {

Review Comment:
   there are other types of dependencies,maybe we should find more certain way 
of making sure that the considered node is a task. I'm affraid this could break 
in some scenario, I'll have to double check.



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