diff --git a/webview_panels/src/modules/lineage/LineageView.tsx b/webview_panels/src/modules/lineage/LineageView.tsx index 267e3a8ca..ed2fa573b 100644 --- a/webview_panels/src/modules/lineage/LineageView.tsx +++ b/webview_panels/src/modules/lineage/LineageView.tsx @@ -14,7 +14,7 @@ import DemoButton from "./components/demo/DemoButton"; const LineageView = (): JSX.Element | null => { const { - state: { theme }, + state: { theme, isComponentsApiInitialized }, } = useAppContext(); const [isApiHelperInitialized, setIsApiHelperInitialized] = useState(false); @@ -28,32 +28,14 @@ const LineageView = (): JSX.Element | null => { MissingLineageMessage | undefined >(); - const render = ( - _data: { - node?: Table; - aiEnabled: boolean; - missingLineageMessage?: MissingLineageMessage; - } & StaticLineageProps, - ) => { - panelLogger.log("thisisiit", "render"); - setMissingLineageMessage(_data.missingLineageMessage); - // const event = new CustomEvent("renderStartNode", { - // detail: data, - // }); - // document.dispatchEvent(event); - setRenderNode(_data); + useEffect(() => { + if (!isComponentsApiInitialized) { + return; + } panelLogger.info("LineageView updating components api helper"); // @ts-expect-error TODO: add type generic for executeRequestInSync ApiHelper.get = async (url: string, data?: Record) => { - panelLogger.log("thisisiit", "ApiHelper.get", url, data); switch (url) { - case "init": { - const event = new CustomEvent("renderStartNode", { - detail: _data, - }); - document.dispatchEvent(event); - return; - } case "upstreamTables": case "downstreamTables": case "getExposureDetails": @@ -62,6 +44,7 @@ const LineageView = (): JSX.Element | null => { case "sendFeedback": case "getLineageSettings": case "persistLineageSettings": + case "init": case "openFile": case "openChat": case "showInfoNotification": @@ -76,6 +59,21 @@ const LineageView = (): JSX.Element | null => { } }; setIsApiHelperInitialized(true); + }, [isComponentsApiInitialized]); + + const render = ( + data: { + node?: Table; + aiEnabled: boolean; + missingLineageMessage?: MissingLineageMessage; + } & StaticLineageProps, + ) => { + setMissingLineageMessage(data.missingLineageMessage); + const event = new CustomEvent("renderStartNode", { + detail: data, + }); + document.dispatchEvent(event); + setRenderNode(data); }; const columnLineage = ({ event }: { event: CllEvents }) => { @@ -97,11 +95,6 @@ const LineageView = (): JSX.Element | null => { ( event: MessageEvent<{ command: string; args: Record }>, ) => { - if (!event.origin.startsWith("vscode-webview://")) { - panelLogger.debug("invalid message ", event); - return; - } - panelLogger.log("lineage:message -> ", JSON.stringify(event.data)); const { command, args } = event.data; @@ -119,14 +112,12 @@ const LineageView = (): JSX.Element | null => { document.documentElement.classList.add(styles.lineageBody); executeRequestInAsync("init", {}); }, []); - panelLogger.log("thisisiit", renderNode); - if (!isApiHelperInitialized) { + if (!isApiHelperInitialized || !renderNode) { return null; } - // const lineageType = renderNode.details ? "sql" : "dynamic"; - const lineageType = "dynamic" as "dynamic" | "sql"; + const lineageType = renderNode.details ? "sql" : "dynamic"; return (
@@ -143,7 +134,7 @@ const LineageView = (): JSX.Element | null => {