Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  UrlFormatter: Fix Javadoc of getSettingsUrl()
  Add a separator between blame and the edit icon
  Remove target=_self from commentlinks
  Update .mailmap
  ReceiveCommits: Factor repeated "internal server error" text to a constant
  Update .mailmap
  Documentation: Add site-path arg to reindex command
  Isolate log4j dep
  Update .mailmap
  Cancel deprecation of change identifiers
  FakeGroupAuditService: Make auditEvents final
  ErrorProne: Increase severity of MutableConstantField to ERROR
  ConfigUpdatedEvent: Use immutable type in field declaration
  Add missing slf4j dependencies in BUILD file
  JGitMetricModule: fix WindowCache miss ration which wasn't reported
  Revert "JGitMetricModule: Replace anonymous Supplier instances with method references"
  Suppress generic logging on docker start for ElasticSearch container
  Replace deprecated OptionParser with ArgumentParser
  Documentation: Replace plugins list with home page

Change-Id: Idae7755cb887a8df60028a96fff0a01d5d637f8a
This commit is contained in:
David Pursehouse
2020-03-01 17:21:02 +09:00
34 changed files with 288 additions and 898 deletions

View File

@@ -290,13 +290,15 @@ limitations under the License.
<span class="separator"></span>
</span>
<template is="dom-if" if="[[_computeIsLoggedIn(_loggedIn)]]">
<span class="separator"></span>
<span class="editButton">
<a href$="[[_computeEditURL(_change, _patchRange, _path)]]">
<iron-icon icon="gr-icons:edit"></iron-icon>
</a>
<span class="separator"></span>
<gr-button
link
title="Edit current file"
on-click="_goToEditFile">edit</gr-button>
</span>
</template>
<span class="separator"></span>
<div class$="diffModeSelector [[_computeModeSelectHideClass(_isImageDiff)]]">
<span>Diff view:</span>
<gr-diff-mode-selector

View File

@@ -566,12 +566,11 @@
return this._getDiffUrl(this._change, this._patchRange, newPath.path);
},
_computeEditURL(change, patchRange, path) {
if ([change, patchRange, path].some(arg => arg === undefined)) {
return '';
}
return Gerrit.Nav.getEditUrlForDiff(
change, path, patchRange.patchNum);
_goToEditFile() {
// TODO(taoalpha): add a shortcut for editing
const editUrl = Gerrit.Nav.getEditUrlForDiff(
this._change, this._path, this._patchRange.patchNum);
return Gerrit.Nav.navigateToRelativeUrl(editUrl);
},
/**

View File

@@ -365,6 +365,53 @@ limitations under the License.
PARENT), 'Should navigate to /c/42/1');
});
test('edit should redirect to edit page', done => {
element._loggedIn = true;
element._path = 't.txt';
element._patchRange = {
basePatchNum: PARENT,
patchNum: '1',
};
element._change = {
_number: 42,
revisions: {
a: {_number: 1, commit: {parents: []}},
b: {_number: 2, commit: {parents: []}},
},
};
const redirectStub = sandbox.stub(Gerrit.Nav, 'navigateToRelativeUrl');
flush(() => {
const editBtn = Polymer.dom(element.root)
.querySelector('.editButton gr-button');
assert.isTrue(!!editBtn);
MockInteractions.tap(editBtn);
assert.isTrue(redirectStub.called);
done();
});
});
test('edit hidden when not logged in', done => {
element._loggedIn = false;
element._path = 't.txt';
element._patchRange = {
basePatchNum: PARENT,
patchNum: '1',
};
element._change = {
_number: 42,
revisions: {
a: {_number: 1, commit: {parents: []}},
b: {_number: 2, commit: {parents: []}},
},
};
flush(() => {
const editBtn = Polymer.dom(element.root)
.querySelector('.editButton gr-button');
assert.isFalse(!!editBtn);
done();
});
});
suite('diff prefs hidden', () => {
test('when no prefs or logged out', () => {
element.disableDiffPrefs = false;

View File

@@ -72,10 +72,11 @@
// Ensure that external links originating from HTML commentlink configs
// open in a new tab. @see Issue 5567
// Ensure links to the same host originating from commentlink configs
// open in the same tab. @see Issue 4616
// open in the same tab. When target is not set - default is _self
// @see Issue 4616
output.querySelectorAll('a').forEach(anchor => {
if (anchor.hostname === window.location.hostname) {
anchor.setAttribute('target', '_self');
anchor.removeAttribute('target');
} else {
anchor.setAttribute('target', '_blank');
}

View File

@@ -144,7 +144,7 @@ limitations under the License.
const linkEl = element.$.output.childNodes[1];
assert.equal(textNode.textContent, prefix);
const url = '/q/' + changeID;
assert.equal(linkEl.target, '_self');
assert.isFalse(linkEl.hasAttribute('target'));
// Since url is a path, the host is added automatically.
assert.isTrue(linkEl.href.endsWith(url));
assert.equal(linkEl.textContent, changeID);
@@ -162,7 +162,7 @@ limitations under the License.
const linkEl = element.$.output.childNodes[1];
assert.equal(textNode.textContent, prefix);
const url = '/r/q/' + changeID;
assert.equal(linkEl.target, '_self');
assert.isFalse(linkEl.hasAttribute('target'));
// Since url is a path, the host is added automatically.
assert.isTrue(linkEl.href.endsWith(url));
assert.equal(linkEl.textContent, changeID);
@@ -203,7 +203,7 @@ limitations under the License.
assert.equal(textNode.textContent, prefix);
assert.equal(changeLinkEl.target, '_self');
assert.isFalse(changeLinkEl.hasAttribute('target'));
assert.isTrue(changeLinkEl.href.endsWith(changeUrl));
assert.equal(changeLinkEl.textContent, changeID);