Skip to content

Fix approvals UI rendering when feature is disabled

Jiaan Louw requested to merge 337651-only-render-mr-approvals-when-enabled into master

What does this MR do?

This MR updates the approvals suggestion partial to only render when the approval feature is available.

Screenshots or Screencasts (strongly suggested)

Before After
image image

How to setup and validate locally (strongly suggested)

@stanhu shared how to reproduce this bug in GDK in this discussion.

It appears that when the project does not have the merge request approval feature, the frontend displays this error for some reason. No backend calls are made.

Locally, I can reproduce this via:

diff --git a/ee/app/models/ee/project.rb b/ee/app/models/ee/project.rb
index 54e9224c8eff..e72786e8c489 100644
--- a/ee/app/models/ee/project.rb
+++ b/ee/app/models/ee/project.rb
@@ -376,6 +376,8 @@ def push_audit_events_enabled?
 
     override :feature_available?
     def feature_available?(feature, user = nil)
+      return false if feature == :merge_request_approvers
+
       if ::ProjectFeature::FEATURES.include?(feature)
         super
       else

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #337651 (closed)

Edited by Jiaan Louw

Merge request reports