@@ -34,6 +34,7 @@ import {
3434} from "./lib/jumpToStatement" ;
3535import { INTERNAL_SETTINGS , SETTINGS } from "src/settings" ;
3636import { generateTextForContext } from "./lib/generateTextForContext" ;
37+ import { exportGraphToInfraNodus } from "./lib/exportGraphToInfraNodus" ;
3738import { unObserveElementAttributes } from "src/utils/observer" ;
3839import { GraphViewOverlaySettings } from "./components/GraphViewOverlaySettings" ;
3940import { InfoTooltip } from "src/components/InfoTootip" ;
@@ -59,7 +60,6 @@ import { TopicsObject } from "src/types/general";
5960
6061import { jwtDecode } from "jwt-decode" ;
6162
62- import { GraphNameModal } from "../components/GraphNameModal" ;
6363
6464import { GraphPanel } from "./types" ;
6565
@@ -155,11 +155,6 @@ const GraphView = (params: {
155155
156156 const auth_token = SETTINGS . INFRANODUS_API_KEY ;
157157
158- const exportToInfraNodus = {
159- type : SETTINGS . EXPORT_TYPE ,
160- graphName : SETTINGS . EXPORT_GRAPH ,
161- } ;
162-
163158 // Seeding from the cache keeps the iframe src stable from the first
164159 // render — an src change mid-load reboots the graph viewer
165160 const cachedUserId = InfraNodus . getCachedUserId ( ) ;
@@ -1201,11 +1196,16 @@ const GraphView = (params: {
12011196 . map ( ( statement ) => statement . content )
12021197 . join ( "\n" ) ;
12031198
1204- goToInfraNodus ( {
1205- textToShow : contentToCopy ,
1206- contextName : filePath ,
1207- exportToInfraNodus,
1208- vaultName,
1199+ exportGraphToInfraNodus ( {
1200+ app,
1201+ text : contentToCopy ,
1202+ defaultGraphName :
1203+ encodeInfraNodusGraphName (
1204+ filePath || "" ,
1205+ SETTINGS . EXPORT_GRAPH ,
1206+ vaultName
1207+ ) ,
1208+ sourceFile : filePath ,
12091209 } ) ;
12101210
12111211 setTimeout (
@@ -1448,59 +1448,3 @@ function convertGraphToText(params: {
14481448 }
14491449 return graphText ;
14501450}
1451-
1452- async function goToInfraNodus ( {
1453- textToShow = "" ,
1454- contextName = "" ,
1455- exportToInfraNodus = { type : "manual" , graphName : "" } ,
1456- vaultName = "" ,
1457- } ) {
1458- if ( ! textToShow || textToShow === "ai generating..." ) {
1459- // console.log("no data to send to InfraNodus");
1460- return ;
1461- }
1462-
1463- const encodedText = encodeURIComponent ( textToShow ) ;
1464- const encodedContext = encodeInfraNodusGraphName (
1465- contextName ,
1466- SETTINGS . EXPORT_GRAPH ,
1467- vaultName
1468- ) ;
1469-
1470- const linkToOpen = `${ SETTINGS . INFRANODUS_API_URL } /import/editor?text=${ encodedText } &context=${ encodedContext } ` ;
1471-
1472- if ( exportToInfraNodus && exportToInfraNodus . type === "auto" ) {
1473- // Change the context name to just be the page title?
1474- const graphTags = [ `context: ${ encodedContext } ` ] ;
1475- let graphName = encodedContext ;
1476-
1477- // Show dialog to confirm/edit graph name
1478- graphName =
1479- ( await new Promise < string | null > ( ( resolve ) => {
1480- new GraphNameModal ( app , graphName , resolve ) . open ( ) ;
1481- } ) ) || "" ;
1482-
1483- if ( ! graphName ) {
1484- return ;
1485- }
1486-
1487- const dataToSave = {
1488- contextName : graphName ,
1489- text : textToShow ,
1490- tags : graphTags ,
1491- } ;
1492-
1493- const exportStatus = await InfraNodus . exportText ( dataToSave ) ;
1494-
1495- // console.log("InfraNodus export status", exportStatus);
1496- if ( exportStatus . error ) {
1497- alert (
1498- `There was an error saving to the ${ graphName } graph in InfraNodus. Reload the page and try again or change your extension setting.`
1499- ) ;
1500- } else {
1501- alert ( `Saved to the ${ graphName } graph in InfraNodus` ) ;
1502- }
1503- } else {
1504- window . open ( linkToOpen , "_blank" ) ;
1505- }
1506- }
0 commit comments