Skip to content
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

Adding export lineage #1257

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
7 changes: 6 additions & 1 deletion new_lineage_panel/src/ActionWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "reactflow/dist/style.css";
import { Alert, Button, Card, CardBody } from "reactstrap";
import ResetIcon from "./assets/icons/reset.svg?react";
import HelpIcon from "./assets/icons/help.svg?react";
import DownloadIcon from "./assets/icons/download-button.svg?react";
import FeedbackIcon from "./assets/icons/feedback.svg?react";
import ExpandIcon from "./assets/icons/expand.svg?react";
import ArrowLeftDoubleIcon from "./assets/icons/arrow-left-double.svg?react";
Expand All @@ -11,7 +12,7 @@ import ArrowLeftIcon from "./assets/icons/arrow-left.svg?react";
import ArrowRightIcon from "./assets/icons/arrow-right.svg?react";
import GearIcon from "./assets/icons/gear.svg?react";
import styles from "./styles.module.scss";
import { HELP_SIDEBAR, SETTINGS_SIDEBAR } from "./constants";
import { HELP_SIDEBAR, SETTINGS_SIDEBAR, EXPORT_SIDEBAR } from "./constants";
import { init, openURL, setLegacyLineageView, CLL, requestExecutor } from "./service_utils";
import { LineageContext, MissingLineageMessage, aiEnabled } from "./Lineage";
import { useReactFlow } from "reactflow";
Expand Down Expand Up @@ -351,6 +352,10 @@ export const ActionWidget = ({missingLineageMessage}: {missingLineageMessage?: M
<FeedbackIcon />
<span>Feedback</span>
</ActionButton>
<ActionButton onClick={() => setSidebarScreen(EXPORT_SIDEBAR)}>
<DownloadIcon />
<span>Export Lineage</span>
</ActionButton>
</div>
);
};
37 changes: 37 additions & 0 deletions new_lineage_panel/src/ExportLineage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Button } from "reactstrap";
import styles from "./styles.module.scss";
import { exportLineage } from "./service_utils";
// import { saveLineage } from "./exporter";

// When the saveLineage is imported and used in the onClick this makes the lineage panel white and unusable
function ExportLineage() {
return (
<div className="p-3 h-100 d-flex flex-column overflow-y">
<div className="mb-2 d-flex">
<div className="fw-semibold fs-5">Export Lineage</div>
<div className="spacer"></div>
<Button
size="sm"
color="primary"
onClick={() => {
exportLineage();
// saveLineage("active-frame");
}}
>
Download
</Button>
</div>
<div className={styles.help_body}>
<p>
Placeholder text for the side panel.
This is to contain options related
to download quality and location.
</p>


</div>
</div>
);
}

export { ExportLineage };
3 changes: 3 additions & 0 deletions new_lineage_panel/src/Lineage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ import {
COLUMNS_SIDEBAR,
EXPOSURE_SIDEBAR,
FEEDBACK_SIDEBAR,
EXPORT_SIDEBAR,
HELP_SIDEBAR,
SETTINGS_SIDEBAR,
} from "./constants";
import ExposureDetails from "./ExposureDetails";
import { Feedback } from "./Feedback";
import { Help } from "./Help";
import { ExportLineage } from "./ExportLineage";
import { Demo } from "./Demo";
import {
handleResponse,
Expand Down Expand Up @@ -481,6 +483,7 @@ export const Lineage = () => {
<Feedback close={() => setSidebarScreen("")} />
)}
{sidebarScreen === HELP_SIDEBAR && <Help />}
{sidebarScreen === EXPORT_SIDEBAR && <ExportLineage />}
{sidebarScreen === SETTINGS_SIDEBAR && <Settings />}
</SidebarModal>
<Modal isOpen={showDemoModal} close={() => setShowDemoModal(false)}>
Expand Down
5 changes: 5 additions & 0 deletions new_lineage_panel/src/assets/icons/download-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions new_lineage_panel/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const EXPOSURE_SIDEBAR = "exposure";
export const TABLES_SIDEBAR = "tables";
export const FEEDBACK_SIDEBAR = "feedback";
export const HELP_SIDEBAR = "help";
export const EXPORT_SIDEBAR = "export";
export const SETTINGS_SIDEBAR = "settings";

// react flow prefix for node types
Expand Down
42 changes: 42 additions & 0 deletions new_lineage_panel/src/exporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as htmlToImage from 'html-to-image';

declare const acquireVsCodeApi: () => { postMessage: (v: unknown) => void };

const vscode = acquireVsCodeApi();
// Adding these lines to enable debug logging

function saveLineage(elementId: string) {
console.log('Starting saveLineage function.');

const element = document.getElementById(elementId);

if (!element) {
vscode.postMessage({ command: "error", text: `Element with ID ${elementId} not found.` });
return;
}

console.log('Element found, converting to SVG.');

function filter(node: Node): boolean {
return (node.nodeName !== 'I'); // Filter out <i> tags
}

htmlToImage.toSvg(element, { filter: filter })
.then((dataUrl: string) => {
console.log('SVG conversion successful.');

const downloadLink = document.createElement('a');
downloadLink.href = dataUrl;
downloadLink.download = 'exported_image.svg';
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);

console.log('SVG download initiated and cleanup done.');
})
.catch((error: Error) => {
vscode.postMessage({ command: "error", text: `Error during SVG export: ${error.message}` });
});
}

export { saveLineage };
4 changes: 4 additions & 0 deletions new_lineage_panel/src/service_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const openURL = (url: string) => {
vscode.postMessage({ command: "openURL", args: { url } });
};

export const exportLineage = () => {
vscode.postMessage({ command: "exportToSVG"});
};

export const openChat = () => openURL("https://app.myaltimate.com/contactus");

export const previewFeature = () => {
Expand Down
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@
"@vscode/vsce": "^2.26.1",
"@vscode/webview-ui-toolkit": "^1.4.0",
"dayjs": "^1.11.11",
"html-to-image": "^1.11.11",
"inversify": "^6.0.2",
"inversify-binding-decorators": "^4.0.0",
"node-abort-controller": "^3.1.1",
Expand Down