Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-05-17 22:58:47 +0300
committerEric Eastwood <contact@ericeastwood.com>2017-05-18 07:30:13 +0300
commit027ad1381e509236b789c58ee7b3d057dd5517b5 (patch)
tree8f5e75ae051fc1ff7f7eeba3802f0fe4d6dc6d9d /app/assets/javascripts/notes.js
parent319cab4115380d3bff1e6543b759e785aa36a666 (diff)
Fix linking to unresolved/expanded diff note
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32424 Bug introduced in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11327
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 91d1afba7b6..93e0dbd900f 100644
--- a/app/assets/javascripts/notes.js
+++ b/app/assets/javascripts/notes.js
@@ -876,10 +876,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");
@@ -924,12 +933,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) {