Merge "Provide full URL to site theme"

This commit is contained in:
Kasper Nilsson 2018-08-22 19:17:36 +00:00 committed by Gerrit Code Review
commit 564d2f945b
2 changed files with 13 additions and 1 deletions

View File

@ -40,7 +40,7 @@
this._handleMigrations(plugins.js_resource_paths || [], htmlPlugins) this._handleMigrations(plugins.js_resource_paths || [], htmlPlugins)
.map(p => this._urlFor(p)) .map(p => this._urlFor(p))
.filter(p => !Gerrit._isPluginPreloaded(p)); .filter(p => !Gerrit._isPluginPreloaded(p));
const defaultTheme = config.default_theme; const defaultTheme = this._urlFor(config.default_theme);
const pluginsPending = const pluginsPending =
[].concat(jsPlugins, htmlPlugins, defaultTheme || []); [].concat(jsPlugins, htmlPlugins, defaultTheme || []);
Gerrit._setPluginsPending(pluginsPending); Gerrit._setPluginsPending(pluginsPending);
@ -98,6 +98,9 @@
}, },
_urlFor(pathOrUrl) { _urlFor(pathOrUrl) {
if (!pathOrUrl) {
return pathOrUrl;
}
if (pathOrUrl.startsWith('preloaded:') || if (pathOrUrl.startsWith('preloaded:') ||
pathOrUrl.startsWith('http')) { pathOrUrl.startsWith('http')) {
// Plugins are loaded from another domain or preloaded. // Plugins are loaded from another domain or preloaded.

View File

@ -188,6 +188,15 @@ limitations under the License.
assert.equal(Gerrit._pluginInstallError.callCount, 2); assert.equal(Gerrit._pluginInstallError.callCount, 2);
}); });
test('default theme is loaded with html plugins', () => {
sandbox.stub(Gerrit, '_setPluginsPending');
element.config = {
default_theme: '/oof',
plugin: {},
};
assert.isTrue(Gerrit._setPluginsPending.calledWith([url + '/oof']));
});
test('skips preloaded plugins', () => { test('skips preloaded plugins', () => {
sandbox.stub(Gerrit, '_isPluginPreloaded') sandbox.stub(Gerrit, '_isPluginPreloaded')
.withArgs(url + '/plugins/foo/bar').returns(true) .withArgs(url + '/plugins/foo/bar').returns(true)