outroll / vesta

VESTA Control Panel
http://vestacp.com
GNU General Public License v3.0
2.97k stars 1.03k forks source link

Building plugins for the new vesta react interface #2148

Open ismaelyws opened 3 years ago

ismaelyws commented 3 years ago

We built a plugin for VestaCP however it isn't compatible with the new vesta react interface.

How do we go about adapting our plugin for the new interface?

We have never built anything with React before so if you can point us in the right direction that will help.

Thank you!

benyaminl commented 3 years ago

If you ever work with jQuery and AJAX, react work like that. Everything is based on API and client side script.

The code is reside at /src/react for now

You can also try to see the component based concept on https://reactjs.org/docs/rendering-elements.html and https://reactjs.org/docs/components-and-props.html

After those 12 tuts, you're good to go, It's like working on Laravel Blade, CI/Symphony Twig, or Other MVVM or MVC concept. you can also see the API on https://github.com/serghey-rodin/vesta/tree/master/web/api , well we can all it AJAX to the API endpoint. It's just like that.

Take example for https://github.com/serghey-rodin/vesta/blob/bba7400b8a01d462dae4b2f805866c2ac5efbf00/web/file_manager/fm_api.php

It;s the endpoint for file manager, and you can see that it use the old API wraped the old PHP classes into AJAX mode https://github.com/serghey-rodin/vesta/blob/master/web/file_manager/fm_core.php

Well it's fun and powerful at same time, as browser now can load component based API, the client side render the view, the server only process the backend request. It's simple as that.

The example file manager directory component is in https://github.com/serghey-rodin/vesta/blob/master/src/react/src/components/Lists/DirectoryList/DirectoryList.jsx and the GUI is in https://github.com/serghey-rodin/vesta/blob/master/src/react/src/containers/FileManager/FileManager.js#L421-L477

For import or such, see https://www.typescriptlang.org/docs/handbook/modules.html

I hope that help in certain ways.

After everything done, you need to build the code as min/prod, and put on /web/static/ folder. Let builded code work for you.

ismaelyws commented 3 years ago

Thanks for that @benyaminl