Skip to content
Snippets Groups Projects
Commit 0c652b07 authored by Ammar Alakkad's avatar Ammar Alakkad Committed by Robert May
Browse files

Allow profile namespaces to use new storage design

parent ed101757
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -7,6 +7,7 @@ class Profiles::UsageQuotasController < Profiles::ApplicationController
 
before_action only: [:index] do
push_frontend_feature_flag(:gitlab_gtm_datalayer, type: :ops)
push_frontend_feature_flag(:update_storage_usage_design, current_user)
end
 
def index
Loading
Loading
Loading
Loading
@@ -91,6 +91,27 @@ def pipeline_usage_app_data(namespace)
)
end
 
def storage_usage_app_data(namespace)
data = {
namespace_path: namespace.full_path,
purchase_storage_url: nil,
buy_addon_target_attr: nil,
is_temporary_storage_increase_visible: temporary_storage_increase_visible?(namespace).to_s,
default_per_page: page_size,
additional_repo_storage_by_namespace: current_user.namespace.additional_repo_storage_by_namespace_enabled?.to_s,
is_free_namespace: (!current_user.namespace.paid?).to_s
}
if purchase_storage_link_enabled?(namespace)
data.merge!({
purchase_storage_url: purchase_storage_url,
buy_addon_target_attr: buy_addon_target_attr(namespace)
})
end
data
end
private
 
def use_customers_dot_for_addon_path?(namespace)
Loading
Loading
Loading
Loading
@@ -5,8 +5,6 @@
 
- page_title s_("UsageQuota|Usage")
- @content_class = "limit-container-width" unless fluid_layout
- url_to_purchase_storage = purchase_storage_url if purchase_storage_link_enabled?(@namespace)
- buy_addon_target_attr = buy_addon_target_attr(@namespace) if purchase_storage_link_enabled?(@namespace)
 
%h3.page-title
= s_('UsageQuota|Usage Quotas')
Loading
Loading
@@ -28,4 +26,4 @@
= render "namespaces/pipelines_quota/list",
locals: { namespace: @namespace, projects_usage: @projects_usage }
.tab-pane#storage-quota-tab
#js-storage-counter-app{ data: { namespace_path: @namespace.full_path, purchase_storage_url: url_to_purchase_storage, buy_addon_target_attr: buy_addon_target_attr, is_temporary_storage_increase_visible: temporary_storage_increase_visible?(@namespace).to_s, default_per_page: page_size, additional_repo_storage_by_namespace: current_user.namespace.additional_repo_storage_by_namespace_enabled?.to_s } }
#js-storage-counter-app{ data: storage_usage_app_data(@namespace) }
Loading
Loading
@@ -340,4 +340,49 @@
end
end
end
describe '#storage_usage_app_data' do
let_it_be(:namespace) { create(:namespace) }
let_it_be(:admin) { create(:user, namespace: namespace) }
before do
allow(helper).to receive(:current_user).and_return(admin)
end
context 'when purchase_storage_link_enabled? is true' do
before do
allow(namespace).to receive(:additional_repo_storage_by_namespace_enabled?).and_return(true)
end
it 'returns a hash with storage data' do
expect(helper.storage_usage_app_data(namespace)).to eql({
additional_repo_storage_by_namespace: "true",
buy_addon_target_attr: "_blank",
purchase_storage_url: "https://customers.staging.gitlab.com/buy_storage",
default_per_page: 20,
namespace_path: namespace.full_path,
is_temporary_storage_increase_visible: "false",
is_free_namespace: "true"
})
end
end
context 'when purchase_storage_link_enabled? is false' do
before do
allow(namespace).to receive(:additional_repo_storage_by_namespace_enabled?).and_return(false)
end
it 'returns a hash with storage data' do
expect(helper.storage_usage_app_data(namespace)).to eql({
additional_repo_storage_by_namespace: "false",
buy_addon_target_attr: nil,
purchase_storage_url: nil,
default_per_page: 20,
namespace_path: namespace.full_path,
is_temporary_storage_increase_visible: "false",
is_free_namespace: "true"
})
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment