fix(next): custom default root views (#9247)

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.
This commit is contained in:
Jacob Fletcher
2024-11-16 14:05:50 -05:00
committed by GitHub
parent 457be31ed2
commit c4269d25d3
3 changed files with 5 additions and 10 deletions

View File

@@ -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
@@ -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,
@@ -156,7 +153,6 @@ export const Account: React.FC<AdminViewProps> = async ({
user,
}}
/>
<EditView />
<AccountClient />
</EditDepthProvider>
</DocumentInfoProvider>

View File

@@ -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 &&
@@ -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={{

View File

@@ -7,6 +7,7 @@ export function parsePayloadComponent(PayloadComponent: PayloadComponent): {
if (!PayloadComponent) {
return null
}
const pathAndMaybeExport =
typeof PayloadComponent === 'string' ? PayloadComponent : PayloadComponent.path