lineage export improvement around selector (#20669)

This commit is contained in:
Ashish Gupta 2025-04-07 18:51:06 +05:30 committed by GitHub
parent b7d43e7ee2
commit e154dbbcc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 7 deletions

View File

@ -131,6 +131,7 @@ const Lineage = ({
<div
className="h-full relative lineage-container"
data-testid="lineage-container"
id="lineage-container" // ID is required for export PNG functionality
ref={reactFlowWrapper}>
{entityLineage && (
<>

View File

@ -15,3 +15,6 @@ export enum ExportTypes {
PNG = 'PNG',
PDF = 'PDF',
}
export const LINEAGE_EXPORT_SELECTOR =
'#lineage-container .react-flow__viewport';

View File

@ -56,7 +56,10 @@ import {
import LineageNodeRemoveButton from '../../components/Lineage/LineageNodeRemoveButton';
import { SourceType } from '../../components/SearchedData/SearchedData.interface';
import { ROUTES } from '../../constants/constants';
import { ExportTypes } from '../../constants/Export.constants';
import {
ExportTypes,
LINEAGE_EXPORT_SELECTOR,
} from '../../constants/Export.constants';
import {
ELEMENT_DELETE_STATE,
ZOOM_VALUE,
@ -460,8 +463,8 @@ const LineageProvider = ({ children }: LineageProviderProps) => {
name: decodedFqn,
exportTypes: [ExportTypes.CSV, ExportTypes.PNG],
}),
documentSelector: '.react-flow__viewport',
viewport: getViewportForLineageExport(nodes),
documentSelector: LINEAGE_EXPORT_SELECTOR,
viewport: getViewportForLineageExport(nodes, LINEAGE_EXPORT_SELECTOR),
onExport: exportLineageData,
});
}

View File

@ -1717,10 +1717,11 @@ export const getViewportForBoundsReactFlow = (
return { x: translateX, y: translateY, zoom: scale };
};
export const getViewportForLineageExport = (nodes: Node[]): ExportViewport => {
const exportElement = document.querySelector(
'.react-flow__viewport'
) as HTMLElement;
export const getViewportForLineageExport = (
nodes: Node[],
documentSelector: string
): ExportViewport => {
const exportElement = document.querySelector(documentSelector) as HTMLElement;
const imageWidth = exportElement.scrollWidth;
const imageHeight = exportElement.scrollHeight;