* chore: enables upload tests on CI * fix: adds relationTo information to field map * chore: updates e2e tests (WIP) * chore: move back to probe-image-size, tiff files do not support buffers * chore: basic runtime err fixes * chore: remove admin thumbnail when creating client config * test: small upload fixes --------- Co-authored-by: Elliot DeNolf <denolfe@gmail.com> Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import type { EditViewComponent } from 'payload/types'
|
|
|
|
import { SetStepNav } from '@payloadcms/ui/elements/StepNav'
|
|
import { notFound, redirect } from 'next/navigation.js'
|
|
import React, { Fragment } from 'react'
|
|
|
|
export const CustomEditView: EditViewComponent = ({ initPageResult }) => {
|
|
if (!initPageResult) {
|
|
notFound()
|
|
}
|
|
|
|
const {
|
|
permissions: { canAccessAdmin },
|
|
req: {
|
|
payload: {
|
|
config: {
|
|
routes: { admin: adminRoute },
|
|
},
|
|
},
|
|
user,
|
|
},
|
|
} = initPageResult
|
|
|
|
// If an unauthorized user tries to navigate straight to this page,
|
|
// Boot 'em out
|
|
if (!user || (user && !canAccessAdmin)) {
|
|
return redirect(`${adminRoute}/unauthorized`)
|
|
}
|
|
|
|
return (
|
|
<Fragment>
|
|
<SetStepNav
|
|
nav={[
|
|
{
|
|
label: 'Custom Edit View',
|
|
},
|
|
]}
|
|
/>
|
|
<div
|
|
style={{
|
|
marginTop: 'calc(var(--base) * 2)',
|
|
paddingLeft: 'var(--gutter-h)',
|
|
paddingRight: 'var(--gutter-h)',
|
|
}}
|
|
>
|
|
<h1>Custom Edit View</h1>
|
|
<p>This custom edit view was added through the following Payload config:</p>
|
|
<code>components.views.Edit</code>
|
|
<p>
|
|
{'This takes precedence over the default edit view, '}
|
|
<b>as well as all nested views like versions.</b>
|
|
{' The document header will be completely overridden.'}
|
|
</p>
|
|
</div>
|
|
</Fragment>
|
|
)
|
|
}
|