-
Notifications
You must be signed in to change notification settings - Fork 8
feat: lineage scoping and explorer dependency chain sort #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -261,8 +261,18 @@ function NoCodeModel({ nodeData }) { | |
| if (lineageData?.nodes && lineageData?.edges) { | ||
| const { nodes: layoutedNodes, edges: layoutedEdges } = | ||
| getLayoutedElements(lineageData.nodes, lineageData.edges, newDirection); | ||
| setNodes(layoutedNodes); | ||
| setEdges(layoutedEdges); | ||
| if (modelName) { | ||
| const scoped = applyScopedStyles( | ||
| layoutedNodes, | ||
| layoutedEdges, | ||
| modelName | ||
| ); | ||
| setNodes(scoped.nodes); | ||
| setEdges(scoped.edges); | ||
| } else { | ||
| setNodes(layoutedNodes); | ||
| setEdges(layoutedEdges); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -740,6 +750,7 @@ function NoCodeModel({ nodeData }) { | |
| setSeqEdges(layoutedEdges); | ||
| runTransformation(res?.data?.model_data); | ||
| setConfigApply(true); | ||
| setRefreshModels(true); | ||
| handleModalClose("ok"); | ||
| }) | ||
| .catch((error) => { | ||
|
|
@@ -2159,6 +2170,80 @@ function NoCodeModel({ nodeData }) { | |
| ); | ||
| }; | ||
|
|
||
| // Find all ancestor and descendant node IDs for a given model | ||
| const getRelatedNodeIds = (allEdges, selectedLabel, allNodes) => { | ||
| const nodeByLabel = {}; | ||
| allNodes.forEach((n) => { | ||
| nodeByLabel[n.data.originalLabel || n.data.label] = n.id; | ||
| }); | ||
| const selectedId = nodeByLabel[selectedLabel]; | ||
| if (!selectedId) return null; | ||
|
|
||
| const related = new Set([selectedId]); | ||
| const findAncestors = (id) => { | ||
| allEdges.forEach((e) => { | ||
| if (e.target === id && !related.has(e.source)) { | ||
| related.add(e.source); | ||
| findAncestors(e.source); | ||
| } | ||
| }); | ||
| }; | ||
| const findDescendants = (id) => { | ||
| allEdges.forEach((e) => { | ||
| if (e.source === id && !related.has(e.target)) { | ||
| related.add(e.target); | ||
| findDescendants(e.target); | ||
| } | ||
| }); | ||
| }; | ||
| findAncestors(selectedId); | ||
| findDescendants(selectedId); | ||
| return related; | ||
| }; | ||
|
|
||
| const applyScopedStyles = (layoutedNodes, layoutedEdges, selectedLabel) => { | ||
| const rawEdges = layoutedEdges.map((e) => ({ | ||
| source: e.source, | ||
| target: e.target, | ||
| })); | ||
| const related = getRelatedNodeIds(rawEdges, selectedLabel, layoutedNodes); | ||
| if (!related) return { nodes: layoutedNodes, edges: layoutedEdges }; | ||
|
|
||
| const styledNodes = layoutedNodes.map((node) => { | ||
| const nodeLabel = node.data.originalLabel || node.data.label; | ||
| const isSelected = nodeLabel === selectedLabel; | ||
| const isRelated = related.has(node.id); | ||
| return { | ||
| ...node, | ||
| style: { | ||
| ...node.style, | ||
| opacity: isRelated ? 1 : 0.25, | ||
| border: isSelected | ||
| ? "2px dashed #1677ff" | ||
| : node.style?.border || "1px solid var(--black)", | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| const relatedEdgeSet = new Set(); | ||
| layoutedEdges.forEach((e) => { | ||
| if (related.has(e.source) && related.has(e.target)) { | ||
| relatedEdgeSet.add(e.id); | ||
| } | ||
| }); | ||
|
|
||
| const styledEdges = layoutedEdges.map((edge) => ({ | ||
| ...edge, | ||
| style: { | ||
| ...edge.style, | ||
| opacity: relatedEdgeSet.has(edge.id) ? 1 : 0.15, | ||
| stroke: relatedEdgeSet.has(edge.id) ? "#1677ff" : undefined, | ||
| }, | ||
| })); | ||
|
|
||
| return { nodes: styledNodes, edges: styledEdges }; | ||
| }; | ||
|
|
||
| const getLineageData = (callSample = false) => { | ||
| if (!projectId) return; | ||
| setLineageData(); | ||
|
Comment on lines
2170
to
2249
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIThis is a comment left during a code review.
Path: frontend/src/ide/editor/no-code-model/no-code-model.jsx
Line: 2170-2249
Comment:
**Duplicated `getRelatedNodeIds` / `applyScopedStyles`**
`getRelatedNodeIds` and `applyScopedStyles` are copied verbatim into both `no-code-model.jsx` and `lineage-tab.jsx`. Consider extracting them into a shared utility (e.g., `src/ide/editor/lineage-utils.js`) so that any future fix or enhancement only needs to be applied once.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed — extracting to a shared |
||
|
|
@@ -2174,8 +2259,18 @@ function NoCodeModel({ nodeData }) { | |
| setLineageData(data); | ||
| const { nodes: layoutedNodes, edges: layoutedEdges } = | ||
| getLayoutedElements(data.nodes, data.edges, lineageLayoutDirection); | ||
| setNodes(layoutedNodes); | ||
| setEdges(layoutedEdges); | ||
| if (modelName) { | ||
| const scoped = applyScopedStyles( | ||
| layoutedNodes, | ||
| layoutedEdges, | ||
| modelName | ||
| ); | ||
| setNodes(scoped.nodes); | ||
| setEdges(scoped.edges); | ||
| } else { | ||
| setNodes(layoutedNodes); | ||
| setEdges(layoutedEdges); | ||
| } | ||
| }) | ||
| .catch((error) => { | ||
| console.error(error); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectedModelNameprop is never wired up from the call siteThe standalone
LineageTabnow acceptsselectedModelNameand gates all scoping logic on it, buteditor-tabs.jsxonly passesnodeData={tabDetails}with noselectedModelName. The prop will always beundefined, soapplyScopedStylesis never called and the scoping feature is dead code for the standalone lineage tab path.If the intent is to scope the standalone lineage tab when opened from a model, the model name needs to be embedded in the
setPendingLineageTabcall inno-code-model.jsxand forwarded througheditor-tabs.jsxto theLazyLoadComponentthat rendersLineageTab.Prompt To Fix With AI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional — the standalone LineageTab shows the full project lineage by design. The
selectedModelNameprop is optional and prepared for future use (e.g., when opening lineage from a specific model context). The scoping feature is active in the bottom section lineage panel wheremodelNameis always available from the open model tab.