Commit 86446846 authored by Phil Hughes's avatar Phil Hughes

Added tests for resolving comments feature

parent b53ccd11
......@@ -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: {
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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);
}
},
......
......@@ -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))
});
}
......
......@@ -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));
}
......
......@@ -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;
}
}
- discussion = local_assigns.fetch(:discussion, false)
%jump-to-discussion{ "inline-template" => true, ":discussion-id" => "'#{discussion.try(:id)}'" }
.btn-group{ role: "group",
"v-show" => "!allResolved",
"v-if" => "!isLast" }
"v-show" => "!allResolved" }
%button.btn.btn-default.discussion-next-btn.has-tooltip{ "@click" => "jumpToNextUnresolvedDiscussion",
title: "Jump to next unresolved discussion",
"aria-label" => "Jump to next unresolved discussion",
......
......@@ -44,17 +44,16 @@
= succeed '.' do
= link_to "command line", "#modal_merge_info", class: "how_to_merge_link vlink", title: "How To Merge", "data-toggle" => "modal"
- if current_user
#resolve-count-app.line-resolve-all-container{ "v-cloak" => true }
%resolve-count{ "inline-template" => true }
.line-resolve-all{ "v-show" => "discussionCount > 0",
":class" => "{ 'has-next-btn': resolved !== discussionCount }" }
%span.line-resolve-btn.is-disabled{ type: "button",
":class" => "{ 'is-active': resolved === discussionCount }" }
= icon("check")
%span.line-resolve-text
{{ resolved }}/{{ discussionCount }} discussions resolved
= render "discussions/jump_to_next"
#resolve-count-app.line-resolve-all-container{ "v-cloak" => true }
%resolve-count{ "inline-template" => true }
.line-resolve-all{ "v-show" => "discussionCount > 0",
":class" => "{ 'has-next-btn': resolved !== discussionCount }" }
%span.line-resolve-btn.is-disabled{ type: "button",
":class" => "{ 'is-active': resolved === discussionCount }" }
= icon("check")
%span.line-resolve-text
{{ resolved }}/{{ discussionCount }} {{ discussionCount | pluralize 'discussion' }} resolved
= render "discussions/jump_to_next"
- if @commits_count.nonzero?
%ul.merge-request-tabs.nav-links.no-top.no-bottom
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment