Skip to content

Draft: Extract common functionality for code suggestions usage for reuse

What does this MR do and why?

Please see the context behind this approach here.

This MR includes an approach to refactor the existing code for Code Suggestions Usage to support both SM and SaaS usage flows.

The changes include:

  1. Updating the existing addOnPurchase query to take an optional parameter for namespaceId.
  2. Refactoring the existing code_suggestions_usage.vue component to use the new query and pass in optional namespaceId ( groupId ) parameter when applicable
    • The only change to this component between SaaS and SM is the optional parameter (groupId) to addOnPurchase query, everything else including the response data structure for both flows will be identical. I don't anticipate this component diverging much between SM and SaaS flows in this future, which is one of the reasons to reuse the existing component without splitting it for SM and SaaS.
  3. Extracting addOnEligibleUsers query related logic from add_on_eligible_user_list.vue to a wrapper component saas_add_on_eligible_user_list.vue (we'd have a similar component for SM) which will be responsible for making the API call to fetch the eligible user list and transforming the response to make it suitable for the common component - add_on_eligible_user_list.vue.
    • The combination of add_on_eligible_user_list.vue and saas_add_on_eligible_user_list.vue should give us flexibility to add features that are either common to both SM and SaaS flows or selectively applicable to either easily without unintended side effects.

This also only includes the changes to purely show the approach for a quicker scan/review before I split the MR into smaller ones. Therefore it doesn't include changes to rename or move files and variables or tests 😅

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

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

Related to #432440

Edited by Vamsi Vempati

Merge request reports

Loading