diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-09-15 12:18:54 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-09-16 10:22:24 +0200 |
commit | 391777173512eae74d7861fac2448bf9c379bcf8 (patch) | |
tree | 6afb9b051bc35b67ac7e5bebac215d2116af74a4 /server | |
parent | 6eb1d268f6bf822d3cec5b64cf7159eb365df1ec (diff) | |
download | sonarqube-391777173512eae74d7861fac2448bf9c379bcf8.tar.gz sonarqube-391777173512eae74d7861fac2448bf9c379bcf8.zip |
SONAR-7790 Improve issue comment modal UI
Diffstat (limited to 'server')
3 files changed, 57 insertions, 12 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 b3ea2c3637c..8b0d7493d8a 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 @@ -26,6 +26,7 @@ import ChangeLogView from './views/changelog-view'; import TransitionsFormView from './views/transitions-form-view'; import AssignFormView from './views/assign-form-view'; import CommentFormView from './views/comment-form-view'; +import DeleteCommentView from './views/DeleteCommentView'; import SetSeverityFormView from './views/set-severity-form-view'; import SetTypeFormView from './views/set-type-form-view'; import TagsFormView from './views/tags-form-view'; @@ -144,18 +145,22 @@ export default Marionette.ItemView.extend({ }, deleteComment (e) { - const that = this; - const commentKey = $(e.target).closest('[data-comment-key]').data('comment-key'); - const confirmMsg = $(e.target).data('confirm-msg'); - if (confirm(confirmMsg)) { - this.disableControls(); - return $.ajax({ - type: 'POST', - url: window.baseUrl + '/api/issues/delete_comment?key=' + commentKey - }).done(function () { - that.updateAfterAction(true); - }); - } + e.stopPropagation(); + $('body').click(); + const commentEl = $(e.currentTarget).closest('.issue-comment'); + const commentKey = commentEl.data('comment-key'); + this.popup = new DeleteCommentView({ + triggerEl: $(e.currentTarget), + bottomRight: true, + onDelete: () => { + this.disableControls(); + $.ajax({ + type: 'POST', + url: window.baseUrl + '/api/issues/delete_comment?key=' + commentKey + }).done(() => this.updateAfterAction(true)); + } + }); + this.popup.render(); }, transition (e) { diff --git a/server/sonar-web/src/main/js/components/issue/templates/DeleteComment.hbs b/server/sonar-web/src/main/js/components/issue/templates/DeleteComment.hbs new file mode 100644 index 00000000000..939bf523509 --- /dev/null +++ b/server/sonar-web/src/main/js/components/issue/templates/DeleteComment.hbs @@ -0,0 +1,6 @@ +<div class="text-right"> + <div class="spacer-bottom">{{t 'issue.comment.delete_confirm_message'}}</div> + <button class="button-red">{{t 'delete'}}</button> +</div> + +<div class="bubble-popup-arrow"></div> diff --git a/server/sonar-web/src/main/js/components/issue/views/DeleteCommentView.js b/server/sonar-web/src/main/js/components/issue/views/DeleteCommentView.js new file mode 100644 index 00000000000..e5aaaaa36fa --- /dev/null +++ b/server/sonar-web/src/main/js/components/issue/views/DeleteCommentView.js @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import PopupView from '../../common/popup'; +import Template from '../templates/DeleteComment.hbs'; + +export default PopupView.extend({ + template: Template, + + events: { + 'click button': 'handleSubmit' + }, + + handleSubmit (e) { + e.preventDefault(); + this.options.onDelete(); + } +}); |