Commit d147894b authored by Phil Hughes's avatar Phil Hughes

Hides jump to next button if only one discussion visible

parent 9878356d
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
allResolved: function () { allResolved: function () {
const discussion = this.discussions[discussionId]; const discussion = this.discussions[discussionId];
return discussion.isResolved(); return discussion.isResolved();
},
discussionsCount: function () {
return Object.keys(this.discussions).length;
},
showButton: function () {
return this.discussionsCount > 1 || !this.discussionId;
} }
}, },
methods: { methods: {
...@@ -67,6 +73,7 @@ ...@@ -67,6 +73,7 @@
if (nextUnresolvedDiscussionId) { if (nextUnresolvedDiscussionId) {
$('#notes').addClass('active'); $('#notes').addClass('active');
$('#commits, #builds, #diffs').removeClass('active'); $('#commits, #builds, #diffs').removeClass('active');
mrTabs.setCurrentAction('notes');
$.scrollTo(`.discussion[data-discussion-id="${nextUnresolvedDiscussionId}"]`, { $.scrollTo(`.discussion[data-discussion-id="${nextUnresolvedDiscussionId}"]`, {
offset: -($('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight()) offset: -($('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight())
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
MergeRequest.prototype.initTabs = function() { MergeRequest.prototype.initTabs = function() {
if (this.opts.action !== 'new') { if (this.opts.action !== 'new') {
return new MergeRequestTabs(this.opts); window.mrTabs = new MergeRequestTabs(this.opts);
} else { } else {
return $('.merge-request-tabs a[data-toggle="tab"]:first').tab('show'); return $('.merge-request-tabs a[data-toggle="tab"]:first').tab('show');
} }
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
- if current_user - if current_user
%jump-to-discussion{ "inline-template" => true, ":discussion-id" => "'#{discussion.try(:id)}'" } %jump-to-discussion{ "inline-template" => true, ":discussion-id" => "'#{discussion.try(:id)}'" }
.btn-group{ role: "group", .btn-group{ role: "group",
"v-show" => "!allResolved" } "v-show" => "!allResolved",
"v-if" => "showButton" }
%button.btn.btn-default.discussion-next-btn.has-tooltip{ "@click" => "jumpToNextUnresolvedDiscussion", %button.btn.btn-default.discussion-next-btn.has-tooltip{ "@click" => "jumpToNextUnresolvedDiscussion",
title: "Jump to next unresolved discussion", title: "Jump to next unresolved discussion",
"aria-label" => "Jump to next unresolved discussion", "aria-label" => "Jump to next unresolved discussion",
......
...@@ -168,6 +168,12 @@ feature 'Diff notes resolve', feature: true, js: true do ...@@ -168,6 +168,12 @@ feature 'Diff notes resolve', feature: true, js: true do
expect(page).to have_content("Resolved by #{user.name}") expect(page).to have_content("Resolved by #{user.name}")
end end
it 'hides jump to next discussion button' do
page.within '.discussion-reply-holder' do
expect(page).not_to have_selector('.discussion-next-btn')
end
end
end end
context 'multiple notes' do context 'multiple notes' do
...@@ -265,6 +271,12 @@ feature 'Diff notes resolve', feature: true, js: true do ...@@ -265,6 +271,12 @@ feature 'Diff notes resolve', feature: true, js: true do
expect(page).to have_content("Resolved by #{user.name}") expect(page).to have_content("Resolved by #{user.name}")
end end
it 'shows jump to next discussion button' do
page.all('.discussion-reply-holder').each do |holder|
expect(holder).to have_selector('.discussion-next-btn')
end
end
end end
context 'changes tab' do context 'changes tab' do
......
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