Commit 6f94f62f authored by Phil Hughes's avatar Phil Hughes

Correctly cycles the unresolved discussions

Switches back to discussion tab when clicking jump to next unresolved button
parent 4e679819
((w) => {
w.ResolveCommentBtn = Vue.extend({
w.CommentAndResolveBtn = Vue.extend({
props: {
discussionId: String
},
......
......@@ -37,9 +37,20 @@
i++;
}
} else {
let nextDiscussionId;
const discussionKeys = Object.keys(this.discussions),
indexOfDiscussion = discussionKeys.indexOf(this.discussionId),
nextDiscussionId = discussionKeys[indexOfDiscussion + 1];
indexOfDiscussion = discussionKeys.indexOf(this.discussionId);
nextDiscussionIds = discussionKeys.splice(indexOfDiscussion);
nextDiscussionIds.forEach((discussionId) => {
if (discussionId !== this.discussionId) {
const discussion = this.discussions[discussionId];
if (!discussion.isResolved()) {
nextDiscussionId = discussion.id;
}
}
});
if (nextDiscussionId) {
nextUnresolvedDiscussionId = nextDiscussionId;
......@@ -54,6 +65,9 @@
}
if (nextUnresolvedDiscussionId) {
$('#notes').addClass('active');
$('#commits, #builds, #diffs').removeClass('active');
$.scrollTo(`.discussion[data-discussion-id="${nextUnresolvedDiscussionId}"]`, {
offset: -($('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight())
});
......
......@@ -12,7 +12,7 @@ $(() => {
components: {
'resolve-btn': ResolveBtn,
'resolve-discussion-btn': ResolveDiscussionBtn,
'resolve-comment-btn': ResolveCommentBtn
'comment-and-resolve-btn': CommentAndResolveBtn
}
});
......
class DiscussionModel {
constructor (discussionId) {
this.discussionId = discussionId;
this.id = discussionId;
this.notes = {};
this.loading = false;
}
createNote (noteId, resolved, user) {
Vue.set(this.notes, noteId, new NoteModel(this.discussionId, noteId, resolved, user));
Vue.set(this.notes, noteId, new NoteModel(this.id, noteId, resolved, user));
}
deleteNote (noteId) {
......
class NoteModel {
constructor (discussionId, noteId, resolved, user) {
this.discussionId = discussionId;
this.noteId = noteId;
this.id = noteId;
this.resolved = resolved;
this.user = user;
}
......
......@@ -4,7 +4,7 @@
= link_to 'Close merge request', merge_request_path(@merge_request, merge_request: {state_event: :close }), method: :put, class: "btn btn-nr btn-comment btn-close close-mr-link js-note-target-close", title: "Close merge request", data: {original_text: "Close merge request", alternative_text: "Comment & close merge request"}
- if @merge_request.closed?
= link_to 'Reopen merge request', merge_request_path(@merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-nr btn-comment btn-reopen reopen-mr-link js-note-target-reopen", title: "Reopen merge request", data: {original_text: "Reopen merge request", alternative_text: "Comment & reopen merge request"}
%resolve-comment-btn{ "inline-template" => true, ":discussion-id" => "" }
%comment-and-resolve-btn{ "inline-template" => true, ":discussion-id" => "" }
%button.btn.btn-nr.btn-default.append-right-10.js-comment-resolve-button{ type: "submit", data: { namespace_path: "#{@merge_request.project.namespace.path}", project_path: "#{@merge_request.project.path}" } }
{{ buttonText }}
......
......@@ -35,6 +35,7 @@ feature 'Diff notes resolve', feature: true, js: true do
find('.line-resolve-btn').click
expect(page).to have_selector('.line-resolve-btn.is-active')
expect(find('.line-resolve-btn')['data-original-title']).to eq("Resolved by #{user.name}")
end
page.within '.diff-content' do
......@@ -54,6 +55,8 @@ feature 'Diff notes resolve', feature: true, js: true do
page.within '.diff-content .note' do
expect(page).to have_selector('.line-resolve-btn.is-active')
expect(find('.line-resolve-btn')['data-original-title']).to eq("Resolved by #{user.name}")
end
page.within '.line-resolve-all-container' do
......@@ -147,6 +150,8 @@ feature 'Diff notes resolve', feature: true, js: true do
it 'does not mark discussion as resolved when resolving single note' do
page.within '.diff-content .note' do
first('.line-resolve-btn').click
sleep 1
expect(first('.line-resolve-btn')['data-original-title']).to eq("Resolved by #{user.name}")
end
expect(page).to have_content('Last updated')
......
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