This PR re-uses the document drawers for editing and creating folders. This allows us to easily render document fields that are added inside `collectionOverrides` on the folder config. Not much changed, the folder drawer UI now resembles what you would expect when you create a document in payload. It is a bit slimmed back but generally very similar.
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
import { devUser } from '../credentials.js'
|
|
import { Autosave } from './collections/Autosave/index.js'
|
|
import { Drafts } from './collections/Drafts/index.js'
|
|
import { Media } from './collections/Media/index.js'
|
|
import { OmittedFromBrowseBy } from './collections/OmittedFromBrowseBy/index.js'
|
|
import { Posts } from './collections/Posts/index.js'
|
|
// import { seed } from './seed/index.js'
|
|
|
|
export default buildConfigWithDefaults({
|
|
admin: {
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
},
|
|
folders: {
|
|
// debug: true,
|
|
collectionOverrides: [
|
|
({ collection }) => {
|
|
collection.fields.push({
|
|
name: 'folderSlug',
|
|
type: 'text',
|
|
})
|
|
return collection
|
|
},
|
|
],
|
|
},
|
|
collections: [Posts, Media, Drafts, Autosave, OmittedFromBrowseBy],
|
|
globals: [
|
|
{
|
|
slug: 'global',
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
onInit: async (payload) => {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
},
|
|
})
|
|
// await seed(payload)
|
|
},
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|