sourcegraph icon indicating copy to clipboard operation
sourcegraph copied to clipboard

chore(plg): provide user Cody plan on a route level

Open taras-yemets opened this issue 1 year ago • 0 comments

1. Lifts the user Cody plan query to Sourcegraph GraphQL backend up to the route level.

All Cody Pro pages require the user’s Cody Pro plan to determine their behavior. Previously, we had repetitive logic to fetch this data and handle loading and error states. This PR moves the fetching of the user’s Cody plan to a higher level, simplifying the code. Now, each Cody Pro page component receives the subscription data as a prop.

2. Creates a Custom Hook for Fetching the User’s Cody Plan.

3. Refactors "/cody/subscription" page component.

  • Updates the CodySubscriptionPage component to use the withAuthenticatedUser higher-order component. This change removes the need for an authenticated user check within the component itself, making it more consistent with other Cody Pro page components.
  • Removes redundant isCodyEnabled() check.

Test plan

  • CI
  • Run Sourcegraph in dotcom mode locally and compare the authenticated user related logic with sourcegraph.com

taras-yemets avatar Jun 20 '24 22:06 taras-yemets