gr-ajax cleanup (gr-related-changes-list)
Bug: Issue 3988 Change-Id: I087f5abfa33e28246ef8701b1cfb06575c15c1db
This commit is contained in:
@@ -266,9 +266,8 @@ limitations under the License.
|
|||||||
</div>
|
</div>
|
||||||
<div class="relatedChanges">
|
<div class="relatedChanges">
|
||||||
<gr-related-changes-list id="relatedChanges"
|
<gr-related-changes-list id="relatedChanges"
|
||||||
change="[[_change]]"
|
change="[[_change]]"
|
||||||
server-config="[[serverConfig]]"
|
patch-num="[[_patchNum]]"></gr-related-changes-list>
|
||||||
patch-num="[[_patchNum]]"></gr-related-changes-list>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@@ -15,8 +15,7 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||||
<link rel="import" href="../../../behaviors/rest-client-behavior.html">
|
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||||
<link rel="import" href="../../shared/gr-ajax/gr-ajax.html">
|
|
||||||
|
|
||||||
<dom-module id="gr-related-changes-list">
|
<dom-module id="gr-related-changes-list">
|
||||||
<template>
|
<template>
|
||||||
@@ -68,25 +67,6 @@ limitations under the License.
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<gr-ajax id="relatedXHR"
|
|
||||||
url="[[_computeRelatedURL(change._number, patchNum)]]"
|
|
||||||
last-response="{{_relatedResponse}}"></gr-ajax>
|
|
||||||
<gr-ajax id="submittedTogetherXHR"
|
|
||||||
url="[[_computeSubmittedTogetherURL(change._number)]]"
|
|
||||||
last-response="{{_submittedTogether}}"></gr-ajax>
|
|
||||||
<gr-ajax id="conflictsXHR"
|
|
||||||
url="/changes/"
|
|
||||||
params="[[_computeConflictsQueryParams(change._number)]]"
|
|
||||||
last-response="{{_conflicts}}"></gr-ajax>
|
|
||||||
<gr-ajax id="cherryPicksXHR"
|
|
||||||
url="/changes/"
|
|
||||||
params="[[_computeCherryPicksQueryParams(change.project, change.change_id, change._number)]]"
|
|
||||||
last-response="{{_cherryPicks}}"></gr-ajax>
|
|
||||||
<gr-ajax id="sameTopicXHR"
|
|
||||||
url="/changes/"
|
|
||||||
params="[[_computeSameTopicQueryParams(change.topic)]]"
|
|
||||||
last-response="{{_sameTopic}}"></gr-ajax>
|
|
||||||
|
|
||||||
<div hidden$="[[!_loading]]">Loading...</div>
|
<div hidden$="[[!_loading]]">Loading...</div>
|
||||||
<section class="relatedChanges" hidden$="[[!_relatedResponse.changes.length]]" hidden>
|
<section class="relatedChanges" hidden$="[[!_relatedResponse.changes.length]]" hidden>
|
||||||
<h4>Relation chain</h4>
|
<h4>Relation chain</h4>
|
||||||
@@ -138,6 +118,7 @@ limitations under the License.
|
|||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
</section>
|
</section>
|
||||||
|
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||||
</template>
|
</template>
|
||||||
<script src="gr-related-changes-list.js"></script>
|
<script src="gr-related-changes-list.js"></script>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
@@ -20,10 +20,6 @@
|
|||||||
properties: {
|
properties: {
|
||||||
change: Object,
|
change: Object,
|
||||||
patchNum: String,
|
patchNum: String,
|
||||||
serverConfig: {
|
|
||||||
type: Object,
|
|
||||||
observer: '_serverConfigChanged',
|
|
||||||
},
|
|
||||||
hidden: {
|
hidden: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
@@ -31,15 +27,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_loading: Boolean,
|
_loading: Boolean,
|
||||||
_resolveServerConfigReady: Function,
|
|
||||||
_serverConfigReady: {
|
|
||||||
type: Object,
|
|
||||||
value: function() {
|
|
||||||
return new Promise(function(resolve) {
|
|
||||||
this._resolveServerConfigReady = resolve;
|
|
||||||
}.bind(this));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_connectedRevisions: {
|
_connectedRevisions: {
|
||||||
type: Array,
|
type: Array,
|
||||||
computed: '_computeConnectedRevisions(change, patchNum, ' +
|
computed: '_computeConnectedRevisions(change, patchNum, ' +
|
||||||
@@ -52,10 +39,6 @@
|
|||||||
_sameTopic: Array,
|
_sameTopic: Array,
|
||||||
},
|
},
|
||||||
|
|
||||||
behaviors: [
|
|
||||||
Gerrit.RESTClientBehavior,
|
|
||||||
],
|
|
||||||
|
|
||||||
observers: [
|
observers: [
|
||||||
'_resultsChanged(_relatedResponse.changes, _submittedTogether, ' +
|
'_resultsChanged(_relatedResponse.changes, _submittedTogether, ' +
|
||||||
'_conflicts, _cherryPicks, _sameTopic)',
|
'_conflicts, _cherryPicks, _sameTopic)',
|
||||||
@@ -67,72 +50,58 @@
|
|||||||
}
|
}
|
||||||
this._loading = true;
|
this._loading = true;
|
||||||
var promises = [
|
var promises = [
|
||||||
this.$.relatedXHR.generateRequest().completes,
|
this._getRelatedChanges().then(function(response) {
|
||||||
this.$.submittedTogetherXHR.generateRequest().completes,
|
this._relatedResponse = response;
|
||||||
this.$.conflictsXHR.generateRequest().completes,
|
}.bind(this)),
|
||||||
this.$.cherryPicksXHR.generateRequest().completes,
|
this._getSubmittedTogether().then(function(response) {
|
||||||
|
this._submittedTogether = response;
|
||||||
|
}.bind(this)),
|
||||||
|
this._getConflicts().then(function(response) {
|
||||||
|
this._conflicts = response;
|
||||||
|
}.bind(this)),
|
||||||
|
this._getCherryPicks().then(function(response) {
|
||||||
|
this._cherryPicks = response;
|
||||||
|
}.bind(this)),
|
||||||
];
|
];
|
||||||
|
|
||||||
return this._serverConfigReady.then(function() {
|
return this._getServerConfig().then(function(config) {
|
||||||
if (this.change.topic &&
|
if (this.change.topic && !config.change.submit_whole_topic) {
|
||||||
!this.serverConfig.change.submit_whole_topic) {
|
return this._getChangesWithSameTopic().then(function(response) {
|
||||||
return this.$.sameTopicXHR.generateRequest().completes;
|
this._sameTopic = response;
|
||||||
|
}.bind(this));
|
||||||
} else {
|
} else {
|
||||||
this._sameTopic = [];
|
this._sameTopic = [];
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return this._sameTopic;
|
||||||
}.bind(this)).then(Promise.all(promises)).then(function() {
|
}.bind(this)).then(Promise.all(promises)).then(function() {
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeRelatedURL: function(changeNum, patchNum) {
|
_getRelatedChanges: function() {
|
||||||
return this.changeBaseURL(changeNum, patchNum) + '/related';
|
return this.$.restAPI.getRelatedChanges(this.change._number,
|
||||||
|
this.patchNum);
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeSubmittedTogetherURL: function(changeNum) {
|
_getSubmittedTogether: function() {
|
||||||
return this.changeBaseURL(changeNum) + '/submitted_together';
|
return this.$.restAPI.getChangesSubmittedTogether(this.change._number);
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeConflictsQueryParams: function(changeNum) {
|
_getServerConfig: function() {
|
||||||
var options = this.listChangesOptionsToHex(
|
return this.$.restAPI.getConfig();
|
||||||
this.ListChangesOption.CURRENT_REVISION,
|
|
||||||
this.ListChangesOption.CURRENT_COMMIT
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
O: options,
|
|
||||||
q: 'status:open is:mergeable conflicts:' + changeNum,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeCherryPicksQueryParams: function(project, changeID, changeNum) {
|
_getConflicts: function() {
|
||||||
var options = this.listChangesOptionsToHex(
|
return this.$.restAPI.getChangeConflicts(this.change._number);
|
||||||
this.ListChangesOption.CURRENT_REVISION,
|
|
||||||
this.ListChangesOption.CURRENT_COMMIT
|
|
||||||
);
|
|
||||||
var query = [
|
|
||||||
'project:' + project,
|
|
||||||
'change:' + changeID,
|
|
||||||
'-change:' + changeNum,
|
|
||||||
'-is:abandoned',
|
|
||||||
].join(' ');
|
|
||||||
return {
|
|
||||||
O: options,
|
|
||||||
q: query
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeSameTopicQueryParams: function(topic) {
|
_getCherryPicks: function() {
|
||||||
var options = this.listChangesOptionsToHex(
|
return this.$.restAPI.getChangeCherryPicks(this.change.project,
|
||||||
this.ListChangesOption.LABELS,
|
this.change.change_id, this.change._number);
|
||||||
this.ListChangesOption.CURRENT_REVISION,
|
},
|
||||||
this.ListChangesOption.CURRENT_COMMIT,
|
|
||||||
this.ListChangesOption.DETAILED_LABELS
|
_getChangesWithSameTopic: function() {
|
||||||
);
|
return this.$.restAPI.getChangesWithSameTopic(this.change.topic);
|
||||||
return {
|
|
||||||
O: options,
|
|
||||||
q: 'status:open topic:' + topic,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeChangeURL: function(changeNum, patchNum) {
|
_computeChangeURL: function(changeNum, patchNum) {
|
||||||
@@ -182,10 +151,6 @@
|
|||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
_serverConfigChanged: function(config) {
|
|
||||||
this._resolveServerConfigReady(config);
|
|
||||||
},
|
|
||||||
|
|
||||||
_resultsChanged: function(related, submittedTogether, conflicts,
|
_resultsChanged: function(related, submittedTogether, conflicts,
|
||||||
cherryPicks, sameTopic) {
|
cherryPicks, sameTopic) {
|
||||||
var results = [
|
var results = [
|
||||||
|
@@ -407,6 +407,60 @@
|
|||||||
return this.send(method, url, body);
|
return this.send(method, url, body);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getRelatedChanges: function(changeNum, patchNum) {
|
||||||
|
return this.fetchJSON(
|
||||||
|
this.getChangeActionURL(changeNum, patchNum, '/related'));
|
||||||
|
},
|
||||||
|
|
||||||
|
getChangesSubmittedTogether: function(changeNum) {
|
||||||
|
return this.fetchJSON(
|
||||||
|
this.getChangeActionURL(changeNum, null, '/submitted_together'));
|
||||||
|
},
|
||||||
|
|
||||||
|
getChangeConflicts: function(changeNum) {
|
||||||
|
var options = this._listChangesOptionsToHex(
|
||||||
|
ListChangesOption.CURRENT_REVISION,
|
||||||
|
ListChangesOption.CURRENT_COMMIT
|
||||||
|
);
|
||||||
|
var params = {
|
||||||
|
O: options,
|
||||||
|
q: 'status:open is:mergeable conflicts:' + changeNum,
|
||||||
|
};
|
||||||
|
return this.fetchJSON('/changes/', null, null, params);
|
||||||
|
},
|
||||||
|
|
||||||
|
getChangeCherryPicks: function(project, changeID, changeNum) {
|
||||||
|
var options = this._listChangesOptionsToHex(
|
||||||
|
ListChangesOption.CURRENT_REVISION,
|
||||||
|
ListChangesOption.CURRENT_COMMIT
|
||||||
|
);
|
||||||
|
var query = [
|
||||||
|
'project:' + project,
|
||||||
|
'change:' + changeID,
|
||||||
|
'-change:' + changeNum,
|
||||||
|
'-is:abandoned',
|
||||||
|
].join(' ');
|
||||||
|
var params = {
|
||||||
|
O: options,
|
||||||
|
q: query
|
||||||
|
};
|
||||||
|
return this.fetchJSON('/changes/', null, null, params);
|
||||||
|
},
|
||||||
|
|
||||||
|
getChangesWithSameTopic: function(topic) {
|
||||||
|
var options = this._listChangesOptionsToHex(
|
||||||
|
ListChangesOption.LABELS,
|
||||||
|
ListChangesOption.CURRENT_REVISION,
|
||||||
|
ListChangesOption.CURRENT_COMMIT,
|
||||||
|
ListChangesOption.DETAILED_LABELS
|
||||||
|
);
|
||||||
|
var params = {
|
||||||
|
O: options,
|
||||||
|
q: 'status:open topic:' + topic,
|
||||||
|
};
|
||||||
|
return this.fetchJSON('/changes/', null, null, params);
|
||||||
|
},
|
||||||
|
|
||||||
getReviewedFiles: function(changeNum, patchNum) {
|
getReviewedFiles: function(changeNum, patchNum) {
|
||||||
return this.fetchJSON(
|
return this.fetchJSON(
|
||||||
this.getChangeActionURL(changeNum, patchNum, '/files?reviewed'));
|
this.getChangeActionURL(changeNum, patchNum, '/files?reviewed'));
|
||||||
|
Reference in New Issue
Block a user