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

Extendable bundle? #66

Open
Invincible83 opened this issue Nov 4, 2023 · 5 comments
Open

Extendable bundle? #66

Invincible83 opened this issue Nov 4, 2023 · 5 comments

Comments

@Invincible83
Copy link

Invincible83 commented Nov 4, 2023

Hello,

Is there any way to extend setup plugin in bundle? I would like to add a new page with extra settings. However I want to keep the OpenPlatform intact.

I'm thinking something like this:

bundles/openplatform.bundle
plugins/setup/--index.js
plugins/setup/public/mypage.html
@petersirka
Copy link
Collaborator

Hi @Invincible83,
we have added a small support for extending setup interface.

Quick summary:

  • create a new plugin (your own)
  • add a type exports.type = 'setup';
  • and then you should see your plugin in the setup UI

@Invincible83
Copy link
Author

Hello,

Nice. This is extactly what I mean. Is there something else I should do? I'm trying it and this is where I get, as far. (I used the profiles plugin from openplatform-application for testing)

This is the openplatform directory structure

bundles/openplatform.bundle
plugins/profiles/index.js
plugins/profiles/public/index.html
plugins/profiles/...

index.js

exports.icon = 'ti ti-totaljs';
exports.name = '@(Profiles)';
exports.position = 2;
exports.permissions = [{ id: 'profiles', name: 'Profiles' }];
exports.visible = user => user.sa || user.permissions.includes('profiles');
exports.type = 'setup'; // extends the `setup` plugin
exports.routes = [
	{ url: '/profiles/{id}/', html: 'detail' }
];

exports.install = function() {
	ROUTE('+API    /api/    -profiles    *Profiles   --> list');
};

It kind of works. I have profiles link in setup menu. Yet, when I click on it, I get this errors in the console

mytesting.com/_profiles/pages/setup.html?language=en 404 (Not Found)
jC: invalid response for IMPORT("/_profiles/pages/setup.html")  [{…}]

Sorry to bother you,
Thank you

@petersirka
Copy link
Collaborator

I tested it. I don't know about it, but you must move the file /public/index.html to /public/pages/index.html and it will work. Be careful with API endpoints, they must be in the form /setup/.

@Invincible83
Copy link
Author

Can you please upload your testing version?

As far I see, there https://github.com/totaljs/openplatform/blob/master/plugins/setup/index.js#L55-L63 is no obj.routes even in setup/index.html it's counting on it. https://github.com/totaljs/openplatform/blob/master/plugins/setup/index.html#L80C1-L86

And there is static setup.html. I believe this should be index.html. https://github.com/totaljs/openplatform/blob/master/plugins/setup/index.html#L79

@Invincible83
Copy link
Author

Sure, so I had some time to spare and did some tests. I found that my suspicions were correct. It's the /setup.html in the component. The second I changed it to /index.html , it started working.

https://github.com/totaljs/openplatform/blob/master/plugins/setup/index.html#L79C95-L79C112

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