Commit 50bad1b8 authored by Francisco Javier López's avatar Francisco Javier López Committed by Aleksei Lipniagov

Add group wiki settings toggle

In this commit we're introducing behind a feature flag
the code to add form in group settings to disable/enable
the group wiki.
parent 3de4814e
...@@ -293,7 +293,7 @@ class GroupsController < Groups::ApplicationController ...@@ -293,7 +293,7 @@ class GroupsController < Groups::ApplicationController
:setup_for_company, :setup_for_company,
:jobs_to_be_done, :jobs_to_be_done,
:crm_enabled :crm_enabled
] ] + [group_feature_attributes: group_feature_attributes]
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
...@@ -396,6 +396,10 @@ class GroupsController < Groups::ApplicationController ...@@ -396,6 +396,10 @@ class GroupsController < Groups::ApplicationController
experiment(:require_verification_for_namespace_creation, user: current_user).track(:start_create_group) experiment(:require_verification_for_namespace_creation, user: current_user).track(:start_create_group)
end end
def group_feature_attributes
[]
end
end end
GroupsController.prepend_mod_with('GroupsController') GroupsController.prepend_mod_with('GroupsController')
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
= render 'groups/settings/ip_restriction_registration_features_cta', f: f = render 'groups/settings/ip_restriction_registration_features_cta', f: f
= render_if_exists 'groups/settings/ip_restriction', f: f, group: @group = render_if_exists 'groups/settings/ip_restriction', f: f, group: @group
= render_if_exists 'groups/settings/allowed_email_domain', f: f, group: @group = render_if_exists 'groups/settings/allowed_email_domain', f: f, group: @group
- if Feature.enabled?(:group_wiki_settings_toggle, @group, default_enabled: :yaml)
= render_if_exists 'groups/settings/wiki', f: f, group: @group
= render 'groups/settings/lfs', f: f = render 'groups/settings/lfs', f: f
= render 'groups/settings/project_creation_level', f: f, group: @group = render 'groups/settings/project_creation_level', f: f, group: @group
= render 'groups/settings/subgroup_creation_level', f: f, group: @group = render 'groups/settings/subgroup_creation_level', f: f, group: @group
......
---
name: group_wiki_settings_toggle
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82298
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/358387
milestone: '14.10'
type: development
group: group::editor
default_enabled: false
...@@ -126,5 +126,12 @@ module EE ...@@ -126,5 +126,12 @@ module EE
invite_members(group, invite_source: 'group-creation-page') invite_members(group, invite_source: 'group-creation-page')
end end
override :group_feature_attributes
def group_feature_attributes
return super if ::Feature.disabled?(:group_wiki_settings_toggle, current_group, default_enabled: :yaml)
super + [:wiki_access_level]
end
end end
end end
%h5= _('Wiki')
- group_feature = group.group_feature
= f.fields_for :group_feature_attributes, group_feature do |group_feature_form|
.form-group.gl-mb-3
= group_feature_form.gitlab_ui_radio_component :wiki_access_level, Featurable::ENABLED,
s_('Enabled'),
help_text: s_('Allow access to everyone')
= group_feature_form.gitlab_ui_radio_component :wiki_access_level, Featurable::PRIVATE,
s_('Private'),
help_text: s_('Allow access only to members of this group')
= group_feature_form.gitlab_ui_radio_component :wiki_access_level, Featurable::DISABLED,
s_('Disabled'),
help_text: s_('Disable the group-level wiki')
...@@ -652,5 +652,35 @@ RSpec.describe GroupsController do ...@@ -652,5 +652,35 @@ RSpec.describe GroupsController do
end end
end end
end end
context 'when group feature setting `wiki_access_level` is specified' do
before do
group.add_owner(user)
sign_in(user)
end
it 'updates the attribute' do
[Featurable::PRIVATE, Featurable::DISABLED, Featurable::ENABLED].each do |visibility_level|
request(visibility_level)
expect(group.reload.group_feature.wiki_access_level).to eq(visibility_level)
end
end
context 'when feature flag :group_wiki_settings_toggle is disabled' do
before do
stub_feature_flags(group_wiki_settings_toggle: false)
end
it 'does not update the attribute' do
expect { request(Featurable::PRIVATE) }.not_to change { group.reload.group_feature.wiki_access_level }
end
end
def request(visibility_level)
put :update, params: { id: group.to_param, group: { group_feature_attributes: { wiki_access_level: visibility_level } } }
end
end
end end
end end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Group' do
describe 'group edit', :js do
let_it_be(:user) { create(:user) }
let_it_be(:group) do
create(:group, :public).tap do |g|
g.add_owner(user)
end
end
let(:path) { edit_group_path(group, anchor: 'js-permissions-settings') }
let(:group_wiki_toggle) { true }
before do
stub_feature_flags(group_wiki_settings_toggle: group_wiki_toggle)
sign_in(user)
visit path
end
context 'wiki_access_level setting' do
it 'saves new settings', :aggregate_failures do
expect(page).to have_content('Disable the group-level wiki')
[Featurable::PRIVATE, Featurable::DISABLED, Featurable::ENABLED].each do |wiki_access_level|
find(
".js-general-permissions-form "\
"#group_group_feature_attributes_wiki_access_level_#{wiki_access_level}").click
click_button 'Save changes'
expect(page).to have_content 'successfully updated'
expect(group.reload.group_feature.wiki_access_level).to eq wiki_access_level
end
end
context 'when feature flag :group_wiki_settings_toggle is disabled' do
let(:group_wiki_toggle) { false }
it 'wiki settings form is not present' do
expect(page).not_to have_content('Disable the group-level wiki')
end
end
end
end
end
...@@ -3666,6 +3666,12 @@ msgstr "" ...@@ -3666,6 +3666,12 @@ msgstr ""
msgid "Allow \"%{group_name}\" to sign you in" msgid "Allow \"%{group_name}\" to sign you in"
msgstr "" msgstr ""
msgid "Allow access only to members of this group"
msgstr ""
msgid "Allow access to everyone"
msgstr ""
msgid "Allow access to members of the following group" msgid "Allow access to members of the following group"
msgstr "" msgstr ""
...@@ -13148,6 +13154,9 @@ msgstr "" ...@@ -13148,6 +13154,9 @@ msgstr ""
msgid "Disable group runners" msgid "Disable group runners"
msgstr "" msgstr ""
msgid "Disable the group-level wiki"
msgstr ""
msgid "Disable two-factor authentication" msgid "Disable two-factor authentication"
msgstr "" 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