Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@

instance.on('transaction', () => {
requestAnimationFrame(() => {
requestAnimationFrame(() => {

Check warning on line 128 in openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/hooks/useCustomEditor.ts

View workflow job for this annotation

GitHub Actions / checkstyle

Refactor this code to not nest functions more than 4 levels deep
if (isMounted) {
forceUpdate();
}
Expand All @@ -135,8 +135,17 @@

return () => {
isMounted = false;
// Without this the ProseMirror view, its plugin state and its
// MutationObserver outlive the component. Tables mount one editor per
// description cell, so every pagination click, search keystroke or tab
// switch used to abandon N live instances for the rest of the session.
// The isDestroyed guard mirrors @tiptap/react's own useEditor cleanup —
// StrictMode double-invokes effects, so this can run twice.
if (!instance.isDestroyed) {
instance.destroy();
}
};
}, deps);

Check warning on line 148 in openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/hooks/useCustomEditor.ts

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useEffect has missing dependencies: 'forceUpdate' and 'options'. Either include them or remove the dependency array

Check warning on line 148 in openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/hooks/useCustomEditor.ts

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useEffect was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies

return editor;
};
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
import {
centerNodePosition,
getViewportForLineageExport,
positionNodesUsingElk,
} from '../../utils/EntityLineageLayoutUtils';
import { positionNodesUsingElk } from '../../utils/Lineage/Layout/ElkLayoutUtils';
import {
createNodes,
getConnectedNodesEdges,
Expand Down Expand Up @@ -202,7 +202,7 @@

export const LineageContext = createContext({} as LineageContextType);

const LineageProvider = ({ children }: LineageProviderProps) => {

Check warning on line 205 in openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

{"message":"Function has a complexity of 13 which is greater than 10 authorized.","cost":3,"secondaryLocations":[{"line":205,"column":61,"endLine":205,"endColumn":63,"message":"+1"},{"line":2176,"column":44,"endLine":2176,"endColumn":46,"message":"+1"},{"line":2177,"column":43,"endLine":2177,"endColumn":45,"message":"+1"},{"line":2179,"column":48,"endLine":2179,"endColumn":50,"message":"+1"},{"line":2179,"column":22,"endLine":2179,"endColumn":24,"message":"+1"},{"line":2189,"column":55,"endLine":2189,"endColumn":57,"message":"+1"},{"line":2189,"column":21,"endLine":2189,"endColumn":23,"message":"+1"},{"line":2189,"column":38,"endLine":2189,"endColumn":40,"message":"+1"},{"line":2202,"column":26,"endLine":2202,"endColumn":28,"message":"+1"},{"line":2215,"column":26,"endLine":2215,"endColumn":28,"message":"+1"},{"line":2228,"column":41,"endLine":2228,"endColumn":43,"message":"+1"},{"line":2228,"column":25,"endLine":2228,"endColumn":27,"message":"+1"},{"line":2264,"column":26,"endLine":2264,"endColumn":28,"message":"+1"}]}
const { t } = useTranslation();
const { fqn: decodedFqn } = useFqn();
const location = useCustomLocation();
Expand Down Expand Up @@ -333,7 +333,7 @@
const existingMust = quickFilterQuery?.query?.bool?.must;
const mustArray = Array.isArray(existingMust)
? [...existingMust]
: existingMust

Check warning on line 336 in openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Extract this nested ternary operation into an independent statement
? [existingMust]
: [];

Expand Down Expand Up @@ -467,7 +467,7 @@
outgoingMap,
isColumnLevelLineage
);
}, [

Check warning on line 470 in openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useMemo has an unnecessary dependency: 'isEditMode'. Either exclude it or remove the dependency array
cachedEdgesAndMaps,
entityLineage.edges,
entityFqn,
Expand Down Expand Up @@ -500,7 +500,7 @@
recenter?: string | boolean,
isFirstTime = false,
activeReactFlowInstance = reactFlowInstanceRef.current
) => {

Check warning on line 503 in openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

{"message":"Function has a complexity of 19 which is greater than 10 authorized.","cost":9,"secondaryLocations":[{"line":503,"column":6,"endLine":503,"endColumn":8,"message":"+1"},{"line":504,"column":6,"endLine":504,"endColumn":8,"message":"+1"},{"line":510,"column":30,"endLine":510,"endColumn":32,"message":"+1"},{"line":511,"column":31,"endLine":511,"endColumn":32,"message":"+1"},{"line":524,"column":59,"endLine":524,"endColumn":61,"message":"+1"},{"line":523,"column":63,"endLine":523,"endColumn":65,"message":"+1"},{"line":522,"column":38,"endLine":522,"endColumn":40,"message":"+1"},{"line":531,"column":6,"endLine":531,"endColumn":8,"message":"+1"},{"line":533,"column":10,"endLine":533,"endColumn":11,"message":"+1"},{"line":540,"column":10,"endLine":540,"endColumn":11,"message":"+1"},{"line":550,"column":28,"endLine":550,"endColumn":30,"message":"+1"},{"line":553,"column":22,"endLine":553,"endColumn":23,"message":"+1"},{"line":561,"column":28,"endLine":561,"endColumn":30,"message":"+1"},{"line":566,"column":22,"endLine":566,"endColumn":23,"message":"+1"},{"line":570,"column":6,"endLine":570,"endColumn":8,"message":"+1"},{"line":597,"column":6,"endLine":597,"endColumn":8,"message":"+1"},{"line":602,"column":12,"endLine":602,"endColumn":13,"message":"+1"},{"line":607,"column":8,"endLine":607,"endColumn":10,"message":"+1"},{"line":609,"column":15,"endLine":609,"endColumn":17,"message":"+1"}]}

Check warning on line 503 in openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed
if (!activeReactFlowInstance?.viewportInitialized) {
return;
}
Expand Down Expand Up @@ -619,7 +619,7 @@
setEdges(visibleEdges);
setColumnsHavingLineage(columnsLineageSet);
},
[

Check warning on line 622 in openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has missing dependencies: 'setColumnsHavingLineage', 'setEdges', 'setIsRepositioning', and 'setNodes'. Either include them or remove the dependency array
entityFqn,
isEditMode,
zoomValue,
Expand Down Expand Up @@ -678,7 +678,7 @@
} catch (err) {
showErrorToast(
err as AxiosError,
t('server.entity-fetch-error', {

Check warning on line 681 in openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Define a constant instead of duplicating this literal 4 times
entity: t('label.lineage-data-lowercase'),
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/

import { graphlib, layout } from '@dagrejs/dagre';
import type { ElkExtendedEdge, ElkNode } from 'elkjs/lib/elk.bundled.js';
import type { Edge, Node, ReactFlowInstance } from 'reactflow';
import { Position } from 'reactflow';
import type { ExportViewport } from '../components/Entity/EntityExportModalProvider/EntityExportModalProvider.interface';
Expand All @@ -24,10 +23,6 @@ import {
ZOOM_VALUE,
} from '../constants/Lineage.constants';
import { EntityLineageDirection } from '../enums/entity.enum';
import { useLineageStore } from '../hooks/useLineageStore';
import { getNodeHeight } from './CanvasUtils';
import { getEntityChildrenAndLabel } from './EntityLineageNodeUtils';
import ELKLayout from './Lineage/Layout/ELKUtil/ELKUtil';

interface LayoutedElements {
node: Array<Node & { nodeHeight: number }>;
Expand Down Expand Up @@ -101,70 +96,6 @@ export const getLayoutedElements = (
return { node: uNode, edge: edgesRequired };
};

export const getELKLayoutedElements = async (
nodes: Node[],
edges: Edge[],
columnsHavingLineage: Map<string, Set<string>> = new Map()
) => {
const { nodeFilterState, isColumnLevelLineage, isEditMode } =
useLineageStore.getState();
const elkNodes: ElkNode[] = nodes.map((node) => {
const isColumnOnlyFilterActive =
(isColumnLevelLineage || nodeFilterState.get(node.id)) ?? false;
const columns = isEditMode
? getEntityChildrenAndLabel(node.data.node).children.length
: columnsHavingLineage.get(node.id)?.size ?? 0;

const nodeHeight = getNodeHeight(node, isColumnOnlyFilterActive, columns);

return {
id: node.id,
width: NODE_WIDTH,
height: nodeHeight,
};
});

const elkEdges: ElkExtendedEdge[] = edges.map((edge) => ({
id: edge.id,
sources: [edge.source],
targets: [edge.target],
}));

try {
const layoutedGraph = await ELKLayout.layoutGraph(elkNodes, elkEdges);
const layoutedMap = new Map(
(layoutedGraph?.children ?? []).map((n) => [n.id, n])
);
const updatedNodes: Node[] = nodes.map((node) => {
const layoutedNode = layoutedMap.get(node.id);

return {
...node,
position: { x: layoutedNode?.x ?? 0, y: layoutedNode?.y ?? 0 },
height: layoutedNode?.height ?? node.height,
hidden: false,
};
});

return { nodes: updatedNodes, edges: edges ?? [] };
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error occurred while layouting graph:', error);

return { nodes: [], edges: [] };
}
};

export const positionNodesUsingElk = async (
nodes: Node[],
edges: Edge[],
columnsHavingLineage: Map<string, Set<string>>
) => {
const obj = await getELKLayoutedElements(nodes, edges, columnsHavingLineage);

return obj;
};

export const getNodesBoundsReactFlow = (nodes: Node[]) => {
const bounds = {
xMin: Infinity,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2026 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { ElkExtendedEdge, ElkNode } from 'elkjs/lib/elk.bundled.js';
import type { Edge, Node } from 'reactflow';
import { NODE_WIDTH } from '../../../constants/Lineage.constants';
import { useLineageStore } from '../../../hooks/useLineageStore';
import { getNodeHeight } from '../../CanvasUtils';
import { getEntityChildrenAndLabel } from '../../EntityLineageNodeUtils';

/**
* Lazy boundary for the ELK engine.
*
* elkjs is ~1.37MB in the built bundle and this is the only module that needs
* it. Loading it here — rather than at module scope — keeps it out of whatever
* chunk imports this file. `LineageProvider` is statically imported by eight
* lineage components, so a top-level import would put the engine in the shared
* chunk that every authenticated route pulls, including glossary pages that
* render with G6/antv-dagre and never call ELK.
*/
const loadElkLayout = async () => (await import('./ELKUtil/ELKUtil')).default;

export const getELKLayoutedElements = async (
nodes: Node[],
edges: Edge[],
columnsHavingLineage: Map<string, Set<string>> = new Map()
) => {
const { nodeFilterState, isColumnLevelLineage, isEditMode } =
useLineageStore.getState();
const elkNodes: ElkNode[] = nodes.map((node) => {
const isColumnOnlyFilterActive =
(isColumnLevelLineage || nodeFilterState.get(node.id)) ?? false;
const columns = isEditMode
? getEntityChildrenAndLabel(node.data.node).children.length
: columnsHavingLineage.get(node.id)?.size ?? 0;

const nodeHeight = getNodeHeight(node, isColumnOnlyFilterActive, columns);

return {
id: node.id,
width: NODE_WIDTH,
height: nodeHeight,
};
});

const elkEdges: ElkExtendedEdge[] = edges.map((edge) => ({
id: edge.id,
sources: [edge.source],
targets: [edge.target],
}));

try {
const ELKLayout = await loadElkLayout();
const layoutedGraph = await ELKLayout.layoutGraph(elkNodes, elkEdges);
const layoutedMap = new Map(
(layoutedGraph?.children ?? []).map((n) => [n.id, n])
);
const updatedNodes: Node[] = nodes.map((node) => {
const layoutedNode = layoutedMap.get(node.id);

return {
...node,
position: { x: layoutedNode?.x ?? 0, y: layoutedNode?.y ?? 0 },
height: layoutedNode?.height ?? node.height,
hidden: false,
};
});

return { nodes: updatedNodes, edges: edges ?? [] };
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error occurred while layouting graph:', error);

return { nodes: [], edges: [] };
}
};

export const positionNodesUsingElk = async (
nodes: Node[],
edges: Edge[],
columnsHavingLineage: Map<string, Set<string>>
) => {
const obj = await getELKLayoutedElements(nodes, edges, columnsHavingLineage);

return obj;
};
Loading