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
This commit is contained in:
Ole Rehmsen
2018-10-23 16:13:35 +02:00
parent 1a0068256d
commit fd42b6452f
5 changed files with 23 additions and 18 deletions

View File

@@ -114,7 +114,6 @@ limitations under the License.
baseImage: Object,
revisionImage: Object,
projectName: String,
parentIndex: Number,
/**
* @type {Defs.LineOfInterest|null}
*/

View File

@@ -16,9 +16,9 @@ limitations under the License.
-->
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.html">
<link rel="import" href="../../core/gr-reporting/gr-reporting.html">
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../gr-diff/gr-diff.html">
<dom-module id="gr-diff-host">
@@ -47,7 +47,8 @@ limitations under the License.
base-image="[[_baseImage]]"
revision-image=[[_revisionImage]]
blame="[[_blame]]"
diff="[[_diff]]"></gr-diff>
diff="[[_diff]]"
parent-index="[[_parentIndex]]"></gr-diff>
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
<gr-reporting id="reporting" category="diff"></gr-reporting>
</template>

View File

@@ -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;
},
});
})();

View File

@@ -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]]">
<table

View File

@@ -176,10 +176,7 @@
observer: '_blameChanged',
},
_parentIndex: {
type: Number,
computed: '_computeParentIndex(patchRange.*)',
},
parentIndex: Number,
_newlineWarning: {
type: String,
@@ -693,16 +690,6 @@
return errorMessage ? 'showError' : '';
},
/**
* @return {number|null}
*/
_computeParentIndex(patchRangeRecord) {
if (!this.isMergeParent(patchRangeRecord.base.basePatchNum)) {
return null;
}
return this.getParentIndex(patchRangeRecord.base.basePatchNum);
},
expandAllContext() {
this._handleFullBypass();
},