Add error handling for add-on assignment
What does this MR do and why?
Adds error handling for add-on assignment on Usage Quotas page.
Related to #420010
Screenshots or screen recordings
Scenario | Screenshot |
---|---|
Error when fetching Code Suggestions add-on details | |
Error when assigning add-on | |
Error when un-assigning add-on | |
No seats available to assign add-on |
How to set up and validate locally
Add-on setup
-
Customers Dot needs to be setup in order to view the billing page for a group
-
Start GDK in SaaS mode
GITLAB_SIMULATE_SAAS=1 gdk start
-
Create a Group
-
Enable
enable_hamilton_in_usage_quotas_ui
FF (globally, or for your group) -
Buy a Subscription for your group from
Settings
>Billing
-
Visit
/groups/<your-namespace-name>/-/usage_quotas#seats-quota-tab
-
Purchase add-on for namespace
# Get the desired namespace namespace = Namespace.last # Create an add-on add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"} # Purchase add-ons for the namespace add_on_purchase = GitlabSubscriptions::AddOnPurchase.create!( add_on: add_on, namespace: namespace, expires_on: 1.month.from_now, quantity: 2, purchase_xid: 'A-S0001' )
-
Add this snippet here to enable add-on assignment. This enables the add-on assignment for the first 2 users in the list (as per
assignable
value).- Note: Make sure there are at least 2 users in the group if using the below snippet to update the first 2 members data.
state.members[0].add_ons = { assigned: [], assignable: [{ name: 'CODE_SUGGESTIONS' }] }; state.members[1].add_ons = { assigned: [], assignable: [{ name: 'CODE_SUGGESTIONS' }] };
Error testing
Error when fetching Code Suggestions add-on details
- Comment this line and refresh the Usage Quotas page
Error when assigning add-on
- Comment this line and attempt to assign add-on to a non-guest user
Error when un-assigning add-on
- Assign add-on to a non-guest user
- Update the
add_on
info for that member to have an assigned add-onstate.members[0].add_ons = { assigned: [{ name: 'CODE_SUGGESTIONS' }], assignable: [{ name: 'CODE_SUGGESTIONS' }] };
- Comment this line
No seats available to assign add-on
Attempt to assign add-on to more users than the purchased add-on quantity. This would need having more number of users in the user list (in the group) than the purchased quantity.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.