Bug 1361255 - UI plugin API: allow executing certain actions while the plugin is loading
Summary: UI plugin API: allow executing certain actions while the plugin is loading
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: Frontend.WebAdmin
Version: 4.0.2
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ovirt-4.0.2
: 4.0.2.4
Assignee: Vojtech Szocs
QA Contact: Pavel Novotny
URL:
Whiteboard:
Depends On:
Blocks: 1351585
TreeView+ depends on / blocked
 
Reported: 2016-07-28 15:39 UTC by Vojtech Szocs
Modified: 2016-08-17 14:44 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Background: UI plugin API performs requested actions only if the given plugin is either initializing (within UiInit callback) or in use (within other callbacks). This means all API actions are no-op while the plugin is loading, e.g. before the plugin calls the ready() function that triggers the UiInit callback. Feature: Allow following API functions to be executed also while the plugin is loading: - loginUserName - loginUserId - ssoToken - engineBaseUrl - currentLocale Above functions are considered "safe to call while loading" as they have no visual or other side effects on WebAdmin UI. Reason: Let UI plugins call above functions within their init code, e.g. before the plugin calls ready() to signal that it's ready for use. Result: Plugins able to call above functions within their init code.
Clone Of:
Environment:
Last Closed: 2016-08-17 14:44:56 UTC
oVirt Team: UX
Embargoed:
rule-engine: ovirt-4.0.z+
rule-engine: exception+
rule-engine: planning_ack+
oourfali: devel_ack+
pstehlik: testing_ack+


Attachments (Terms of Use)
UI plugin used to verify the new API behavior (532 bytes, application/x-gzip)
2016-07-29 15:21 UTC, Vojtech Szocs
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1361656 0 unspecified CLOSED UI plugin API: loginUserName and loginUserId functions return null before WebAdmin UI is fully initialized 2021-02-22 00:41:40 UTC
oVirt gerrit 61664 0 master MERGED webadmin: Allow UI plugins to run certain actions while loading 2016-08-01 14:42:25 UTC
oVirt gerrit 61778 0 ovirt-engine-4.0 MERGED webadmin: Allow UI plugins to run certain actions while loading 2016-08-01 17:18:26 UTC
oVirt gerrit 61779 0 ovirt-engine-4.0.2 MERGED webadmin: Allow UI plugins to run certain actions while loading 2016-08-01 17:18:38 UTC

Internal Links: 1361656

Description Vojtech Szocs 2016-07-28 15:39:28 UTC
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)

Comment 1 Vojtech Szocs 2016-07-28 16:56:30 UTC
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.

Comment 2 Vojtech Szocs 2016-07-29 15:21:16 UTC
Created attachment 1185592 [details]
UI plugin used to verify the new API behavior

Comment 3 Vojtech Szocs 2016-07-29 15:26:30 UTC
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.

Comment 4 Vojtech Szocs 2016-07-29 15:56:44 UTC
(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.

Comment 5 Oved Ourfali 2016-08-02 06:43:14 UTC
Pavel - can you qe-ack?

Comment 6 Pavel Novotny 2016-08-16 17:35:46 UTC
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]
-~-


Note You need to log in before you can comment on or make changes to this bug.