Repository navigation
refactor(mosaic): render self-contained sections in the organization general panel #10189
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f414648
refactor(mosaic): render self-contained sections in the organization …
alexcarpenter c8915be
feat(swingset): add live organization details section
alexcarpenter ab5fc20
refactor(mosaic): drop afterLeaveOrganizationUrl from the organizatio…
alexcarpenter c027004
test(mosaic): drop stale general page fixture props from the organiza…
alexcarpenter 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,2 @@ | ||
| --- | ||
| --- |
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
37 changes: 15 additions & 22 deletions
37
packages/mosaic/src/features/organization-profile/organization-profile-general-panel.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,29 +1,22 @@ | ||
| import type { ReactNode } from 'react'; | ||
|
|
||
| import { OrganizationProfileDangerSection } from './organization-profile-danger-section/organization-profile-danger-section'; | ||
| import { useOrganizationProfileGeneralPanelModel } from './organization-profile-general-panel.model'; | ||
| import { OrganizationProfileGeneralPanelView } from './organization-profile-general-panel.view'; | ||
| import { OrganizationProfileProfileSection } from './organization-profile-profile-section/organization-profile-profile-section'; | ||
|
|
||
| export function OrganizationProfileGeneralPanel({ | ||
| fallback, | ||
| afterLeaveOrganizationUrl, | ||
| }: { | ||
| fallback?: React.ReactNode; | ||
| afterLeaveOrganizationUrl?: string; | ||
| }) { | ||
| const model = useOrganizationProfileGeneralPanelModel(); | ||
|
|
||
| if (model.status === 'loading') { | ||
| return fallback ?? null; | ||
| } | ||
| if (model.status === 'hidden') { | ||
| return null; | ||
| } | ||
| export interface OrganizationProfileGeneralPanelProps { | ||
| children?: ReactNode; | ||
| } | ||
|
|
||
| const { status, organizationId, ...general } = model; | ||
| export function OrganizationProfileGeneralPanel({ children }: OrganizationProfileGeneralPanelProps) { | ||
| return ( | ||
| <OrganizationProfileGeneralPanelView | ||
| key={organizationId} | ||
| {...general} | ||
| dangerSlot={<OrganizationProfileDangerSection afterLeaveOrganizationUrl={afterLeaveOrganizationUrl} />} | ||
| /> | ||
| <OrganizationProfileGeneralPanelView> | ||
| {children ?? ( | ||
| <> | ||
| <OrganizationProfileProfileSection /> | ||
| <OrganizationProfileDangerSection /> | ||
| </> | ||
| )} | ||
| </OrganizationProfileGeneralPanelView> | ||
| ); | ||
| } | ||
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
14 changes: 6 additions & 8 deletions
14
...ganization-profile-general-panel.model.ts → ...nization-profile-profile-section.model.ts
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
27 changes: 27 additions & 0 deletions
27
...ion-profile/organization-profile-profile-section/organization-profile-profile-section.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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import type { ReactNode } from 'react'; | ||
|
|
||
| import { useOrganizationProfileProfileSectionModel } from './organization-profile-profile-section.model'; | ||
| import { OrganizationProfileProfileSectionView } from './organization-profile-profile-section.view'; | ||
|
|
||
| export interface OrganizationProfileProfileSectionProps { | ||
| fallback?: ReactNode; | ||
| } | ||
|
|
||
| export function OrganizationProfileProfileSection({ fallback }: OrganizationProfileProfileSectionProps) { | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| const model = useOrganizationProfileProfileSectionModel(); | ||
|
|
||
| if (model.status === 'loading') { | ||
| return fallback ?? null; | ||
| } | ||
| if (model.status === 'hidden') { | ||
| return null; | ||
| } | ||
|
|
||
| const { status, organizationId, ...profile } = model; | ||
| return ( | ||
| <OrganizationProfileProfileSectionView | ||
| key={organizationId} | ||
| {...profile} | ||
| /> | ||
| ); | ||
| } | ||
40 changes: 40 additions & 0 deletions
40
packages/swingset/src/app/(clerk)/live/organization-details/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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| 'use client'; | ||
|
|
||
| import { OrganizationProfileProfileSection } from '@clerk/mosaic/features/organization-profile/organization-profile-profile-section/organization-profile-profile-section'; | ||
| import { MosaicProvider } from '@clerk/mosaic/mosaic-provider'; | ||
| import { useOrganization, useUser } from '@clerk/nextjs'; | ||
| import Link from 'next/link'; | ||
|
|
||
| export default function OrganizationDetailsLivePage() { | ||
| const { isLoaded, isSignedIn } = useUser(); | ||
| const { organization } = useOrganization(); | ||
|
|
||
| return ( | ||
| <MosaicProvider> | ||
| <div className='mx-auto flex w-full max-w-3xl flex-col gap-6 p-3 sm:p-8'> | ||
| <div className='flex flex-col gap-1'> | ||
| <h1 className='text-xl font-semibold'>Organization details</h1> | ||
| <p className='text-muted-foreground text-sm'> | ||
| The active organization's logo, name, and slug. Editing needs the manage profile permission. | ||
| </p> | ||
| </div> | ||
| {!isLoaded ? <p className='text-muted-foreground text-sm'>Loading…</p> : null} | ||
| {isLoaded && !isSignedIn ? ( | ||
| <p className='text-muted-foreground text-sm'> | ||
| <Link | ||
| href='/sign-in' | ||
| className='text-foreground underline underline-offset-4' | ||
| > | ||
| Sign in | ||
| </Link>{' '} | ||
| and pick an active organization. | ||
| </p> | ||
| ) : null} | ||
| {isLoaded && isSignedIn && !organization ? ( | ||
| <p className='text-muted-foreground text-sm'>Pick an active organization to see its details.</p> | ||
| ) : null} | ||
| {isLoaded && isSignedIn ? <OrganizationProfileProfileSection /> : null} | ||
| </div> | ||
| </MosaicProvider> | ||
| ); | ||
| } |
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
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.