Remove mutable export from plugin loader
Change-Id: Id92bc80e7228ccda155ed965837ccb2793a3a3f7
This commit is contained in:
@@ -39,7 +39,7 @@ import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-admin-view_html.js';
|
||||
import {getBaseUrl} from '../../../utils/url-util.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getAdminLinks} from '../../../utils/admin-nav-util.js';
|
||||
|
||||
const INTERNAL_GROUP_REGEX = /^[\da-f]{40}$/;
|
||||
@@ -112,7 +112,7 @@ class GrAdminView extends GestureEventListeners(
|
||||
reload() {
|
||||
const promises = [
|
||||
this.$.restAPI.getAccount(),
|
||||
pluginLoader.awaitPluginsLoaded(),
|
||||
getPluginLoader().awaitPluginsLoaded(),
|
||||
];
|
||||
return Promise.all(promises).then(result => {
|
||||
this._account = result[0];
|
||||
|
@@ -19,7 +19,7 @@ import '../../../test/common-test-setup-karma.js';
|
||||
import './gr-admin-view.js';
|
||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {stubBaseUrl} from '../../../test/test-utils.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-admin-view');
|
||||
@@ -35,7 +35,7 @@ suite('gr-admin-view tests', () => {
|
||||
},
|
||||
});
|
||||
const pluginsLoaded = Promise.resolve();
|
||||
sinon.stub(pluginLoader, 'awaitPluginsLoaded').returns(pluginsLoaded);
|
||||
sinon.stub(getPluginLoader(), 'awaitPluginsLoaded').returns(pluginsLoaded);
|
||||
pluginsLoaded.then(() => flush(done));
|
||||
});
|
||||
|
||||
|
@@ -34,7 +34,7 @@ import {ChangeTableMixin} from '../../../mixins/gr-change-table-mixin/gr-change-
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {getDisplayName} from '../../../utils/display-name-util.js';
|
||||
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {appContext} from '../../../services/app-context.js';
|
||||
import {truncatePath} from '../../../utils/path-list-util.js';
|
||||
import {changeStatuses} from '../../../utils/change-util.js';
|
||||
@@ -107,10 +107,11 @@ class GrChangeListItem extends ChangeTableMixin(GestureEventListeners(
|
||||
/** @override */
|
||||
attached() {
|
||||
super.attached();
|
||||
pluginLoader.awaitPluginsLoaded().then(() => {
|
||||
this._dynamicCellEndpoints = getPluginEndpoints().getDynamicEndpoints(
|
||||
'change-list-item-cell');
|
||||
});
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
this._dynamicCellEndpoints = getPluginEndpoints().getDynamicEndpoints(
|
||||
'change-list-item-cell');
|
||||
});
|
||||
}
|
||||
|
||||
_changeStatuses(change) {
|
||||
|
@@ -31,7 +31,7 @@ import {ChangeTableMixin} from '../../../mixins/gr-change-table-mixin/gr-change-
|
||||
import {KeyboardShortcutMixin, Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {changeIsOpen} from '../../../utils/change-util.js';
|
||||
|
||||
const NUMBER_FIXED_COLUMNS = 3;
|
||||
@@ -166,10 +166,11 @@ class GrChangeList extends ChangeTableMixin(
|
||||
/** @override */
|
||||
attached() {
|
||||
super.attached();
|
||||
pluginLoader.awaitPluginsLoaded().then(() => {
|
||||
this._dynamicHeaderEndpoints = getPluginEndpoints().getDynamicEndpoints(
|
||||
'change-list-header');
|
||||
});
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
this._dynamicHeaderEndpoints = getPluginEndpoints().
|
||||
getDynamicEndpoints('change-list-header');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -37,7 +37,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-change-actions_html.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {appContext} from '../../../services/app-context.js';
|
||||
import {
|
||||
fetchChangeUpdates,
|
||||
@@ -551,7 +551,8 @@ class GrChangeActions extends GestureEventListeners(
|
||||
}
|
||||
|
||||
_handleLoadingComplete() {
|
||||
pluginLoader.awaitPluginsLoaded().then(() => this._loading = false);
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => this._loading = false);
|
||||
}
|
||||
|
||||
_sendShowRevisionActions(detail) {
|
||||
|
@@ -19,7 +19,7 @@ import '../../../test/common-test-setup-karma.js';
|
||||
import './gr-change-actions.js';
|
||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {generateChange} from '../../../test/test-utils.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-change-actions');
|
||||
@@ -85,7 +85,7 @@ suite('gr-change-actions tests', () => {
|
||||
getProjectConfig() { return Promise.resolve({}); },
|
||||
});
|
||||
|
||||
sinon.stub(pluginLoader, 'awaitPluginsLoaded')
|
||||
sinon.stub(getPluginLoader(), 'awaitPluginsLoaded')
|
||||
.returns(Promise.resolve());
|
||||
|
||||
element = basicFixture.instantiate();
|
||||
@@ -2013,7 +2013,7 @@ suite('gr-change-actions tests', () => {
|
||||
getProjectConfig() { return Promise.resolve({}); },
|
||||
});
|
||||
|
||||
sinon.stub(pluginLoader, 'awaitPluginsLoaded')
|
||||
sinon.stub(getPluginLoader(), 'awaitPluginsLoaded')
|
||||
.returns(Promise.resolve());
|
||||
|
||||
element = basicFixture.instantiate();
|
||||
|
@@ -19,7 +19,7 @@ import '../../../test/common-test-setup-karma.js';
|
||||
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
import './gr-change-metadata.js';
|
||||
import {resetPlugins} from '../../../test/test-utils.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
|
||||
const testHtmlPlugin = document.createElement('dom-module');
|
||||
@@ -117,10 +117,11 @@ suite('gr-change-metadata integration tests', () => {
|
||||
plugin.registerStyleModule('change-metadata', 'my-plugin-style');
|
||||
}, undefined, 'http://test.com/plugins/style.js');
|
||||
element = createElement();
|
||||
pluginLoader.loadPlugins([]);
|
||||
pluginLoader.awaitPluginsLoaded().then(() => {
|
||||
flush(done);
|
||||
});
|
||||
getPluginLoader().loadPlugins([]);
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
flush(done);
|
||||
});
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -143,8 +144,8 @@ suite('gr-change-metadata integration tests', () => {
|
||||
plugin = p;
|
||||
plugin.registerStyleModule('change-metadata', 'my-plugin-style');
|
||||
}, undefined, 'http://test.com/plugins/style.js');
|
||||
sinon.stub(pluginLoader, 'arePluginsLoaded').returns(true);
|
||||
pluginLoader.loadPlugins([]);
|
||||
sinon.stub(getPluginLoader(), 'arePluginsLoaded').returns(true);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
element = createElement();
|
||||
});
|
||||
|
||||
|
@@ -19,7 +19,7 @@ import '../../../test/common-test-setup-karma.js';
|
||||
import '../../core/gr-router/gr-router.js';
|
||||
import './gr-change-metadata.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-change-metadata');
|
||||
@@ -763,7 +763,7 @@ suite('gr-change-metadata tests', () => {
|
||||
},
|
||||
'0.1',
|
||||
'http://some/plugins/url.html');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
flush(() => {
|
||||
assert.strictEqual(hookEl.plugin, plugin);
|
||||
assert.strictEqual(hookEl.change, element.change);
|
||||
|
@@ -56,7 +56,7 @@ import {GrCountStringFormatter} from '../../shared/gr-count-string-formatter/gr-
|
||||
import {getComputedStyleValue} from '../../../utils/dom-util.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {RevisionInfo} from '../../shared/revision-info/revision-info.js';
|
||||
import {PrimaryTab, SecondaryTab} from '../../../constants/constants.js';
|
||||
import {NO_ROBOT_COMMENTS_THREADS_MSG} from '../../../constants/messages.js';
|
||||
@@ -498,7 +498,7 @@ class GrChangeView extends KeyboardShortcutMixin(
|
||||
this._setDiffViewMode();
|
||||
});
|
||||
|
||||
pluginLoader.awaitPluginsLoaded()
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
this._dynamicTabHeaderEndpoints =
|
||||
getPluginEndpoints().getDynamicEndpoints('change-view-tab-header');
|
||||
@@ -1075,9 +1075,10 @@ class GrChangeView extends KeyboardShortcutMixin(
|
||||
this._performPostLoadTasks();
|
||||
});
|
||||
|
||||
pluginLoader.awaitPluginsLoaded().then(() => {
|
||||
this._initActiveTabs(value);
|
||||
});
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
this._initActiveTabs(value);
|
||||
});
|
||||
}
|
||||
|
||||
_initActiveTabs(params = {}) {
|
||||
@@ -1180,7 +1181,7 @@ class GrChangeView extends KeyboardShortcutMixin(
|
||||
}
|
||||
|
||||
_maybeShowRevertDialog() {
|
||||
pluginLoader.awaitPluginsLoaded()
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(this._getLoggedIn.bind(this))
|
||||
.then(loggedIn => {
|
||||
if (!loggedIn || !this._change ||
|
||||
|
@@ -25,7 +25,7 @@ import {GrEditConstants} from '../../edit/gr-edit-constants.js';
|
||||
import {_testOnly_resetEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {getComputedStyleValue} from '../../../utils/dom-util.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
import {EventType} from '../../plugins/gr-plugin-types.js';
|
||||
|
||||
@@ -301,7 +301,7 @@ suite('gr-change-view tests', () => {
|
||||
});
|
||||
element = fixture.instantiate();
|
||||
sinon.stub(element.$.actions, 'reload').returns(Promise.resolve());
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
pluginApi.install(
|
||||
plugin => {
|
||||
plugin.registerDynamicCustomComponent(
|
||||
@@ -1642,7 +1642,7 @@ suite('gr-change-view tests', () => {
|
||||
test('revert dialog opened with revert param', done => {
|
||||
sinon.stub(element.$.restAPI, 'getLoggedIn')
|
||||
.callsFake(() => Promise.resolve(true));
|
||||
sinon.stub(pluginLoader, 'awaitPluginsLoaded')
|
||||
sinon.stub(getPluginLoader(), 'awaitPluginsLoaded')
|
||||
.callsFake(() => Promise.resolve());
|
||||
|
||||
element._patchRange = {
|
||||
@@ -1671,7 +1671,7 @@ suite('gr-change-view tests', () => {
|
||||
done);
|
||||
|
||||
element._maybeShowRevertDialog();
|
||||
assert.isTrue(pluginLoader.awaitPluginsLoaded.called);
|
||||
assert.isTrue(getPluginLoader().awaitPluginsLoaded.called);
|
||||
});
|
||||
|
||||
suite('scroll related tests', () => {
|
||||
|
@@ -38,7 +38,7 @@ import {GrFileListConstants} from '../gr-file-list-constants.js';
|
||||
import {GrCountStringFormatter} from '../../shared/gr-count-string-formatter/gr-count-string-formatter.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {appContext} from '../../../services/app-context.js';
|
||||
import {SpecialFilePath} from '../../../constants/constants.js';
|
||||
import {descendedFromClass} from '../../../utils/dom-util.js';
|
||||
@@ -310,34 +310,35 @@ class GrFileList extends KeyboardShortcutMixin(
|
||||
/** @override */
|
||||
attached() {
|
||||
super.attached();
|
||||
pluginLoader.awaitPluginsLoaded().then(() => {
|
||||
this._dynamicHeaderEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-header');
|
||||
this._dynamicContentEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-content');
|
||||
this._dynamicPrependedHeaderEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-header-prepend');
|
||||
this._dynamicPrependedContentEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-content-prepend');
|
||||
this._dynamicSummaryEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-summary');
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
this._dynamicHeaderEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-header');
|
||||
this._dynamicContentEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-content');
|
||||
this._dynamicPrependedHeaderEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-header-prepend');
|
||||
this._dynamicPrependedContentEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-content-prepend');
|
||||
this._dynamicSummaryEndpoints = getPluginEndpoints()
|
||||
.getDynamicEndpoints('change-view-file-list-summary');
|
||||
|
||||
if (this._dynamicHeaderEndpoints.length !==
|
||||
if (this._dynamicHeaderEndpoints.length !==
|
||||
this._dynamicContentEndpoints.length) {
|
||||
console.warn(
|
||||
'Different number of dynamic file-list header and content.');
|
||||
}
|
||||
if (this._dynamicPrependedHeaderEndpoints.length !==
|
||||
console.warn(
|
||||
'Different number of dynamic file-list header and content.');
|
||||
}
|
||||
if (this._dynamicPrependedHeaderEndpoints.length !==
|
||||
this._dynamicPrependedContentEndpoints.length) {
|
||||
console.warn(
|
||||
'Different number of dynamic file-list header and content.');
|
||||
}
|
||||
if (this._dynamicHeaderEndpoints.length !==
|
||||
console.warn(
|
||||
'Different number of dynamic file-list header and content.');
|
||||
}
|
||||
if (this._dynamicHeaderEndpoints.length !==
|
||||
this._dynamicSummaryEndpoints.length) {
|
||||
console.warn(
|
||||
'Different number of dynamic file-list headers and summary.');
|
||||
}
|
||||
});
|
||||
console.warn(
|
||||
'Different number of dynamic file-list headers and summary.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** @override */
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import './gr-related-changes-list.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
import {resetPlugins} from '../../../test/test-utils.js';
|
||||
|
||||
@@ -581,7 +581,7 @@ suite('gr-related-changes-list plugin tests', () => {
|
||||
},
|
||||
'0.1',
|
||||
'http://some/plugins/url1.html');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
flush(() => {
|
||||
assert.strictEqual(hookEl.plugin, plugin);
|
||||
assert.strictEqual(hookEl.change, element.change);
|
||||
@@ -605,7 +605,7 @@ suite('gr-related-changes-list plugin tests', () => {
|
||||
},
|
||||
'0.1',
|
||||
'http://some/plugins/url2.html');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
flush(() => {
|
||||
// No changes, and plugin without hidden attribute. So it's visible.
|
||||
element._resultsChanged({}, {}, [], [], []);
|
||||
|
@@ -19,7 +19,7 @@ import '../../../test/common-test-setup-karma.js';
|
||||
import {resetPlugins} from '../../../test/test-utils.js';
|
||||
import './gr-reply-dialog.js';
|
||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
const basicFixture = fixtureFromElement('gr-reply-dialog');
|
||||
const pluginApi = _testOnly_initGerritPluginApi();
|
||||
@@ -122,20 +122,21 @@ suite('gr-reply-dialog-it tests', () => {
|
||||
}, null, 'http://test.com/plugins/lgtm.js');
|
||||
element = basicFixture.instantiate();
|
||||
setupElement(element);
|
||||
pluginLoader.loadPlugins([]);
|
||||
pluginLoader.awaitPluginsLoaded().then(() => {
|
||||
flush(() => {
|
||||
const textarea = element.$.textarea.getNativeTextarea();
|
||||
textarea.value = 'LGTM';
|
||||
textarea.dispatchEvent(new CustomEvent(
|
||||
'input', {bubbles: true, composed: true}));
|
||||
const labelScoreRows = dom(element.$.labelScores.root)
|
||||
.querySelector('gr-label-score-row[name="Code-Review"]');
|
||||
const selectedBtn = dom(labelScoreRows.root)
|
||||
.querySelector('gr-button[data-value="+1"].iron-selected');
|
||||
assert.isOk(selectedBtn);
|
||||
done();
|
||||
});
|
||||
});
|
||||
getPluginLoader().loadPlugins([]);
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
flush(() => {
|
||||
const textarea = element.$.textarea.getNativeTextarea();
|
||||
textarea.value = 'LGTM';
|
||||
textarea.dispatchEvent(new CustomEvent(
|
||||
'input', {bubbles: true, composed: true}));
|
||||
const labelScoreRows = dom(element.$.labelScores.root)
|
||||
.querySelector('gr-label-score-row[name="Code-Review"]');
|
||||
const selectedBtn = dom(labelScoreRows.root)
|
||||
.querySelector('gr-button[data-value="+1"].iron-selected');
|
||||
assert.isOk(selectedBtn);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -26,7 +26,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-main-header_html.js';
|
||||
import {getBaseUrl, getDocsBaseUrl} from '../../../utils/url-util.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getAdminLinks} from '../../../utils/admin-nav-util.js';
|
||||
|
||||
const DEFAULT_LINKS = [{
|
||||
@@ -259,7 +259,7 @@ class GrMainHeader extends GestureEventListeners(
|
||||
const promises = [
|
||||
this.$.restAPI.getAccount(),
|
||||
this.$.restAPI.getTopMenus(),
|
||||
pluginLoader.awaitPluginsLoaded(),
|
||||
getPluginLoader().awaitPluginsLoaded(),
|
||||
];
|
||||
|
||||
return Promise.all(promises).then(result => {
|
||||
|
@@ -19,7 +19,7 @@ import '../test/common-test-setup-karma.js';
|
||||
import {getComputedStyleValue} from '../utils/dom-util.js';
|
||||
import './shared/gr-rest-api-interface/gr-rest-api-interface.js';
|
||||
import './gr-app.js';
|
||||
import {pluginLoader} from './shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from './shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {removeTheme} from '../styles/themes/dark-theme.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-app');
|
||||
@@ -30,8 +30,9 @@ suite('gr-app custom dark theme tests', () => {
|
||||
window.localStorage.setItem('dark-theme', 'true');
|
||||
|
||||
element = basicFixture.instantiate();
|
||||
pluginLoader.loadPlugins([]);
|
||||
pluginLoader.awaitPluginsLoaded().then(() => flush(done));
|
||||
getPluginLoader().loadPlugins([]);
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => flush(done));
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
|
@@ -19,7 +19,7 @@ import '../test/common-test-setup-karma.js';
|
||||
import {getComputedStyleValue} from '../utils/dom-util.js';
|
||||
import './shared/gr-rest-api-interface/gr-rest-api-interface.js';
|
||||
import './gr-app.js';
|
||||
import {pluginLoader} from './shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from './shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-app');
|
||||
|
||||
@@ -36,8 +36,9 @@ suite('gr-app custom light theme tests', () => {
|
||||
_fetchSharedCacheURL() { return Promise.resolve({}); },
|
||||
});
|
||||
element = basicFixture.instantiate();
|
||||
pluginLoader.loadPlugins([]);
|
||||
pluginLoader.awaitPluginsLoaded().then(() => flush(done));
|
||||
getPluginLoader().loadPlugins([]);
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => flush(done));
|
||||
});
|
||||
teardown(() => {
|
||||
// The app sends requests to server. This can lead to
|
||||
|
@@ -60,7 +60,7 @@ import {GrPluginRestApi} from './shared/gr-js-api-interface/gr-plugin-rest-api.j
|
||||
import {GrRepoApi} from './plugins/gr-repo-api/gr-repo-api.js';
|
||||
import {GrSettingsApi} from './plugins/gr-settings-api/gr-settings-api.js';
|
||||
import {GrStylesApi} from './plugins/gr-styles-api/gr-styles-api.js';
|
||||
import {pluginLoader, PluginLoader} from './shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader, PluginLoader} from './shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {GrPluginActionContext} from './shared/gr-js-api-interface/gr-plugin-action-context.js';
|
||||
import {getPluginNameFromUrl, getRestAPI, PLUGIN_LOADING_TIMEOUT_MS, PRELOADED_PROTOCOL, send} from './shared/gr-js-api-interface/gr-api-utils.js';
|
||||
import {getBaseUrl} from '../utils/url-util.js';
|
||||
@@ -138,7 +138,7 @@ export function initGlobalVariables() {
|
||||
window.Gerrit.getRootElement = getRootElement;
|
||||
window.Gerrit.Auth = appContext.authService;
|
||||
|
||||
window.Gerrit._pluginLoader = pluginLoader;
|
||||
window.Gerrit._pluginLoader = getPluginLoader();
|
||||
// TODO: should define as a getter
|
||||
window.Gerrit._endpoints = getPluginEndpoints();
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
|
||||
const pluginApi = _testOnly_initGerritPluginApi();
|
||||
@@ -29,7 +29,7 @@ suite('gr-admin-api tests', () => {
|
||||
let plugin;
|
||||
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||
'http://test.com/plugins/testplugin/static/test.js');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
adminApi = plugin.admin();
|
||||
});
|
||||
|
||||
|
@@ -20,7 +20,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-endpoint-decorator_html.js';
|
||||
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
|
||||
const INIT_PROPERTIES_TIMEOUT_MS = 10000;
|
||||
|
||||
@@ -162,7 +162,7 @@ class GrEndpointDecorator extends GestureEventListeners(
|
||||
this._endpointCallBack = this._initModule.bind(this);
|
||||
getPluginEndpoints().onNewEndpoint(this.name, this._endpointCallBack);
|
||||
if (this.name) {
|
||||
pluginLoader.awaitPluginsLoaded()
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => getPluginEndpoints().getAndImportPlugins(this.name))
|
||||
.then(() =>
|
||||
getPluginEndpoints()
|
||||
|
@@ -21,7 +21,7 @@ import '../gr-endpoint-param/gr-endpoint-param.js';
|
||||
import '../gr-endpoint-slot/gr-endpoint-slot.js';
|
||||
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
import {resetPlugins} from '../../../test/test-utils.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
|
||||
@@ -71,7 +71,7 @@ suite('gr-endpoint-decorator', () => {
|
||||
replacementHook = plugin.registerCustomComponent(
|
||||
'second', 'other-module', {replace: true});
|
||||
// Mimic all plugins loaded.
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
flush(done);
|
||||
});
|
||||
|
||||
|
@@ -21,7 +21,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-external-style_html.js';
|
||||
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
|
||||
/** @extends PolymerElement */
|
||||
class GrExternalStyle extends GestureEventListeners(
|
||||
@@ -75,7 +75,8 @@ class GrExternalStyle extends GestureEventListeners(
|
||||
/** @override */
|
||||
ready() {
|
||||
super.ready();
|
||||
pluginLoader.awaitPluginsLoaded().then(() => this._importAndApply());
|
||||
getPluginLoader().awaitPluginsLoaded()
|
||||
.then(() => this._importAndApply());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import {resetPlugins} from '../../../test/test-utils.js';
|
||||
import './gr-external-style.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
@@ -68,7 +68,7 @@ suite('gr-external-style integration tests', () => {
|
||||
setup(() => {
|
||||
sinon.stub(getPluginEndpoints(), 'importUrl')
|
||||
.callsFake( url => Promise.resolve());
|
||||
sinon.stub(pluginLoader, 'awaitPluginsLoaded')
|
||||
sinon.stub(getPluginLoader(), 'awaitPluginsLoaded')
|
||||
.returns(Promise.resolve());
|
||||
});
|
||||
|
||||
|
@@ -18,7 +18,7 @@ import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
||||
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
||||
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
|
||||
/** @extends PolymerElement */
|
||||
class GrPluginHost extends GestureEventListeners(
|
||||
@@ -42,7 +42,7 @@ class GrPluginHost extends GestureEventListeners(
|
||||
plugins && plugins.js_resource_paths || [], htmlPlugins
|
||||
);
|
||||
const shouldLoadTheme = config.default_theme &&
|
||||
!pluginLoader.isPluginPreloaded('preloaded:gerrit-theme');
|
||||
!getPluginLoader().isPluginPreloaded('preloaded:gerrit-theme');
|
||||
const themeToLoad =
|
||||
shouldLoadTheme ? [config.default_theme] : [];
|
||||
|
||||
@@ -57,7 +57,7 @@ class GrPluginHost extends GestureEventListeners(
|
||||
pluginOpts[config.default_theme] = {sync: true};
|
||||
}
|
||||
|
||||
pluginLoader.loadPlugins(pluginsPending, pluginOpts);
|
||||
getPluginLoader().loadPlugins(pluginsPending, pluginOpts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import './gr-plugin-host.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-plugin-host');
|
||||
|
||||
@@ -31,21 +31,21 @@ suite('gr-plugin-host tests', () => {
|
||||
});
|
||||
|
||||
test('load plugins should be called', () => {
|
||||
sinon.stub(pluginLoader, 'loadPlugins');
|
||||
sinon.stub(getPluginLoader(), 'loadPlugins');
|
||||
element.config = {
|
||||
plugin: {
|
||||
html_resource_paths: ['plugins/foo/bar', 'plugins/baz'],
|
||||
js_resource_paths: ['plugins/42'],
|
||||
},
|
||||
};
|
||||
assert.isTrue(pluginLoader.loadPlugins.calledOnce);
|
||||
assert.isTrue(pluginLoader.loadPlugins.calledWith([
|
||||
assert.isTrue(getPluginLoader().loadPlugins.calledOnce);
|
||||
assert.isTrue(getPluginLoader().loadPlugins.calledWith([
|
||||
'plugins/42', 'plugins/foo/bar', 'plugins/baz',
|
||||
], {}));
|
||||
});
|
||||
|
||||
test('theme plugins should be loaded if enabled', () => {
|
||||
sinon.stub(pluginLoader, 'loadPlugins');
|
||||
sinon.stub(getPluginLoader(), 'loadPlugins');
|
||||
element.config = {
|
||||
default_theme: 'gerrit-theme.html',
|
||||
plugin: {
|
||||
@@ -53,23 +53,23 @@ suite('gr-plugin-host tests', () => {
|
||||
js_resource_paths: ['plugins/42'],
|
||||
},
|
||||
};
|
||||
assert.isTrue(pluginLoader.loadPlugins.calledOnce);
|
||||
assert.isTrue(pluginLoader.loadPlugins.calledWith([
|
||||
assert.isTrue(getPluginLoader().loadPlugins.calledOnce);
|
||||
assert.isTrue(getPluginLoader().loadPlugins.calledWith([
|
||||
'gerrit-theme.html', 'plugins/42', 'plugins/foo/bar', 'plugins/baz',
|
||||
], {'gerrit-theme.html': {sync: true}}));
|
||||
});
|
||||
|
||||
test('skip theme if preloaded', () => {
|
||||
sinon.stub(pluginLoader, 'isPluginPreloaded')
|
||||
sinon.stub(getPluginLoader(), 'isPluginPreloaded')
|
||||
.withArgs('preloaded:gerrit-theme')
|
||||
.returns(true);
|
||||
sinon.stub(pluginLoader, 'loadPlugins');
|
||||
sinon.stub(getPluginLoader(), 'loadPlugins');
|
||||
element.config = {
|
||||
default_theme: '/oof',
|
||||
plugin: {},
|
||||
};
|
||||
assert.isTrue(pluginLoader.loadPlugins.calledOnce);
|
||||
assert.isTrue(pluginLoader.loadPlugins.calledWith([], {}));
|
||||
assert.isTrue(getPluginLoader().loadPlugins.calledOnce);
|
||||
assert.isTrue(getPluginLoader().loadPlugins.calledWith([], {}));
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
|
||||
@@ -35,7 +35,7 @@ suite('gr-repo-api tests', () => {
|
||||
let plugin;
|
||||
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||
'http://test.com/plugins/testplugin/static/test.js');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
repoApi = plugin.project();
|
||||
});
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
|
||||
@@ -37,7 +37,7 @@ suite('gr-settings-api tests', () => {
|
||||
let plugin;
|
||||
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||
'http://test.com/plugins/testplugin/static/test.js');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
settingsApi = plugin.settings();
|
||||
});
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
|
||||
@@ -41,7 +41,7 @@ suite('gr-styles-api tests', () => {
|
||||
let plugin;
|
||||
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||
'http://test.com/plugins/testplugin/static/test.js');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
stylesApi = plugin.styles();
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ suite('gr-styles-api tests', () => {
|
||||
let plugin;
|
||||
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||
'http://test.com/plugins/testplugin/static/test.js');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
stylesApi = plugin.styles();
|
||||
displayInlineStyle = stylesApi.css('display: inline');
|
||||
displayNoneStyle = stylesApi.css('display: none');
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
|
||||
@@ -56,7 +56,7 @@ suite('gr-theme-api tests', () => {
|
||||
/** @override */
|
||||
ready() { customHeader = this; },
|
||||
});
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
});
|
||||
|
||||
test('sets logo and title', done => {
|
||||
|
@@ -22,7 +22,7 @@ import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mix
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
|
||||
import {htmlTemplate} from './gr-avatar_html.js';
|
||||
import {getBaseUrl} from '../../../utils/url-util.js';
|
||||
import {pluginLoader} from '../gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../gr-js-api-interface/gr-plugin-loader.js';
|
||||
|
||||
/**
|
||||
* @extends PolymerElement
|
||||
@@ -56,7 +56,7 @@ class GrAvatar extends GestureEventListeners(
|
||||
super.attached();
|
||||
Promise.all([
|
||||
this._getConfig(),
|
||||
pluginLoader.awaitPluginsLoaded(),
|
||||
getPluginLoader().awaitPluginsLoaded(),
|
||||
]).then(([cfg]) => {
|
||||
this._hasAvatars = !!(cfg && cfg.plugin && cfg.plugin.has_avatars);
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import './gr-avatar.js';
|
||||
import {pluginLoader} from '../gr-js-api-interface/gr-plugin-loader.js';
|
||||
import {getPluginLoader} from '../gr-js-api-interface/gr-plugin-loader.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-avatar');
|
||||
|
||||
@@ -101,11 +101,11 @@ suite('gr-avatar tests', () => {
|
||||
assert.strictEqual(element.style.backgroundImage, '');
|
||||
|
||||
// Emulate plugins loaded.
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
|
||||
return Promise.all([
|
||||
element.$.restAPI.getConfig(),
|
||||
pluginLoader.awaitPluginsLoaded(),
|
||||
getPluginLoader().awaitPluginsLoaded(),
|
||||
]).then(() => {
|
||||
assert.isFalse(element.hasAttribute('hidden'));
|
||||
|
||||
@@ -131,11 +131,11 @@ suite('gr-avatar tests', () => {
|
||||
assert.isFalse(element.hasAttribute('hidden'));
|
||||
|
||||
// Emulate plugins loaded.
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
|
||||
return Promise.all([
|
||||
element.$.restAPI.getConfig(),
|
||||
pluginLoader.awaitPluginsLoaded(),
|
||||
getPluginLoader().awaitPluginsLoaded(),
|
||||
]).then(() => {
|
||||
assert.isTrue(element.hasAttribute('hidden'));
|
||||
|
||||
@@ -164,11 +164,11 @@ suite('gr-avatar tests', () => {
|
||||
_account_id: 123,
|
||||
};
|
||||
// Emulate plugins loaded.
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
|
||||
return Promise.all([
|
||||
element.$.restAPI.getConfig(),
|
||||
pluginLoader.awaitPluginsLoaded(),
|
||||
getPluginLoader().awaitPluginsLoaded(),
|
||||
]).then(() => {
|
||||
assert.isTrue(element.hasAttribute('hidden'));
|
||||
});
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import '../../change/gr-change-actions/gr-change-actions.js';
|
||||
import {resetPlugins} from '../../../test/test-utils.js';
|
||||
import {pluginLoader} from './gr-plugin-loader.js';
|
||||
import {getPluginLoader} from './gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-change-actions');
|
||||
@@ -44,7 +44,7 @@ suite('gr-change-actions-js-api-interface tests', () => {
|
||||
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||
'http://test.com/plugins/testplugin/static/test.js');
|
||||
// Mimic all plugins loaded.
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
changeActions = plugin.changeActions();
|
||||
element = basicFixture.instantiate();
|
||||
});
|
||||
@@ -72,7 +72,7 @@ suite('gr-change-actions-js-api-interface tests', () => {
|
||||
'http://test.com/plugins/testplugin/static/test.js');
|
||||
changeActions = plugin.changeActions();
|
||||
// Mimic all plugins loaded.
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
|
@@ -19,7 +19,7 @@
|
||||
* This defines the Gerrit instance. All methods directly attached to Gerrit
|
||||
* should be defined or linked here.
|
||||
*/
|
||||
import {pluginLoader, PluginOptionMap} from './gr-plugin-loader';
|
||||
import {getPluginLoader, PluginOptionMap} from './gr-plugin-loader';
|
||||
import {getRestAPI, send} from './gr-api-utils';
|
||||
import {appContext} from '../../../services/app-context';
|
||||
import {PluginApi} from '../../plugins/gr-plugin-types';
|
||||
@@ -81,7 +81,7 @@ export function initGerritPluginApi() {
|
||||
// Preloaded plugins should be installed after Gerrit.install() is set,
|
||||
// since plugin preloader substitutes Gerrit.install() temporarily.
|
||||
// (Gerrit.install() is set in initGerritPluginsMethods)
|
||||
pluginLoader.installPreloadedPlugins();
|
||||
getPluginLoader().installPreloadedPlugins();
|
||||
}
|
||||
|
||||
export function _testOnly_initGerritPluginApi(): GerritGlobal {
|
||||
@@ -136,7 +136,7 @@ function initGerritPluginsMethods(globalGerritObj: GerritGlobal) {
|
||||
};
|
||||
|
||||
globalGerritObj.install = (callback, opt_version, opt_src) => {
|
||||
pluginLoader.install(callback, opt_version, opt_src);
|
||||
getPluginLoader().install(callback, opt_version, opt_src);
|
||||
};
|
||||
|
||||
globalGerritObj.getLoggedIn = () => {
|
||||
@@ -181,29 +181,29 @@ function initGerritPluginsMethods(globalGerritObj: GerritGlobal) {
|
||||
};
|
||||
|
||||
globalGerritObj.awaitPluginsLoaded = () => {
|
||||
return pluginLoader.awaitPluginsLoaded();
|
||||
return getPluginLoader().awaitPluginsLoaded();
|
||||
};
|
||||
|
||||
// TODO(taoalpha): consider removing these proxy methods
|
||||
// and using pluginLoader directly
|
||||
// and using getPluginLoader() directly
|
||||
globalGerritObj._loadPlugins = (plugins, opt_option) => {
|
||||
pluginLoader.loadPlugins(plugins, opt_option);
|
||||
getPluginLoader().loadPlugins(plugins, opt_option);
|
||||
};
|
||||
|
||||
globalGerritObj._arePluginsLoaded = () => {
|
||||
return pluginLoader.arePluginsLoaded();
|
||||
return getPluginLoader().arePluginsLoaded();
|
||||
};
|
||||
|
||||
globalGerritObj._isPluginPreloaded = url => {
|
||||
return pluginLoader.isPluginPreloaded(url);
|
||||
return getPluginLoader().isPluginPreloaded(url);
|
||||
};
|
||||
|
||||
globalGerritObj._isPluginEnabled = pathOrUrl => {
|
||||
return pluginLoader.isPluginEnabled(pathOrUrl);
|
||||
return getPluginLoader().isPluginEnabled(pathOrUrl);
|
||||
};
|
||||
|
||||
globalGerritObj._isPluginLoaded = pathOrUrl => {
|
||||
return pluginLoader.isPluginLoaded(pathOrUrl);
|
||||
return getPluginLoader().isPluginLoaded(pathOrUrl);
|
||||
};
|
||||
|
||||
const eventEmitter = appContext.eventEmitter;
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import './gr-js-api-interface.js';
|
||||
import {pluginLoader} from './gr-plugin-loader.js';
|
||||
import {getPluginLoader} from './gr-plugin-loader.js';
|
||||
import {resetPlugins} from '../../../test/test-utils.js';
|
||||
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||
|
||||
@@ -52,10 +52,10 @@ suite('gr-gerrit tests', () => {
|
||||
});
|
||||
|
||||
suite('proxy methods', () => {
|
||||
test('Gerrit._isPluginEnabled proxy to pluginLoader', () => {
|
||||
test('Gerrit._isPluginEnabled proxy to getPluginLoader()', () => {
|
||||
const stubFn = sinon.stub();
|
||||
sinon.stub(
|
||||
pluginLoader,
|
||||
getPluginLoader(),
|
||||
'isPluginEnabled')
|
||||
.callsFake((...args) => stubFn(...args)
|
||||
);
|
||||
@@ -63,20 +63,20 @@ suite('gr-gerrit tests', () => {
|
||||
assert.isTrue(stubFn.calledWith('test_plugin'));
|
||||
});
|
||||
|
||||
test('Gerrit._isPluginLoaded proxy to pluginLoader', () => {
|
||||
test('Gerrit._isPluginLoaded proxy to getPluginLoader()', () => {
|
||||
const stubFn = sinon.stub();
|
||||
sinon.stub(
|
||||
pluginLoader,
|
||||
getPluginLoader(),
|
||||
'isPluginLoaded')
|
||||
.callsFake((...args) => stubFn(...args));
|
||||
pluginApi._isPluginLoaded('test_plugin');
|
||||
assert.isTrue(stubFn.calledWith('test_plugin'));
|
||||
});
|
||||
|
||||
test('Gerrit._isPluginPreloaded proxy to pluginLoader', () => {
|
||||
test('Gerrit._isPluginPreloaded proxy to getPluginLoader()', () => {
|
||||
const stubFn = sinon.stub();
|
||||
sinon.stub(
|
||||
pluginLoader,
|
||||
getPluginLoader(),
|
||||
'isPluginPreloaded')
|
||||
.callsFake((...args) => stubFn(...args));
|
||||
pluginApi._isPluginPreloaded('test_plugin');
|
||||
|
@@ -17,7 +17,7 @@
|
||||
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners';
|
||||
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
|
||||
import {PolymerElement} from '@polymer/polymer/polymer-element';
|
||||
import {pluginLoader} from './gr-plugin-loader';
|
||||
import {getPluginLoader} from './gr-plugin-loader';
|
||||
import {patchNumEquals} from '../../../utils/patch-set-util';
|
||||
import {customElement} from '@polymer/decorators';
|
||||
import {ChangeInfo, RevisionInfo} from '../../../types/common';
|
||||
@@ -42,31 +42,36 @@ export class GrJsApiInterface
|
||||
extends GestureEventListeners(LegacyElementMixin(PolymerElement))
|
||||
implements JsApiService {
|
||||
handleEvent(type: EventType, detail: any) {
|
||||
pluginLoader.awaitPluginsLoaded().then(() => {
|
||||
switch (type) {
|
||||
case EventType.HISTORY:
|
||||
this._handleHistory(detail);
|
||||
break;
|
||||
case EventType.SHOW_CHANGE:
|
||||
this._handleShowChange(detail);
|
||||
break;
|
||||
case EventType.COMMENT:
|
||||
this._handleComment(detail);
|
||||
break;
|
||||
case EventType.LABEL_CHANGE:
|
||||
this._handleLabelChange(detail);
|
||||
break;
|
||||
case EventType.SHOW_REVISION_ACTIONS:
|
||||
this._handleShowRevisionActions(detail);
|
||||
break;
|
||||
case EventType.HIGHLIGHTJS_LOADED:
|
||||
this._handleHighlightjsLoaded(detail);
|
||||
break;
|
||||
default:
|
||||
console.warn('handleEvent called with unsupported event type:', type);
|
||||
break;
|
||||
}
|
||||
});
|
||||
getPluginLoader()
|
||||
.awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
switch (type) {
|
||||
case EventType.HISTORY:
|
||||
this._handleHistory(detail);
|
||||
break;
|
||||
case EventType.SHOW_CHANGE:
|
||||
this._handleShowChange(detail);
|
||||
break;
|
||||
case EventType.COMMENT:
|
||||
this._handleComment(detail);
|
||||
break;
|
||||
case EventType.LABEL_CHANGE:
|
||||
this._handleLabelChange(detail);
|
||||
break;
|
||||
case EventType.SHOW_REVISION_ACTIONS:
|
||||
this._handleShowRevisionActions(detail);
|
||||
break;
|
||||
case EventType.HIGHLIGHTJS_LOADED:
|
||||
this._handleHighlightjsLoaded(detail);
|
||||
break;
|
||||
default:
|
||||
console.warn(
|
||||
'handleEvent called with unsupported event type:',
|
||||
type
|
||||
);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addElement(key: TargetElement, el: HTMLElement) {
|
||||
@@ -274,13 +279,15 @@ export class GrJsApiInterface
|
||||
* will resolve to null.
|
||||
*/
|
||||
getCoverageAnnotationApi(): Promise<CoverageProvider | undefined> {
|
||||
return pluginLoader.awaitPluginsLoaded().then(
|
||||
() =>
|
||||
this._getEventCallbacks(EventType.ANNOTATE_DIFF).find(cb => {
|
||||
const annotationApi = (cb as unknown) as GrAnnotationActionsInterface;
|
||||
return annotationApi.getCoverageProvider();
|
||||
}) as CoverageProvider | undefined
|
||||
);
|
||||
return getPluginLoader()
|
||||
.awaitPluginsLoaded()
|
||||
.then(
|
||||
() =>
|
||||
this._getEventCallbacks(EventType.ANNOTATE_DIFF).find(cb => {
|
||||
const annotationApi = (cb as unknown) as GrAnnotationActionsInterface;
|
||||
return annotationApi.getCoverageProvider();
|
||||
}) as CoverageProvider | undefined
|
||||
);
|
||||
}
|
||||
|
||||
getAdminMenuLinks() {
|
||||
|
@@ -22,7 +22,7 @@ import {GrSettingsApi} from '../../plugins/gr-settings-api/gr-settings-api.js';
|
||||
import {EventType} from '../../plugins/gr-plugin-types.js';
|
||||
import {GrPluginActionContext} from './gr-plugin-action-context.js';
|
||||
import {PLUGIN_LOADING_TIMEOUT_MS} from './gr-api-utils.js';
|
||||
import {pluginLoader} from './gr-plugin-loader.js';
|
||||
import {getPluginLoader} from './gr-plugin-loader.js';
|
||||
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||
import {stubBaseUrl} from '../../../test/test-utils.js';
|
||||
|
||||
@@ -60,7 +60,7 @@ suite('gr-js-api-interface tests', () => {
|
||||
errorStub = sinon.stub(console, 'error');
|
||||
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||
'http://test.com/plugins/testplugin/static/test.js');
|
||||
pluginLoader.loadPlugins([]);
|
||||
getPluginLoader().loadPlugins([]);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -234,7 +234,7 @@ suite('gr-js-api-interface tests', () => {
|
||||
revisions: {def: {_number: 2}, abc: {_number: 1}},
|
||||
};
|
||||
const spy = sinon.spy();
|
||||
pluginLoader.loadPlugins(['plugins/test.html']);
|
||||
getPluginLoader().loadPlugins(['plugins/test.html']);
|
||||
plugin.on(EventType.SHOW_CHANGE, spy);
|
||||
element.handleEvent(EventType.SHOW_CHANGE,
|
||||
{change: testChange, patchNum: 1});
|
||||
|
@@ -444,8 +444,12 @@ export class PluginLoader {
|
||||
}
|
||||
|
||||
// TODO(dmfilippov): Convert to service and add to appContext
|
||||
export let pluginLoader = new PluginLoader();
|
||||
let pluginLoader = new PluginLoader();
|
||||
export function _testOnly_resetPluginLoader() {
|
||||
pluginLoader = new PluginLoader();
|
||||
return pluginLoader;
|
||||
}
|
||||
|
||||
export function getPluginLoader() {
|
||||
return pluginLoader;
|
||||
}
|
||||
|
@@ -540,4 +540,3 @@ suite('gr-plugin-loader tests', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user