From 86446846e963ea1304b56fa74b4ca795a491bbb5 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 27 Jul 2016 16:57:48 +0100 Subject: Added tests for resolving comments feature --- .../javascripts/diff_notes/components/jump_to_discussion.js.es6 | 6 ------ .../javascripts/diff_notes/components/resolve_comment_btn.js.es6 | 3 ++- app/assets/javascripts/diff_notes/services/resolve.js.es6 | 3 ++- app/assets/javascripts/diff_notes/stores/comments.js.es6 | 3 ++- app/assets/javascripts/merge_request_tabs.js | 4 ++-- app/assets/javascripts/notes.js | 8 ++++---- app/assets/stylesheets/pages/notes.scss | 4 ++-- 7 files changed, 14 insertions(+), 17 deletions(-) (limited to 'app/assets') diff --git a/app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 b/app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 index e85562454e3..3f107e26421 100644 --- a/app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 +++ b/app/assets/javascripts/diff_notes/components/jump_to_discussion.js.es6 @@ -24,12 +24,6 @@ } return allResolved; - }, - isLast: function () { - const discussionKeys = Object.keys(this.discussions), - indexOfDiscussion = discussionKeys.indexOf(this.discussionId); - - return discussionKeys.length - 1 === indexOfDiscussion; } }, methods: { diff --git a/app/assets/javascripts/diff_notes/components/resolve_comment_btn.js.es6 b/app/assets/javascripts/diff_notes/components/resolve_comment_btn.js.es6 index 1ffe4cf99d6..897a7657bf6 100644 --- a/app/assets/javascripts/diff_notes/components/resolve_comment_btn.js.es6 +++ b/app/assets/javascripts/diff_notes/components/resolve_comment_btn.js.es6 @@ -9,7 +9,8 @@ discussion = CommentsStore.state[this.discussionId]; let allResolved = true; - for (const noteId of notes) { + for (let i = 0; i < notes.length; i++) { + const noteId = notes[i]; const note = discussion[noteId]; if (!note.resolved) { diff --git a/app/assets/javascripts/diff_notes/services/resolve.js.es6 b/app/assets/javascripts/diff_notes/services/resolve.js.es6 index 29de46f2dc7..28830f4af4e 100644 --- a/app/assets/javascripts/diff_notes/services/resolve.js.es6 +++ b/app/assets/javascripts/diff_notes/services/resolve.js.es6 @@ -27,7 +27,8 @@ const noteIds = CommentsStore.notesForDiscussion(discussionId); let isResolved = true; - for (const noteId of noteIds) { + for (let i = 0; i < noteIds.length; i++) { + const noteId = noteIds[i]; const resolved = CommentsStore.state[discussionId][noteId].resolved; if (!resolved) { diff --git a/app/assets/javascripts/diff_notes/stores/comments.js.es6 b/app/assets/javascripts/diff_notes/stores/comments.js.es6 index f42ed29b619..e199b774f59 100644 --- a/app/assets/javascripts/diff_notes/stores/comments.js.es6 +++ b/app/assets/javascripts/diff_notes/stores/comments.js.es6 @@ -28,7 +28,8 @@ updateCommentsForDiscussion: function (discussionId, resolve, user) { const noteIds = CommentsStore.resolvedNotesForDiscussion(discussionId, resolve); - for (const noteId of noteIds) { + for (let i = 0; i < noteIds.length; i++) { + const noteId = noteIds[i]; CommentsStore.update(discussionId, noteId, resolve, user); } }, diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 332288dcf8e..2343ace3b68 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -120,8 +120,8 @@ return function(data) { $('#diffs').html(data.html); - if ($('resolve-btn, resolve-all-btn').length && (typeof DiffNotesApp !== "undefined" && DiffNotesApp !== null)) { - $('resolve-btn, resolve-all-btn').each(function () { + if ($('resolve-btn, resolve-all-btn, jump-to-discussion').length && (typeof DiffNotesApp !== "undefined" && DiffNotesApp !== null)) { + $('resolve-btn, resolve-all-btn, jump-to-discussion').each(function () { DiffNotesApp.$compile($(this).get(0)) }); } diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 67ea47e67b2..5293e5f8dda 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -429,7 +429,7 @@ $html.find('.js-task-list-container').taskList('enable'); $note_li = $('.note-row-' + note.id); - if (DiffNotesApp != null) { + if (typeof DiffNotesApp !== "undefined" && DiffNotesApp !== null) { ref = DiffNotesApp.$refs['' + note.id + '']; if (ref) { @@ -525,7 +525,7 @@ note = $(el); notes = note.closest(".notes"); - if (DiffNotesApp != null) { + if (typeof DiffNotesApp !== "undefined" && DiffNotesApp !== null) { ref = DiffNotesApp.$refs['' + noteId + '']; if (ref) { @@ -604,10 +604,10 @@ if (canResolve === 'false') { form.find('resolve-comment-btn').remove(); - } else if (DiffNotesApp) { + } else if (typeof DiffNotesApp !== "undefined" && DiffNotesApp !== null) { var $commentBtn = form.find('resolve-comment-btn'); $commentBtn - .attr(':discussion-id', dataHolder.data('discussionId')); + .attr(':discussion-id', "'" + dataHolder.data('discussionId') + "'"); DiffNotesApp.$compile($commentBtn.get(0)); } diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss index 6b34ab30121..c2762b3e3a1 100644 --- a/app/assets/stylesheets/pages/notes.scss +++ b/app/assets/stylesheets/pages/notes.scss @@ -454,13 +454,13 @@ ul.notes { position: relative; top: 2px; font-size: 8px; - color: #c3c3c3; + color: $notes-action-color; vertical-align: top; } } .discussion-next-btn { path { - fill: #7E7E7E; + fill: $gray-darkest; } } -- cgit v1.2.1