diff --git a/src/applications/differential/view/DifferentialInlineCommentView.php b/src/applications/differential/view/DifferentialInlineCommentView.php index 2a0ed077c4..a52578a59e 100644 --- a/src/applications/differential/view/DifferentialInlineCommentView.php +++ b/src/applications/differential/view/DifferentialInlineCommentView.php @@ -90,6 +90,9 @@ final class DifferentialInlineCommentView extends AphrontView { ); $sigil = 'differential-inline-comment'; + if ($this->preview) { + $sigil = $sigil . ' differential-inline-comment-preview'; + } $content = $inline->getContent(); $handles = $this->handles; @@ -177,6 +180,14 @@ final class DifferentialInlineCommentView extends AphrontView { 'sigil' => 'differential-inline-preview-jump', ), 'Not Visible'); + $links[] = javelin_render_tag( + 'a', + array( + 'href' => '#', + 'mustcapture' => true, + 'sigil' => 'differential-inline-delete', + ), + 'Delete'); } if ($links) { diff --git a/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js b/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js index eddd655317..6e544fe787 100644 --- a/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js +++ b/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js @@ -134,6 +134,10 @@ JX.install('DifferentialInlineCommentEditor', { var remove_old = (op == 'edit' || op == 'delete'); if (remove_old) { JX.DOM.remove(this.getRow()); + var other_rows = this.getOtherRows(); + for(var i = 0; i < other_rows.length; ++i) { + JX.DOM.remove(other_rows[i]); + } } // Once the user saves something, get rid of the 'undo' option. A @@ -251,6 +255,7 @@ JX.install('DifferentialInlineCommentEditor', { properties : { operation : null, row : null, + otherRows: [], table : null, onRight : null, ID : null, diff --git a/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js b/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js index e28c4ebcd4..ae8bb3c042 100644 --- a/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js +++ b/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js @@ -200,6 +200,25 @@ JX.behavior('differential-edit-inline-comments', function(config) { var handle_inline_action = function(node, op) { var data = JX.Stratcom.getData(node); var row = node.parentNode.parentNode; + var other_rows = []; + if (JX.Stratcom.hasSigil(node, 'differential-inline-comment-preview')) { + // The DOM structure around the comment is different if it's part of the + // preview, so make sure not to pass the wrong container. + row = node; + if (op === 'delete') { + // Furthermore, deleting a comment in the preview does not automatically + // delete other occurrences of the same comment, so do that manually. + var nodes = JX.DOM.scry( + document.body, + 'div', + 'differential-inline-comment'); + for (var i = 0; i < nodes.length; ++i) { + if (JX.Stratcom.getData(nodes[i]).id === data.id) { + other_rows.push(nodes[i]); + } + } + } + } var original = data.original; if (op == 'reply') { @@ -217,6 +236,7 @@ JX.behavior('differential-edit-inline-comments', function(config) { .setOnRight(data.on_right) .setOriginalText(original) .setRow(row) + .setOtherRows(other_rows) .setTable(row.parentNode) .start();