Commit 14d97308 authored by Ragnar-H's avatar Ragnar-H

Make frontend aware of dependant storage feature flags

We are using `additional_repo_storage_by_namespace_enabled?`
as a guard for dependant feature flags on the backend.
Let us be consistent with this on the frontend.
parent d99701be
......@@ -4,7 +4,7 @@ class Groups::UsageQuotasController < Groups::ApplicationController
before_action :authorize_admin_group!
before_action :verify_usage_quotas_enabled!
before_action do
push_frontend_feature_flag(:additional_repo_storage_by_namespace, @group)
push_additional_repo_storage_by_namespace_feature_flag
end
layout 'group_settings'
......@@ -21,4 +21,9 @@ class Groups::UsageQuotasController < Groups::ApplicationController
render_404 unless License.feature_available?(:usage_quotas)
render_404 if @group.has_parent?
end
def push_additional_repo_storage_by_namespace_feature_flag
additional_repo_storage_by_namespace_flag = :additional_repo_storage_by_namespace
gon.push({ features: { additional_repo_storage_by_namespace_flag.to_s.camelize(:lower) => @group.additional_repo_storage_by_namespace_enabled? } }, true)
end
end
......@@ -2,7 +2,7 @@
class Profiles::UsageQuotasController < Profiles::ApplicationController
before_action do
push_frontend_feature_flag(:additional_repo_storage_by_namespace, @group)
push_additional_repo_storage_by_namespace_feature_flag
end
feature_category :purchase
......@@ -11,4 +11,9 @@ class Profiles::UsageQuotasController < Profiles::ApplicationController
@namespace = current_user.namespace
@projects = @namespace.projects.with_shared_runners_limit_enabled.page(params[:page])
end
def push_additional_repo_storage_by_namespace_feature_flag
additional_repo_storage_by_namespace_flag = :additional_repo_storage_by_namespace
gon.push({ features: { additional_repo_storage_by_namespace_flag.to_s.camelize(:lower) => current_user.namespace.additional_repo_storage_by_namespace_enabled? } }, true)
end
end
......@@ -9,7 +9,7 @@ RSpec.describe 'Groups > Usage Quotas' do
let(:gitlab_dot_com) { true }
before do
stub_feature_flags(additional_repo_storage_by_namespace: true)
stub_feature_flags(additional_repo_storage_by_namespace: true, namespace_storage_limit: false)
allow(Gitlab).to receive(:com?).and_return(gitlab_dot_com)
group.add_owner(user)
......@@ -38,6 +38,20 @@ RSpec.describe 'Groups > Usage Quotas' do
end
end
context 'when `additional_repo_storage_by_namespace` is overruled by `namespace_storage_limit`' do
before do
stub_feature_flags(namespace_storage_limit: true, thing: group)
end
it 'pushes disabled feature flag to the frontend' do
visit profile_usage_quotas_path
expect(page).to have_pushed_frontend_feature_flags(
additionalRepoStorageByNamespace: false
)
end
end
shared_examples 'linked in group settings dropdown' do
it 'is linked within the group settings dropdown' do
visit edit_group_path(group)
......
......@@ -12,7 +12,7 @@ RSpec.describe 'Profile > Usage Quota' do
let_it_be(:other_project) { create(:project, namespace: namespace, shared_runners_enabled: false) }
before do
stub_feature_flags(additional_repo_storage_by_namespace: true)
stub_feature_flags(additional_repo_storage_by_namespace: true, namespace_storage_limit: false)
gitlab_sign_in(user)
end
......@@ -38,6 +38,20 @@ RSpec.describe 'Profile > Usage Quota' do
end
end
context 'when `additional_repo_storage_by_namespace` is overruled by `namespace_storage_limit`' do
before do
stub_feature_flags(namespace_storage_limit: true, thing: namespace)
end
it 'pushes disabled feature flag to the frontend' do
visit profile_usage_quotas_path
expect(page).to have_pushed_frontend_feature_flags(
additionalRepoStorageByNamespace: false
)
end
end
it 'is linked within the profile page' do
visit profile_path
......
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