-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Chore(UI): Improve relation traverse functionality in knowledge graph #27883
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 all commits
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 |
|---|---|---|
|
|
@@ -100,6 +100,7 @@ import { | |
| ZOOM_OUT_FACTOR, | ||
| } from './KnowledgeGraph.constants'; | ||
| import { | ||
| EdgeTooltipState, | ||
| GraphData, | ||
| GraphNode, | ||
| KnowledgeGraphLayout, | ||
|
|
@@ -127,6 +128,7 @@ const KnowledgeGraph: React.FC<KnowledgeGraphProps> = ({ | |
| const [selectedDepth, setSelectedDepth] = useState(depth); | ||
| const [layout, setLayout] = useState<KnowledgeGraphLayout>('dagre'); | ||
| const [selectedNode, setSelectedNode] = useState<GraphNode | null>(null); | ||
| const [edgeTooltip, setEdgeTooltip] = useState<EdgeTooltipState | null>(null); | ||
| const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]); | ||
| const [selectedRelationshipTypes, setSelectedRelationshipTypes] = useState< | ||
| string[] | ||
|
|
@@ -392,6 +394,7 @@ const KnowledgeGraph: React.FC<KnowledgeGraphProps> = ({ | |
|
|
||
| const focusNodeId = entity?.id | ||
| ? (g6Data.nodes ?? []).find( | ||
| // Server may prefix IDs (e.g. "table::<uuid>"); suffix-match the raw UUID to cover both forms. | ||
| (n) => n.id === entity.id || n.id.endsWith(entity.id) | ||
| )?.id ?? entity.id | ||
| : ''; | ||
|
|
@@ -544,6 +547,8 @@ const KnowledgeGraph: React.FC<KnowledgeGraphProps> = ({ | |
| pendingHighlightRef, | ||
| selectedNodeIdRef, | ||
| setSelectedNode, | ||
| setEdgeTooltip, | ||
| canvasRef: containerRef, | ||
| }); | ||
|
|
||
| resizeObserver = new ResizeObserver(() => { | ||
|
|
@@ -728,6 +733,27 @@ const KnowledgeGraph: React.FC<KnowledgeGraphProps> = ({ | |
| ))} | ||
| </div> | ||
|
|
||
| {edgeTooltip && ( | ||
| <div | ||
| aria-hidden="true" | ||
| className="kg-edge-tooltip" | ||
| data-testid="edge-tooltip" | ||
| style={{ | ||
| left: edgeTooltip.x + 12, | ||
| position: 'fixed', | ||
| top: edgeTooltip.y + 12, | ||
| }}> | ||
| <div className="kg-edge-tooltip__direction"> | ||
| {`${edgeTooltip.sourceLabel} → ${edgeTooltip.targetLabel}`} | ||
|
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. 💡 Quality: Hardcoded strings in edge tooltip instead of i18nThe edge tooltip in KnowledgeGraph.tsx line 747 uses a template literal with a hardcoded Was this helpful? React with 👍 / 👎 | Reply |
||
| </div> | ||
| {edgeTooltip.labels.map((label) => ( | ||
| <div className="kg-edge-tooltip__label" key={label}> | ||
|
Comment on lines
+749
to
+750
|
||
| {label} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| )} | ||
|
|
||
| {selectedNode?.fullyQualifiedName && ( | ||
| <SlideoutMenu | ||
| isDismissable | ||
|
|
||
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.
💡 Quality: Hardcoded colors in tooltip styles violate theming guidelines
The new
.kg-edge-tooltipstyles inKnowledgeGraph.style.lessuse hardcodedrgba(0, 0, 0, ...)values for text colors, borders, and shadows (lines 128, 137, 145, 131). Per the project's frontend architecture guidelines, semantic CSS custom properties (--color-*,--shadow-*) should be used instead of hardcoded color values to ensure consistency with the theme system.Was this helpful? React with 👍 / 👎 | Reply
gitar fixto apply this suggestion