Add API to set membership state

Merged Nicolas Dular requested to merge nd/membership-state-api into master

What does this MR do and why?

  1. Adds an API to change the membership state
  2. Implements the Frontend to toggle the membership state on the usage quota page

Part of: https://gitlab.com/gitlab-org/gitlab/-/issues/352638

Screenshots or screen recordings

toggle-recording

How to set up and validate locally

  1. Start GDK as if it would be SaaS, start rails console
    export GITLAB_SIMULATE_SAAS=1
    gdk start
    
    bin/rails c
  2. Enable feature flag and use namespace-plans:
    # Set your instance to be on namespace-plans
    ApplicationSetting.first.update(check_namespace_plan: true)
    
    # Either choose a group that you want for testing. It must be a group on a free-plan
    group = Group.find(ID)
    Feature.enable(:free_user_cap, group)
    # or... enable it for all groups
    Feature.enable(:free_user_cap)
  3. Go to the group Usage Quota page http://localhost:3000/groups/GROUP_NAME/-/usage_quotas#seats-quota-tab

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 Nicolas Dular