Skip to content

Add “Pending owner approval” badge for members

Sheldon Led requested to merge led/334292-add-pending-owner-approval-badge into master

What does this MR do and why?

Relates to #334292 (closed)

A user can be Pending owner approval in 2 scenarios:

  1. Gitlab instance-wide root approval (steps to reproduce below)
  2. User Cap: with the User Cap setting, admins can prevent accidental user overages, so when the group is at limit of number of users, they should be on the invited tab (!70675 (merged)), with Pending Owner Approval status.

Screenshots or screen recordings

In my screenshots, I have 3 users in the invited tab:

  1. Arnulfo Jakubowski (@valeria): Existing user, added to the group when UserCap was reached (steps to reproduce below)
  2. new-team-member1@gitlab.com: New Member, already registered, but still pending because UserCap was reached
  3. new-team-member2@gitlab.com: New Member, but not registered yet. This will receive an Awaiting user signup badge to be introduced on this MR: !65410 (closed)
Before After
pending_owner_approval_badge_before pending_owner_approval_badge_after

How to set up and validate locally

Case 1: Gitlab instance-wide root approval

In order to have this behavior in your GitLab local instance, you have to enable this option in admin:

  1. Login as root
  2. Navigate to /admin/application_settings/general
  3. Expand Sign-up restrictions section
  4. Make sure Require admin approval for new sign-ups is checked.

Now let's get someone with Pending owner approval badge:

  1. Go to the browser, and navigate to your group: groups/my_group/-/group_members
  2. Invite a user via email (e.g. new-team-member1@gitlab.com)
  3. In another browser/session, register the user.
    1. You'll receive this message after successful registration: You have signed up successfully. However, we could not sign you in because your account is awaiting approval from your GitLab administrator
    2. Here the team member should be in the invited tab, User.state is blocked_pending_approval
  4. You should see the Pending owner approval badge on the invited column of the table

Case 2: SaaS UserCap

  1. Activate Feature Flag using rails c
    1. my_group = Group.find(<group_id>)
    2. Feature.enable(:saas_user_caps, my_group)
  2. On the same rails console session, check user cap
    1. my_group.user_cap_reached?. Output should be false
    2. my_group.namespace_settings.update!(new_user_signups_cap: my_group.group_members.count)
    3. my_group.user_cap_reached?. Output should be true
  3. Go to the browser, and navigate to groups/my_group/-/group_members
  4. Add a new member (e.g. @valeria from the seeded data)
    1. Now GroupMember.state is 1 (STATE_AWAITING) and the user is pending owner approval
  5. You should see the Pending owner approval badge on the invited column of the table

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sheldon Led

Merge request reports