Description of problem: UI plugin API performs requested actions only if the given plugin is either initializing (code within UiInit callback) or in use (code within other callbacks). This means all API actions are no-op while the plugin is loading (before the plugin calls ready function that triggers UiInit callback). Some API functions are "harmless" (e.g. without visual or other side effects): - loginUserName - loginUserId - ssoToken - engineBaseUrl - currentLocale For above mentioned actions, API should allow their execution even while the plugin is still loading. Why is this important: let plugins do proper initialization (using api.currentLocale for example) *before* calling api.ready function. There is no impact on existing UI plugins. Steps to Reproduce: 1. var locale = api.currentLocale() 2. api.ready() 3. console.log('locale = ' + locale) Actual results: locale = undefined Expected results: locale = en-US (or similar)
This change is low risk and has no impact on existing UI plugins. The practical effect is relaxing the condition when UI plugin API interaction is allowed, but only for specific ("harmless") API functions.
Created attachment 1185592 [details] UI plugin used to verify the new API behavior
Attached test UI plugin to ease the verification. After loading WebAdmin page, browser console should say: ---Before ready call null null <actual-sso-token> <base-engine-path> <webadmin-locale> ---After ready call null null <actual-sso-token> <base-engine-path> <webadmin-locale> The first two nulls are for loginUserName + loginUserId. This is expected behavior due to adopting SSO. I'll post another patch to address that.
(In reply to vszocs from comment #3) > The first two nulls are for loginUserName + loginUserId. This is expected > behavior due to adopting SSO. It's actually a bug, I've got the fix ready, will open a separate BZ on that.
Pavel - can you qe-ack?
Verified in rhevm-4.0.2.6-0.1.el7ev.noarch ovirt-engine-webadmin-portal-4.0.2.6-0.1.el7ev.noarch Verification: I verified with Vojta's test UI plugin from attachment 1185592 [details]. After reloading the Webadmin page, the browser console says: -~- Tue Aug 16 19:22:23 GMT+200 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager INFO: Plugin [loading-test] has registered the event handler object plugin.html:11 ---Before ready call plugin.html:12 null plugin.html:13 null plugin.html:14 YC6XzGIlksd_GMYqM5PbtcqsD12ff7Goz7EF6u869Egd52lu9aWkWgSQ8dZJeJTbBhBk0Bn_43tSEBaQchnGvw plugin.html:15 https://rhvm.example.com/ovirt-engine/ plugin.html:16 en-US webadmin-0.js:15466 Tue Aug 16 19:22:23 GMT+200 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager INFO: Plugin [loading-test] reports in as ready webadmin-0.js:15466 Tue Aug 16 19:22:24 GMT+200 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager INFO: Plugin [dashboard] has registered the event handler object webadmin-0.js:15466 Tue Aug 16 19:22:24 GMT+200 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager INFO: Plugin [dashboard] reports in as ready ... ... Tue Aug 16 19:22:26 GMT+200 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager INFO: Invoking event handler function [UiInit] for plugin [loading-test] plugin.html:11 ---After ready call plugin.html:12 admin@internal-authz plugin.html:13 0000002c-002c-002c-002c-000000000411 plugin.html:14 YC6XzGIlksd_GMYqM5PbtcqsD12ff7Goz7EF6u869Egd52lu9aWkWgSQ8dZJeJTbBhBk0Bn_43tSEBaQchnGvw plugin.html:15 https://rhvm.example.com/ovirt-engine/ plugin.html:16 en-US webadmin-0.js:15466 Tue Aug 16 19:22:26 GMT+200 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager INFO: Plugin [loading-test] is initialized and in use now webadmin-0.js:15466 Tue Aug 16 19:22:26 GMT+200 2016 org.ovirt.engine.ui.webadmin.plugin.PluginManager INFO: Invoking event handler function [UserLogin] for plugin [loading-test] -~-