Commit c6da83ef authored by Robert Speicher's avatar Robert Speicher

Merge branch 'tweak-group-policy' into 'master'

Convert group wikis into a licensed feature

See merge request gitlab-org/gitlab!42219
parents f0985664 2c501b7f
...@@ -10,19 +10,19 @@ module EE ...@@ -10,19 +10,19 @@ module EE
with_scope :subject with_scope :subject
condition(:ldap_synced) { @subject.ldap_synced? } condition(:ldap_synced) { @subject.ldap_synced? }
condition(:epics_available) { feature_available?(:epics) } condition(:epics_available) { @subject.feature_available?(:epics) }
condition(:iterations_available) { feature_available?(:iterations) } condition(:iterations_available) { @subject.feature_available?(:iterations) }
condition(:subepics_available) { feature_available?(:subepics) } condition(:subepics_available) { @subject.feature_available?(:subepics) }
condition(:contribution_analytics_available) do condition(:contribution_analytics_available) do
feature_available?(:contribution_analytics) @subject.feature_available?(:contribution_analytics)
end end
condition(:cycle_analytics_available) do condition(:cycle_analytics_available) do
feature_available?(:cycle_analytics_for_groups) @subject.feature_available?(:cycle_analytics_for_groups)
end end
condition(:group_merge_request_analytics_available) do condition(:group_merge_request_analytics_available) do
feature_available?(:group_merge_request_analytics) @subject.feature_available?(:group_merge_request_analytics)
end end
condition(:group_repository_analytics_available) do condition(:group_repository_analytics_available) do
...@@ -30,7 +30,7 @@ module EE ...@@ -30,7 +30,7 @@ module EE
end end
condition(:group_activity_analytics_available) do condition(:group_activity_analytics_available) do
feature_available?(:group_activity_analytics) && ::Feature.enabled?(:group_activity_analytics, @subject, default_enabled: true) @subject.feature_available?(:group_activity_analytics) && ::Feature.enabled?(:group_activity_analytics, @subject, type: :licensed, default_enabled: true)
end end
condition(:can_owners_manage_ldap, scope: :global) do condition(:can_owners_manage_ldap, scope: :global) do
...@@ -46,11 +46,11 @@ module EE ...@@ -46,11 +46,11 @@ module EE
end end
condition(:security_dashboard_enabled) do condition(:security_dashboard_enabled) do
feature_available?(:security_dashboard) @subject.feature_available?(:security_dashboard)
end end
condition(:prevent_group_forking_available) do condition(:prevent_group_forking_available) do
feature_available?(:group_forking_protection) @subject.feature_available?(:group_forking_protection)
end end
condition(:needs_new_sso_session) do condition(:needs_new_sso_session) do
...@@ -62,11 +62,11 @@ module EE ...@@ -62,11 +62,11 @@ module EE
end end
condition(:dependency_proxy_available) do condition(:dependency_proxy_available) do
feature_available?(:dependency_proxy) @subject.feature_available?(:dependency_proxy)
end end
condition(:cluster_deployments_available) do condition(:cluster_deployments_available) do
feature_available?(:cluster_deployments) @subject.feature_available?(:cluster_deployments)
end end
condition(:group_saml_enabled) do condition(:group_saml_enabled) do
...@@ -74,7 +74,7 @@ module EE ...@@ -74,7 +74,7 @@ module EE
end end
condition(:group_timelogs_available) do condition(:group_timelogs_available) do
feature_available?(:group_timelogs) @subject.feature_available?(:group_timelogs)
end end
with_scope :global with_scope :global
...@@ -88,15 +88,15 @@ module EE ...@@ -88,15 +88,15 @@ module EE
end end
condition(:commit_committer_check_available) do condition(:commit_committer_check_available) do
feature_available?(:commit_committer_check) @subject.feature_available?(:commit_committer_check)
end end
condition(:reject_unsigned_commits_available) do condition(:reject_unsigned_commits_available) do
feature_available?(:reject_unsigned_commits) @subject.feature_available?(:reject_unsigned_commits)
end end
condition(:push_rules_available) do condition(:push_rules_available) do
feature_available?(:push_rules) @subject.feature_available?(:push_rules)
end end
condition(:over_storage_limit, scope: :subject) { @subject.over_storage_limit? } condition(:over_storage_limit, scope: :subject) { @subject.over_storage_limit? }
...@@ -245,8 +245,10 @@ module EE ...@@ -245,8 +245,10 @@ module EE
prevent :update_default_branch_protection prevent :update_default_branch_protection
end end
# TODO: Switch to `feature_enabled?` when we enable the feature flag by default
# https://gitlab.com/gitlab-org/gitlab/-/issues/207888
desc "Group has wiki disabled" desc "Group has wiki disabled"
condition(:wiki_disabled, score: 32) { !feature_available?(:group_wikis) } condition(:wiki_disabled, score: 32) { !@subject.beta_feature_available?(:group_wikis) }
rule { wiki_disabled }.policy do rule { wiki_disabled }.policy do
prevent(*create_read_update_admin_destroy(:wiki)) prevent(*create_read_update_admin_destroy(:wiki))
...@@ -304,19 +306,6 @@ module EE ...@@ -304,19 +306,6 @@ module EE
super super
end end
# TODO: Once we implement group-level feature toggles, see if we can refactor
# the shared logic in ProjectPolicy and GroupPolicy.
# https://gitlab.com/gitlab-org/gitlab/-/issues/208412
def feature_available?(feature)
if feature == :group_wikis
# TODO: Remove this special case when we remove the feature flag
# https://gitlab.com/gitlab-org/gitlab/-/issues/207888
::Feature.enabled?(:group_wikis_feature_flag, subject) && subject.feature_available?(feature)
else
subject.feature_available?(feature)
end
end
def ldap_lock_bypassable? def ldap_lock_bypassable?
return false unless ::Feature.enabled?(:ldap_settings_unlock_groups_by_owners) return false unless ::Feature.enabled?(:ldap_settings_unlock_groups_by_owners)
return false unless ::Gitlab::CurrentSettings.allow_group_owners_to_manage_ldap? return false unless ::Gitlab::CurrentSettings.allow_group_owners_to_manage_ldap?
......
--- ---
name: group_wikis_feature_flag name: group_wikis
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/29176 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/29176
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/207888 rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/207888
group: group::knowledge group: group::knowledge
type: development type: licensed
default_enabled: false default_enabled: [false, true]
...@@ -1075,9 +1075,9 @@ RSpec.describe GroupPolicy do ...@@ -1075,9 +1075,9 @@ RSpec.describe GroupPolicy do
def set_access_level(access_level) def set_access_level(access_level)
case access_level case access_level
when ProjectFeature::ENABLED when ProjectFeature::ENABLED
stub_feature_flags(group_wikis_feature_flag: true) stub_feature_flags(group_wikis: true)
when ProjectFeature::DISABLED when ProjectFeature::DISABLED
stub_feature_flags(group_wikis_feature_flag: false) stub_feature_flags(group_wikis: false)
when ProjectFeature::PRIVATE when ProjectFeature::PRIVATE
skip('Access level private is not supported yet for group wikis, see https://gitlab.com/gitlab-org/gitlab/-/issues/208412') skip('Access level private is not supported yet for group wikis, see https://gitlab.com/gitlab-org/gitlab/-/issues/208412')
end end
...@@ -1085,7 +1085,7 @@ RSpec.describe GroupPolicy do ...@@ -1085,7 +1085,7 @@ RSpec.describe GroupPolicy do
context 'when the feature flag is disabled on this group' do context 'when the feature flag is disabled on this group' do
before do before do
stub_feature_flags(group_wikis_feature_flag: create(:group)) stub_feature_flags(group_wikis: create(:group))
end end
it 'does not include the wiki permissions' do it 'does not include the wiki permissions' do
......
...@@ -4,7 +4,7 @@ module WikiHelpers ...@@ -4,7 +4,7 @@ module WikiHelpers
extend self extend self
def stub_group_wikis(enabled) def stub_group_wikis(enabled)
stub_feature_flags(group_wikis_feature_flag: enabled) stub_feature_flags(group_wikis: enabled)
stub_licensed_features(group_wikis: enabled) stub_licensed_features(group_wikis: enabled)
end end
......
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