When using the `admin.hidden: true` property on a collection, it rightfully removes all navigation and routing for that particular collection. However, this also affects the expected behavior of hidden entities when they are rendered within a drawer, such as the document drawer or list drawer. For example, when creating a new _admin.hidden_ document through the relationship or join field, the drawer should still render the view, despite the underlying route for that view being disabled. This change was a result of the introduction of on-demand server components in #8364, where we now make a server roundtrip to render the view in its entirety, which include the logic that redirects these hidden entities. Now, we pass a new `overrideEntityVisibility` argument through the server function that, when true, skips this step. This way documents can continue to respect `admin.hidden` while also having the ability to override on a case-by-case basis throughout the UI.
132 lines
2.9 KiB
TypeScript
132 lines
2.9 KiB
TypeScript
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
import { Categories } from './collections/Categories.js'
|
|
import { CategoriesVersions } from './collections/CategoriesVersions.js'
|
|
import { HiddenPosts } from './collections/HiddenPosts.js'
|
|
import { Posts } from './collections/Posts.js'
|
|
import { Singular } from './collections/Singular.js'
|
|
import { Uploads } from './collections/Uploads.js'
|
|
import { Versions } from './collections/Versions.js'
|
|
import { seed } from './seed.js'
|
|
import {
|
|
localizedCategoriesSlug,
|
|
localizedPostsSlug,
|
|
postsSlug,
|
|
restrictedCategoriesSlug,
|
|
restrictedPostsSlug,
|
|
} from './shared.js'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfigWithDefaults({
|
|
collections: [
|
|
Posts,
|
|
Categories,
|
|
HiddenPosts,
|
|
Uploads,
|
|
Versions,
|
|
CategoriesVersions,
|
|
Singular,
|
|
{
|
|
slug: localizedPostsSlug,
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'category',
|
|
type: 'relationship',
|
|
localized: true,
|
|
relationTo: localizedCategoriesSlug,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: localizedCategoriesSlug,
|
|
admin: {
|
|
useAsTitle: 'name',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'name',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'relatedPosts',
|
|
type: 'join',
|
|
collection: localizedPostsSlug,
|
|
on: 'category',
|
|
localized: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: restrictedCategoriesSlug,
|
|
admin: {
|
|
useAsTitle: 'name',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'name',
|
|
type: 'text',
|
|
},
|
|
{
|
|
// this field is misconfigured to have `where` constraint using a restricted field
|
|
name: 'restrictedPosts',
|
|
type: 'join',
|
|
collection: postsSlug,
|
|
on: 'category',
|
|
where: {
|
|
restrictedField: { equals: 'restricted' },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: restrictedPostsSlug,
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'restrictedField',
|
|
type: 'text',
|
|
access: {
|
|
read: () => false,
|
|
update: () => false,
|
|
},
|
|
},
|
|
{
|
|
name: 'category',
|
|
type: 'relationship',
|
|
relationTo: restrictedCategoriesSlug,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
localization: {
|
|
locales: ['en', 'es'],
|
|
defaultLocale: 'en',
|
|
},
|
|
onInit: async (payload) => {
|
|
if (process.env.SEED_IN_CONFIG_ONINIT !== 'false') {
|
|
await seed(payload)
|
|
}
|
|
},
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|