Skip to content

Commit db24a3e

Browse files
committed
[DOP-23920] Highlight related nodes on double click
1 parent f4ea22d commit db24a3e

File tree

12 files changed

+188
-9
lines changed

12 files changed

+188
-9
lines changed

src/components/lineage/LineageGraph.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { DatasetNode, JobNode, RunNode, OperationNode } from "./nodes";
1212
import { useEffect } from "react";
1313
import { BaseEdge, IOEdge } from "./edges";
14+
import { useLineageSelection } from "./selection";
1415

1516
export const MIN_ZOOM_VALUE = 0.1;
1617
export const MAX_ZOOM_VALUE = 2.5;
@@ -29,6 +30,7 @@ const nodeTypes = {
2930

3031
const LineageGraph = (props: ReactFlowProps) => {
3132
const { fitView } = useReactFlow();
33+
const lineageSelection = useLineageSelection();
3234

3335
const nodesInitialized = useNodesInitialized();
3436

@@ -38,6 +40,9 @@ const LineageGraph = (props: ReactFlowProps) => {
3840

3941
return (
4042
<ReactFlow
43+
className={
44+
lineageSelection.hideNonSelected ? "hideNonSelected" : undefined
45+
}
4146
nodeTypes={nodeTypes}
4247
edgeTypes={edgeTypes}
4348
nodesFocusable={true}
@@ -53,6 +58,11 @@ const LineageGraph = (props: ReactFlowProps) => {
5358
zoomOnDoubleClick={false}
5459
fitView
5560
onDoubleClick={() => fitView()}
61+
onPaneClick={lineageSelection.onPaneClick}
62+
onEdgeClick={lineageSelection.onEdgeClick}
63+
onNodeClick={lineageSelection.onNodeClick}
64+
onEdgeDoubleClick={lineageSelection.onEdgeDoubleClick}
65+
onNodeDoubleClick={lineageSelection.onNodeDoubleClick}
5666
{...props}
5767
>
5868
<Background variant={BackgroundVariant.Dots} />

src/components/lineage/LineageView.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { useDataProvider, useNotify } from "react-admin";
22

3-
import buildLineageLayout from "./utils/buildLayout";
3+
import { buildLineageLayout } from "./layout";
44
import { Edge, Node, useNodesState, useEdgesState } from "@xyflow/react";
55
import LineageFilters from "./LineageFilters";
66
import LineageGraph from "./LineageGraph";
77

88
import "@xyflow/react/dist/style.css";
9-
import getGraphNodes from "./utils/getGraphNodes";
10-
import getGraphEdges from "./utils/getGraphEdges";
9+
import { getGraphNodes, getGraphEdges } from "./converters";
1110
import { LineageResponseV1 } from "@/dataProvider/types";
1211

1312
type LineageViewProps = {
@@ -22,6 +21,9 @@ const LineageView = (props: LineageViewProps) => {
2221
const dataProvider = useDataProvider();
2322
const notify = useNotify();
2423

24+
// datasets + 123 -> DATASET-123
25+
const currentNodeId = `${props.resource.slice(0, -1).toUpperCase()}-${props.recordId}`;
26+
2527
const [nodes, setNodes, onNodesChange] = useNodesState<Node>([]);
2628
const [edges, setEdges, onEdgesChange] = useEdgesState<Edge>([]);
2729

@@ -44,6 +46,13 @@ const LineageView = (props: LineageViewProps) => {
4446
.then((data: LineageResponseV1) => {
4547
const initialNodes = getGraphNodes(data);
4648
const initialEdges = getGraphEdges(data);
49+
50+
initialNodes
51+
.filter((node) => node.id == currentNodeId)
52+
.forEach((node) => {
53+
node.selected = true;
54+
});
55+
4756
const { nodes: layoutedNodes, edges: layoutedEdges } =
4857
buildLineageLayout({
4958
nodes: initialNodes,
File renamed without changes.
File renamed without changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import getGraphEdges from "./getGraphEdges";
2+
import getGraphNodes from "./getGraphNodes";
3+
4+
export { getGraphEdges, getGraphNodes };
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.react-flow.hideNonSelected .react-flow__node:not(.selected),
2+
.react-flow.hideNonSelected .react-flow__edge:not(.selected),
3+
.react-flow.hideNonSelected
4+
.react-flow__edgelabel-renderer
5+
> div:not(.selected) {
6+
opacity: 0.3 !important;
7+
}

src/components/lineage/edges/BaseEdge.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import {
77
} from "@xyflow/react";
88
import { Chip } from "@mui/material";
99

10-
const BaseEdge = ({ id, label, ...props }: EdgeProps): ReactElement => {
10+
import "./BaseEdge.css";
11+
12+
const BaseEdge = ({
13+
id,
14+
label,
15+
selected,
16+
...props
17+
}: EdgeProps): ReactElement => {
1118
const [edgePath, labelX, labelY] = getBezierPath(props);
1219

1320
return (
@@ -21,7 +28,7 @@ const BaseEdge = ({ id, label, ...props }: EdgeProps): ReactElement => {
2128
position: "absolute",
2229
transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
2330
}}
24-
className="nodrag nopan"
31+
className={`nodrag nopan ${selected ? "selected" : ""}`}
2532
>
2633
<Chip
2734
size="small"

src/components/lineage/edges/IOEdge.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ReactElement } from "react";
22
import {
33
getBezierPath,
44
EdgeLabelRenderer,
5-
BaseEdge,
5+
BaseEdge as ReactFlowBaseEdge,
66
EdgeProps,
77
} from "@xyflow/react";
88
import {
@@ -13,11 +13,14 @@ import formatNumberApprox from "@/utils/numbers";
1313
import formatBytes from "@/utils/bytes";
1414
import { Card, Chip, Typography } from "@mui/material";
1515

16+
import "./BaseEdge.css";
17+
1618
const IOEdge = ({
1719
id,
1820
/* eslint-disable @typescript-eslint/no-unused-vars */
1921
label,
2022
data,
23+
selected,
2124
...props
2225
}: EdgeProps & {
2326
data: InputRelationLineageResponseV1 | OutputRelationLineageResponseV1;
@@ -28,12 +31,12 @@ const IOEdge = ({
2831
data.type || data.num_rows || data.num_bytes || data.num_files;
2932

3033
if (!hasContent) {
31-
return <BaseEdge id={id} path={edgePath} {...props} />;
34+
return <ReactFlowBaseEdge id={id} path={edgePath} {...props} />;
3235
}
3336

3437
return (
3538
<>
36-
<BaseEdge id={id} path={edgePath} {...props} />
39+
<ReactFlowBaseEdge id={id} path={edgePath} {...props} />
3740
<EdgeLabelRenderer>
3841
<Card
3942
style={{
@@ -43,7 +46,7 @@ const IOEdge = ({
4346
position: "absolute",
4447
transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
4548
}}
46-
className="nodrag nopan"
49+
className={`nodrag nopan ${selected ? "selected" : ""}`}
4750
>
4851
{data.type ? (
4952
<Chip
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import buildLineageLayout from "./buildLineageLayout";
2+
3+
export { buildLineageLayout };

0 commit comments

Comments
 (0)