Skip to content

Commit 8a6e4e4

Browse files
authored
Ontology filter persist (#27702)
* Added filter persist overall mode * Fix name fallback
1 parent aaeab9e commit 8a6e4e4

6 files changed

Lines changed: 19 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export interface OntologyGraphProps {
109109
nodePositions?: Record<string, { x: number; y: number }>;
110110
selectedNodeId?: string | null;
111111
expandedTermIds?: Set<string>;
112+
glossaries: Glossary[];
112113
glossaryColorMap: Record<string, string>;
113114
dataSignature?: string;
114115
explorationMode?: ExplorationMode;
@@ -208,6 +209,7 @@ export interface BuildGraphDataProps {
208209
expandedTermIds?: Set<string>;
209210
clickedEdgeId: string | null;
210211
nodePositions?: Record<string, { x: number; y: number }>;
212+
glossaries: Glossary[];
211213
glossaryColorMap: Record<string, string>;
212214
layoutType: LayoutEngineType;
213215
hierarchyCombos?: HierarchyComboInfo[];

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ const OntologyExplorer: React.FC<OntologyExplorerProps> = ({
243243
? selectedNode?.id ?? entityId
244244
: entityId
245245
}
246+
glossaries={glossaries}
246247
glossaryColorMap={glossaryColorMap}
247248
graphSearchHighlight={graphSearchHighlight}
248249
hierarchyCombos={

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const OntologyGraph = forwardRef<OntologyGraphHandle, OntologyGraphProps>(
6161
settings,
6262
selectedNodeId,
6363
expandedTermIds,
64+
glossaries,
6465
glossaryColorMap,
6566
dataSignature = '',
6667
explorationMode = 'model',
@@ -99,6 +100,7 @@ const OntologyGraph = forwardRef<OntologyGraphHandle, OntologyGraphProps>(
99100
selectedNodeId: selectedNodeId ?? null,
100101
expandedTermIds,
101102
clickedEdgeId,
103+
glossaries,
102104
glossaryColorMap,
103105
hierarchyCombos: hierarchyCombos ?? [],
104106
graphSearchHighlight,

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export function useGraphDataBuilder({
150150
expandedTermIds,
151151
clickedEdgeId,
152152
nodePositions,
153+
glossaries,
153154
glossaryColorMap,
154155
layoutType,
155156
hierarchyCombos = [],
@@ -718,7 +719,10 @@ export function useGraphDataBuilder({
718719
if (terms.length === 0) {
719720
return;
720721
}
721-
const name = terms[0].group ?? glossaryId;
722+
const glossary = glossaries.find((g) => g.id === glossaryId);
723+
const name =
724+
terms[0].group ??
725+
(glossary ? glossary.displayName || glossary.name : '');
722726
const color = glossaryColorMap[glossaryId] ?? 'var(--color-gray-400)';
723727
const isComboDimmed = Boolean(
724728
searchGlossarySet && !searchGlossarySet.has(glossaryId)
@@ -752,6 +756,7 @@ export function useGraphDataBuilder({
752756
explorationMode,
753757
hierarchyCombos,
754758
graphSearchHighlight,
759+
glossaries,
755760
]);
756761

757762
const assetToTermMap = useMemo(() => {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,7 @@ export function useOntologyExplorer({
11901190
if (mode === 'data') {
11911191
modelFiltersRef.current = filters;
11921192
const nextFilters: GraphFilters = {
1193-
...dataFiltersRef.current,
1194-
glossaryIds: filters.glossaryIds,
1193+
...filters,
11951194
viewMode: 'overview' satisfies GraphViewMode,
11961195
};
11971196
if (graphData) {
@@ -1205,7 +1204,10 @@ export function useOntologyExplorer({
12051204
setSelectedNode(null);
12061205
setExpandedTermIds(new Set());
12071206
setExplorationMode(mode);
1208-
setFilters(modelFiltersRef.current);
1207+
setFilters({
1208+
...filters,
1209+
viewMode: modelFiltersRef.current.viewMode,
1210+
});
12091211
setTermAssetCounts({});
12101212
}
12111213
},

openmetadata-ui/src/main/resources/ui/src/components/OntologyExplorer/utils/graphBuilders.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,16 @@ export function buildGraphFromAllTerms(
200200
(term.children && term.children.length > 0) ||
201201
term.parent;
202202

203+
const glossary = glossaryList.find((g) => g.id === term.glossary?.id);
204+
203205
nodesMap.set(term.id, {
204206
id: term.id,
205207
label: term.displayName || term.name,
206208
type: hasRelations ? 'glossaryTerm' : 'glossaryTermIsolated',
207209
fullyQualifiedName: term.fullyQualifiedName,
208210
description: term.description,
209211
glossaryId: term.glossary?.id,
210-
group: glossaryList.find((g) => g.id === term.glossary?.id)?.name,
212+
group: glossary ? glossary.displayName || glossary.name : undefined,
211213
owners: term.owners,
212214
});
213215

0 commit comments

Comments
 (0)