Remove support of HTML plugins
Change-Id: If7b5503d57ea847e6cf2c038e589a55779fb551c
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
index 59287b2..c6e012d 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
@@ -938,7 +938,7 @@
.then(el => (hookEl = el as MetadataGrEndpointDecorator));
},
'0.1',
- 'http://some/plugins/url.html'
+ 'http://some/plugins/url.js'
);
getPluginLoader().loadPlugins([]);
flush(() => {
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
index b4e39f5..2868ae3 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
@@ -390,7 +390,7 @@
);
},
'0.1',
- 'http://some/plugins/url.html'
+ 'http://some/plugins/url.js'
);
});
@@ -2861,7 +2861,7 @@
.then(el => (hookEl = el));
},
'0.1',
- 'http://some/plugins/url.html'
+ 'http://some/plugins/url.js'
);
flush(() => {
assert.strictEqual((hookEl as any).plugin, plugin);
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
index 3567d58..5ea3ecb 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
@@ -732,7 +732,7 @@
.then(el => (hookEl = el as RelatedChangesListGrEndpointDecorator));
},
'0.1',
- 'http://some/plugins/url1.html'
+ 'http://some/plugins/url1.js'
);
getPluginLoader().loadPlugins([]);
flush(() => {
@@ -766,7 +766,7 @@
.then(el => (hookEl = el));
},
'0.1',
- 'http://some/plugins/url2.html'
+ 'http://some/plugins/url2.js'
);
getPluginLoader().loadPlugins([]);
flush(() => {
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
index b52fef0..4290e75 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
@@ -181,7 +181,6 @@
if (this.name) {
getPluginLoader()
.awaitPluginsLoaded()
- .then(() => getPluginEndpoints().getAndImportPlugins(this.name))
.then(() =>
getPluginEndpoints()
.getDetails(this.name)
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.js b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.js
index c48258d..8138ff0 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.js
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
import '../../../test/common-test-setup-karma.js';
import './gr-endpoint-decorator.js';
import '../gr-endpoint-param/gr-endpoint-param.js';
@@ -22,7 +21,6 @@
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
import {resetPlugins} from '../../../test/test-utils.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';
const pluginApi = _testOnly_initGerritPluginApi();
@@ -56,10 +54,8 @@
setup(done => {
resetPlugins();
container = basicFixture.instantiate();
- sinon.stub(getPluginEndpoints(), 'importUrl')
- .callsFake( url => Promise.resolve());
pluginApi.install(p => plugin = p, '0.1',
- 'http://some/plugin/url.html');
+ 'http://some/plugin/url.js');
// Decoration
decorationHook = plugin.registerCustomComponent('first', 'some-module');
decorationHookWithSlot = plugin.registerCustomComponent(
@@ -83,9 +79,6 @@
const endpoints =
Array.from(container.querySelectorAll('gr-endpoint-decorator'));
assert.equal(endpoints.length, 3);
- assert.isTrue(getPluginEndpoints().importUrl.calledWith(
- new URL('http://some/plugin/url.html')
- ));
});
test('decoration', () => {
diff --git a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
index 25cc354..5bc9965 100644
--- a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
@@ -53,14 +53,10 @@
}
_importAndApply() {
- getPluginEndpoints()
- .getAndImportPlugins(this.name)
- .then(() => {
- const moduleNames = getPluginEndpoints().getModules(this.name);
- for (const name of moduleNames) {
- this._applyStyle(name);
- }
- });
+ const moduleNames = getPluginEndpoints().getModules(this.name);
+ for (const name of moduleNames) {
+ this._applyStyle(name);
+ }
}
/** @override */
diff --git a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.js b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.js
index ad30f48..a192f80 100644
--- a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.js
@@ -14,12 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
import '../../../test/common-test-setup-karma.js';
import {resetPlugins} from '../../../test/test-utils.js';
import './gr-external-style.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';
@@ -30,7 +28,7 @@
);
suite('gr-external-style integration tests', () => {
- const TEST_URL = 'http://some.com/plugins/url.html';
+ const TEST_URL = 'http://some.com/plugins/url.js';
let element;
let plugin;
@@ -66,8 +64,6 @@
};
setup(() => {
- sinon.stub(getPluginEndpoints(), 'importUrl')
- .callsFake( url => Promise.resolve());
sinon.stub(getPluginLoader(), 'awaitPluginsLoaded')
.returns(Promise.resolve());
});
@@ -78,27 +74,12 @@
.forEach(style => style.remove());
});
- test('imports plugin-provided module', async () => {
- lateRegister();
- await new Promise(flush);
- assert.isTrue(getPluginEndpoints().importUrl.calledWith(new URL(TEST_URL)));
- });
-
test('applies plugin-provided styles', async () => {
lateRegister();
await new Promise(flush);
assert.isTrue(element._applyStyle.calledWith('some-module'));
});
- test('does not double import', async () => {
- earlyRegister();
- await new Promise(flush);
- plugin.registerStyleModule('foo', 'some-module');
- await new Promise(flush);
- // since loaded, should not call again
- assert.isFalse(getPluginEndpoints().importUrl.calledOnce);
- });
-
test('does not double apply', async () => {
earlyRegister();
await new Promise(flush);
diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
index 70087a5..6434c15 100644
--- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
@@ -27,11 +27,7 @@
_configChanged(config: ServerInfo) {
const plugins = config.plugin;
- const htmlPlugins = (plugins && plugins.html_resource_paths) || [];
- const jsPlugins = this._handleMigrations(
- (plugins && plugins.js_resource_paths) || [],
- htmlPlugins
- );
+ const jsPlugins = (plugins && plugins.js_resource_paths) || [];
const shouldLoadTheme =
!!config.default_theme &&
!getPluginLoader().isPluginPreloaded('preloaded:gerrit-theme');
@@ -39,30 +35,9 @@
const themeToLoad: string[] = shouldLoadTheme
? [config.default_theme!]
: [];
-
- // Theme should be loaded first if has one to have better UX
- const pluginsPending = themeToLoad.concat(jsPlugins, htmlPlugins);
-
- const pluginOpts: {[key: string]: {sync: boolean}} = {};
-
- if (shouldLoadTheme) {
- // config.default_theme is defined when shouldLoadTheme is true
- // Theme needs to be loaded synchronous.
- pluginOpts[config.default_theme!] = {sync: true};
- }
-
- getPluginLoader().loadPlugins(pluginsPending, pluginOpts);
- }
-
- /**
- * Omit .js plugins that have .html counterparts.
- * For example, if plugin provides foo.js and foo.html, skip foo.js.
- */
- _handleMigrations(jsPlugins: string[], htmlPlugins: string[]) {
- return jsPlugins.filter(url => {
- const counterpart = url.replace(/\.js$/, '.html');
- return !htmlPlugins.includes(counterpart);
- });
+ // Theme should be loaded first for better UX.
+ const pluginsPending = themeToLoad.concat(jsPlugins);
+ getPluginLoader().loadPlugins(pluginsPending);
}
}
diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.js b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.js
index 7a99dc4..3d35aa4 100644
--- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.js
@@ -34,29 +34,27 @@
sinon.stub(getPluginLoader(), 'loadPlugins');
element.config = {
plugin: {
- html_resource_paths: ['plugins/foo/bar', 'plugins/baz'],
- js_resource_paths: ['plugins/42'],
+ js_resource_paths: ['plugins/42', 'plugins/foo/bar', 'plugins/baz'],
},
};
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(getPluginLoader(), 'loadPlugins');
element.config = {
- default_theme: 'gerrit-theme.html',
+ default_theme: 'gerrit-theme.js',
plugin: {
- html_resource_paths: ['plugins/foo/bar', 'plugins/baz'],
- js_resource_paths: ['plugins/42'],
+ js_resource_paths: ['plugins/42', 'plugins/foo/bar', 'plugins/baz'],
},
};
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}}));
+ 'gerrit-theme.js', 'plugins/42', 'plugins/foo/bar', 'plugins/baz',
+ ]));
});
test('skip theme if preloaded', () => {
@@ -69,7 +67,7 @@
plugin: {},
};
assert.isTrue(getPluginLoader().loadPlugins.calledOnce);
- assert.isTrue(getPluginLoader().loadPlugins.calledWith([], {}));
+ assert.isTrue(getPluginLoader().loadPlugins.calledWith([]));
});
});
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.ts
index 979b86e..db127f3 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.ts
@@ -59,9 +59,9 @@
}
// Pathname should normally look like this:
- // /plugins/PLUGINNAME/static/SCRIPTNAME.html
+ // /plugins/PLUGINNAME/static/SCRIPTNAME.js
// Or, for app/samples:
- // /plugins/PLUGINNAME.html
+ // /plugins/PLUGINNAME.js
// TODO(taoalpha): guard with a regex
return pathname.split('/')[2].split('.')[0];
}
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.js
index 85c62cb..a09d887 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.js
@@ -34,18 +34,18 @@
test('with random invalid url', () => {
assert.equal(getPluginNameFromUrl('http://example.com'), null);
assert.equal(
- getPluginNameFromUrl('http://example.com/static/a.html'),
+ getPluginNameFromUrl('http://example.com/static/a.js'),
null
);
});
test('with valid urls', () => {
assert.equal(
- getPluginNameFromUrl('http://example.com/plugins/a.html'),
+ getPluginNameFromUrl('http://example.com/plugins/a.js'),
'a'
);
assert.equal(
- getPluginNameFromUrl('http://example.com/plugins/a/static/t.html'),
+ getPluginNameFromUrl('http://example.com/plugins/a/static/t.js'),
'a'
);
});
@@ -56,7 +56,7 @@
test('with gerrit-theme override', () => {
assert.equal(
- getPluginNameFromUrl('http://example.com/static/gerrit-theme.html'),
+ getPluginNameFromUrl('http://example.com/static/gerrit-theme.js'),
'gerrit-theme'
);
});
@@ -64,7 +64,7 @@
test('with ASSETS_PATH', () => {
window.ASSETS_PATH = 'http://cdn.com/2';
assert.equal(
- getPluginNameFromUrl(`${window.ASSETS_PATH}/plugins/a.html`),
+ getPluginNameFromUrl(`${window.ASSETS_PATH}/plugins/a.js`),
'a'
);
window.ASSETS_PATH = undefined;
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
index 7f9218a..34d77be 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
@@ -210,8 +210,8 @@
// TODO(taoalpha): consider removing these proxy methods
// and using getPluginLoader() directly
- globalGerritObj._loadPlugins = (plugins, opt_option) => {
- getPluginLoader().loadPlugins(plugins, opt_option);
+ globalGerritObj._loadPlugins = plugins => {
+ getPluginLoader().loadPlugins(plugins);
};
globalGerritObj._arePluginsLoaded = () => {
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
index 12a4056..a7fda9c 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
@@ -236,7 +236,7 @@
revisions: {def: {_number: 2}, abc: {_number: 1}},
};
const spy = sinon.spy();
- getPluginLoader().loadPlugins(['plugins/test.html']);
+ getPluginLoader().loadPlugins(['plugins/test.js']);
plugin.on(EventType.SHOW_CHANGE, spy);
element.handleEvent(EventType.SHOW_CHANGE,
{change: testChange, patchNum: 1});
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
index 46e91d0..0cc95a3 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
@@ -14,13 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-import {importHref} from '../../../scripts/import-href';
import {PluginApi} from '../../../api/plugin';
import {notUndefined} from '../../../types/types';
import {HookApi} from '../../../api/hook';
-import {appContext} from '../../../services/app-context';
-import {Execution} from '../../../constants/reporting';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Callback = (value: any) => void;
@@ -51,10 +47,6 @@
private readonly _dynamicPlugins = new Map<string, Set<string>>();
- private readonly _importedUrls = new Set<string>();
-
- private readonly reporting = appContext.reportingService;
-
private pluginLoaded = false;
setPluginsReady() {
@@ -183,47 +175,6 @@
notUndefined
);
}
-
- importUrl(pluginUrl: URL) {
- this.reporting.reportExecution(Execution.METHOD_USED, {
- id: 'import-href-endpoints',
- pluginUrl,
- });
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- let timerId: any;
- return Promise.race([
- new Promise((resolve, reject) => {
- this._importedUrls.add(pluginUrl.href);
- importHref(pluginUrl.href, resolve, reject);
- }),
- // Timeout after 3s
- new Promise(r => (timerId = setTimeout(r, 3000))),
- ]).finally(() => {
- if (timerId) clearTimeout(timerId);
- });
- }
-
- /**
- * Get plugin URLs with element and module definitions.
- */
- getAndImportPlugins(name: string, options?: Options) {
- return Promise.all(
- this.getPlugins(name, options).map(pluginUrl => {
- if (this._importedUrls.has(pluginUrl.href)) {
- return Promise.resolve();
- }
-
- // TODO: we will deprecate html plugins entirely
- // for now, keep the original behavior and import
- // only for html ones
- if (pluginUrl?.pathname.endsWith('.html')) {
- return this.importUrl(pluginUrl);
- } else {
- return Promise.resolve();
- }
- })
- );
- }
}
// TODO(dmfilippov): Convert to service and add to appContext
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.js
index 5b931b4..e3475ad 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.js
@@ -33,7 +33,7 @@
domHook = {};
instance = new GrPluginEndpoints();
pluginApi.install(p => { pluginFoo = p; }, '0.1',
- 'http://test.com/plugins/testplugin/static/foo.html');
+ 'http://test.com/plugins/testplugin/static/foo.js');
instance.registerModule(
pluginFoo,
{
@@ -44,7 +44,7 @@
}
);
pluginApi.install(p => { pluginBar = p; }, '0.1',
- 'http://test.com/plugins/testplugin/static/bar.html');
+ 'http://test.com/plugins/testplugin/static/bar.js');
instance.registerModule(
pluginBar,
{
@@ -54,7 +54,6 @@
domHook,
}
);
- sinon.spy(instance, 'importUrl');
});
teardown(() => {
@@ -120,14 +119,6 @@
instance.getPlugins('a-place'), [pluginFoo._url]);
});
- test('getAndImportPlugins', () => {
- instance.getAndImportPlugins('a-place');
- assert.isTrue(instance.importUrl.called);
- assert.isTrue(instance.importUrl.calledOnce);
- instance.getAndImportPlugins('a-place');
- assert.isTrue(instance.importUrl.calledOnce);
- });
-
test('onNewEndpoint', () => {
const newModuleStub = sinon.stub();
instance.setPluginsReady();
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
index 550a35f..85b6747 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
@@ -15,7 +15,6 @@
* limitations under the License.
*/
import {appContext} from '../../../services/app-context';
-import {importHref} from '../../../scripts/import-href';
import {
PLUGIN_LOADING_TIMEOUT_MS,
PRELOADED_PROTOCOL,
@@ -28,7 +27,6 @@
import {ReportingService} from '../../../services/gr-reporting/gr-reporting';
import {hasOwnProperty} from '../../../utils/common-util';
import {ShowAlertEventDetail} from '../../../types/events';
-import {Execution} from '../../../constants/reporting';
enum PluginState {
/** State that indicates the plugin is pending to be loaded. */
@@ -70,8 +68,8 @@
// Prefix for any unrecognized plugin urls.
// Url should match following patterns:
-// /plugins/PLUGINNAME/static/SCRIPTNAME.(html|js)
-// /plugins/PLUGINNAME.(js|html)
+// /plugins/PLUGINNAME/static/SCRIPTNAME.js
+// /plugins/PLUGINNAME.js
const UNKNOWN_PLUGIN_PREFIX = '__$$__';
// Current API version for Plugin,
@@ -117,7 +115,7 @@
/**
* Load multiple plugins with certain options.
*/
- loadPlugins(plugins: string[] = [], opts: PluginOptionMap = {}) {
+ loadPlugins(plugins: string[] = []) {
this._pluginListLoaded = true;
plugins.forEach(path => {
@@ -135,9 +133,7 @@
plugin: null,
});
- if (this._isPathEndsWith(url, '.html')) {
- this._importHtmlPlugin(path, opts && opts[path]);
- } else if (this._isPathEndsWith(url, '.js')) {
+ if (this._isPathEndsWith(url, '.js')) {
this._loadJsPlugin(path);
} else {
this._failToLoad(`Unrecognized plugin path ${path}`, path);
@@ -337,34 +333,6 @@
: false;
}
- _importHtmlPlugin(pluginUrl: string, opts: PluginOption = {}) {
- const urlWithAP = this._urlFor(pluginUrl, window.ASSETS_PATH);
- const urlWithoutAP = this._urlFor(pluginUrl);
- let onerror = undefined;
- this._getReporting().reportExecution(Execution.METHOD_USED, {
- id: 'html-plugin',
- pluginUrl,
- });
- if (urlWithAP !== urlWithoutAP) {
- onerror = () => this._loadHtmlPlugin(urlWithoutAP, opts.sync);
- }
- this._loadHtmlPlugin(urlWithAP, opts.sync, onerror);
- }
-
- _loadHtmlPlugin(url: string, sync?: boolean, onerror?: (e: Event) => void) {
- if (!onerror) {
- onerror = () => {
- this._failToLoad(`${url} import error`, url);
- };
- }
-
- this._getReporting().reportExecution(Execution.METHOD_USED, {
- id: 'import-href-loader',
- url,
- });
- importHref(url, () => {}, onerror, !sync);
- }
-
_loadJsPlugin(pluginUrl: string) {
const urlWithAP = this._urlFor(pluginUrl, window.ASSETS_PATH);
const urlWithoutAP = this._urlFor(pluginUrl);
@@ -394,9 +362,7 @@
_urlFor(pathOrUrl: string, assetsPath?: string): string {
// theme is per host, should always load from assetsPath
- const isThemeFile =
- pathOrUrl.endsWith('static/gerrit-theme.html') ||
- pathOrUrl.endsWith('static/gerrit-theme.js');
+ const isThemeFile = pathOrUrl.endsWith('static/gerrit-theme.js');
const shouldTryLoadFromAssetsPathFirst = !isThemeFile && assetsPath;
if (
pathOrUrl.startsWith(PRELOADED_PROTOCOL) ||
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
index f5b1fca..b139574 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
@@ -270,13 +270,8 @@
});
suite('plugin path and url', () => {
- let importHtmlPluginStub;
let loadJsPluginStub;
setup(() => {
- importHtmlPluginStub = sinon.stub();
- sinon.stub(pluginLoader, '_loadHtmlPlugin').callsFake( url => {
- importHtmlPluginStub(url);
- });
loadJsPluginStub = sinon.stub();
sinon.stub(pluginLoader, '_createScriptTag').callsFake( url => {
loadJsPluginStub(url);
@@ -303,13 +298,8 @@
test('relative path for plugins', () => {
pluginLoader.loadPlugins([
'foo/bar.js',
- 'foo/bar.html',
]);
- assert.isTrue(importHtmlPluginStub.calledOnce);
- assert.isTrue(
- importHtmlPluginStub.calledWithExactly(`${url}/foo/bar.html`)
- );
assert.isTrue(loadJsPluginStub.calledOnce);
assert.isTrue(
loadJsPluginStub.calledWithExactly(`${url}/foo/bar.js`)
@@ -322,17 +312,10 @@
pluginLoader.loadPlugins([
'foo/bar.js',
- 'foo/bar.html',
]);
- assert.isTrue(importHtmlPluginStub.calledOnce);
assert.isTrue(loadJsPluginStub.calledOnce);
assert.isTrue(
- importHtmlPluginStub.calledWithExactly(
- `${url}${testUrl}/foo/bar.html`
- )
- );
- assert.isTrue(
loadJsPluginStub.calledWithExactly(`${url}${testUrl}/foo/bar.js`)
);
});
@@ -340,13 +323,8 @@
test('absolute path for plugins', () => {
pluginLoader.loadPlugins([
'http://e.com/foo/bar.js',
- 'http://e.com/foo/bar.html',
]);
- assert.isTrue(importHtmlPluginStub.calledOnce);
- assert.isTrue(
- importHtmlPluginStub.calledWithExactly(`http://e.com/foo/bar.html`)
- );
assert.isTrue(loadJsPluginStub.calledOnce);
assert.isTrue(
loadJsPluginStub.calledWithExactly(`http://e.com/foo/bar.js`)
@@ -355,14 +333,9 @@
});
suite('With ASSETS_PATH', () => {
- let importHtmlPluginStub;
let loadJsPluginStub;
setup(() => {
window.ASSETS_PATH = 'https://cdn.com';
- importHtmlPluginStub = sinon.stub();
- sinon.stub(pluginLoader, '_loadHtmlPlugin').callsFake( url => {
- importHtmlPluginStub(url);
- });
loadJsPluginStub = sinon.stub();
sinon.stub(pluginLoader, '_createScriptTag').callsFake( url => {
loadJsPluginStub(url);
@@ -376,13 +349,8 @@
test('Should try load plugins from assets path instead', () => {
pluginLoader.loadPlugins([
'foo/bar.js',
- 'foo/bar.html',
]);
- assert.isTrue(importHtmlPluginStub.calledOnce);
- assert.isTrue(
- importHtmlPluginStub.calledWithExactly(`https://cdn.com/foo/bar.html`)
- );
assert.isTrue(loadJsPluginStub.calledOnce);
assert.isTrue(
loadJsPluginStub.calledWithExactly(`https://cdn.com/foo/bar.js`));
@@ -390,14 +358,9 @@
test('Should honor original path if exists', () => {
pluginLoader.loadPlugins([
- 'http://e.com/foo/bar.html',
'http://e.com/foo/bar.js',
]);
- assert.isTrue(importHtmlPluginStub.calledOnce);
- assert.isTrue(
- importHtmlPluginStub.calledWithExactly(`http://e.com/foo/bar.html`)
- );
assert.isTrue(loadJsPluginStub.calledOnce);
assert.isTrue(
loadJsPluginStub.calledWithExactly(`http://e.com/foo/bar.js`));
@@ -406,14 +369,9 @@
test('Should try replace current host with assetsPath', () => {
const host = window.location.origin;
pluginLoader.loadPlugins([
- `${host}/foo/bar.html`,
`${host}/foo/bar.js`,
]);
- assert.isTrue(importHtmlPluginStub.calledOnce);
- assert.isTrue(
- importHtmlPluginStub.calledWithExactly(`https://cdn.com/foo/bar.html`)
- );
assert.isTrue(loadJsPluginStub.calledOnce);
assert.isTrue(
loadJsPluginStub.calledWithExactly(`https://cdn.com/foo/bar.js`));
@@ -456,10 +414,6 @@
window.Gerrit._preloadedPlugins = null;
});
test('skips preloaded plugins when load plugins', () => {
- const importHtmlPluginStub = sinon.stub();
- sinon.stub(pluginLoader, '_importHtmlPlugin').callsFake( url => {
- importHtmlPluginStub(url);
- });
const loadJsPluginStub = sinon.stub();
sinon.stub(pluginLoader, '_loadJsPlugin').callsFake( url => {
loadJsPluginStub(url);
@@ -472,11 +426,9 @@
pluginLoader.loadPlugins([
'http://e.com/plugins/foo.js',
- 'plugins/bar.html',
'http://e.com/plugins/test/foo.js',
]);
- assert.isTrue(importHtmlPluginStub.notCalled);
assert.isTrue(loadJsPluginStub.calledOnce);
});
@@ -502,8 +454,8 @@
let plugin;
pluginApi.install(p => { plugin = p; }, '0.1', 'preloaded:foo');
assert.strictEqual(plugin.getPluginName(), 'foo');
- assert.strictEqual(plugin.url('/some/thing.html'),
- `${window.location.origin}/plugins/foo/some/thing.html`);
+ assert.strictEqual(plugin.url('/some/thing.js'),
+ `${window.location.origin}/plugins/foo/some/thing.js`);
});
});
});
diff --git a/polygerrit-ui/app/test/test-data-generators.ts b/polygerrit-ui/app/test/test-data-generators.ts
index 26547fb..6c37074 100644
--- a/polygerrit-ui/app/test/test-data-generators.ts
+++ b/polygerrit-ui/app/test/test-data-generators.ts
@@ -363,7 +363,6 @@
return {
has_avatars: false,
js_resource_paths: [],
- html_resource_paths: [],
};
}
diff --git a/polygerrit-ui/app/types/common.ts b/polygerrit-ui/app/types/common.ts
index 0649002..638669a 100644
--- a/polygerrit-ui/app/types/common.ts
+++ b/polygerrit-ui/app/types/common.ts
@@ -1023,9 +1023,8 @@
*/
export interface PluginConfigInfo {
has_avatars: boolean;
- // The following 2 properties exists in Java class, but don't mention in docs
+ // Exists in Java class, but not mentioned in docs.
js_resource_paths: string[];
- html_resource_paths: string[];
}
/**