Load default site theme if provided

Change-Id: Ic0b691aafa35abbaf293099634d652c01e703456
This commit is contained in:
Viktar Donich
2017-08-04 13:32:42 -07:00
parent 1bb17c7c4b
commit dee1ae912e
2 changed files with 20 additions and 1 deletions

View File

@@ -31,6 +31,11 @@
_configChanged(config) {
const jsPlugins = config.js_resource_paths || [];
const htmlPlugins = config.html_resource_paths || [];
const defaultTheme = config.default_theme;
if (defaultTheme) {
// Make theme first to be first to load.
htmlPlugins.unshift(defaultTheme);
}
Gerrit._setPluginsCount(jsPlugins.length + htmlPlugins.length);
this._loadJsPlugins(jsPlugins);
this._importHtmlPlugins(htmlPlugins);
@@ -62,7 +67,10 @@
if (pathOrUrl.startsWith('http')) {
return pathOrUrl;
}
return this.getBaseUrl() + '/' + pathOrUrl;
if (!pathOrUrl.startsWith('/')) {
pathOrUrl = '/' + pathOrUrl;
}
return this.getBaseUrl() + pathOrUrl;
},
});
})();

View File

@@ -131,5 +131,16 @@ limitations under the License.
assert.isTrue(element._createScriptTag.calledWith(
'https://example.com/baz'));
});
test('default theme is loaded with html plugins', () => {
element.config = {
default_theme: '/oof',
html_resource_paths: ['some'],
};
assert.isTrue(element.importHref.calledWith(
'/oof', Gerrit._pluginInstalled, Gerrit._pluginInstalled, true));
assert.isTrue(element.importHref.calledWith(
'/some', Gerrit._pluginInstalled, Gerrit._pluginInstalled, true));
});
});
</script>