### What? Refactors the `LeaveWithoutSaving` modal to be generic and delegates document unlock logic back to the `DefaultEditView` component via a callback. ### Why? Previously, `unlockDocument` was triggered in a cleanup `useEffect` in the edit view. When logging out from the edit view, the unlock request would often fail due to the session ending — leaving the document in a locked state. ### How? - Introduced `onConfirm` and `onPrevent` props for `LeaveWithoutSaving`. - Moved all document lock/unlock logic into `DefaultEditView`’s `handleLeaveConfirm`. - Captures the next navigation target via `onPrevent` and evaluates whether to unlock based on: - Locking being enabled. - Current user owning the lock. - Navigation not targeting internal admin views (`/preview`, `/api`, `/versions`). --------- Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
35 lines
667 B
TypeScript
35 lines
667 B
TypeScript
import type { Config } from 'payload'
|
|
|
|
import { v4 as uuid } from 'uuid'
|
|
|
|
import { devUser } from '../credentials.js'
|
|
import { apiKeysSlug } from './shared.js'
|
|
|
|
export const seed: Config['onInit'] = async (payload) => {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
custom: 'Hello, world!',
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
roles: ['admin'],
|
|
},
|
|
})
|
|
|
|
await payload.create({
|
|
collection: apiKeysSlug,
|
|
data: {
|
|
apiKey: uuid(),
|
|
enableAPIKey: true,
|
|
},
|
|
})
|
|
|
|
await payload.create({
|
|
collection: apiKeysSlug,
|
|
data: {
|
|
apiKey: uuid(),
|
|
enableAPIKey: true,
|
|
},
|
|
})
|
|
}
|