Commit 3a0d9df1 authored by Douwe Maan's avatar Douwe Maan

Merge branch '10684-enable-approval-rule-by-default' into 'master'

Enable approval_rules by default

Closes #10684

See merge request gitlab-org/gitlab-ee!10504
parents 2473b50f 09947bed
...@@ -9,7 +9,7 @@ module EE ...@@ -9,7 +9,7 @@ module EE
prepended do prepended do
before_action only: [:show] do before_action only: [:show] do
push_frontend_feature_flag(:approval_rules, merge_request.project) push_frontend_feature_flag(:approval_rules, merge_request.project, default_enabled: true)
end end
before_action :whitelist_query_limiting_ee_merge, only: [:merge] before_action :whitelist_query_limiting_ee_merge, only: [:merge]
...@@ -65,7 +65,7 @@ module EE ...@@ -65,7 +65,7 @@ module EE
def render_approvals_json def render_approvals_json
respond_to do |format| respond_to do |format|
format.json do format.json do
entity = if ::Feature.enabled?(:approval_rules, merge_request.project) entity = if ::Feature.enabled?(:approval_rules, merge_request.project, default_enabled: true)
EE::API::Entities::ApprovalState.new(merge_request.approval_state, current_user: current_user) EE::API::Entities::ApprovalState.new(merge_request.approval_state, current_user: current_user)
else else
EE::API::Entities::MergeRequestApprovals.new(merge_request, current_user: current_user) EE::API::Entities::MergeRequestApprovals.new(merge_request, current_user: current_user)
......
...@@ -34,6 +34,6 @@ module VisibleApprovableForRule ...@@ -34,6 +34,6 @@ module VisibleApprovableForRule
end end
def approval_rules_disabled? def approval_rules_disabled?
::Feature.disabled?(:approval_rules, project) ::Feature.disabled?(:approval_rules, project, default_enabled: true)
end end
end end
...@@ -65,7 +65,7 @@ module EE ...@@ -65,7 +65,7 @@ module EE
end end
def validate_approval_rule_source def validate_approval_rule_source
return if ::Feature.disabled?(:approval_rules, project) return if ::Feature.disabled?(:approval_rules, project, default_enabled: true)
return unless approval_rules.any? return unless approval_rules.any?
local_project_rule_ids = approval_rules.map { |rule| rule.approval_merge_request_rule_source&.approval_project_rule_id } local_project_rule_ids = approval_rules.map { |rule| rule.approval_merge_request_rule_source&.approval_project_rule_id }
...@@ -84,7 +84,7 @@ module EE ...@@ -84,7 +84,7 @@ module EE
strong_memoize(:participant_approvers) do strong_memoize(:participant_approvers) do
next [] unless approval_needed? next [] unless approval_needed?
if ::Feature.enabled?(:approval_rules, project) if ::Feature.enabled?(:approval_rules, project, default_enabled: true)
approval_state.filtered_approvers(code_owner: false, unactioned: true) approval_state.filtered_approvers(code_owner: false, unactioned: true)
else else
approvers = [ approvers = [
......
...@@ -323,7 +323,7 @@ module EE ...@@ -323,7 +323,7 @@ module EE
end end
def visible_regular_approval_rules def visible_regular_approval_rules
return approval_rules.none unless ::Feature.enabled?(:approval_rules, self) return approval_rules.none unless ::Feature.enabled?(:approval_rules, self, default_enabled: true)
strong_memoize(:visible_regular_approval_rules) do strong_memoize(:visible_regular_approval_rules) do
regular_rules = approval_rules.regular.order(:id) regular_rules = approval_rules.regular.order(:id)
......
...@@ -40,7 +40,7 @@ module EE ...@@ -40,7 +40,7 @@ module EE
def update_approvers def update_approvers
return yield unless project.feature_available?(:code_owners) return yield unless project.feature_available?(:code_owners)
if ::Feature.enabled?(:approval_rules, project) if ::Feature.enabled?(:approval_rules, project, default_enabled: true)
results = yield results = yield
merge_requests_for_source_branch.each do |merge_request| merge_requests_for_source_branch.each do |merge_request|
......
...@@ -52,7 +52,7 @@ module EE ...@@ -52,7 +52,7 @@ module EE
# TODO remove after #1979 is closed # TODO remove after #1979 is closed
def sync_approval_rules(merge_request) def sync_approval_rules(merge_request)
return if ::Feature.enabled?(:approval_rules, merge_request.target_project) return if ::Feature.enabled?(:approval_rules, merge_request.target_project, default_enabled: true)
return if merge_request.merged? return if merge_request.merged?
return unless merge_request.previous_changes.include?(:approvals_before_merge) return unless merge_request.previous_changes.include?(:approvals_before_merge)
......
...@@ -72,7 +72,7 @@ module EE ...@@ -72,7 +72,7 @@ module EE
# TODO remove after #1979 is closed # TODO remove after #1979 is closed
def sync_approval_rules def sync_approval_rules
return if ::Feature.enabled?(:approval_rules, project) return if ::Feature.enabled?(:approval_rules, project, default_enabled: true)
return unless project.previous_changes.include?(:approvals_before_merge) return unless project.previous_changes.include?(:approvals_before_merge)
project.approval_rules.update_all(approvals_required: project.approvals_before_merge) project.approval_rules.update_all(approvals_required: project.approvals_before_merge)
......
- can_override_approvers = project.can_override_approvers? - can_override_approvers = project.can_override_approvers?
- if Feature.enabled?(:approval_rules, project) - if Feature.enabled?(:approval_rules, project, default_enabled: true)
= render 'shared/merge_request_approvals_settings/multiple_rules_form', form: form, project: project = render 'shared/merge_request_approvals_settings/multiple_rules_form', form: form, project: project
- else - else
= render 'shared/merge_request_approvals_settings/single_rule_form', form: form, project: project = render 'shared/merge_request_approvals_settings/single_rule_form', form: form, project: project
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
= form.label :approver_ids, class: 'col-form-label col-sm-2' do = form.label :approver_ids, class: 'col-form-label col-sm-2' do
Approvers Approvers
.col-sm-10 .col-sm-10
- if Feature.enabled?(:approval_rules, @target_project) - if Feature.enabled?(:approval_rules, @target_project, default_enabled: true)
= render 'shared/issuable/approvals_multiple_rule', issuable: issuable = render 'shared/issuable/approvals_multiple_rule', issuable: issuable
- else - else
= render 'shared/issuable/approvals_single_rule', issuable: issuable, presenter: presenter, form: form = render 'shared/issuable/approvals_single_rule', issuable: issuable, presenter: presenter, form: form
......
...@@ -4,7 +4,7 @@ module API ...@@ -4,7 +4,7 @@ module API
module Helpers module Helpers
module ApprovalHelpers module ApprovalHelpers
def present_approval(merge_request) def present_approval(merge_request)
if Feature.enabled?(:approval_rules, merge_request.project) if Feature.enabled?(:approval_rules, merge_request.project, default_enabled: true)
present merge_request.approval_state, with: ::EE::API::Entities::ApprovalState, current_user: current_user present merge_request.approval_state, with: ::EE::API::Entities::ApprovalState, current_user: current_user
else else
present merge_request.present(current_user: current_user), with: ::EE::API::Entities::MergeRequestApprovals, current_user: current_user present merge_request.present(current_user: current_user), with: ::EE::API::Entities::MergeRequestApprovals, current_user: current_user
......
...@@ -54,7 +54,7 @@ module API ...@@ -54,7 +54,7 @@ module API
hidden: true hidden: true
} }
get 'approval_settings' do get 'approval_settings' do
not_found! unless ::Feature.enabled?(:approval_rules, user_project) not_found! unless ::Feature.enabled?(:approval_rules, user_project, default_enabled: true)
merge_request = find_merge_request_with_access(params[:merge_request_iid]) merge_request = find_merge_request_with_access(params[:merge_request_iid])
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module API module API
class ProjectApprovalRules < ::Grape::API class ProjectApprovalRules < ::Grape::API
before { authenticate! } before { authenticate! }
before { not_found! unless ::Feature.enabled?(:approval_rules, user_project) } before { not_found! unless ::Feature.enabled?(:approval_rules, user_project, default_enabled: true) }
ARRAY_COERCION_LAMBDA = ->(val) { val.empty? ? [] : Array.wrap(val) } ARRAY_COERCION_LAMBDA = ->(val) { val.empty? ? [] : Array.wrap(val) }
......
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