Commit 0de1ed4e authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'nfriend-add-release-links-to-milestone-detail-page' into 'master'

Add links to associated release(s) to the milestone detail page sidebar

See merge request gitlab-org/gitlab!17278
parents 45d00ef1 094be8f5
......@@ -170,6 +170,14 @@ module MilestonesHelper
content.join('<br />').html_safe
end
def milestone_releases_tooltip_text(milestone)
count = milestone.releases.count
return _("Releases") if count.zero?
n_("%{releases} release", "%{releases} releases", count) % { releases: count }
end
def recent_releases_with_counts(milestone)
total_count = milestone.releases.size
return [[], 0, 0] if total_count == 0
......
......@@ -138,6 +138,27 @@
Merged:
= milestone.merge_requests.merged.count
- if project
- recent_releases, total_count, more_count = recent_releases_with_counts(milestone)
.block.releases
.sidebar-collapsed-icon.has-tooltip{ title: milestone_releases_tooltip_text(milestone), data: { container: 'body', placement: 'left', boundary: 'viewport' } }
%strong
= icon('rocket')
%span= total_count
.title.hide-collapsed= n_('Release', 'Releases', total_count)
.hide-collapsed
- if total_count.zero?
.no-value= _('None')
- else
.font-weight-bold
- recent_releases.each do |release|
= link_to release.name, project_releases_path(project, :anchor => release.tag)
- unless release == recent_releases.last
%span.font-weight-normal &bull;
- if more_count > 0
%span.font-weight-normal &bull;
= link_to n_('%{count} more release', '%{count} more releases', more_count) % { count: more_count }, project_releases_path(project), class: 'font-weight-normal'
- milestone_ref = milestone.try(:to_reference, full: true)
- if milestone_ref.present?
.block.reference
......
---
title: Add links to associated release(s) to the milestone detail page
merge_request: 17278
author:
type: added
......@@ -324,6 +324,11 @@ msgstr ""
msgid "%{percent}%% complete"
msgstr ""
msgid "%{releases} release"
msgid_plural "%{releases} releases"
msgstr[0] ""
msgstr[1] ""
msgid "%{service_title} activated."
msgstr ""
......
......@@ -7,6 +7,18 @@ describe 'Project milestone' do
let(:project) { create(:project, name: 'test', namespace: user.namespace) }
let(:milestone) { create(:milestone, project: project) }
def toggle_sidebar
find('.milestone-sidebar .gutter-toggle').click
end
def sidebar_release_block
find('.milestone-sidebar .block.releases')
end
def sidebar_release_block_collapsed_icon
find('.milestone-sidebar .block.releases .sidebar-collapsed-icon')
end
before do
sign_in(user)
end
......@@ -75,17 +87,96 @@ describe 'Project milestone' do
describe 'the collapsed sidebar' do
before do
find('.milestone-sidebar .gutter-toggle').click
toggle_sidebar
end
it 'shows the total MR and issue counts' do
find('.milestone-sidebar .block', match: :first)
aggregate_failures 'MR and issue blocks' do
expect(find('.milestone-sidebar .block.issues')).to have_content 1
expect(find('.milestone-sidebar .block.merge-requests')).to have_content 0
expect(find('.milestone-sidebar .block.issues')).to have_content '1'
expect(find('.milestone-sidebar .block.merge-requests')).to have_content '0'
end
end
end
end
context 'when the milestone is not associated with a release' do
before do
visit project_milestone_path(project, milestone)
end
it 'shows "None" in the "Releases" section' do
expect(sidebar_release_block).to have_content 'Releases None'
end
describe 'when the sidebar is collapsed' do
before do
toggle_sidebar
end
it 'shows "0" in the "Releases" section' do
expect(sidebar_release_block).to have_content '0'
end
it 'has a tooltip that reads "Releases"' do
expect(sidebar_release_block_collapsed_icon['title']).to eq 'Releases'
end
end
end
context 'when the milestone is associated with one release' do
before do
create(:release, project: project, name: 'Version 5', milestones: [milestone])
visit project_milestone_path(project, milestone)
end
it 'shows "Version 5" in the "Release" section' do
expect(sidebar_release_block).to have_content 'Release Version 5'
end
describe 'when the sidebar is collapsed' do
before do
toggle_sidebar
end
it 'shows "1" in the "Releases" section' do
expect(sidebar_release_block).to have_content '1'
end
it 'has a tooltip that reads "1 release"' do
expect(sidebar_release_block_collapsed_icon['title']).to eq '1 release'
end
end
end
context 'when the milestone is associated with multiple releases' do
before do
(5..10).each do |num|
released_at = Time.zone.parse('2019-10-04') + num.months
create(:release, project: project, name: "Version #{num}", milestones: [milestone], released_at: released_at)
end
visit project_milestone_path(project, milestone)
end
it 'shows a shortened list of releases in the "Releases" section' do
expect(sidebar_release_block).to have_content 'Releases Version 10 • Version 9 • Version 8 • 3 more releases'
end
describe 'when the sidebar is collapsed' do
before do
toggle_sidebar
end
it 'shows "6" in the "Releases" section' do
expect(sidebar_release_block).to have_content '6'
end
it 'has a tooltip that reads "6 releases"' do
expect(sidebar_release_block_collapsed_icon['title']).to eq '6 releases'
end
end
end
end
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