Merge "Added a types.js file to support cross-module types"
diff --git a/java/com/google/gerrit/server/change/FileContentUtil.java b/java/com/google/gerrit/server/change/FileContentUtil.java
index 5c7946c..49c1fe2 100644
--- a/java/com/google/gerrit/server/change/FileContentUtil.java
+++ b/java/com/google/gerrit/server/change/FileContentUtil.java
@@ -100,7 +100,7 @@
public BinaryResult getContent(
Repository repo, ProjectState project, ObjectId revstr, String path)
- throws IOException, ResourceNotFoundException {
+ throws IOException, ResourceNotFoundException, BadRequestException {
try (RevWalk rw = new RevWalk(repo)) {
RevCommit commit = rw.parseCommit(revstr);
try (TreeWalk tw = TreeWalk.forPath(rw.getObjectReader(), path, commit.getTree())) {
@@ -114,6 +114,10 @@
return BinaryResult.create(id.name()).setContentType(X_GIT_GITLINK).base64();
}
+ if (mode == org.eclipse.jgit.lib.FileMode.TREE) {
+ throw new BadRequestException("cannot retrieve content of directories");
+ }
+
ObjectLoader obj = repo.open(id, OBJ_BLOB);
byte[] raw;
try {
diff --git a/java/com/google/gerrit/server/fixes/FixReplacementInterpreter.java b/java/com/google/gerrit/server/fixes/FixReplacementInterpreter.java
index a1682fe..9d6df7d 100644
--- a/java/com/google/gerrit/server/fixes/FixReplacementInterpreter.java
+++ b/java/com/google/gerrit/server/fixes/FixReplacementInterpreter.java
@@ -20,6 +20,7 @@
import com.google.gerrit.common.RawInputUtil;
import com.google.gerrit.entities.Comment;
import com.google.gerrit.entities.FixReplacement;
+import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
@@ -69,7 +70,8 @@
ProjectState projectState,
ObjectId patchSetCommitId,
List<FixReplacement> fixReplacements)
- throws ResourceNotFoundException, IOException, ResourceConflictException {
+ throws BadRequestException, ResourceNotFoundException, IOException,
+ ResourceConflictException {
requireNonNull(fixReplacements, "Fix replacements must not be null");
Map<String, List<FixReplacement>> fixReplacementsPerFilePath =
@@ -91,7 +93,8 @@
ObjectId patchSetCommitId,
String filePath,
List<FixReplacement> fixReplacements)
- throws ResourceNotFoundException, IOException, ResourceConflictException {
+ throws BadRequestException, ResourceNotFoundException, IOException,
+ ResourceConflictException {
String fileContent = getFileContent(repository, projectState, patchSetCommitId, filePath);
String newFileContent = getNewFileContent(fileContent, fixReplacements);
return new ChangeFileContentModification(filePath, RawInputUtil.create(newFileContent));
@@ -99,7 +102,7 @@
private String getFileContent(
Repository repository, ProjectState projectState, ObjectId patchSetCommitId, String filePath)
- throws ResourceNotFoundException, IOException {
+ throws ResourceNotFoundException, BadRequestException, IOException {
try (BinaryResult fileContent =
fileContentUtil.getContent(repository, projectState, patchSetCommitId, filePath)) {
return fileContent.asString();
diff --git a/java/com/google/gerrit/server/restapi/change/ApplyFix.java b/java/com/google/gerrit/server/restapi/change/ApplyFix.java
index d31fd92..74c5bc2 100644
--- a/java/com/google/gerrit/server/restapi/change/ApplyFix.java
+++ b/java/com/google/gerrit/server/restapi/change/ApplyFix.java
@@ -18,6 +18,7 @@
import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.restapi.AuthException;
+import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response;
@@ -65,8 +66,8 @@
@Override
public Response<EditInfo> apply(FixResource fixResource, Void nothing)
- throws AuthException, ResourceConflictException, IOException, ResourceNotFoundException,
- PermissionBackendException {
+ throws AuthException, BadRequestException, ResourceConflictException, IOException,
+ ResourceNotFoundException, PermissionBackendException {
RevisionResource revisionResource = fixResource.getRevisionResource();
Project.NameKey project = revisionResource.getProject();
ProjectState projectState = projectCache.checkedGet(project);
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
index 32941ff..ad73e0f 100644
--- a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
@@ -1328,6 +1328,23 @@
}
@Test
+ public void cannotGetContentOfDirectory() throws Exception {
+ Map<String, String> files = ImmutableMap.of("dir/file1.txt", "content 1");
+ PushOneCommit.Result result =
+ pushFactory.create(admin.newIdent(), testRepo, SUBJECT, files).to("refs/for/master");
+ result.assertOkStatus();
+
+ assertThrows(
+ BadRequestException.class,
+ () ->
+ gApi.changes()
+ .id(result.getChangeId())
+ .revision(result.getCommit().name())
+ .file("dir")
+ .content());
+ }
+
+ @Test
public void contentType() throws Exception {
PushOneCommit.Result r = createChange();
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
index 46b79b1..4783509 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
@@ -36,6 +36,7 @@
<link rel="import" href="../gr-confirm-move-dialog/gr-confirm-move-dialog.html">
<link rel="import" href="../gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.html">
<link rel="import" href="../gr-confirm-revert-dialog/gr-confirm-revert-dialog.html">
+<link rel="import" href="../gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.html">
<link rel="import" href="../gr-confirm-submit-dialog/gr-confirm-submit-dialog.html">
<link rel="import" href="../../../styles/shared-styles.html">
@@ -208,6 +209,11 @@
on-confirm="_handleRevertDialogConfirm"
on-cancel="_handleConfirmDialogCancel"
hidden></gr-confirm-revert-dialog>
+ <gr-confirm-revert-submission-dialog id="confirmRevertSubmissionDialog"
+ class="confirmDialog"
+ on-confirm="_handleRevertSubmissionDialogConfirm"
+ on-cancel="_handleConfirmDialogCancel"
+ hidden></gr-confirm-revert-submission-dialog>
<gr-confirm-abandon-dialog id="confirmAbandonDialog"
class="confirmDialog"
on-confirm="_handleAbandonDialogConfirm"
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
index fe70239..c8466df 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
@@ -64,6 +64,7 @@
REBASE_EDIT: 'rebaseEdit',
RESTORE: 'restore',
REVERT: 'revert',
+ REVERT_SUBMISSION: 'revert_submission',
REVIEWED: 'reviewed',
STOP_EDIT: 'stopEdit',
UNIGNORE: 'unignore',
@@ -86,6 +87,7 @@
rebase: 'Rebasing...',
restore: 'Restoring...',
revert: 'Reverting...',
+ revert_submission: 'Reverting Submission...',
submit: 'Submitting...',
};
@@ -180,6 +182,7 @@
ChangeActions.REBASE_EDIT,
ChangeActions.RESTORE,
ChangeActions.REVERT,
+ ChangeActions.REVERT_SUBMISSION,
ChangeActions.STOP_EDIT,
QUICK_APPROVE_ACTION.key,
RevisionActions.REBASE,
@@ -906,6 +909,19 @@
this._showActionDialog(this.$.confirmRevertDialog);
},
+ _modifyRevertSubmissionMsg() {
+ return this.$.jsAPI.modifyRevertSubmissionMsg(this.change,
+ this.$.confirmRevertSubmissionDialog.message, this.commitMessage);
+ },
+
+ showRevertSubmissionDialog() {
+ this.$.confirmRevertSubmissionDialog.populateRevertSubmissionMessage(
+ this.commitMessage, this.change.current_revision);
+ this.$.confirmRevertSubmissionDialog.message =
+ this._modifyRevertSubmissionMsg();
+ this._showActionDialog(this.$.confirmRevertSubmissionDialog);
+ },
+
_handleActionTap(e) {
e.preventDefault();
let el = Polymer.dom(e).localTarget;
@@ -956,6 +972,9 @@
case ChangeActions.REVERT:
this.showRevertDialog();
break;
+ case ChangeActions.REVERT_SUBMISSION:
+ this.showRevertSubmissionDialog();
+ break;
case ChangeActions.ABANDON:
this._showActionDialog(this.$.confirmAbandonDialog);
break;
@@ -1118,6 +1137,14 @@
{message: el.message});
},
+ _handleRevertSubmissionDialogConfirm() {
+ const el = this.$.confirmRevertSubmissionDialog;
+ this.$.overlay.close();
+ el.hidden = true;
+ this._fireAction('/revert_submission', this.actions.revert_submission,
+ false, {message: el.message});
+ },
+
_handleAbandonDialogConfirm() {
const el = this.$.confirmAbandonDialog;
this.$.overlay.close();
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
index a84a465..e36587b 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
@@ -362,7 +362,7 @@
<div
id="mainContent"
class="container"
- on-show-checks-table="_handleShowChecksTable"
+ on-show-checks-table="_handleShowTab"
hidden$="{{_loading}}">
<div class$="[[_computeHeaderClass(_editMode)]]">
<div class="headerTitle">
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
index 2a6c18a..e6ceea2 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
@@ -415,15 +415,23 @@
this._showMessagesView = this.$.commentTabs.selected === 0;
},
- _handleFileTabChange() {
+ _handleFileTabChange(e) {
const selectedIndex = this.$$('#primaryTabs').selected;
this._showFileTabContent = selectedIndex === 0;
// Initial tab is the static files list.
- this._selectedFilesTabPluginEndpoint =
+ const newSelectedTab =
this._dynamicTabContentEndpoints[selectedIndex - 1];
+ if (newSelectedTab !== this._selectedFilesTabPluginEndpoint) {
+ this._selectedFilesTabPluginEndpoint = newSelectedTab;
+
+ const tabName = this._selectedFilesTabPluginEndpoint || 'files';
+ const source = e && e.type ? e.type : '';
+ this.$.reporting.reportInteraction('tab-changed',
+ `tabname: ${tabName}, source: ${source}`);
+ }
},
- _handleShowChecksTable(e) {
+ _handleShowTab(e) {
const idx = this._dynamicTabContentEndpoints.indexOf(e.detail.tab);
if (idx === -1) {
console.warn(e.detail.tab + ' tab not found');
@@ -431,7 +439,7 @@
}
this.$$('#primaryTabs').selected = idx + 1;
this.$$('#primaryTabs').scrollIntoView();
- this._handleFileTabChange();
+ this.$.reporting.reportInteraction('show-tab', e.detail.tab);
},
_handleEditCommitMessage(e) {
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.html b/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.html
new file mode 100644
index 0000000..b334989
--- /dev/null
+++ b/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.html
@@ -0,0 +1,71 @@
+<!--
+@license
+Copyright (C) 2019 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<link rel="import" href="/bower_components/iron-autogrow-textarea/iron-autogrow-textarea.html">
+<link rel="import" href="/bower_components/polymer/polymer.html">
+<link rel="import" href="../../../behaviors/fire-behavior/fire-behavior.html">
+<link rel="import" href="../../shared/gr-dialog/gr-dialog.html">
+<link rel="import" href="../../../styles/shared-styles.html">
+
+<dom-module id="gr-confirm-revert-submission-dialog">
+ <template>
+ <!-- TODO(taoalpha): move all shared styles to a style module. -->
+ <style include="shared-styles">
+ :host {
+ display: block;
+ }
+ :host([disabled]) {
+ opacity: .5;
+ pointer-events: none;
+ }
+ label {
+ cursor: pointer;
+ display: block;
+ width: 100%;
+ }
+ iron-autogrow-textarea {
+ font-family: var(--monospace-font-family);
+ padding: 0;
+ width: 73ch; /* Add a char to account for the border. */
+
+ --iron-autogrow-textarea {
+ border: 1px solid var(--border-color);
+ box-sizing: border-box;
+ font-family: var(--monospace-font-family);
+ }
+ }
+ </style>
+ <gr-dialog
+ confirm-label="Revert Submission"
+ on-confirm="_handleConfirmTap"
+ on-cancel="_handleCancelTap">
+ <div class="header" slot="header">Revert Submission</div>
+ <div class="main" slot="main">
+ <label for="messageInput">
+ Revert Commit Message
+ </label>
+ <iron-autogrow-textarea
+ id="messageInput"
+ class="message"
+ autocomplete="on"
+ max-rows="15"
+ bind-value="{{message}}"></iron-autogrow-textarea>
+ </div>
+ </gr-dialog>
+ </template>
+ <script src="gr-confirm-revert-submission-dialog.js"></script>
+</dom-module>
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.js
new file mode 100644
index 0000000..6cbbb37
--- /dev/null
+++ b/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog.js
@@ -0,0 +1,69 @@
+/**
+ * @license
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+(function() {
+ 'use strict';
+
+ const ERR_COMMIT_NOT_FOUND =
+ 'Unable to find the commit hash of this change.';
+
+ Polymer({
+ is: 'gr-confirm-revert-submission-dialog',
+
+ /**
+ * Fired when the confirm button is pressed.
+ *
+ * @event confirm
+ */
+
+ /**
+ * Fired when the cancel button is pressed.
+ *
+ * @event cancel
+ */
+
+ properties: {
+ message: String,
+ },
+
+ behaviors: [
+ Gerrit.FireBehavior,
+ ],
+
+ populateRevertSubmissionMessage(message, commitHash) {
+ // Follow the same convention of the revert
+ const revertTitle = 'Revert submission';
+ if (!commitHash) {
+ this.fire('show-alert', {message: ERR_COMMIT_NOT_FOUND});
+ return;
+ }
+ this.message = `${revertTitle}\n\n` +
+ `Reason for revert: <INSERT REASONING HERE>\n`;
+ },
+
+ _handleConfirmTap(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ this.fire('confirm', null, {bubbles: false});
+ },
+
+ _handleCancelTap(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ this.fire('cancel', null, {bubbles: false});
+ },
+ });
+})();
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog_test.html b/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog_test.html
new file mode 100644
index 0000000..c0f2dc3
--- /dev/null
+++ b/polygerrit-ui/app/elements/change/gr-confirm-revert-submission-dialog/gr-confirm-revert-submission-dialog_test.html
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<!--
+@license
+Copyright (C) 2019 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
+<title>gr-confirm-revert-submission-dialog</title>
+<script src="/test/common-test-setup.js"></script>
+<script src="/bower_components/webcomponentsjs/custom-elements-es5-adapter.js"></script>
+
+<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
+<script src="/bower_components/web-component-tester/browser.js"></script>
+<link rel="import" href="../../../test/common-test-setup.html"/>
+<link rel="import" href="gr-confirm-revert-submission-dialog.html">
+
+<script>void(0);</script>
+
+<test-fixture id="basic">
+ <template>
+ <gr-confirm-revert-submission-dialog>
+ </gr-confirm-revert-submission-dialog>
+ </template>
+</test-fixture>
+
+<script>
+ suite('gr-confirm-revert-submission-dialog tests', () => {
+ let element;
+ let sandbox;
+
+ setup(() => {
+ element = fixture('basic');
+ sandbox =sinon.sandbox.create();
+ });
+
+ teardown(() => sandbox.restore());
+
+ test('no match', () => {
+ assert.isNotOk(element.message);
+ const alertStub = sandbox.stub();
+ element.addEventListener('show-alert', alertStub);
+ element.populateRevertSubmissionMessage(
+ 'not a commitHash in sight'
+ );
+ assert.isTrue(alertStub.calledOnce);
+ });
+
+ test('single line', () => {
+ assert.isNotOk(element.message);
+ element.populateRevertSubmissionMessage(
+ 'one line commit\n\nChange-Id: abcdefg\n',
+ 'abcd123');
+ const expected = 'Revert submission\n\n' +
+ 'Reason for revert: <INSERT REASONING HERE>\n';
+ assert.equal(element.message, expected);
+ });
+
+ test('multi line', () => {
+ assert.isNotOk(element.message);
+ element.populateRevertSubmissionMessage(
+ 'many lines\ncommit\n\nmessage\n\nChange-Id: abcdefg\n',
+ 'abcd123');
+ const expected = 'Revert submission\n\n' +
+ 'Reason for revert: <INSERT REASONING HERE>\n';
+ assert.equal(element.message, expected);
+ });
+
+ test('issue above change id', () => {
+ assert.isNotOk(element.message);
+ element.populateRevertSubmissionMessage(
+ 'test \nvery\n\ncommit\n\nBug: Issue 42\nChange-Id: abcdefg\n',
+ 'abcd123');
+ const expected = 'Revert submission\n\n' +
+ 'Reason for revert: <INSERT REASONING HERE>\n';
+ assert.equal(element.message, expected);
+ });
+
+ test('revert a revert', () => {
+ assert.isNotOk(element.message);
+ element.populateRevertSubmissionMessage(
+ 'Revert "one line commit"\n\nChange-Id: abcdefg\n',
+ 'abcd123');
+ const expected = 'Revert submission\n\n' +
+ 'Reason for revert: <INSERT REASONING HERE>\n';
+ assert.equal(element.message, expected);
+ });
+ });
+</script>
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.html b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.html
index 0a00a01..69c2419 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.html
@@ -16,7 +16,6 @@
-->
<link rel="import" href="/bower_components/polymer/polymer.html">
<link rel="import" href="../../../behaviors/fire-behavior/fire-behavior.html">
-<link rel="import" href="../../shared/gr-js-api-interface/gr-js-api-interface.html">
<link rel="import" href="../gr-coverage-layer/gr-coverage-layer.html">
<link rel="import" href="../gr-diff-processor/gr-diff-processor.html">
<link rel="import" href="../gr-ranged-comment-layer/gr-ranged-comment-layer.html">
@@ -40,7 +39,6 @@
<gr-diff-processor
id="processor"
groups="{{_groups}}"></gr-diff-processor>
- <gr-js-api-interface id="jsAPI"></gr-js-api-interface>
</template>
<script src="../../../scripts/util.js"></script>
<script src="../gr-diff/gr-diff-line.js"></script>
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js
index c25e90c..07d0c1f 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js
@@ -292,6 +292,7 @@
e.detail = {
groups,
section,
+ numLines,
};
// Let it bubble up the DOM tree.
});
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder_test.html b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder_test.html
index 45de810..3fdf242 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder_test.html
@@ -30,6 +30,7 @@
<script src="../gr-diff-highlight/gr-annotation.js"></script>
<script src="gr-diff-builder.js"></script>
+<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../../shared/gr-rest-api-interface/mock-diff-response_test.html">
<link rel="import" href="gr-diff-builder.html">
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_test.html b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_test.html
index ffb5efa..1c1100d 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor_test.html
@@ -28,6 +28,7 @@
<link rel="import" href="../gr-diff/gr-diff.html">
<link rel="import" href="./gr-diff-cursor.html">
+<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../../shared/gr-rest-api-interface/mock-diff-response_test.html">
<script>void(0);</script>
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
index 54398b8..8b62103 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
@@ -250,6 +250,7 @@
'render-content': '_handleRenderContent',
'normalize-range': '_handleNormalizeRange',
+ 'diff-context-expanded': '_handleDiffContextExpanded',
},
observers: [
@@ -958,5 +959,10 @@
`Modified invalid comment range on l. ${event.detail.lineNum}` +
` of the ${event.detail.side} side`);
},
+
+ _handleDiffContextExpanded(event) {
+ this.$.reporting.reportInteraction(
+ 'diff-context-expanded', event.detail.numLines);
+ },
});
})();
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
index fc3862b..54e202d 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
@@ -118,6 +118,14 @@
* @event render
*/
+ /**
+ * Fired for interaction reporting when a diff context is expanded.
+ * Contains an event.detail with numLines about the number of lines that
+ * were expanded.
+ *
+ * @event diff-context-expanded
+ */
+
properties: {
changeNum: String,
noAutoRender: {
@@ -471,6 +479,9 @@
const el = Polymer.dom(e).localTarget;
if (el.classList.contains('showContext')) {
+ this.fire('diff-context-expanded', {
+ numLines: e.detail.numLines,
+ });
this.$.diffBuilder.showContext(e.detail.groups, e.detail.section);
} else if (el.classList.contains('lineNum')) {
this.addDraftAtLine(el);
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.html b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.html
index 8a0b58c..09342e1 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.html
@@ -26,6 +26,7 @@
<link rel="import" href="../../../test/common-test-setup.html"/>
<script src="../../../scripts/util.js"></script>
+<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../../shared/gr-rest-api-interface/mock-diff-response_test.html">
<link rel="import" href="gr-diff.html">
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
index 093667c..b7fe8b0 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
@@ -212,7 +212,8 @@
},
_hideActions(_showActions, _lastComment) {
- return !_showActions || !_lastComment || !!_lastComment.__draft;
+ return !_showActions || !_lastComment || !!_lastComment.__draft ||
+ !!_lastComment.robot_id;
},
_getLastComment() {
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html
index 86da001..b6222b4 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html
@@ -161,6 +161,9 @@
showActions = true;
lastComment.__draft = true;
assert.equal(element._hideActions(showActions, lastComment), true);
+ const robotComment = {};
+ robotComment.robot_id = true;
+ assert.equal(element._hideActions(showActions, robotComment), true);
});
test('setting project name loads the project config', done => {
diff --git a/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.html b/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.html
index 7bd6f48..743923b 100644
--- a/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.html
+++ b/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.html
@@ -76,6 +76,7 @@
<g id="restore"><path d="M12,8 L12,13 L16.28,15.54 L17,14.33 L13.5,12.25 L13.5,8 L12,8 Z M13,3 C8.03,3 4,7.03 4,12 L1,12 L4.89,15.89 L4.96,16.03 L9,12 L6,12 C6,8.13 9.13,5 13,5 C16.87,5 20,8.13 20,12 C20,15.87 16.87,19 13,19 C11.07,19 9.32,18.21 8.06,16.94 L6.64,18.36 C8.27,19.99 10.51,21 13,21 C17.97,21 22,16.97 22,12 C22,7.03 17.97,3 13,3 Z"></path></g>
<!-- This is a custom PolyGerrit SVG -->
<g id="revert"><path d="M12.3,8.5 C9.64999995,8.5 7.24999995,9.49 5.39999995,11.1 L1.79999995,7.5 L1.79999995,16.5 L10.8,16.5 L7.17999995,12.88 C8.56999995,11.72 10.34,11 12.3,11 C15.84,11 18.85,13.31 19.9,16.5 L22.27,15.72 C20.88,11.53 16.95,8.5 12.3,8.5"></path></g>
+ <g id="revert_submission"><path d="M12.3,8.5 C9.64999995,8.5 7.24999995,9.49 5.39999995,11.1 L1.79999995,7.5 L1.79999995,16.5 L10.8,16.5 L7.17999995,12.88 C8.56999995,11.72 10.34,11 12.3,11 C15.84,11 18.85,13.31 19.9,16.5 L22.27,15.72 C20.88,11.53 16.95,8.5 12.3,8.5"></path></g>
<!-- This is a custom PolyGerrit SVG -->
<g id="stopEdit"><path d="M4 4 20 4 20 20 4 20z"></path></g>
<!-- This is a custom PolyGerrit SVG -->
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 70a7a01..dd18987 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
@@ -25,6 +25,7 @@
COMMIT_MSG_EDIT: 'commitmsgedit',
COMMENT: 'comment',
REVERT: 'revert',
+ REVERT_SUBMISSION: 'revert_submission',
POST_REVERT: 'postrevert',
ANNOTATE_DIFF: 'annotatediff',
ADMIN_MENU_LINKS: 'admin-menu-links',
@@ -213,6 +214,17 @@
return revertMsg;
},
+ modifyRevertSubmissionMsg(change, revertSubmissionMsg, origMsg) {
+ for (const cb of this._getEventCallbacks(EventType.REVERT_SUBMISSION)) {
+ try {
+ revertSubmissionMsg = cb(change, revertSubmissionMsg, origMsg);
+ } catch (err) {
+ console.error(err);
+ }
+ }
+ return revertSubmissionMsg;
+ },
+
getDiffLayers(path, changeNum, patchNum) {
const layers = [];
for (const annotationApi of