This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
chore(plg): provide user Cody plan on a route level #63409
Open
taras-yemets
wants to merge
13
commits into
main
Choose a base branch
from
ty/plg-provide-user-plan-on-route-level
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…aph into ty/plg-remove-seats
…lan-on-route-level
vdavid
approved these changes
Jun 24, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for the refactor, so much nicer now.
Note: I think you forgot to finish or remove the "Changelog" section.
|
||
if (!data.currentUser) { | ||
// Cody plan is not available if the user is not authenticated. Redirecting to the sign-in page. | ||
return <Navigate to={`/sign-in?returnTo=${CodyProRoutes.Manage}`} replace={true} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I wonder if we can do better, and redirect the user back to the page they wanted to view, including the query params. Would be a lot helpful to users.
Could be out of scope for this PR, but if so, it'd be great to track this as a new gap.
client/web/src/cody/management/subscription/new/NewCodyProSubscriptionPage.tsx
Show resolved
Hide resolved
…criptionPage.tsx Co-authored-by: David Veszelovszki <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
CodySubscriptionPage
component to use thewithAuthenticatedUser
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.isCodyEnabled()
check.isCodyEnabled()
check consists of two fields from jscontext:codyEnabled
: reads its value from the site config and it's obviouslytrue
for dotcomcodyEnabledForCurrentUser
: returnsfalse
only if the actor is not authenticated, which is already ensured at a higher level (see 2.).Test plan