New way to style the Gerrit UI does not work properly

74 views
Skip to first unread message

David Åkerman

unread,
Jun 23, 2022, 7:59:35 AM6/23/22
to Repo and Gerrit Discussion
Hi,

I tried to port our Javascript theme plugin to the new way of styling DOM elements (https://gerrit-review.googlesource.com/c/gerrit/+/331259).
The style is applied but the header freezes(the part where the style is applied), then I get a pop-up "Timeout when loading plugins: <name of plugin>" after about 5 sec, then it work properly until the page is loaded again.
The same thing happen with the example plugin shown in "Documentation/pg-plugin-dev.txt".
I have tested on both Gerrit v3.6 and v3.6.1.

Is there some additional thing I need to do to make the new way to work?

Best regards,
David

Ben Rohlfs

unread,
Jun 23, 2022, 10:40:33 AM6/23/22
to David Åkerman, Repo and Gerrit Discussion
Can you send me the full code of the plugin that does not work?

Are you calling Gerrit.install()?


--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/82bdd0fb-cf5e-4cba-96b5-89da53a1ff29n%40googlegroups.com.

Rikard Almgren

unread,
Jun 23, 2022, 11:08:59 AM6/23/22
to Repo and Gerrit Discussion
It's a ridiculously simple header-theme-only plugin.

------------

const stagingTheme = document.createElement('style');

stagingTheme.innerHTML = `
    html {
      --header-title-content: "Staging";
      --header-background-color: #FFE4DB;  //(yes, I know, it's horrible)
      --header-text-color: #000
    }
`;
document.head.appendChild(stagingTheme);

----------
But no, it was missing the Gerrit.install() call.
I wrapped it in

Gerrit.install(plugin => {
<theme code here>
});

and it stopped complaining (no more timeout, works as expected).

Thanks for spotting the silly mistake, Ben!

What threw us off was that the old documentation for the RegisterStyleModule includes the Gerrit.install(), but the new one [1] does not.
It is however mentioned at the top of the same file [2].

BR
Rikard

[1] https://gerrit-review.googlesource.com/c/gerrit/+/331259/1/Documentation/pg-plugin-dev.txt#107
[2] https://gerrit-review.googlesource.com/c/gerrit/+/331259/1/Documentation/pg-plugin-dev.txt#27
Reply all
Reply to author
Forward
0 new messages