aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-01-25 15:47:42 +0100
committerStas Vilchik <vilchiks@gmail.com>2017-01-26 12:31:01 +0100
commit4768a6fb34222419f805a6bcdd067017dcb87c6e (patch)
treec0a1a67568e6bc6d618154e8c3b753bd1a837252
parentb723f7d1f2fcc51e9cded0c2e33ea5a27b48f952 (diff)
downloadsonarqube-4768a6fb34222419f805a6bcdd067017dcb87c6e.tar.gz
sonarqube-4768a6fb34222419f805a6bcdd067017dcb87c6e.zip
SONAR-8539 Avoid useless WS call when adding/editing/deleting a comment to refresh the issue
-rw-r--r--server/sonar-web/src/main/js/components/issue/issue-view.js17
-rw-r--r--server/sonar-web/src/main/js/components/issue/models/issue.js5
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/comment-form-view.js12
3 files changed, 13 insertions, 21 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/issue-view.js b/server/sonar-web/src/main/js/components/issue/issue-view.js
index 0d133a2e452..325a153dff6 100644
--- a/server/sonar-web/src/main/js/components/issue/issue-view.js
+++ b/server/sonar-web/src/main/js/components/issue/issue-view.js
@@ -100,12 +100,12 @@ export default Marionette.ItemView.extend({
});
},
- updateAfterAction (fetch) {
+ updateAfterAction (response) {
if (this.popup) {
this.popup.destroy();
}
- if (fetch) {
- this.resetIssue();
+ if (response) {
+ this.model.set(this.model.parse(response));
}
},
@@ -155,7 +155,7 @@ export default Marionette.ItemView.extend({
$.ajax({
type: 'POST',
url: window.baseUrl + '/api/issues/delete_comment?key=' + commentKey
- }).done(() => this.updateAfterAction(true));
+ }).done(r => this.updateAfterAction(r));
}
});
this.popup.render();
@@ -222,15 +222,10 @@ export default Marionette.ItemView.extend({
},
action (action) {
- const that = this;
this.disableControls();
return this.model.customAction(action)
- .done(() => {
- that.updateAfterAction(true);
- })
- .fail(() => {
- that.enableControls();
- });
+ .done(r => this.updateAfterAction(r))
+ .fail(() => this.enableControls());
},
editTags (e) {
diff --git a/server/sonar-web/src/main/js/components/issue/models/issue.js b/server/sonar-web/src/main/js/components/issue/models/issue.js
index a115c93129a..46f31dbcc86 100644
--- a/server/sonar-web/src/main/js/components/issue/models/issue.js
+++ b/server/sonar-web/src/main/js/components/issue/models/issue.js
@@ -69,14 +69,13 @@ export default Backbone.Model.extend({
_injectCommentsRelational (issue, users) {
if (issue.comments) {
- const that = this;
const newComments = issue.comments.map(comment => {
let newComment = { ...comment, author: comment.login };
delete newComment.login;
- newComment = that._injectRelational(newComment, users, 'author', 'login');
+ newComment = this._injectRelational(newComment, users, 'author', 'login');
return newComment;
});
- issue = { ...issue, comments: newComments };
+ return { ...issue, comments: newComments };
}
return issue;
},
diff --git a/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js b/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js
index eec1250de3c..b80d0b5603d 100644
--- a/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js
+++ b/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js
@@ -65,7 +65,7 @@ export default PopupView.extend({
},
cancel () {
- this.options.detailView.updateAfterAction(false);
+ this.options.detailView.updateAfterAction();
},
disableForm () {
@@ -77,7 +77,6 @@ export default PopupView.extend({
},
submit () {
- const that = this;
const text = this.ui.textarea.val();
if (!text.length) {
@@ -96,11 +95,10 @@ export default PopupView.extend({
this.disableForm();
this.options.detailView.disableControls();
return $.post(url, data)
- .done(() => {
- that.options.detailView.updateAfterAction(true);
- }).fail(() => {
- that.enableForm();
- that.options.detailView.enableControls();
+ .done(r => this.options.detailView.updateAfterAction(r))
+ .fail(() => {
+ this.enableForm();
+ this.options.detailView.enableControls();
});
},