Commit f7384cc8 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '247846-global-storage-alert-text' into 'master'

Make storage alert text more dynamic

See merge request gitlab-org/gitlab!45570
parents a8067094 70cb290e
......@@ -15,11 +15,16 @@ module Namespaces
def usage_message
if root_namespace.contains_locked_projects?
params = { namespace_name: root_namespace.name,
locked_project_count: root_namespace.repository_size_excess_project_count,
free_size_limit: formatted(root_namespace.actual_size_limit) }
if root_namespace.additional_purchased_storage_size == 0
params = { locked_project_count: root_namespace.repository_size_excess_project_count }
s_("NamespaceStorageSize|You have reached the free storage limit of 10GB on %{locked_project_count} projects. To unlock them, please purchase additional storage" % params)
ns_("NamespaceStorageSize|You have reached the free storage limit of %{free_size_limit} on %{locked_project_count} project. To unlock it, please purchase additional storage",
"NamespaceStorageSize|You have reached the free storage limit of %{free_size_limit} on %{locked_project_count} projects. To unlock them, please purchase additional storage",
params[:locked_project_count]) % params
else
s_("NamespaceStorageSize|%{namespace_name} contains a locked project" % { namespace_name: root_namespace.name })
ns_("NamespaceStorageSize|%{namespace_name} contains %{locked_project_count} locked project", "NamespaceStorageSize|%{namespace_name} contains %{locked_project_count} locked projects", params[:locked_project_count]) % params
end
else
s_("NamespaceStorageSize|You have reached %{usage_in_percent} of %{namespace_name}'s storage capacity (%{used_storage} of %{storage_limit})" % current_usage_params)
......@@ -28,10 +33,14 @@ module Namespaces
def above_size_limit_message
if root_namespace.additional_purchased_storage_size > 0
s_("NamespaceStorageSize|You have consumed all of your additional storage, please purchase more to unlock your projects over the free 10GB limit. You can't %{base_message}" % { base_message: base_message })
s_("NamespaceStorageSize|You have consumed all of your additional storage, please purchase more to unlock your projects over the free %{free_size_limit} limit. You can't %{base_message}" % { base_message: base_message, free_size_limit: formatted(root_namespace.actual_size_limit) })
else
s_("NamespaceStorageSize|Please purchase additional storage to unlock your projects over the free 10GB project limit. You can't %{base_message}" % { base_message: base_message })
s_("NamespaceStorageSize|Please purchase additional storage to unlock your projects over the free %{free_size_limit} project limit. You can't %{base_message}" % { base_message: base_message, free_size_limit: formatted(root_namespace.actual_size_limit) })
end
end
def formatted(number)
number_to_human_size(number, delimiter: ',', precision: 2)
end
end
end
......@@ -9,6 +9,8 @@ RSpec.describe Namespaces::CheckExcessStorageSizeService, '#execute' do
let(:total_repository_size_excess) { 150.megabytes }
let(:additional_purchased_storage_size) { 100 }
let(:storage_allocation_enabled) { true }
let(:actual_size_limit) { 10.gigabytes }
let(:locked_project_count) { 1 }
subject(:response) { service.execute }
......@@ -17,6 +19,8 @@ RSpec.describe Namespaces::CheckExcessStorageSizeService, '#execute' do
allow(namespace).to receive(:root_ancestor).and_return(namespace)
allow(namespace).to receive(:total_repository_size_excess).and_return(total_repository_size_excess)
allow(namespace).to receive(:actual_size_limit).and_return(actual_size_limit)
allow(namespace).to receive(:repository_size_excess_project_count).and_return(locked_project_count)
end
context 'without limit enforcement' do
......@@ -165,8 +169,18 @@ RSpec.describe Namespaces::CheckExcessStorageSizeService, '#execute' do
let(:contains_locked_projects) { true }
context 'when there is additional storage' do
it 'returns message about containing a locked project' do
expect(response).to include("contains a locked project")
context 'with one locked project' do
it 'returns message about containing a locked project' do
expect(response).to include("#{locked_project_count} locked project")
end
end
context 'with multiple projects' do
let(:locked_project_count) { 3 }
it 'returns a pluralized message about locked projects' do
expect(response).to include("#{locked_project_count} locked projects")
end
end
end
......@@ -174,12 +188,8 @@ RSpec.describe Namespaces::CheckExcessStorageSizeService, '#execute' do
let(:additional_purchased_storage_size) { 0 }
let(:locked_project_count) { 3 }
before do
allow(namespace).to receive(:repository_size_excess_project_count).and_return(locked_project_count)
end
it 'returns message to have reached the free storage limit' do
expect(response).to include("You have reached the free storage limit of 10GB")
expect(response).to include("You have reached the free storage limit of 10 GB")
expect(response).to include("#{locked_project_count} projects")
end
end
......
......@@ -17394,8 +17394,10 @@ msgstr ""
msgid "Namespace:"
msgstr ""
msgid "NamespaceStorageSize|%{namespace_name} contains a locked project"
msgstr ""
msgid "NamespaceStorageSize|%{namespace_name} contains %{locked_project_count} locked project"
msgid_plural "NamespaceStorageSize|%{namespace_name} contains %{locked_project_count} locked projects"
msgstr[0] ""
msgstr[1] ""
msgid "NamespaceStorageSize|%{namespace_name} is now read-only. You cannot: %{base_message}"
msgstr ""
......@@ -17403,17 +17405,19 @@ msgstr ""
msgid "NamespaceStorageSize|If you reach 100%% storage capacity, you will not be able to: %{base_message}"
msgstr ""
msgid "NamespaceStorageSize|Please purchase additional storage to unlock your projects over the free 10GB project limit. You can't %{base_message}"
msgid "NamespaceStorageSize|Please purchase additional storage to unlock your projects over the free %{free_size_limit} project limit. You can't %{base_message}"
msgstr ""
msgid "NamespaceStorageSize|You have consumed all of your additional storage, please purchase more to unlock your projects over the free 10GB limit. You can't %{base_message}"
msgid "NamespaceStorageSize|You have consumed all of your additional storage, please purchase more to unlock your projects over the free %{free_size_limit} limit. You can't %{base_message}"
msgstr ""
msgid "NamespaceStorageSize|You have reached %{usage_in_percent} of %{namespace_name}'s storage capacity (%{used_storage} of %{storage_limit})"
msgstr ""
msgid "NamespaceStorageSize|You have reached the free storage limit of 10GB on %{locked_project_count} projects. To unlock them, please purchase additional storage"
msgstr ""
msgid "NamespaceStorageSize|You have reached the free storage limit of %{free_size_limit} on %{locked_project_count} project. To unlock it, please purchase additional storage"
msgid_plural "NamespaceStorageSize|You have reached the free storage limit of %{free_size_limit} on %{locked_project_count} projects. To unlock them, please purchase additional storage"
msgstr[0] ""
msgstr[1] ""
msgid "NamespaceStorageSize|push to your repository, create pipelines, create issues or add comments. To reduce storage capacity, delete unused repositories, artifacts, wikis, issues, and pipelines."
msgstr ""
......
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