diff --git a/polygerrit-ui/app/.eslintrc.js b/polygerrit-ui/app/.eslintrc.js index c9e0110687..9bc8c992b4 100644 --- a/polygerrit-ui/app/.eslintrc.js +++ b/polygerrit-ui/app/.eslintrc.js @@ -166,11 +166,8 @@ module.exports = { // Instead export variables from modules // TODO(dmfilippov): Remove global variables from polygerrit "Gerrit": "readonly", - "GrChangeMetadataApi": "readonly", "GrChangeViewApi": "readonly", - "GrEmailSuggestionsProvider": "readonly", "GrEventHelper": "readonly", - "GrGroupSuggestionsProvider": "readonly", "GrPluginActionContext": "readonly", "GrPluginRestApi": "readonly", "GrRepoApi": "readonly", diff --git a/polygerrit-ui/app/elements/gr-app-global-var-init.js b/polygerrit-ui/app/elements/gr-app-global-var-init.js index 05ca09f459..219857f9ba 100644 --- a/polygerrit-ui/app/elements/gr-app-global-var-init.js +++ b/polygerrit-ui/app/elements/gr-app-global-var-init.js @@ -55,6 +55,9 @@ import {EventEmitter} from './shared/gr-event-interface/gr-event-interface.js'; import {GrAdminApi} from './plugins/gr-admin-api/gr-admin-api.js'; import {GrAnnotationActionsContext} from './shared/gr-js-api-interface/gr-annotation-actions-context.js'; import {GrAnnotationActionsInterface} from './shared/gr-js-api-interface/gr-annotation-actions-js-api.js'; +import {GrChangeMetadataApi} from './plugins/gr-change-metadata-api/gr-change-metadata-api.js'; +import {GrEmailSuggestionsProvider} from '../scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.js'; +import {GrGroupSuggestionsProvider} from '../scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.js'; export function initGlobalVariables() { window.GrDisplayNameUtils = GrDisplayNameUtils; @@ -93,4 +96,7 @@ export function initGlobalVariables() { window.GrAdminApi = GrAdminApi; window.GrAnnotationActionsContext = GrAnnotationActionsContext; window.GrAnnotationActionsInterface = GrAnnotationActionsInterface; + window.GrChangeMetadataApi = GrChangeMetadataApi; + window.GrEmailSuggestionsProvider = GrEmailSuggestionsProvider; + window.GrGroupSuggestionsProvider = GrGroupSuggestionsProvider; } diff --git a/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.js b/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.js index daf48f0ae1..8be50b1d46 100644 --- a/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.js +++ b/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.js @@ -24,27 +24,21 @@ $_documentContainer.innerHTML = ` document.head.appendChild($_documentContainer.content); -(function(window) { - 'use strict'; +/** @constructor */ +export function GrChangeMetadataApi(plugin) { + this._hook = null; + this.plugin = plugin; +} - /** @constructor */ - function GrChangeMetadataApi(plugin) { - this._hook = null; - this.plugin = plugin; +GrChangeMetadataApi.prototype._createHook = function() { + this._hook = this.plugin.hook('change-metadata-item'); +}; + +GrChangeMetadataApi.prototype.onLabelsChanged = function(callback) { + if (!this._hook) { + this._createHook(); } - - GrChangeMetadataApi.prototype._createHook = function() { - this._hook = this.plugin.hook('change-metadata-item'); - }; - - GrChangeMetadataApi.prototype.onLabelsChanged = function(callback) { - if (!this._hook) { - this._createHook(); - } - this._hook.onAttached(element => - this.plugin.attributeHelper(element).bind('labels', callback)); - return this; - }; - - window.GrChangeMetadataApi = GrChangeMetadataApi; -})(window); + this._hook.onAttached(element => + this.plugin.attributeHelper(element).bind('labels', callback)); + return this; +}; diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.js index ee2cace608..4f4d615ca0 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.js +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.js @@ -16,7 +16,6 @@ */ import '../../../scripts/bundled-polymer.js'; import '../../core/gr-reporting/gr-reporting.js'; -import '../../plugins/gr-change-metadata-api/gr-change-metadata-api.js'; import '../../plugins/gr-event-helper/gr-event-helper.js'; import '../../plugins/gr-repo-api/gr-repo-api.js'; import '../../plugins/gr-settings-api/gr-settings-api.js'; diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.js index f57c2dc70d..0fee5939bd 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.js +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.js @@ -24,6 +24,7 @@ import {GrThemeApi} from '../../plugins/gr-theme-api/gr-theme-api.js'; import {GrPopupInterface} from '../../plugins/gr-popup-interface/gr-popup-interface.js'; import {GrAdminApi} from '../../plugins/gr-admin-api/gr-admin-api.js'; import {GrAnnotationActionsInterface} from './gr-annotation-actions-js-api.js'; +import {GrChangeMetadataApi} from '../../plugins/gr-change-metadata-api/gr-change-metadata-api.js'; (function(window) { 'use strict'; diff --git a/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.js b/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.js index ed36c4cb71..2d2deaca19 100644 --- a/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.js +++ b/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.js @@ -16,33 +16,24 @@ */ import {GrDisplayNameUtils} from '../gr-display-name-utils/gr-display-name-utils.js'; -(function(window) { - 'use strict'; - - if (window.GrEmailSuggestionsProvider) { - return; +export class GrEmailSuggestionsProvider { + constructor(restAPI) { + this._restAPI = restAPI; } - class GrEmailSuggestionsProvider { - constructor(restAPI) { - this._restAPI = restAPI; - } - - getSuggestions(input) { - return this._restAPI.getSuggestedAccounts(`${input}`) - .then(accounts => { - if (!accounts) { return []; } - return accounts; - }); - } - - makeSuggestionItem(account) { - return { - name: GrDisplayNameUtils.getAccountDisplayName(null, account), - value: {account, count: 1}, - }; - } + getSuggestions(input) { + return this._restAPI.getSuggestedAccounts(`${input}`) + .then(accounts => { + if (!accounts) { return []; } + return accounts; + }); } - window.GrEmailSuggestionsProvider = GrEmailSuggestionsProvider; -})(window); + makeSuggestionItem(account) { + return { + name: GrDisplayNameUtils.getAccountDisplayName(null, account), + value: {account, count: 1}, + }; + } +} + diff --git a/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider_test.html b/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider_test.html index 1f0c9399a0..979fe80c38 100644 --- a/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider_test.html +++ b/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider_test.html @@ -33,7 +33,8 @@ limitations under the License.