-
Notifications
You must be signed in to change notification settings - Fork 419
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
60
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,877
−1,053
Open
Changes from 34 commits
Commits
Show all changes
60 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 8496c81
pr feedback
jacekradko 4d73e5c
Merge branch 'main' into feat/protect-refactor
jacekradko fe0a275
Merge branch 'main' into feat/protect-refactor
jacekradko c9ce109
Merge branch 'main' into feat/protect-refactor
jacekradko 8d52c4b
remove obsolete components
jacekradko 6081f07
fix types and add test
jacekradko 9043fea
fix e2e templates
jacekradko 37d9acd
improve codemod
jacekradko 160d82c
Merge branch 'main' into feat/protect-refactor
jacekradko 72f3d07
Merge branch 'main' into feat/protect-refactor
jacekradko f045134
wip
jacekradko be35c47
wip
jacekradko 68b9078
wip
jacekradko 6229696
wip
jacekradko 1349533
pr feedback
jacekradko 485c353
wip
jacekradko 5cda2cf
wip
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/react': major | ||
| '@clerk/nextjs': major | ||
| '@clerk/expo': major | ||
| '@clerk/chrome-extension': major | ||
| '@clerk/shared': minor | ||
| '@clerk/astro': patch | ||
| '@clerk/vue': patch | ||
| --- | ||
|
|
||
| Restrict `<Protect>` to App Router server usage and introduce `<Show when={...}>` as the client-side authorization component, updating shared types and Astro/Vue 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
10 changes: 5 additions & 5 deletions
10
integration/templates/next-app-router-quickstart/src/app/page.tsx
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, SignedOut, SignInButton, SignUpButton, UserButton } from '@clerk/nextjs'; | ||
| import { Show, SignInButton, SignUpButton, UserButton } from '@clerk/nextjs'; | ||
|
|
||
| export default function Home() { | ||
| return ( | ||
| <header> | ||
| <SignedOut> | ||
| <Show when='signedOut'> | ||
| <p>signed-out-state</p> | ||
| <SignInButton /> | ||
| <SignUpButton /> | ||
| </SignedOut> | ||
| <SignedIn> | ||
| </Show> | ||
| <Show when='signedIn'> | ||
| <p>signed-in-state</p> | ||
| <UserButton /> | ||
| </SignedIn> | ||
| </Show> | ||
| </header> | ||
| ); | ||
| } |
6 changes: 3 additions & 3 deletions
6
integration/templates/next-app-router/src/app/billing/checkout-btn/page.tsx
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 } from '@clerk/nextjs'; | ||
| import { Show } from '@clerk/nextjs'; | ||
| import { CheckoutButton } from '@clerk/nextjs/experimental'; | ||
|
|
||
| export default function Home() { | ||
| return ( | ||
| <main> | ||
| <SignedIn> | ||
| <Show when='signedIn'> | ||
| <CheckoutButton | ||
| planId='cplan_2wMjqdlza0hTJc4HLCoBwAiExhF' | ||
| planPeriod='month' | ||
| > | ||
| Checkout Now | ||
| </CheckoutButton> | ||
| </SignedIn> | ||
| </Show> | ||
| </main> | ||
| ); | ||
| } |
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
9 changes: 4 additions & 5 deletions
9
integration/templates/next-app-router/src/app/settings/rcc-protect/page.tsx
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,14 +1,13 @@ | ||
| 'use client'; | ||
| import { Protect } from '@clerk/nextjs'; | ||
| import { Show } from '@clerk/nextjs'; | ||
|
|
||
| export default function Page() { | ||
| return ( | ||
| <Protect | ||
| permission='org:posts:manage' | ||
| /* @ts-ignore Need to take a look at the TS files, might be a types/react version thing */ | ||
| <Show | ||
| fallback={<p>User is missing permissions</p>} | ||
| when={{ permission: 'org:posts:manage' }} | ||
| > | ||
| <p>User has access</p> | ||
| </Protect> | ||
| </Show> | ||
| ); | ||
| } |
8 changes: 4 additions & 4 deletions
8
integration/templates/next-app-router/src/app/settings/rsc-protect/page.tsx
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,12 +1,12 @@ | ||
| import { Protect } from '@clerk/nextjs'; | ||
| import { Show } from '@clerk/nextjs'; | ||
|
|
||
| export default function Page() { | ||
| return ( | ||
| <Protect | ||
| role='org:admin' | ||
| <Show | ||
| fallback={<p>User is not admin</p>} | ||
| when={{ role: 'org:admin' }} | ||
| > | ||
| <p>User has access</p> | ||
| </Protect> | ||
| </Show> | ||
| ); | ||
| } |
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
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
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,11 +1,11 @@ | ||
| import { SignedIn } from '@clerk/react'; | ||
| import { Show } from '@clerk/react'; | ||
|
|
||
| export default function Page() { | ||
| return ( | ||
| <div> | ||
| <SignedIn> | ||
| <Show when='signedIn'> | ||
| <div data-testid='protected'>Protected</div> | ||
| </SignedIn> | ||
| </Show> | ||
| </div> | ||
| ); | ||
| } |
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
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,12 +1,12 @@ | ||
| <script setup lang="ts"> | ||
| import { Protect } from '@clerk/vue'; | ||
| import { Show } from '@clerk/vue'; | ||
| </script> | ||
|
|
||
| <template> | ||
| <Protect> | ||
| <Show :when="{ role: 'org:admin' }"> | ||
| <p>I am an admin</p> | ||
| <template #fallback> | ||
| <p>Not an admin</p> | ||
| </template> | ||
| </Protect> | ||
| </Show> | ||
| </template> |
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,16 +1,18 @@ | ||
| <script setup lang="ts"> | ||
| import { SignedIn, OrganizationSwitcher, useAuth } from '@clerk/vue'; | ||
| const { isSignedIn } = useAuth(); | ||
| import { OrganizationSwitcher, Show } from '@clerk/vue'; | ||
| </script> | ||
|
|
||
| <template> | ||
| <SignedIn> | ||
| <Show when="signedIn"> | ||
| <OrganizationSwitcher /> | ||
| </SignedIn> | ||
| </Show> | ||
| <div> | ||
| <ul> | ||
| <li v-if="isSignedIn"><RouterLink to="/profile">Profile</RouterLink></li> | ||
| <Show when="signedIn"> | ||
| <li> | ||
| <RouterLink to="/profile">Profile</RouterLink> | ||
| </li> | ||
| </Show> | ||
jacekradko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </ul> | ||
| </div> | ||
| </template> | ||
6 changes: 3 additions & 3 deletions
6
integration/templates/vue-vite/src/views/billing/CheckoutBtn.vue
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 @@ | ||
| <template> | ||
| <main> | ||
| <SignedIn> | ||
| <Show when="signedIn"> | ||
| <CheckoutButton | ||
| planId="cplan_2wMjqdlza0hTJc4HLCoBwAiExhF" | ||
| planPeriod="month" | ||
| > | ||
| Checkout Now | ||
| </CheckoutButton> | ||
| </SignedIn> | ||
| </Show> | ||
| </main> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { SignedIn } from '@clerk/vue'; | ||
| import { Show } from '@clerk/vue'; | ||
| import { CheckoutButton } from '@clerk/vue/experimental'; | ||
| </script> |
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.