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'; ...@@ -5,7 +5,9 @@ import { initGroupPermissionsFormSubmit } from 'ee/groups/settings/permissions';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
initGroupPermissionsFormSubmit(); if (gon.features.saasUserCapsAutoApprovePendingUsersOnCapIncrease) {
initGroupPermissionsFormSubmit();
}
initAccessRestrictionField({ initAccessRestrictionField({
selector: '.js-allowed-email-domains', selector: '.js-allowed-email-domains',
......
...@@ -13,6 +13,10 @@ module EE ...@@ -13,6 +13,10 @@ module EE
before_action :ee_authorize_admin_group!, only: [:restore] before_action :ee_authorize_admin_group!, only: [:restore]
before_action :check_subscription!, only: [:destroy] 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] feature_category :subgroups, [:restore]
end end
......
...@@ -11,6 +11,13 @@ module EE ...@@ -11,6 +11,13 @@ module EE
} }
end 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 private
def delayed_project_removal_i18n_string def delayed_project_removal_i18n_string
...@@ -20,6 +27,14 @@ module EE ...@@ -20,6 +27,14 @@ module EE
s_('GroupSettings|Projects will be permanently deleted after a %{waiting_period}-day delay. Inherited by subgroups.') s_('GroupSettings|Projects will be permanently deleted after a %{waiting_period}-day delay. Inherited by subgroups.')
end end
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 end
end end
- return unless Feature.enabled?(:saas_user_caps, group.root_ancestor) - 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 .form-group
= f.label :new_user_signups_cap, _('User cap'), class: 'gl-font-weight-bold' = 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' = 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 ...@@ -7,7 +7,7 @@ RSpec.describe 'Edit group settings' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:developer) { 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 before_all do
group.add_owner(user) group.add_owner(user)
...@@ -454,8 +454,6 @@ RSpec.describe 'Edit group settings' do ...@@ -454,8 +454,6 @@ RSpec.describe 'Edit group settings' do
end end
describe 'form submit button', :js do 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) def fill_in_new_user_signups_cap(new_user_signups_cap_value)
page.within('#js-permissions-settings') do page.within('#js-permissions-settings') do
fill_in 'group[new_user_signups_cap]', with: new_user_signups_cap_value fill_in 'group[new_user_signups_cap]', with: new_user_signups_cap_value
...@@ -480,15 +478,22 @@ RSpec.describe 'Edit group settings' do ...@@ -480,15 +478,22 @@ RSpec.describe 'Edit group settings' do
end end
end end
before_all do before do
stub_feature_flags(saas_user_caps: true) stub_feature_flags(saas_user_caps: true)
group.namespace_settings.update!(new_user_signups_cap: group.group_members.count) group.namespace_settings.update!(new_user_signups_cap: group.group_members.count)
end end
context 'when the auto approve pending users feature flag is enabled' do
before 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') visit edit_group_path(group, anchor: 'js-permissions-settings')
end end
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 'should show confirmation modal' do
context 'if user cap increases' do context 'if user cap increases' do
it_behaves_like 'confirmation modal before submit' do it_behaves_like 'confirmation modal before submit' do
...@@ -522,6 +527,49 @@ RSpec.describe 'Edit group settings' do ...@@ -522,6 +527,49 @@ RSpec.describe 'Edit group settings' do
end end
end end
end 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 '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
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
end
end end
def save_permissions_group def save_permissions_group
......
...@@ -16854,6 +16854,12 @@ msgstr "" ...@@ -16854,6 +16854,12 @@ msgstr ""
msgid "GroupSettings|What are badges?" msgid "GroupSettings|What are badges?"
msgstr "" 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." msgid "GroupSettings|You can only transfer the group to a group you manage."
msgstr "" msgstr ""
...@@ -39107,9 +39113,6 @@ msgstr "" ...@@ -39107,9 +39113,6 @@ msgstr ""
msgid "When paused, GitLab still tracks the changes. This is useful for cluster/index migrations." msgid "When paused, GitLab still tracks the changes. This is useful for cluster/index migrations."
msgstr "" 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 "When this merge request is accepted"
msgid_plural "When these merge requests are accepted" msgid_plural "When these merge requests are accepted"
msgstr[0] "" 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