Commit 4712adc4 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch 'hide-user-cap-increase-confirmation-modal' into 'master'

Hide Auto Approve Pending Users Modal Behind Feature Flag

See merge request gitlab-org/gitlab!74842
parents 76eda726 2a40d170
......@@ -5,7 +5,9 @@ import { initGroupPermissionsFormSubmit } from 'ee/groups/settings/permissions';
import createFlash from '~/flash';
import { __ } from '~/locale';
initGroupPermissionsFormSubmit();
if (gon.features.saasUserCapsAutoApprovePendingUsersOnCapIncrease) {
initGroupPermissionsFormSubmit();
}
initAccessRestrictionField({
selector: '.js-allowed-email-domains',
......
......@@ -13,6 +13,10 @@ module EE
before_action :ee_authorize_admin_group!, only: [:restore]
before_action :check_subscription!, only: [:destroy]
before_action do
push_frontend_feature_flag(:saas_user_caps_auto_approve_pending_users_on_cap_increase, @group, default_enabled: :yaml)
end
feature_category :subgroups, [:restore]
end
......
......@@ -11,6 +11,13 @@ module EE
}
end
def saas_user_caps_help_text(group)
user_cap_docs_link_url = help_page_path("/user/admin_area/settings/sign_up_restrictions", anchor: "user-cap")
user_cap_docs_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: user_cap_docs_link_url }
html_escape(saas_user_caps_i18n_string(group)) % { user_cap_docs_link_start: user_cap_docs_link_start, user_cap_docs_link_end: '</a>'.html_safe }
end
private
def delayed_project_removal_i18n_string
......@@ -20,6 +27,14 @@ module EE
s_('GroupSettings|Projects will be permanently deleted after a %{waiting_period}-day delay. Inherited by subgroups.')
end
end
def saas_user_caps_i18n_string(group)
if ::Feature.enabled?(:saas_user_caps_auto_approve_pending_users_on_cap_increase, group.root_ancestor, default_enabled: :yaml)
s_('GroupSettings|When the number of active users exceeds this number, additional users must be %{user_cap_docs_link_start}approved by an owner%{user_cap_docs_link_end}. Leave empty if you don\'t want to enforce approvals.')
else
s_('GroupSettings|When the number of active users exceeds this number, additional users must be %{user_cap_docs_link_start}approved by an owner%{user_cap_docs_link_end}. Leave empty if you don\'t want to enforce approvals. Increasing the user cap will not automatically approve pending users.')
end
end
end
end
end
- return unless Feature.enabled?(:saas_user_caps, group.root_ancestor)
- user_cap_docs_link_url = help_page_path("/user/admin_area/settings/sign_up_restrictions", anchor: "user-cap")
- user_cap_docs_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: user_cap_docs_link_url }
.form-group
= f.label :new_user_signups_cap, _('User cap'), class: 'gl-font-weight-bold'
.form-text.text-muted= html_escape(_('When the number of active users exceeds this number, additional users must be %{user_cap_docs_link_start}approved by an owner%{user_cap_docs_link_end}. Leave empty if you don\'t want to enforce approvals.')) % { user_cap_docs_link_start: user_cap_docs_link_start, user_cap_docs_link_end: '</a>'.html_safe }
.form-text.text-muted= saas_user_caps_help_text(group)
= f.number_field :new_user_signups_cap, min: 1, class: 'form-control form-control-sm gl-form-input gl-w-full gl-mt-3'
---
name: saas_user_caps_auto_approve_pending_users_on_cap_increase
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74842
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/346156
milestone: '14.6'
type: development
group: group::utilization
default_enabled: false
......@@ -7,7 +7,7 @@ RSpec.describe 'Edit group settings' do
let_it_be(:user) { create(:user) }
let_it_be(:developer) { create(:user) }
let_it_be(:group) { create(:group, name: 'Foo bar', path: 'foo') }
let_it_be(:group, refind: true) { create(:group, name: 'Foo bar', path: 'foo') }
before_all do
group.add_owner(user)
......@@ -454,8 +454,6 @@ RSpec.describe 'Edit group settings' do
end
describe 'form submit button', :js do
let_it_be(:pending_user) { create(:user) }
def fill_in_new_user_signups_cap(new_user_signups_cap_value)
page.within('#js-permissions-settings') do
fill_in 'group[new_user_signups_cap]', with: new_user_signups_cap_value
......@@ -480,44 +478,94 @@ RSpec.describe 'Edit group settings' do
end
end
before_all do
before do
stub_feature_flags(saas_user_caps: true)
group.namespace_settings.update!(new_user_signups_cap: group.group_members.count)
end
before do
visit edit_group_path(group, anchor: 'js-permissions-settings')
end
context 'when the auto approve pending users feature flag is enabled' do
before do
stub_feature_flags(saas_user_caps_auto_approve_pending_users_on_cap_increase: true)
visit edit_group_path(group, anchor: 'js-permissions-settings')
end
context 'should show confirmation modal' do
context 'if user cap increases' do
it_behaves_like 'confirmation modal before submit' do
let(:new_user_signups_cap_value) { group.namespace_settings.new_user_signups_cap + 1 }
it 'shows correct helper text' do
expect(page).to have_content 'When the number of active users exceeds this number, additional users must be approved by an owner'
expect(page).not_to have_content 'Increasing the user cap will not automatically approve pending users'
end
context 'should show confirmation modal' do
context 'if user cap increases' do
it_behaves_like 'confirmation modal before submit' do
let(:new_user_signups_cap_value) { group.namespace_settings.new_user_signups_cap + 1 }
end
end
context 'if user cap changes from limited to unlimited' do
it_behaves_like 'confirmation modal before submit' do
let(:new_user_signups_cap_value) { nil }
end
end
end
context 'if user cap changes from limited to unlimited' do
it_behaves_like 'confirmation modal before submit' do
let(:new_user_signups_cap_value) { nil }
context 'should not show confirmation modal' do
context 'if user cap decreases' do
it_behaves_like 'successful form submit' do
let(:new_user_signups_cap_value) { group.namespace_settings.new_user_signups_cap - 1 }
end
end
context 'if user cap changes from unlimited to limited' do
before do
group.namespace_settings.update!(new_user_signups_cap: nil)
visit edit_group_path(group, anchor: 'js-permissions-settings')
end
it_behaves_like 'successful form submit' do
let(:new_user_signups_cap_value) { 1 }
end
end
end
end
context 'should not show confirmation modal' do
context 'if user cap decreases' do
it_behaves_like 'successful form submit' do
let(:new_user_signups_cap_value) { group.namespace_settings.new_user_signups_cap - 1 }
end
context 'when the auto approve pending users feature flag is disabled' do
before do
stub_feature_flags(saas_user_caps_auto_approve_pending_users_on_cap_increase: false)
visit edit_group_path(group, anchor: 'js-permissions-settings')
end
it 'shows correct helper text' do
expect(page).to have_content 'Increasing the user cap will not automatically approve pending users'
end
context 'if user cap changes from unlimited to limited' do
before do
group.namespace_settings.update!(new_user_signups_cap: nil)
visit edit_group_path(group, anchor: 'js-permissions-settings')
context 'should not show confirmation modal' do
context 'if user cap increases' do
it_behaves_like 'successful form submit' do
let(:new_user_signups_cap_value) { group.namespace_settings.new_user_signups_cap + 1 }
end
end
it_behaves_like 'successful form submit' do
let(:new_user_signups_cap_value) { 1 }
context 'if user cap changes from limited to unlimited' do
it_behaves_like 'successful form submit' do
let(:new_user_signups_cap_value) { nil }
end
end
context 'if user cap decreases' do
it_behaves_like 'successful form submit' do
let(:new_user_signups_cap_value) { group.namespace_settings.new_user_signups_cap - 1 }
end
end
context 'if user cap changes from unlimited to limited' do
before do
group.namespace_settings.update!(new_user_signups_cap: nil)
visit edit_group_path(group, anchor: 'js-permissions-settings')
end
it_behaves_like 'successful form submit' do
let(:new_user_signups_cap_value) { 1 }
end
end
end
end
......
......@@ -16854,6 +16854,12 @@ msgstr ""
msgid "GroupSettings|What are badges?"
msgstr ""
msgid "GroupSettings|When the number of active users exceeds this number, additional users must be %{user_cap_docs_link_start}approved by an owner%{user_cap_docs_link_end}. Leave empty if you don't want to enforce approvals."
msgstr ""
msgid "GroupSettings|When the number of active users exceeds this number, additional users must be %{user_cap_docs_link_start}approved by an owner%{user_cap_docs_link_end}. Leave empty if you don't want to enforce approvals. Increasing the user cap will not automatically approve pending users."
msgstr ""
msgid "GroupSettings|You can only transfer the group to a group you manage."
msgstr ""
......@@ -39107,9 +39113,6 @@ msgstr ""
msgid "When paused, GitLab still tracks the changes. This is useful for cluster/index migrations."
msgstr ""
msgid "When the number of active users exceeds this number, additional users must be %{user_cap_docs_link_start}approved by an owner%{user_cap_docs_link_end}. Leave empty if you don't want to enforce approvals."
msgstr ""
msgid "When this merge request is accepted"
msgid_plural "When these merge requests are accepted"
msgstr[0] ""
......
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