]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7790 Improve issue comment modal UI
authorStas Vilchik <vilchiks@gmail.com>
Thu, 15 Sep 2016 10:18:54 +0000 (12:18 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 16 Sep 2016 08:22:24 +0000 (10:22 +0200)
server/sonar-web/src/main/js/components/issue/issue-view.js
server/sonar-web/src/main/js/components/issue/templates/DeleteComment.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/components/issue/views/DeleteCommentView.js [new file with mode: 0644]

index b3ea2c3637cf87f8a784c37575735f1a04d55d7b..8b0d7493d8acf82fedc8e2b52136a40cd080651a 100644 (file)
@@ -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 (file)
index 0000000..939bf52
--- /dev/null
@@ -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 (file)
index 0000000..e5aaaaa
--- /dev/null
@@ -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();
+  }
+});