i2group / notebook-sdk

Create plug-ins that expand and enhance the functionality of the i2 Notebook web client by using the i2 Notebook SDK. The SDK is comprised of documentation, tools, and sample code.
https://i2group.github.io/notebook-sdk/
MIT License
4 stars 1 forks source link

Plugin not loading in local running environment #4

Closed stvdo closed 1 year ago

stvdo commented 1 year ago

Good morning,

I created a React plugin, https://i2group.github.io/notebook-sdk/guide/tutorials/react-plugin.html. I worked perfect with the proxy on http://localhost:4000/opal/.

I added the 'script-src': 'unsafe-inline' to the plugin.json and ran 'npm run build'. After this I added the output to my config and redeployed it (Docker setup). But the plugin (button) doesn't appear.

Can you see what I do wrong, or which step I missed?

My entrypoint.js // @ts-check / global notebook / ///

/**

async function main() { const api = await notebook.getEntryPointApi("13225b66-a546-4900-9a04-0f36c3dd17ad", "1.1"); api.logger.info("plug-in running");

const toolView = api.createToolView("React Leaflet Plugin", "./"); const toggle = api.commands.createToolViewToggleCommand( { id: "00000000-0000-0000-0000-000000000007", name: "React Leaflet", icon: { type: "inlineSvg", svg: ' ', }, keyboardHelp: { category: "discover", label: "Toggle record inspector plug-in", keys: ["shift+r"], }, }, toolView ); api.commands.applicationRibbon.homeTab.after(api.commands.applicationRibbon.homeTab.systemGroups.searchInfoStore).surfaceCommands(toggle);

api.initializationComplete(); }

void main();

image image image

Tim-Mawson-i2 commented 1 year ago

Hi sdorresteijn88,

Given you mentioned that it's all working with the devproxy, it's likely that it's the deployment that's causing issues. First, can you confirm that you plugin isn't being loaded at all (you should see something like "Your plugin name" Loading plug-in (<you plugin guid>) in the browser devtools console when opening i2 Notebook).

If the plugin isn't loading, then it might be that you've copied the whole plugin source folder to the i2a-plugins/react-leaflet folder, rather than the built code that's in the build folder of your plugin (build contains the output of the npm run build command) - meaning the deployment can't see your plugin. Try emptying i2s-plugins/react-leaflet and then copying everything inside your original react-leaflet/build to i2a-plugins/react-leaflet.

Tim

stvdo commented 1 year ago

Hi Tim,

Thanks a lot, the problem was indeed that I copied everything instead of only the build folder:(

Anthony-Johnson-i2 commented 1 year ago

Thanks for the swift response @Tim-Mawson-i2.

Closing as solved.