Commit bf6b1432 authored by Roger Meier's avatar Roger Meier Committed by Nick Thomas

Show storage_size on project page

parent 76948de3
...@@ -25,6 +25,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated ...@@ -25,6 +25,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
branches_anchor_data, branches_anchor_data,
tags_anchor_data, tags_anchor_data,
files_anchor_data, files_anchor_data,
storage_anchor_data,
releases_anchor_data releases_anchor_data
].compact.select(&:is_link) ].compact.select(&:is_link)
end end
...@@ -154,6 +155,17 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated ...@@ -154,6 +155,17 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
empty_repo? ? nil : project_tree_path(project)) empty_repo? ? nil : project_tree_path(project))
end end
def storage_anchor_data
AnchorData.new(true,
statistic_icon('disk') +
_('%{strong_start}%{human_size}%{strong_end} Storage').html_safe % {
human_size: storage_counter(statistics.storage_size),
strong_start: '<strong class="project-stat-value">'.html_safe,
strong_end: '</strong>'.html_safe
},
empty_repo? ? nil : project_tree_path(project))
end
def releases_anchor_data def releases_anchor_data
return unless can?(current_user, :read_release, project) return unless can?(current_user, :read_release, project)
......
---
title: Show storage size on project page
merge_request: 27724
author: Roger Meier
type: added
...@@ -459,6 +459,9 @@ msgstr[1] "" ...@@ -459,6 +459,9 @@ msgstr[1] ""
msgid "%{strong_start}%{human_size}%{strong_end} Files" msgid "%{strong_start}%{human_size}%{strong_end} Files"
msgstr "" msgstr ""
msgid "%{strong_start}%{human_size}%{strong_end} Storage"
msgstr ""
msgid "%{strong_start}%{release_count}%{strong_end} Release" msgid "%{strong_start}%{release_count}%{strong_end} Release"
msgid_plural "%{strong_start}%{release_count}%{strong_end} Releases" msgid_plural "%{strong_start}%{release_count}%{strong_end} Releases"
msgstr[0] "" msgstr[0] ""
......
...@@ -179,6 +179,16 @@ describe ProjectPresenter do ...@@ -179,6 +179,16 @@ describe ProjectPresenter do
end end
end end
describe '#storage_anchor_data' do
it 'returns storage data' do
expect(presenter.storage_anchor_data).to have_attributes(
is_link: true,
label: a_string_including('0 Bytes'),
link: nil
)
end
end
describe '#releases_anchor_data' do describe '#releases_anchor_data' do
it 'does not return release count' do it 'does not return release count' do
expect(presenter.releases_anchor_data).to be_nil expect(presenter.releases_anchor_data).to be_nil
...@@ -232,6 +242,16 @@ describe ProjectPresenter do ...@@ -232,6 +242,16 @@ describe ProjectPresenter do
end end
end end
describe '#storage_anchor_data' do
it 'returns storage data' do
expect(presenter.storage_anchor_data).to have_attributes(
is_link: true,
label: a_string_including('0 Bytes'),
link: presenter.project_tree_path(project)
)
end
end
describe '#releases_anchor_data' do describe '#releases_anchor_data' do
it 'returns release count if user can read release' do it 'returns release count if user can read release' do
project.add_maintainer(user) project.add_maintainer(user)
......
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