-
Notifications
You must be signed in to change notification settings - Fork 417
feat(repo): Migrate Protect to Show #7373
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
Open
jacekradko
wants to merge
43
commits into
main
Choose a base branch
from
feat/protect-refactor
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.
+1,309
−518
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
c9f3d62
feat(repo): Protect -> Show
jacekradko 1f8e652
typing tweak
jacekradko 880b5c8
Merge branch 'vincent-and-the-doctor' into feat/protect-refactor
jacekradko fe77607
wip
jacekradko e007eed
wip
jacekradko 9ff6422
Merge branch 'vincent-and-the-doctor' into feat/protect-refactor
jacekradko 3862af9
Merge branch 'vincent-and-the-doctor' into feat/protect-refactor
jacekradko 11726bb
wip
jacekradko b632485
wip
jacekradko 07a3f7d
wip
jacekradko 75cc284
Merge branch 'main' into feat/protect-refactor
jacekradko 05b73ca
wip
jacekradko 0f345b8
wip
jacekradko 7c0b86c
better JSDoc
jacekradko c133f9a
wip
jacekradko 0ec9b9c
Merge branch 'main' into feat/protect-refactor
jacekradko f774e21
wip
jacekradko fdbb5cd
wip
jacekradko 72fcf09
Merge branch 'main' into feat/protect-refactor
jacekradko 4a3a968
update codemod
jacekradko 197ae2c
backfill codemod
jacekradko 88f3e35
wip
jacekradko aba8aad
adjust JSDocs
jacekradko c9b1d2a
Merge branch 'main' into feat/protect-refactor
jacekradko 8db6d35
update app router template
jacekradko a603b43
wip
jacekradko 671c0f1
changesets
jacekradko 73637d8
Merge branch 'main' into feat/protect-refactor
jacekradko 3aacf7b
more removals
jacekradko 6fc15a3
update codemods
jacekradko 826a9cb
wip
jacekradko 9121fbc
wip
jacekradko 01afa55
fix vue tests
jacekradko 5d6149b
wip
jacekradko 4657f99
wip
jacekradko 3bb1953
wip
jacekradko 5ee8745
Merge branch 'main' into feat/protect-refactor
jacekradko 8c719cd
wip
jacekradko d768f6e
update changeset
jacekradko b064082
update astro SDK
jacekradko 3014891
wip
jacekradko 476451e
Merge branch 'main' into feat/protect-refactor
jacekradko 4c6b69d
Merge branch 'main' into feat/protect-refactor
jacekradko 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@clerk/upgrade': minor | ||
| --- | ||
|
|
||
| Add a `transform-protect-to-show` codemod that migrates client-side `<Protect>` usage to `<Show>` with automatic prop and import updates. | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| '@clerk/astro': major | ||
| '@clerk/chrome-extension': major | ||
| '@clerk/expo': major | ||
| '@clerk/nextjs': major | ||
| '@clerk/react': major | ||
| '@clerk/shared': minor | ||
| '@clerk/vue': major | ||
| --- | ||
|
|
||
| Introduce `<Show when={...}>` as the cross-framework authorization control component and remove `<Protect>`, `<SignedIn>`, and `<SignedOut>` in favor of `<Show>`, updating shared types and framework wrappers to align with the new API. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,22 @@ | ||
| --- | ||
| import { UserButton, SignInButton, SignedIn, SignedOut } from '@clerk/astro/components'; | ||
| import { Show, UserButton, SignInButton } from '@clerk/astro/components'; | ||
| import { OrganizationSwitcher } from '@clerk/astro/react'; | ||
| import Layout from '../layouts/Layout.astro'; | ||
|
|
||
| export const prerender = true; | ||
| --- | ||
|
|
||
| <Layout title='Home'> | ||
| <SignedOut> | ||
| <Show when='signedOut'> | ||
| <h1>Signed out</h1> | ||
| <SignInButton | ||
| mode='modal' | ||
| fallbackRedirectUrl='/' | ||
| /> | ||
| </SignedOut> | ||
| <SignedIn> | ||
| </Show> | ||
| <Show when='signedIn'> | ||
| <h1>Signed in</h1> | ||
| <UserButton /> | ||
| <OrganizationSwitcher client:only='react' /> | ||
| </SignedIn> | ||
| </Show> | ||
| </Layout> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,22 @@ | ||
| --- | ||
| import { UserButton, SignInButton, SignedIn, SignedOut } from '@clerk/astro/components'; | ||
| import { Show, UserButton, SignInButton } from '@clerk/astro/components'; | ||
| import { OrganizationSwitcher } from '@clerk/astro/react'; | ||
| import Layout from '../layouts/Layout.astro'; | ||
|
|
||
| export const prerender = false; | ||
| --- | ||
|
|
||
| <Layout title='Home'> | ||
| <SignedOut isStatic={false}> | ||
| <Show when='signedOut' isStatic={false}> | ||
| <h1>Signed out</h1> | ||
| <SignInButton | ||
| mode='modal' | ||
| fallbackRedirectUrl='/' | ||
| /> | ||
| </SignedOut> | ||
| <SignedIn isStatic={false}> | ||
| </Show> | ||
| <Show when='signedIn' isStatic={false}> | ||
| <h1>Signed in</h1> | ||
| <UserButton /> | ||
| <OrganizationSwitcher client:load /> | ||
| </SignedIn> | ||
| </Show> | ||
| </Layout> |
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
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
6 changes: 3 additions & 3 deletions
6
integration/templates/astro-node/src/pages/billing/checkout-btn.astro
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
| --- | ||
| import { SignedIn, __experimental_CheckoutButton as CheckoutButton } from '@clerk/astro/components'; | ||
| import { Show, __experimental_CheckoutButton as CheckoutButton } from '@clerk/astro/components'; | ||
| import Layout from '../../layouts/Layout.astro'; | ||
| --- | ||
|
|
||
| <Layout title="Checkout Button"> | ||
| <main> | ||
| <SignedIn> | ||
| <Show when='signedIn'> | ||
| <CheckoutButton | ||
| planId='cplan_2wMjqdlza0hTJc4HLCoBwAiExhF' | ||
| planPeriod='month' | ||
| > | ||
| Checkout Now | ||
| </CheckoutButton> | ||
| </SignedIn> | ||
| </Show> | ||
| </main> | ||
| </Layout> |
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
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
29 changes: 17 additions & 12 deletions
29
integration/templates/astro-node/src/pages/react/only-admins.astro
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,28 @@ | ||
| --- | ||
| import { Protect } from '@clerk/astro/react'; | ||
| import { Show } from '@clerk/astro/react'; | ||
| import Layout from '../../layouts/react/Layout.astro'; | ||
| --- | ||
|
|
||
| <Layout title='Page is only accessible by members'> | ||
| <div class='w-full flex justify-center flex-col'> | ||
| <Protect | ||
| <Show | ||
| client:load | ||
| role='org:admin' | ||
| when={{ role: 'org:admin' }} | ||
| > | ||
| <Fragment slot='fallback'> | ||
| <h1 class='text-2xl text-center'>Not an admin</h1> | ||
| <a | ||
| class='text-sm text-center text-gray-100 transition hover:text-gray-400' | ||
| href='/only-members' | ||
| >Go to Members Page</a | ||
| > | ||
| </Fragment> | ||
| <h1 class='text-2xl text-center'>I'm an admin</h1> | ||
| </Protect> | ||
| </Show> | ||
|
|
||
| <Show | ||
| client:load | ||
| when={(has) => !has({ role: 'org:admin' })} | ||
| > | ||
| <h1 class='text-2xl text-center'>Not an admin</h1> | ||
| <a | ||
| class='text-sm text-center text-gray-100 transition hover:text-gray-400' | ||
| href='/only-members' | ||
| > | ||
| Go to Members Page | ||
| </a> | ||
| </Show> | ||
| </div> | ||
| </Layout> |
29 changes: 17 additions & 12 deletions
29
integration/templates/astro-node/src/pages/react/only-members.astro
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,28 @@ | ||
| --- | ||
| import { Protect } from '@clerk/astro/react'; | ||
| import { Show } from '@clerk/astro/react'; | ||
| import Layout from '../../layouts/react/Layout.astro'; | ||
| --- | ||
|
|
||
| <Layout title='Page is only accessible by members'> | ||
| <div class='w-full flex justify-center flex-col'> | ||
| <Protect | ||
| <Show | ||
| client:load | ||
| role='basic_member' | ||
| when={{ role: 'basic_member' }} | ||
| > | ||
| <Fragment slot='fallback'> | ||
| <h1 class='text-2xl text-center'>Not a member</h1> | ||
| <a | ||
| class='text-sm text-center text-gray-100 transition hover:text-gray-400' | ||
| href='/only-admins' | ||
| >Go to Admin Page</a | ||
| > | ||
| </Fragment> | ||
| <h1 class='text-2xl text-center'>I'm a member</h1> | ||
| </Protect> | ||
| </Show> | ||
|
|
||
| <Show | ||
| client:load | ||
| when={(has) => !has({ role: 'basic_member' })} | ||
| > | ||
| <h1 class='text-2xl text-center'>Not a member</h1> | ||
| <a | ||
| class='text-sm text-center text-gray-100 transition hover:text-gray-400' | ||
| href='/only-admins' | ||
| > | ||
| Go to Admin Page | ||
| </a> | ||
| </Show> | ||
| </div> | ||
| </Layout> |
10 changes: 5 additions & 5 deletions
10
integration/templates/astro-node/src/pages/transitions/index.astro
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| --- | ||
| import { SignedIn, SignedOut, UserButton } from '@clerk/astro/components'; | ||
| import { Show, UserButton } from '@clerk/astro/components'; | ||
| import Layout from '../../layouts/ViewTransitionsLayout.astro'; | ||
| --- | ||
|
|
||
| <Layout title='Sign in'> | ||
| <div class='w-full flex justify-center'> | ||
| <SignedOut> | ||
| <Show when='signedOut'> | ||
| <a href='/transitions/sign-in'>Sign in</a> | ||
| </SignedOut> | ||
| <SignedIn> | ||
| </Show> | ||
| <Show when='signedIn'> | ||
| <UserButton /> | ||
| </SignedIn> | ||
| </Show> | ||
| </div> | ||
| </Layout> |
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
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.
Uh oh!
There was an error while loading. Please reload this page.