Cleanup gr-change-view (remove gr-ajax use)
Bug: Issue 3988
Change-Id: I9a0134ef96ee48a54cac85bd92e3dea88cb7c76f
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 9af6aa9..0709f62 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
@@ -225,31 +225,6 @@
return '(' + status.toLowerCase() + ')';
},
- _computeDetailPath: function(changeNum) {
- return '/changes/' + changeNum + '/detail';
- },
-
- _computeCommitInfoPath: function(changeNum, patchNum) {
- return this.changeBaseURL(changeNum, patchNum) + '/commit?links';
- },
-
- _computeCommentsPath: function(changeNum) {
- return '/changes/' + changeNum + '/comments';
- },
-
- _computeProjectConfigPath: function(project) {
- return '/projects/' + encodeURIComponent(project) + '/config';
- },
-
- _computeDetailQueryParams: function() {
- var options = this.listChangesOptionsToHex(
- this.ListChangesOption.ALL_REVISIONS,
- this.ListChangesOption.CHANGE_ACTIONS,
- this.ListChangesOption.DOWNLOAD_COMMANDS
- );
- return {O: options};
- },
-
_computeLatestPatchNum: function(change) {
return change.revisions[change.current_revision]._number;
},
@@ -345,13 +320,44 @@
_getDiffDrafts: function() {
return this.$.restAPI.getDiffDrafts(this._changeNum).then(
- function(drafts) { return this._diffDrafts = drafts; }.bind(this));
+ function(drafts) {
+ return this._diffDrafts = drafts;
+ }.bind(this));
},
_getLoggedIn: function() {
return this.$.restAPI.getLoggedIn();
},
+ _getProjectConfig: function() {
+ return this.$.restAPI.getProjectConfig(this._change.project).then(
+ function(config) {
+ this._projectConfig = config;
+ }.bind(this));
+ },
+
+ _getChangeDetail: function() {
+ return this.$.restAPI.getChangeDetail(this._changeNum).then(
+ function(change) {
+ this._change = change;
+ }.bind(this));
+ },
+
+ _getComments: function() {
+ return this.$.restAPI.getDiffComments(this._changeNum).then(
+ function(comments) {
+ this._comments = comments;
+ }.bind(this));
+ },
+
+ _getCommitInfo: function() {
+ return this.$.restAPI.getChangeCommitInfo(
+ this._changeNum, this._patchNum).then(
+ function(commitInfo) {
+ this._commitInfo = commitInfo;
+ }.bind(this));
+ },
+
_reloadDiffDrafts: function() {
this._diffDrafts = {};
this._getDiffDrafts().then(function() {
@@ -362,24 +368,31 @@
},
_reload: function() {
+ this._loading = true;
+
this._getLoggedIn().then(function(loggedIn) {
if (!loggedIn) { return; }
this._reloadDiffDrafts();
}.bind(this));
- var detailCompletes = this.$.detailXHR.generateRequest().completes;
- this.$.commentsXHR.generateRequest();
+ var detailCompletes = this._getChangeDetail().then(function() {
+ this._loading = false;
+ }.bind(this));
+ this._getComments();
var reloadPatchNumDependentResources = function() {
return Promise.all([
- this.$.commitInfoXHR.generateRequest().completes,
+ this._getCommitInfo(),
this.$.actions.reload(),
this.$.fileList.reload(),
]);
}.bind(this);
var reloadDetailDependentResources = function() {
- return this.$.relatedChanges.reload();
+ return Promise.all([
+ this.$.relatedChanges.reload(),
+ this._getProjectConfig(),
+ ]);
}.bind(this);
this._resetHeaderEl();