ES6ify /plugins/*
Bug: Issue 6179 Change-Id: I2ddd0d9e522b06041c08ec2e7902806b4a6924f7
This commit is contained in:
@@ -24,28 +24,27 @@
|
||||
},
|
||||
},
|
||||
|
||||
_configChanged: function(config) {
|
||||
var jsPlugins = config.js_resource_paths || [];
|
||||
var htmlPlugins = config.html_resource_paths || [];
|
||||
_configChanged(config) {
|
||||
const jsPlugins = config.js_resource_paths || [];
|
||||
const htmlPlugins = config.html_resource_paths || [];
|
||||
Gerrit._setPluginsCount(jsPlugins.length + htmlPlugins.length);
|
||||
this._loadJsPlugins(jsPlugins);
|
||||
this._importHtmlPlugins(htmlPlugins);
|
||||
},
|
||||
|
||||
_importHtmlPlugins: function(plugins) {
|
||||
plugins.forEach(function(url) {
|
||||
if (url.indexOf('http') !== 0) {
|
||||
_importHtmlPlugins(plugins) {
|
||||
for (let url of plugins) {
|
||||
if (!url.startsWith('http')) {
|
||||
url = '/' + url;
|
||||
}
|
||||
this.importHref(
|
||||
url, Gerrit._pluginInstalled, Gerrit._pluginInstalled, true);
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
_loadJsPlugins: function(plugins) {
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
var url = plugins[i];
|
||||
var scriptEl = document.createElement('script');
|
||||
_loadJsPlugins(plugins) {
|
||||
for (let i = 0; i < plugins.length; i++) {
|
||||
const scriptEl = document.createElement('script');
|
||||
scriptEl.defer = true;
|
||||
scriptEl.src = '/' + plugins[i];
|
||||
scriptEl.onerror = Gerrit._pluginInstalled;
|
||||
|
@@ -30,22 +30,22 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-diff tests', function() {
|
||||
var element;
|
||||
var sandbox;
|
||||
suite('gr-diff tests', () => {
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
setup(function() {
|
||||
setup(() => {
|
||||
element = fixture('basic');
|
||||
sandbox = sinon.sandbox.create();
|
||||
sandbox.stub(document.body, 'appendChild');
|
||||
sandbox.stub(element, 'importHref');
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('counts plugins', function() {
|
||||
test('counts plugins', () => {
|
||||
sandbox.stub(Gerrit, '_setPluginsCount');
|
||||
element.config = {
|
||||
html_resource_paths: ['foo/bar', 'baz'],
|
||||
@@ -54,7 +54,7 @@ limitations under the License.
|
||||
assert.isTrue(Gerrit._setPluginsCount.calledWith(3));
|
||||
});
|
||||
|
||||
test('imports html plugins from config', function() {
|
||||
test('imports html plugins from config', () => {
|
||||
element.config = {
|
||||
html_resource_paths: ['foo/bar', 'baz'],
|
||||
};
|
||||
|
Reference in New Issue
Block a user