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:
@@ -37,11 +37,7 @@ export const Account: React.FC<AdminViewProps> = async ({
|
|||||||
} = initPageResult
|
} = initPageResult
|
||||||
|
|
||||||
const {
|
const {
|
||||||
admin: {
|
admin: { theme, user: userSlug },
|
||||||
components: { views: { Account: CustomAccountComponent } = {} } = {},
|
|
||||||
theme,
|
|
||||||
user: userSlug,
|
|
||||||
},
|
|
||||||
routes: { api },
|
routes: { api },
|
||||||
serverURL,
|
serverURL,
|
||||||
} = config
|
} = config
|
||||||
@@ -142,7 +138,8 @@ export const Account: React.FC<AdminViewProps> = async ({
|
|||||||
/>
|
/>
|
||||||
<HydrateAuthProvider permissions={permissions} />
|
<HydrateAuthProvider permissions={permissions} />
|
||||||
<RenderServerComponent
|
<RenderServerComponent
|
||||||
Component={CustomAccountComponent}
|
Component={config.admin?.components?.views?.Account?.Component}
|
||||||
|
Fallback={EditView}
|
||||||
importMap={payload.importMap}
|
importMap={payload.importMap}
|
||||||
serverProps={{
|
serverProps={{
|
||||||
i18n,
|
i18n,
|
||||||
@@ -156,7 +153,6 @@ export const Account: React.FC<AdminViewProps> = async ({
|
|||||||
user,
|
user,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<EditView />
|
|
||||||
<AccountClient />
|
<AccountClient />
|
||||||
</EditDepthProvider>
|
</EditDepthProvider>
|
||||||
</DocumentInfoProvider>
|
</DocumentInfoProvider>
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ export const Dashboard: React.FC<AdminViewProps> = async ({
|
|||||||
visibleEntities,
|
visibleEntities,
|
||||||
} = initPageResult
|
} = initPageResult
|
||||||
|
|
||||||
const CustomDashboardComponent = config.admin.components?.views?.Dashboard
|
|
||||||
|
|
||||||
const collections = config.collections.filter(
|
const collections = config.collections.filter(
|
||||||
(collection) =>
|
(collection) =>
|
||||||
permissions?.collections?.[collection.slug]?.read &&
|
permissions?.collections?.[collection.slug]?.read &&
|
||||||
@@ -115,7 +113,7 @@ export const Dashboard: React.FC<AdminViewProps> = async ({
|
|||||||
Link,
|
Link,
|
||||||
locale,
|
locale,
|
||||||
}}
|
}}
|
||||||
Component={CustomDashboardComponent}
|
Component={config.admin?.components?.views?.Dashboard?.Component}
|
||||||
Fallback={DefaultDashboard}
|
Fallback={DefaultDashboard}
|
||||||
importMap={payload.importMap}
|
importMap={payload.importMap}
|
||||||
serverProps={{
|
serverProps={{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export function parsePayloadComponent(PayloadComponent: PayloadComponent): {
|
|||||||
if (!PayloadComponent) {
|
if (!PayloadComponent) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathAndMaybeExport =
|
const pathAndMaybeExport =
|
||||||
typeof PayloadComponent === 'string' ? PayloadComponent : PayloadComponent.path
|
typeof PayloadComponent === 'string' ? PayloadComponent : PayloadComponent.path
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user