From fd42b6452f9a98c59d0a61a82f23ddaa29280293 Mon Sep 17 00:00:00 2001 From: Ole Rehmsen Date: Tue, 23 Oct 2018 16:13:35 +0200 Subject: [PATCH] Move parentIndex computation to gr-diff-host We need the parentIndex there when we move the creation of the comment threads to gr-diff-host. I also stopped passing it on to gr-diff-builder, because it was actually not used in there. Change-Id: Iac17d4fa0d6a99a765732b02f45707dd56e4122a --- .../diff/gr-diff-builder/gr-diff-builder.html | 1 - .../diff/gr-diff-host/gr-diff-host.html | 5 +++-- .../diff/gr-diff-host/gr-diff-host.js | 19 +++++++++++++++++++ .../app/elements/diff/gr-diff/gr-diff.html | 1 - .../app/elements/diff/gr-diff/gr-diff.js | 15 +-------------- 5 files changed, 23 insertions(+), 18 deletions(-) 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 cc66e3bdff..0997fee43f 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 @@ -114,7 +114,6 @@ limitations under the License. baseImage: Object, revisionImage: Object, projectName: String, - parentIndex: Number, /** * @type {Defs.LineOfInterest|null} */ diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.html b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.html index e3bf86690a..0e0f5422c4 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.html @@ -16,9 +16,9 @@ limitations under the License. --> + - @@ -47,7 +47,8 @@ limitations under the License. base-image="[[_baseImage]]" revision-image=[[_revisionImage]] blame="[[_blame]]" - diff="[[_diff]]"> + diff="[[_diff]]" + parent-index="[[_parentIndex]]"> 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 19fb308ed8..5ab37e1d31 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 @@ -174,8 +174,17 @@ }, _loadedWhitespaceLevel: String, + + _parentIndex: { + type: Number, + computed: '_computeParentIndex(patchRange.*)', + }, }, + behaviors: [ + Gerrit.PatchSetBehavior, + ], + listeners: { 'create-comment': '_handleCreateComment', }, @@ -530,5 +539,15 @@ this.reload(); } }, + + /** + * @param {Object} patchRangeRecord + * @return {number|null} + */ + _computeParentIndex(patchRangeRecord) { + return this.isMergeParent(patchRangeRecord.base.basePatchNum) ? + this.getParentIndex(patchRangeRecord.base.basePatchNum) : null; + }, + }); })(); diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html index bddfc6d636..adb4dd6055 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html +++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html @@ -290,7 +290,6 @@ limitations under the License. is-image-diff="[[isImageDiff]]" base-image="[[baseImage]]" revision-image="[[revisionImage]]" - parent-index="[[_parentIndex]]" create-comment-fn="[[_createThreadGroupFn]]" line-of-interest="[[lineOfInterest]]">