-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(clerk-js,types): Navigate to after-auth tasks #5187
Draft
LauraBeatris
wants to merge
12
commits into
main
Choose a base branch
from
laura/tasks-sign-sign-up-routes
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.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
56e6957
Add `tasks` on `Session` resource
LauraBeatris 8f1c0c4
Add changeset
LauraBeatris a3095a3
Update redirect guard to explict check for `active`
LauraBeatris 33c724a
Display pending task routes
LauraBeatris 5470a36
Update handling for array of tasks
LauraBeatris 6dada15
Fix session task key
LauraBeatris b03092a
Implement unit tests for Task component
LauraBeatris 09f893e
Add unit tests for `useTaskRoute`
LauraBeatris e6c10fa
Add option for a custom tasks URL to cover custom flow
LauraBeatris 07f897c
Refactor redirect guards for tasks
LauraBeatris 5d55006
Does not trigger `redirectUrl` logic
LauraBeatris 3e274ee
Trigger navigation on client-piggybacking
LauraBeatris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@clerk/clerk-js': patch | ||
'@clerk/types': patch | ||
--- | ||
|
||
Navigate to after-auth tasks |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { SessionTask } from '@clerk/types'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const sessionTaskRoutePaths: Record<SessionTask['key'], string> = { | ||
org: 'select-organization', | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useSessionContext } from '@clerk/shared/react/index'; | ||
import type { SessionTask } from '@clerk/types'; | ||
import { type ComponentType } from 'react'; | ||
|
||
import { OrganizationListContext } from '../../contexts'; | ||
import { OrganizationList } from '../OrganizationList'; | ||
|
||
const TaskRegistry: Record<SessionTask['key'], ComponentType> = { | ||
org: () => ( | ||
<OrganizationListContext.Provider value={{ componentName: 'OrganizationList', hidePersonal: true }}> | ||
<OrganizationList /> | ||
</OrganizationListContext.Provider> | ||
), | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function Task(): React.ReactNode { | ||
const session = useSessionContext(); | ||
|
||
if (!session?.currentTask) { | ||
return null; | ||
} | ||
|
||
const [task] = session.tasks ?? []; | ||
const Content = TaskRegistry[task.key]; | ||
|
||
return Content ? <Content /> : null; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
hidePersonal
is being directly provided here, but this is going to be updated in a next PR.We're going to include a property on
Enviroment
to indicate whether an after-auth task is enabled for instance.For the use case of forcing to select an org, this is going to be checked once the environment loads, and the org components are going to have
hidePersonal: true
by default.