[Engine-devel] Update on UI Plugins feature: PoC patch revision 2

Vojtech Szocs vszocs at redhat.com
Thu Aug 9 16:56:06 UTC 2012


Hi guys, 

I've improved the original plugin infrastructure, please find the 2nd revision of UI Plugins proof-of-concept (PoC) patch attached. 

Here's a quick summary of changes: 

    * PluginSourcePageServlet looks up the actual plugin code in local filesystem (<pluginName>.js), so you can experiment with different plugins. If you want to add new plugins, just modify WebadminDynamicHostingServlet.writeAdditionalJsData() method. 
    * PluginManager now calls UiInit function on plugins (plugin objects) within the scope of WebAdmin main section (user has logged in, main section UI is initialized and ready), and disables plugin execution outside main section (e.g. when the user logs out) . 

(Please find a sample plugin code attached as well. PluginSourcePageServlet tries to load it from a hard-coded location in local filesystem, you probably want to modify this to suit your environment.) 

UiInit function is a special event handler function that gets called once, after plugin reports as ready, and before other event handler functions are called. UiInit function would be a good place to extend default WebAdmin UI (adding main tab, etc.). 

This is illustrated on the following use case: 

    1. user requests WebAdmin page, during initialization a plugin iframe gets created and attached to DOM, plugin HTML page gets requested asynchronously, application init code still runs so iframe plugin code evaluation is blocked (this is because of JavaScript runtime being single-threaded in its nature) 
    2. application init code finishes, plugin code gets evaluated, plugin registers itself into pluginApi.plugins and reports back as ready (calls the ready function) 
    3. since the user is still in login section (not logged into WebAdmin), plugin invocation is disabled, until the user logs in 
    4. user logs into the application, UI redirects to main section, and after UI gets initialized, plugin invocation is enabled 
    5. UiInit function is called on the plugin 
    6. <NOT IMPLEMENTED YET> user performs some actions and WebAdmin calls different functions on the plugin 
    7. assume the user logs out, plugin invocation is disabled, until the user logs in again 
    8. user logs in again, but UiInit isn't called now because it has been called already before 
    9. goto step 6 

The reason why UiInit is called just once (after visiting main section for the first time), is because WebAdmin UI (Views) are mostly singletons, so even when you switch to different section (login section) and go to main section again, singleton Views will still be there, with any adjustments/extensions made previously by plugins. 

Now, as for the next steps, we can proceed with actual tasks Itamar outlined in his email: 

    * use UiInit event to extend UI (add main tab, etc.) 
    * define other events (table context menu event, etc.) 
    * allow plugins to do REST API calls through pluginApi object 

I've tried to implement "add main tab" functionality. Unfortunately, this isn't quite easy to do with GWT-Platform (GWTP) framework we use. Each tab in WebAdmin has some place (GWT history token = URL hash fragment) associated. The way GWTP handles tabs is that individual tabs (Presenter) reveal themselves into tab container (TabContainerPresenter), with presenter reveal flow being processed bottom-up. I strongly suggest to go through [http://code.google.com/p/gwt-platform/wiki/GettingStarted] to get some basic understanding of GWTP framework and how tabs work in general. 

Long story short, to add tabs dynamically in a proper way, we need to write custom presenter proxy, here are some links on this matter: 
Discussion [https://groups.google.com/forum/#!topic/gwt-platform/aJrGOf9Gu04/discussion ] 
Dynamic tab example [http://code.google.com/r/goudreauchristian-update/source/browse/ ] 
Working demo [http://olivier.monaco.free.fr/lab/gwtp-editor/] 

So adding main/sub tabs is a task that will require some additional work, especially since we wish to combine both static tabs and dynamic tabs in one tab container. I'll try to work on this one. 

On the other hand, it would be great if others could take the latest PoC patch (attached), and experiment with other stuff like context menu events, REST API calls, etc. You can always reach me on #ovirt (vszocs) if you have a question or need help with anything. 

Cheers, 
Vojtech 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/engine-devel/attachments/20120809/d098ad7a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myPlugin.js.example
Type: application/octet-stream
Size: 276 bytes
Desc: not available
URL: <http://lists.ovirt.org/pipermail/engine-devel/attachments/20120809/d098ad7a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-WIP-UI-Plugins-PoC-revision-2.patch
Type: text/x-patch
Size: 23281 bytes
Desc: not available
URL: <http://lists.ovirt.org/pipermail/engine-devel/attachments/20120809/d098ad7a/attachment.bin>


More information about the Engine-devel mailing list