Merge "Introduce a palette of three gray background colors"
diff --git a/Documentation/js-api.txt b/Documentation/js-api.txt
index 030541d..893ab36 100644
--- a/Documentation/js-api.txt
+++ b/Documentation/js-api.txt
@@ -150,6 +150,13 @@
parameter the URL of the plugin is returned. If passed a string
the argument is appended to the plugin URL.
+A plugin's URL is where this plugin is loaded, it doesn't
+necessary to be the same as the Gerrit host. Use `window.location`
+if you need to access the Gerrit host info.
+
+For preloaded plugins, the plugin url is based on a global
+configuration of where to load all plugins, default to current host.
+
[source,javascript]
----
self.url(); // "https://gerrit-review.googlesource.com/plugins/demo/"
diff --git a/polygerrit-ui/app/behaviors/gr-path-list-behavior/gr-path-list-behavior.html b/polygerrit-ui/app/behaviors/gr-path-list-behavior/gr-path-list-behavior.html
index 8f9bf00..67e4ca6 100644
--- a/polygerrit-ui/app/behaviors/gr-path-list-behavior/gr-path-list-behavior.html
+++ b/polygerrit-ui/app/behaviors/gr-path-list-behavior/gr-path-list-behavior.html
@@ -81,6 +81,12 @@
return path;
},
+ isMagicPath(path) {
+ return !!path &&
+ (path === Gerrit.PathListBehavior.COMMIT_MESSAGE_PATH || path ===
+ Gerrit.PathListBehavior.MERGE_LIST_PATH);
+ },
+
computeTruncatedPath(path) {
return Gerrit.PathListBehavior.truncatePath(
Gerrit.PathListBehavior.computeDisplayPath(path));
diff --git a/polygerrit-ui/app/behaviors/gr-path-list-behavior/gr-path-list-behavior_test.html b/polygerrit-ui/app/behaviors/gr-path-list-behavior/gr-path-list-behavior_test.html
index 924c98c..12b981c 100644
--- a/polygerrit-ui/app/behaviors/gr-path-list-behavior/gr-path-list-behavior_test.html
+++ b/polygerrit-ui/app/behaviors/gr-path-list-behavior/gr-path-list-behavior_test.html
@@ -56,6 +56,14 @@
assert.equal(name('/MERGE_LIST'), 'Merge list');
});
+ test('isMagicPath', () => {
+ const isMagic = Gerrit.PathListBehavior.isMagicPath;
+ assert.isFalse(isMagic(undefined));
+ assert.isFalse(isMagic('/foo.cc'));
+ assert.isTrue(isMagic('/COMMIT_MSG'));
+ assert.isTrue(isMagic('/MERGE_LIST'));
+ });
+
test('truncatePath with long path should add ellipsis', () => {
const truncatePath = Gerrit.PathListBehavior.truncatePath;
let path = 'level1/level2/level3/level4/file.js';
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
index fb57164..9943192 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
@@ -339,9 +339,9 @@
}
_calculatePatchChange(files) {
- const magicFilesExcluded = files.filter(files => {
- return files.__path !== '/COMMIT_MSG' && files.__path !== '/MERGE_LIST';
- });
+ const magicFilesExcluded = files.filter(files =>
+ !this.isMagicPath(files.__path)
+ );
return magicFilesExcluded.reduce((acc, obj) => {
const inserted = obj.lines_inserted ? obj.lines_inserted : 0;
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
index 40a02a3..cd53510 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
@@ -277,7 +277,7 @@
</span>
</div>
<div class="rightControls">
- <span class$="blameLoader [[_computeBlameLoaderClass(_isImageDiff)]]">
+ <span class$="blameLoader [[_computeBlameLoaderClass(_isImageDiff, _path)]]">
<gr-button
link
disabled="[[_isBlameLoading]]"
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
index 4c401cf..2f2b3863 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
@@ -1101,8 +1101,8 @@
});
}
- _computeBlameLoaderClass(isImageDiff) {
- return !isImageDiff ? 'show' : '';
+ _computeBlameLoaderClass(isImageDiff, path) {
+ return !this.isMagicPath(path) && !isImageDiff ? 'show' : '';
}
_getRevisionInfo(change) {
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
index 89b28d5..0567777 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
@@ -90,6 +90,7 @@
as="comment">
<gr-comment
comment="{{comment}}"
+ comments="{{comments}}"
robot-button-disabled="[[_shouldDisableAction(_showActions, _lastComment)]]"
change-num="[[changeNum]]"
patch-num="[[patchNum]]"
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
index cb87bd9..d1d60f1 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
@@ -60,7 +60,7 @@
display: none;
}
.header {
- align-items: baseline;
+ align-items: center;
cursor: pointer;
display: flex;
margin: calc(0px - var(--spacing-m)) calc(0px - var(--spacing-m)) 0 calc(0px - var(--spacing-m));
@@ -271,7 +271,7 @@
secondary
class$="action delete [[_computeDeleteButtonClass(_isAdmin, draft)]]"
on-click="_handleCommentDelete">
- (Delete)
+ <iron-icon id="icon" icon="gr-icons:delete"></iron-icon>
</gr-button>
<span class="date" on-click="_handleAnchorClick">
<gr-date-formatter
@@ -348,14 +348,16 @@
</div>
<div class="robotActions" hidden$="[[!_showRobotActions]]">
<template is="dom-if" if="[[isRobotComment]]">
- <gr-button
- link
- secondary
- class="action fix"
- on-click="_handleFix"
- disabled="[[robotButtonDisabled]]">
- Please Fix
- </gr-button>
+ <template is="dom-if" if="[[!_hasHumanReply]]">
+ <gr-button
+ link
+ secondary
+ class="action fix"
+ on-click="_handleFix"
+ disabled="[[robotButtonDisabled]]">
+ Please Fix
+ </gr-button>
+ </template>
<gr-endpoint-decorator name="robot-comment-controls">
<gr-endpoint-param name="comment" value="[[comment]]">
</gr-endpoint-param>
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
index 7951d20..eb4081e 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
@@ -81,6 +81,9 @@
notify: true,
observer: '_commentChanged',
},
+ comments: {
+ type: Array,
+ },
isRobotComment: {
type: Boolean,
value: false,
@@ -119,6 +122,7 @@
/** @type {?} */
projectConfig: Object,
robotButtonDisabled: Boolean,
+ _hasHumanReply: Boolean,
_isAdmin: {
type: Boolean,
value: false,
@@ -165,6 +169,7 @@
'_loadLocalDraft(changeNum, patchNum, comment)',
'_isRobotComment(comment)',
'_calculateActionstoShow(showActions, isRobotComment)',
+ '_computeHasHumanReply(comment, comments.*)',
];
}
@@ -310,6 +315,15 @@
}
}
+ _computeHasHumanReply() {
+ if (!this.comment || !this.comments) return;
+ // hide please fix button for robot comment that has human reply
+ this._hasHumanReply = this.comments.some(c => {
+ return c.in_reply_to && c.in_reply_to === this.comment.id
+ && !c.robot_id;
+ });
+ }
+
/**
* @param {!Object=} opt_mixin
*
@@ -356,7 +370,7 @@
if (editing) {
this.async(() => {
Polymer.dom.flush();
- this.textarea.putCursorAtEnd();
+ this.textarea && this.textarea.putCursorAtEnd();
}, 1);
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.html b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.html
index ad8b5e4..3111475 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.html
@@ -867,9 +867,145 @@
done();
});
element.isRobotComment = true;
+ element.comments = [element.comment];
flushAsynchronousOperations();
MockInteractions.tap(element.$$('.fix'));
});
+
+ test('do not show Please Fix button if human reply exists', () => {
+ element.comments = [
+ {
+ robot_id: 'happy_robot_id',
+ robot_run_id: '5838406743490560',
+ fix_suggestions: [
+ {
+ fix_id: '478ff847_3bf47aaf',
+ description: 'Make the smiley happier by giving it a nose.',
+ replacements: [
+ {
+ path: 'Documentation/config-gerrit.txt',
+ range: {
+ start_line: 10,
+ start_character: 7,
+ end_line: 10,
+ end_character: 9,
+ },
+ replacement: ':-)',
+ },
+ ],
+ },
+ ],
+ author: {
+ _account_id: 1030912,
+ name: 'Alice Kober-Sotzek',
+ email: 'aliceks@google.com',
+ avatars: [
+ {
+ url: '/s32-p/photo.jpg',
+ height: 32,
+ },
+ {
+ url: '/AaAdOFzPlFI/s56-p/photo.jpg',
+ height: 56,
+ },
+ {
+ url: '/AaAdOFzPlFI/s100-p/photo.jpg',
+ height: 100,
+ },
+ {
+ url: '/AaAdOFzPlFI/s120-p/photo.jpg',
+ height: 120,
+ },
+ ],
+ },
+ patch_set: 1,
+ id: 'eb0d03fd_5e95904f',
+ line: 10,
+ updated: '2017-04-04 15:36:17.000000000',
+ message: 'This is a robot comment with a fix.',
+ unresolved: false,
+ __commentSide: 'right',
+ collapsed: false,
+ },
+ {
+ __draft: true,
+ __draftID: '0.wbrfbwj89sa',
+ __date: '2019-12-04T13:41:03.689Z',
+ path: 'Documentation/config-gerrit.txt',
+ patchNum: 1,
+ side: 'REVISION',
+ __commentSide: 'right',
+ line: 10,
+ in_reply_to: 'eb0d03fd_5e95904f',
+ message: '> This is a robot comment with a fix.\n\nPlease Fix',
+ unresolved: true,
+ },
+ ];
+ element.comment = element.comments[0];
+ flushAsynchronousOperations();
+ assert.isNull(element.$$('robotActions gr-button'));
+ });
+
+ test('show Please Fix if no human reply', () => {
+ element.comments = [
+ {
+ robot_id: 'happy_robot_id',
+ robot_run_id: '5838406743490560',
+ fix_suggestions: [
+ {
+ fix_id: '478ff847_3bf47aaf',
+ description: 'Make the smiley happier by giving it a nose.',
+ replacements: [
+ {
+ path: 'Documentation/config-gerrit.txt',
+ range: {
+ start_line: 10,
+ start_character: 7,
+ end_line: 10,
+ end_character: 9,
+ },
+ replacement: ':-)',
+ },
+ ],
+ },
+ ],
+ author: {
+ _account_id: 1030912,
+ name: 'Alice Kober-Sotzek',
+ email: 'aliceks@google.com',
+ avatars: [
+ {
+ url: '/s32-p/photo.jpg',
+ height: 32,
+ },
+ {
+ url: '/AaAdOFzPlFI/s56-p/photo.jpg',
+ height: 56,
+ },
+ {
+ url: '/AaAdOFzPlFI/s100-p/photo.jpg',
+ height: 100,
+ },
+ {
+ url: '/AaAdOFzPlFI/s120-p/photo.jpg',
+ height: 120,
+ },
+ ],
+ },
+ patch_set: 1,
+ id: 'eb0d03fd_5e95904f',
+ line: 10,
+ updated: '2017-04-04 15:36:17.000000000',
+ message: 'This is a robot comment with a fix.',
+ unresolved: false,
+ __commentSide: 'right',
+ collapsed: false,
+ },
+ ];
+ element.comment = element.comments[0];
+ flushAsynchronousOperations();
+ assert.isNotNull(element.$$('.robotActions gr-button'));
+ });
});
</script>
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js
index 2d66cfa..0ec3d6a 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js
@@ -50,7 +50,11 @@
return url.pathname;
}
const base = Gerrit.BaseUrlBehavior.getBaseUrl();
- const pathname = url.pathname.replace(base, '');
+ let pathname = url.pathname.replace(base, '');
+ // Load from ASSETS_PATH
+ if (window.ASSETS_PATH && url.href.includes(window.ASSETS_PATH)) {
+ pathname = url.href.replace(window.ASSETS_PATH, '');
+ }
// Site theme is server from predefined path.
if (pathname === '/static/gerrit-theme.html') {
return 'gerrit-theme';
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.html
index 128738d..b43796f 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils_test.html
@@ -72,6 +72,15 @@
'gerrit-theme'
);
});
+
+ test('with ASSETS_PATH', () => {
+ window.ASSETS_PATH = 'http://cdn.com/2';
+ assert.equal(
+ getPluginNameFromUrl(`${window.ASSETS_PATH}/plugins/a.html`),
+ 'a'
+ );
+ window.ASSETS_PATH = undefined;
+ });
});
});
</script>
\ No newline at end of file
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
index 537e55b..bdce91f 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
@@ -82,6 +82,28 @@
'http://test.com/plugins/testplugin/static/test.js');
});
+ test('url for preloaded plugin without ASSETS_PATH', () => {
+ let plugin;
+ Gerrit.install(p => { plugin = p; }, '0.1',
+ 'preloaded:testpluginB');
+ assert.equal(plugin.url(),
+ `${window.location.origin}/plugins/testpluginB/`);
+ assert.equal(plugin.url('/static/test.js'),
+ `${window.location.origin}/plugins/testpluginB/static/test.js`);
+ });
+
+ test('url for preloaded plugin without ASSETS_PATH', () => {
+ const oldAssetsPath = window.ASSETS_PATH;
+ window.ASSETS_PATH = 'http://test.com';
+ let plugin;
+ Gerrit.install(p => { plugin = p; }, '0.1',
+ 'preloaded:testpluginC');
+ assert.equal(plugin.url(), `${window.ASSETS_PATH}/plugins/testpluginC/`);
+ assert.equal(plugin.url('/static/test.js'),
+ `${window.ASSETS_PATH}/plugins/testpluginC/static/test.js`);
+ window.ASSETS_PATH = oldAssetsPath;
+ });
+
test('_send on failure rejects with response text', () => {
sendStub.returns(Promise.resolve(
{status: 400, text() { return Promise.resolve('text'); }}));
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.js
index 4be38b6..081ce55 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.js
@@ -113,7 +113,7 @@
this._pluginListLoaded = true;
plugins.forEach(path => {
- const url = this._urlFor(path);
+ const url = this._urlFor(path, window.ASSETS_PATH);
// Skip if preloaded, for bundling.
if (this.isPluginPreloaded(url)) return;
@@ -128,11 +128,11 @@
});
if (this._isPathEndsWith(url, '.html')) {
- this._importHtmlPlugin(url, opts && opts[path]);
+ this._importHtmlPlugin(path, opts && opts[path]);
} else if (this._isPathEndsWith(url, '.js')) {
- this._loadJsPlugin(url);
+ this._loadJsPlugin(path);
} else {
- this._failToLoad(`Unrecognized plugin url ${url}`, url);
+ this._failToLoad(`Unrecognized plugin path ${path}`, path);
}
});
@@ -181,14 +181,15 @@
return;
}
- const pluginObject = this.getPlugin(src);
+ const url = this._urlFor(src);
+ const pluginObject = this.getPlugin(url);
let plugin = pluginObject && pluginObject.plugin;
if (!plugin) {
- plugin = new Plugin(src);
+ plugin = new Plugin(url);
}
try {
callback(plugin);
- this._pluginInstalled(src, plugin);
+ this._pluginInstalled(url, plugin);
} catch (e) {
this._failToLoad(`${e.name}: ${e.message}`, src);
}
@@ -313,38 +314,79 @@
}
_importHtmlPlugin(pluginUrl, opts = {}) {
- // onload (second param) needs to be a function. When null or undefined
- // were passed, plugins were not loaded correctly.
+ const urlWithAP = this._urlFor(pluginUrl, window.ASSETS_PATH);
+ const urlWithoutAP = this._urlFor(pluginUrl);
+ let onerror = null;
+ if (urlWithAP !== urlWithoutAP) {
+ onerror = () => this._loadHtmlPlugin(urlWithoutAP, opts.sync);
+ }
+ this._loadHtmlPlugin(urlWithAP, opts.sync, onerror);
+ }
+
+ _loadHtmlPlugin(url, sync, onerror) {
+ if (!onerror) {
+ onerror = () => {
+ this._failToLoad(`${url} import error`, url);
+ };
+ }
+
(Polymer.importHref || Polymer.Base.importHref)(
- this._urlFor(pluginUrl), () => {},
- () => this._failToLoad(`${pluginUrl} import error`, pluginUrl),
- !opts.sync);
+ url, () => {},
+ onerror,
+ !sync);
}
_loadJsPlugin(pluginUrl) {
- this._createScriptTag(this._urlFor(pluginUrl));
+ const urlWithAP = this._urlFor(pluginUrl, window.ASSETS_PATH);
+ const urlWithoutAP = this._urlFor(pluginUrl);
+ let onerror = null;
+ if (urlWithAP !== urlWithoutAP) {
+ onerror = () => this._createScriptTag(urlWithoutAP);
+ }
+
+ this._createScriptTag(urlWithAP, onerror);
}
- _createScriptTag(url) {
+ _createScriptTag(url, onerror) {
+ if (!onerror) {
+ onerror = () => this._failToLoad(`${url} load error`, url);
+ }
+
const el = document.createElement('script');
el.defer = true;
el.setAttribute('src', url);
- el.onerror = () => this._failToLoad(`${url} load error`, url);
+ el.onerror = onerror;
return document.body.appendChild(el);
}
- _urlFor(pathOrUrl) {
+ _urlFor(pathOrUrl, assetsPath) {
if (!pathOrUrl) {
return pathOrUrl;
}
+
+ // theme is per host, should always load from assetsPath
+ const isThemeFile = pathOrUrl.endsWith('static/gerrit-theme.html');
+ const shouldTryLoadFromAssetsPathFirst = !isThemeFile && assetsPath;
if (pathOrUrl.startsWith(PRELOADED_PROTOCOL) ||
pathOrUrl.startsWith('http')) {
// Plugins are loaded from another domain or preloaded.
+ if (pathOrUrl.includes(location.host)
+ && shouldTryLoadFromAssetsPathFirst) {
+ // if is loading from host server, try replace with cdn when assetsPath provided
+ return pathOrUrl
+ .replace(location.origin, assetsPath);
+ }
return pathOrUrl;
}
+
if (!pathOrUrl.startsWith('/')) {
pathOrUrl = '/' + pathOrUrl;
}
+
+ if (shouldTryLoadFromAssetsPathFirst) {
+ return assetsPath + pathOrUrl;
+ }
+
return window.location.origin + getBaseUrl() + pathOrUrl;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html
index 8c1ec96..151c340 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html
@@ -325,11 +325,11 @@
let loadJsPluginStub;
setup(() => {
importHtmlPluginStub = sandbox.stub();
- sandbox.stub(Gerrit._pluginLoader, '_importHtmlPlugin', url => {
+ sandbox.stub(Gerrit._pluginLoader, '_loadHtmlPlugin', url => {
importHtmlPluginStub(url);
});
loadJsPluginStub = sandbox.stub();
- sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ sandbox.stub(Gerrit._pluginLoader, '_createScriptTag', url => {
loadJsPluginStub(url);
});
});
@@ -346,8 +346,8 @@
assert.isTrue(failToLoadStub.calledOnce);
assert.isTrue(failToLoadStub.calledWithExactly(
- `Unrecognized plugin url ${url}/foo/bar`,
- `${url}/foo/bar`
+ 'Unrecognized plugin path foo/bar',
+ 'foo/bar'
));
});
@@ -407,6 +407,72 @@
});
});
+ suite('With ASSETS_PATH', () => {
+ let importHtmlPluginStub;
+ let loadJsPluginStub;
+ setup(() => {
+ window.ASSETS_PATH = 'https://cdn.com';
+ importHtmlPluginStub = sandbox.stub();
+ sandbox.stub(Gerrit._pluginLoader, '_loadHtmlPlugin', url => {
+ importHtmlPluginStub(url);
+ });
+ loadJsPluginStub = sandbox.stub();
+ sandbox.stub(Gerrit._pluginLoader, '_createScriptTag', url => {
+ loadJsPluginStub(url);
+ });
+ });
+
+ teardown(() => {
+ window.ASSETS_PATH = '';
+ });
+
+ test('Should try load plugins from assets path instead', () => {
+ Gerrit._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`));
+ });
+
+ test('Should honor original path if exists', () => {
+ Gerrit._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`));
+ });
+
+ test('Should try replace current host with assetsPath', () => {
+ const host = window.location.origin;
+ Gerrit._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`));
+ });
+ });
+
test('adds js plugins will call the body', () => {
Gerrit._loadPlugins([
'http://e.com/foo/bar.js',
@@ -489,12 +555,10 @@
test('installing preloaded plugin', () => {
let plugin;
- window.ASSETS_PATH = 'http://blips.com/chitz';
Gerrit.install(p => { plugin = p; }, '0.1', 'preloaded:foo');
assert.strictEqual(plugin.getPluginName(), 'foo');
assert.strictEqual(plugin.url('/some/thing.html'),
- 'http://blips.com/chitz/plugins/foo/some/thing.html');
- delete window.ASSETS_PATH;
+ `${window.location.origin}/plugins/foo/some/thing.html`);
});
});
});
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 6c306d9..6dc0309 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
@@ -17,8 +17,6 @@
(function(window) {
'use strict';
- const PRELOADED_PROTOCOL = 'preloaded:';
-
const PANEL_ENDPOINTS_MAPPING = {
CHANGE_SCREEN_BELOW_COMMIT_INFO_BLOCK: 'change-view-integration',
CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK: 'change-metadata-item',
@@ -26,6 +24,7 @@
// Import utils methods
const {
+ PRELOADED_PROTOCOL,
getPluginNameFromUrl,
send,
} = window._apiUtils;
@@ -66,13 +65,6 @@
this._url = new URL(opt_url);
this._name = getPluginNameFromUrl(this._url);
- if (this._url.protocol === PRELOADED_PROTOCOL) {
- // Original plugin URL is used in plugin assets URLs calculation.
- const assetsBaseUrl = window.ASSETS_PATH ||
- (window.location.origin + Gerrit.BaseUrlBehavior.getBaseUrl());
- this._url = new URL(assetsBaseUrl + '/plugins/' + this._name +
- '/static/' + this._name + '.js');
- }
}
Plugin._sharedAPIElement = document.createElement('gr-js-api-interface');
@@ -139,9 +131,15 @@
Plugin.prototype.url = function(opt_path) {
const relPath = '/plugins/' + this._name + (opt_path || '/');
+ const sameOriginPath = window.location.origin +
+ `${Gerrit.BaseUrlBehavior.getBaseUrl()}${relPath}`;
if (window.location.origin === this._url.origin) {
// Plugin loaded from the same origin as gr-app, getBaseUrl in effect.
- return this._url.origin + Gerrit.BaseUrlBehavior.getBaseUrl() + relPath;
+ return sameOriginPath;
+ } else if (this._url.protocol === PRELOADED_PROTOCOL) {
+ // Plugin is preloaded, load plugin with ASSETS_PATH or location.origin
+ return window.ASSETS_PATH ? `${window.ASSETS_PATH}${relPath}`
+ : sameOriginPath;
} else {
// Plugin loaded from assets bundle, expect assets placed along with it.
return this._url.href.split('/plugins/' + this._name)[0] + relPath;
diff --git a/polygerrit-ui/app/styles/themes/app-theme.html b/polygerrit-ui/app/styles/themes/app-theme.html
index e6d8528..87230e6 100644
--- a/polygerrit-ui/app/styles/themes/app-theme.html
+++ b/polygerrit-ui/app/styles/themes/app-theme.html
@@ -170,9 +170,13 @@
--syntax-title-color: #0000c0;
--syntax-type-color: #2a66d9;
--syntax-variable-color: var(--primary-text-color);
+
/* misc */
--border-radius: 4px;
--reply-overlay-z-index: 1000;
+
+ /* paper and iron component overrides */
+ --iron-overlay-backdrop-background-color: black;
--iron-overlay-backdrop-opacity: 0.32;
--iron-overlay-backdrop: {
transition: none;
diff --git a/polygerrit-ui/app/styles/themes/dark-theme.html b/polygerrit-ui/app/styles/themes/dark-theme.html
index 865d44c..78bc48b 100644
--- a/polygerrit-ui/app/styles/themes/dark-theme.html
+++ b/polygerrit-ui/app/styles/themes/dark-theme.html
@@ -88,7 +88,7 @@
--dark-rebased-remove-highlight-color: rgba(255, 139, 6, 0.15);
--dark-remove-highlight-color: #62110f;
--diff-blank-background-color: #212121;
- --diff-context-control-background-color: #131416;
+ --diff-context-control-background-color: #333311;
--diff-context-control-border-color: var(--border-color);
--diff-context-control-color: var(--deemphasized-text-color);
--diff-highlight-range-color: rgba(0, 100, 200, 0.5);
@@ -133,6 +133,9 @@
/* misc */
+ /* paper and iron component overrides */
+ --iron-overlay-backdrop-background-color: white;
+
/* rules applied to <html> */
background-color: var(--view-background-color);
}