Skip to content

Commit

Permalink
fix(next): custom default root views (#9247)
Browse files Browse the repository at this point in the history
Fixes #9246. Custom default root views (account and dashboard) were not
being properly thread to the custom component renderer. Custom account
views were also improperly _stacking_ instead of _replacing_ the default
view.

Tests for this are incoming. To properly test this we need to wrap our
default root views with custom ones, so that out existing `admin` test
suite can continue to work alongside tests specifically for this issue.
  • Loading branch information
jacobsfletch authored Nov 16, 2024
1 parent 457be31 commit c4269d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
10 changes: 3 additions & 7 deletions packages/next/src/views/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ export const Account: React.FC<AdminViewProps> = async ({
} = initPageResult

const {
admin: {
components: { views: { Account: CustomAccountComponent } = {} } = {},
theme,
user: userSlug,
},
admin: { theme, user: userSlug },
routes: { api },
serverURL,
} = config
Expand Down Expand Up @@ -142,7 +138,8 @@ export const Account: React.FC<AdminViewProps> = async ({
/>
<HydrateAuthProvider permissions={permissions} />
<RenderServerComponent
Component={CustomAccountComponent}
Component={config.admin?.components?.views?.Account?.Component}
Fallback={EditView}
importMap={payload.importMap}
serverProps={{
i18n,
Expand All @@ -156,7 +153,6 @@ export const Account: React.FC<AdminViewProps> = async ({
user,
}}
/>
<EditView />
<AccountClient />
</EditDepthProvider>
</DocumentInfoProvider>
Expand Down
4 changes: 1 addition & 3 deletions packages/next/src/views/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export const Dashboard: React.FC<AdminViewProps> = async ({
visibleEntities,
} = initPageResult

const CustomDashboardComponent = config.admin.components?.views?.Dashboard

const collections = config.collections.filter(
(collection) =>
permissions?.collections?.[collection.slug]?.read &&
Expand Down Expand Up @@ -115,7 +113,7 @@ export const Dashboard: React.FC<AdminViewProps> = async ({
Link,
locale,
}}
Component={CustomDashboardComponent}
Component={config.admin?.components?.views?.Dashboard?.Component}
Fallback={DefaultDashboard}
importMap={payload.importMap}
serverProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export function parsePayloadComponent(PayloadComponent: PayloadComponent): {
if (!PayloadComponent) {
return null
}

const pathAndMaybeExport =
typeof PayloadComponent === 'string' ? PayloadComponent : PayloadComponent.path

Expand Down

0 comments on commit c4269d2

Please sign in to comment.