summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-05-18 14:13:37 +0000
committerPhil Hughes <me@iamphill.com>2017-05-18 14:13:37 +0000
commit4d2d2b11796fbf6f115b5e427794ec1c8126b2a0 (patch)
treef1a20d1ff96cc04d503afc94b5df9ee0d66f0971 /app/assets/javascripts/notes.js
parent4e410a6e5100d76529e66bb23c4496b14d24f4af (diff)
parent027ad1381e509236b789c58ee7b3d057dd5517b5 (diff)
downloadgitlab-ce-4d2d2b11796fbf6f115b5e427794ec1c8126b2a0.tar.gz
Merge branch '32424-fix-linking-to-unresolved-expanded-diff-note' into 'master'
Fix linking to unresolved/expanded diff note Closes #32424 See merge request !11458
Diffstat (limited to 'app/assets/javascripts/notes.js')
-rw-r--r--app/assets/javascripts/notes.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js
index e960f1e8018..67df1c0c4d7 100644
--- a/app/assets/javascripts/notes.js
+++ b/app/assets/javascripts/notes.js
@@ -860,10 +860,19 @@ const normalizeNewlines = function(str) {
e.preventDefault();
const $link = $(e.currentTarget || e.target);
const showReplyInput = !$link.hasClass('js-diff-comment-avatar');
- this.addDiffNote($link, $link.data('lineType'), showReplyInput);
+ this.toggleDiffNote({
+ target: $link,
+ lineType: $link.data('lineType'),
+ showReplyInput
+ });
};
- Notes.prototype.addDiffNote = function(target, lineType, showReplyInput) {
+ Notes.prototype.toggleDiffNote = function({
+ target,
+ lineType,
+ forceShow,
+ showReplyInput = false,
+ }) {
var $link, addForm, hasNotes, newForm, noteForm, replyButton, row, rowCssToAdd, targetContent, isDiffCommentAvatar;
$link = $(target);
row = $link.closest("tr");
@@ -908,12 +917,12 @@ const normalizeNewlines = function(str) {
notesContent = targetRow.find(notesContentSelector);
addForm = true;
} else {
- targetRow.show();
- notesContent.toggle(!notesContent.is(':visible'));
+ const isCurrentlyShown = targetRow.find('.content:not(:empty)').is(':visible');
+ const isForced = forceShow === true || forceShow === false;
+ const showNow = forceShow === true || (!isCurrentlyShown && !isForced);
- if (!targetRow.find('.content:not(:empty)').is(':visible')) {
- targetRow.hide();
- }
+ targetRow.toggle(showNow);
+ notesContent.toggle(showNow);
}
if (addForm) {