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

Incompatibility with Altair v3 #1

Open
imolorhe opened this issue Jan 1, 2021 · 6 comments
Open

Incompatibility with Altair v3 #1

imolorhe opened this issue Jan 1, 2021 · 6 comments

Comments

@imolorhe
Copy link
Contributor

imolorhe commented Jan 1, 2021

Hello @isaachvazquez!

First, I want to thank you for building this plugin for Altair! This was one of the very few plugins publicly available for Altair, even though it was in beta. I wanted to let you know I appreciate the effort. 🙂

Unfortunately, the plugin architecture has been rewritten, to be more flexible, performant, maintainable, and easier to create. I rewrote it from the ground up, so plugins based on the previous plugin implementation are no longer compatible.

From Altair v3.0.0, older plugins would no longer show up in the plugin finder, or activate when installed.

Considering your plugin was already working with the previous plugin implementation, rewriting it to work with the new architecture should not be too difficult, and I'm willing to help any way I can.

Just a heads up, I am fairly comfortable with the current plugin implementation, and will be removing it from beta (finally 🥳 ), so your migration changes wouldn't go to waste 😄

Thanks again for your contributions!

Reference plugin creation guide: https://altair.sirmuel.design/docs/plugins/writing-plugin.html

@isaachvazquez
Copy link
Contributor

Hey @imolorhe,

Thanks for the heads up. I have a couple questions:

  1. How do I get my new plugin to show up in the app v3.0.0?
  2. Can I test my plugin locally? How do I test it?

Thanks!

@imolorhe
Copy link
Contributor Author

imolorhe commented Jan 6, 2021

@isaachvazquez The testing approach is the same as in the older version. Hosting the plugin locally and using something like url:altair-graphql-plugin-some-plugin@0.0.1::[url]->[http://localhost:8080] to load the local plugin should work fine for testing. The manifest version should be set to 2 for it to show up in the newer version.

@imolorhe
Copy link
Contributor Author

imolorhe commented Jan 6, 2021

Like I mentioned earlier, the plugin API is a bit different. When you define the plugin with an initialize(), you get a context object which gives you access to the available plugin APIs. In your case, you would be using the ctx.app.createAction({ title, execute(state) {} }) method to create the action button with a title and an execute() method to be executed when the button is clicked. The execute context is called with the state of the current window which has this structure: https://github.com/imolorhe/altair/blob/staging/packages/altair-app/src/app/services/plugin/context/plugin-context.service.ts#L166-L180. Hope this helps.

Ps: You can see the graphql explorer plugin using this new API, for reference: https://github.com/XKojiMedia/altair-graphql-plugin-graphql-explorer/blob/master/src/index.js

@isaachvazquez
Copy link
Contributor

@isaachvazquez The testing approach is the same as in the older version. Hosting the plugin locally and using something like url:altair-graphql-plugin-some-plugin@0.0.1::[url]->[http://localhost:8080] to load the local plugin should work fine for testing. The manifest version should be set to 2 for it to show up in the newer version.

@imolorhe Thanks for the reply. It was helpful to see your example plugin. That part makes sense.

Can you help me understand what the "url" should be in this format?
url:altair-graphql-plugin-some-plugin@0.0.1::[url]->[http://localhost:8080]
Is this right?
http://localhost:8080:altair-graphql-plugin-some-plugin::[http://localhost:8080]->[http://localhost:8080]

2 questions:

  1. Do I use that entire string?
  2. Where do I put it once I have the right format? Do I put it in the settings in altair, or in app.component.ts?

Thanks!

@imolorhe
Copy link
Contributor Author

imolorhe commented Jan 6, 2021

Using the graphql explorer plugin example again, I have an npm script that to create a local webserver for the plugin during development: https://github.com/XKojiMedia/altair-graphql-plugin-graphql-explorer/blob/master/package.json#L10

It hosts the plugin at http://localhost:8002, such that http://localhost:8002/manifest.json would return the manifest.json file and so on.

To use this locally hosted version, I can add url:altair-graphql-plugin-graphql-explorer@0.0.1::[url]->[http://localhost:8002] in the plugin list in the settings, and restart Altair. In my case, I now see the created panel since the plugin was successfully installed. You can add console.log in your plugin code while implementing to verify it was properly initialized.

Ps: You don't need to use the Altair source code for this approach. You can use any Altair extensions you already have (chrome extension, firefox addon, desktop app, etc) 🙂

Screenshot 2021-01-06 at 6 13 44 PM

@isaachvazquez
Copy link
Contributor

@imolorhe Thank you much! That's what I needed. It's working now. I'll update my plugin and publish shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants