Skip to content

Commit 218e942

Browse files
authored
Fix: relation filter only show nessary node connection (#27659)
* Fix: relation filter only show nessary node connection * fix lint issue * nit
1 parent ca8dd1e commit 218e942

8 files changed

Lines changed: 467 additions & 472 deletions

File tree

openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/OntologyExplorer.spec.ts

Lines changed: 414 additions & 216 deletions
Large diffs are not rendered by default.

openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/NodeContextMenu.tsx

Lines changed: 0 additions & 158 deletions
This file was deleted.

openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyExplorer.interface.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ export interface OntologyGraphProps {
124124
}
125125
) => void;
126126
onNodeDoubleClick: (node: OntologyNode) => void;
127-
onNodeContextMenu: (
128-
node: OntologyNode,
129-
position: { x: number; y: number }
130-
) => void;
131127
onPaneClick: () => void;
132128
onScrollNearEdge?: () => void;
133129
}
@@ -147,15 +143,6 @@ export interface GraphSettingsPanelProps {
147143
onSettingsChange: (settings: GraphSettings) => void;
148144
}
149145

150-
export interface NodeContextMenuProps {
151-
node: OntologyNode;
152-
position: { x: number; y: number };
153-
onClose: () => void;
154-
onFocus: (node: OntologyNode) => void;
155-
onViewDetails: (node: OntologyNode) => void;
156-
onOpenInNewTab: (node: OntologyNode) => void;
157-
}
158-
159146
export interface OntologyControlButtonsProps {
160147
onZoomIn: () => void;
161148
onZoomOut: () => void;

openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyExplorer.tsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
DEFAULT_FILTERS,
3434
useOntologyExplorer,
3535
} from './hooks/useOntologyExplorer';
36-
import NodeContextMenu from './NodeContextMenu';
3736
import OntologyControlButtons from './OntologyControlButtons';
3837
import { withoutOntologyAutocompleteAll } from './OntologyExplorer.constants';
3938
import {
@@ -99,7 +98,6 @@ const OntologyExplorer: React.FC<OntologyExplorerProps> = ({
9998
filters,
10099
explorationMode,
101100
selectedNode,
102-
contextMenu,
103101
expandedTermIds,
104102
rdfEnabled,
105103
graphDataToShow,
@@ -125,13 +123,8 @@ const OntologyExplorer: React.FC<OntologyExplorerProps> = ({
125123
handleScrollNearEdge,
126124
handleSettingsChange,
127125
handleFiltersChange,
128-
handleContextMenuClose,
129-
handleContextMenuFocus,
130-
handleContextMenuViewDetails,
131-
handleContextMenuOpenInNewTab,
132126
handleGraphNodeClick,
133127
handleGraphNodeDoubleClick,
134-
handleGraphNodeContextMenu,
135128
handleGraphPaneClick,
136129
} = useOntologyExplorer({
137130
scope,
@@ -271,7 +264,6 @@ const OntologyExplorer: React.FC<OntologyExplorerProps> = ({
271264
}
272265
settings={settings}
273266
onNodeClick={handleGraphNodeClick}
274-
onNodeContextMenu={handleGraphNodeContextMenu}
275267
onNodeDoubleClick={handleGraphNodeDoubleClick}
276268
onPaneClick={handleGraphPaneClick}
277269
onScrollNearEdge={handleScrollNearEdge}
@@ -454,17 +446,6 @@ const OntologyExplorer: React.FC<OntologyExplorerProps> = ({
454446
)}
455447
</SlideoutMenu>
456448
)}
457-
458-
{contextMenu && (
459-
<NodeContextMenu
460-
node={contextMenu.node}
461-
position={contextMenu.position}
462-
onClose={handleContextMenuClose}
463-
onFocus={handleContextMenuFocus}
464-
onOpenInNewTab={handleContextMenuOpenInNewTab}
465-
onViewDetails={handleContextMenuViewDetails}
466-
/>
467-
)}
468449
</div>
469450
</div>
470451
</div>

openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/OntologyGraphG6.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import {
1414
forwardRef,
1515
useCallback,
16+
useEffect,
1617
useImperativeHandle,
1718
useRef,
1819
useState,
@@ -38,6 +39,20 @@ function writeNodePositions(
3839
}
3940
}
4041

42+
function writeSearchHighlightIds(
43+
container: HTMLDivElement | null,
44+
ids: readonly string[] | null
45+
) {
46+
if (!container) {
47+
return;
48+
}
49+
if (ids) {
50+
container.dataset.searchHighlightIds = JSON.stringify(ids);
51+
} else {
52+
delete container.dataset.searchHighlightIds;
53+
}
54+
}
55+
4156
const OntologyGraph = forwardRef<OntologyGraphHandle, OntologyGraphProps>(
4257
(
4358
{
@@ -54,7 +69,6 @@ const OntologyGraph = forwardRef<OntologyGraphHandle, OntologyGraphProps>(
5469
focusNodeId,
5570
onNodeClick,
5671
onNodeDoubleClick,
57-
onNodeContextMenu,
5872
onPaneClick,
5973
onScrollNearEdge,
6074
nodePositions,
@@ -111,7 +125,6 @@ const OntologyGraph = forwardRef<OntologyGraphHandle, OntologyGraphProps>(
111125
dataSignature,
112126
onNodeClick,
113127
onNodeDoubleClick,
114-
onNodeContextMenu,
115128
onPaneClick,
116129
onScrollNearEdge,
117130
setClickedEdgeId,
@@ -195,6 +208,15 @@ const OntologyGraph = forwardRef<OntologyGraphHandle, OntologyGraphProps>(
195208
[explorationMode, extractNodePositions, graphRef, suppressEdgeCheck]
196209
);
197210

211+
useEffect(() => {
212+
writeSearchHighlightIds(
213+
containerRef.current,
214+
graphSearchHighlight?.active
215+
? graphSearchHighlight.highlightedNodeIds
216+
: null
217+
);
218+
}, [graphSearchHighlight]);
219+
198220
return (
199221
<div
200222
className="tw:w-full tw:h-full tw:relative ontology-g6-container"

openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/hooks/useOntologyExplorer.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,6 @@ export function useOntologyExplorer({
268268
const [filters, setFilters] = useState<GraphFilters>(DEFAULT_FILTERS);
269269
const [explorationMode, setExplorationMode] =
270270
useState<ExplorationMode>('model');
271-
const [contextMenu, setContextMenu] = useState<{
272-
node: OntologyNode;
273-
position: { x: number; y: number };
274-
} | null>(null);
275271
const [termAssetCounts, setTermAssetCounts] = useState<
276272
Record<string, number>
277273
>({});
@@ -1216,19 +1212,6 @@ export function useOntologyExplorer({
12161212
[filters, graphData]
12171213
);
12181214

1219-
const handleContextMenuClose = useCallback(() => {
1220-
setContextMenu(null);
1221-
}, []);
1222-
1223-
const handleContextMenuFocus = useCallback((node: OntologyNode) => {
1224-
setSelectedNode(node);
1225-
graphRef.current?.focusNode(node.id);
1226-
}, []);
1227-
1228-
const handleContextMenuViewDetails = useCallback((node: OntologyNode) => {
1229-
setSelectedNode(node);
1230-
}, []);
1231-
12321215
const getNodePath = useCallback((node: OntologyNode) => {
12331216
if (node.entityRef?.type && node.entityRef?.fullyQualifiedName) {
12341217
const entityType = Object.values(EntityType).find(
@@ -1251,17 +1234,6 @@ export function useOntologyExplorer({
12511234
return '';
12521235
}, []);
12531236

1254-
const handleContextMenuOpenInNewTab = useCallback(
1255-
(node: OntologyNode) => {
1256-
const path = getNodePath(node);
1257-
if (!path) {
1258-
return;
1259-
}
1260-
window.open(path, '_blank');
1261-
},
1262-
[getNodePath]
1263-
);
1264-
12651237
const handleRefresh = useCallback(() => {
12661238
if (explorationMode === 'data') {
12671239
if (scope === 'global') {
@@ -1375,7 +1347,6 @@ export function useOntologyExplorer({
13751347
dataModeLoadMoreBadgeClick?: boolean;
13761348
}
13771349
) => {
1378-
setContextMenu(null);
13791350
if (explorationMode === 'data' && isTermNode(node)) {
13801351
if (meta?.dataModeLoadMoreBadgeClick) {
13811352
const loaded = node.loadedAssetCount ?? 0;
@@ -1429,15 +1400,7 @@ export function useOntologyExplorer({
14291400
[getNodePath]
14301401
);
14311402

1432-
const handleGraphNodeContextMenu = useCallback(
1433-
(node: OntologyNode, position: { x: number; y: number }) => {
1434-
setContextMenu({ node, position });
1435-
},
1436-
[]
1437-
);
1438-
14391403
const handleGraphPaneClick = useCallback(() => {
1440-
setContextMenu(null);
14411404
setSelectedNode(null);
14421405
}, []);
14431406

@@ -1451,7 +1414,6 @@ export function useOntologyExplorer({
14511414
filters,
14521415
explorationMode,
14531416
selectedNode,
1454-
contextMenu,
14551417
expandedTermIds,
14561418
rdfEnabled,
14571419
graphDataToShow,
@@ -1477,13 +1439,8 @@ export function useOntologyExplorer({
14771439
handleScrollNearEdge,
14781440
handleSettingsChange,
14791441
handleFiltersChange,
1480-
handleContextMenuClose,
1481-
handleContextMenuFocus,
1482-
handleContextMenuViewDetails,
1483-
handleContextMenuOpenInNewTab,
14841442
handleGraphNodeClick,
14851443
handleGraphNodeDoubleClick,
1486-
handleGraphNodeContextMenu,
14871444
handleGraphPaneClick,
14881445
};
14891446
}

0 commit comments

Comments
 (0)