#11769 improved the lexical version view diff component. This PR improves the rest of the version view. ## What changed - Column layout when selecting a version: - Previously: Selected version on the left, latest version on the left - Now: Previous version on the left, previous version on the right (mimics behavior of GitHub) - Locale selector now displayed in pill selector, rather than react-select - Smoother, more reliable locale, modifiedOnly and version selection. Now uses clean event callbacks rather than useEffects - React-diff-viewer-continued has been replaced with the html differ we use in lexical - Updated Design for all field diffs - Version columns now have a clearly defined separator line - Fixed collapsibles showing in version view despite having no modified fields if modifiedOnly is true - New, redesigned header ## Screenshots ### Before   ### After    
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import type { Endpoint, PayloadHandler } from 'payload'
|
|
|
|
import { status as httpStatus } from 'http-status'
|
|
import * as qs from 'qs-esm'
|
|
|
|
import { path } from './reInitializeDB.js'
|
|
import { seedDB } from './seed.js'
|
|
|
|
const handler: PayloadHandler = async (req) => {
|
|
process.env.SEED_IN_CONFIG_ONINIT = 'true'
|
|
const { payload } = req
|
|
|
|
if (!req.url) {
|
|
throw new Error('Request URL is required')
|
|
}
|
|
|
|
const query: {
|
|
deleteOnly?: boolean
|
|
snapshotKey?: string
|
|
uploadsDir?: string | string[]
|
|
} = qs.parse(req.url.split('?')[1] ?? '', {
|
|
depth: 10,
|
|
ignoreQueryPrefix: true,
|
|
})
|
|
|
|
try {
|
|
await seedDB({
|
|
_payload: payload,
|
|
collectionSlugs: payload.config.collections.map(({ slug }) => slug),
|
|
seedFunction: payload.config.onInit,
|
|
snapshotKey: String(query.snapshotKey),
|
|
// uploadsDir can be string or stringlist
|
|
uploadsDir: query.uploadsDir as string | string[],
|
|
deleteOnly: query.deleteOnly,
|
|
})
|
|
|
|
return Response.json(
|
|
{
|
|
message: 'Database reset and onInit run successfully.',
|
|
},
|
|
{
|
|
status: httpStatus.OK,
|
|
},
|
|
)
|
|
} catch (err) {
|
|
payload.logger.error(err)
|
|
return Response.json(err, {
|
|
status: httpStatus.BAD_REQUEST,
|
|
})
|
|
}
|
|
}
|
|
|
|
export const reInitEndpoint: Endpoint = {
|
|
path,
|
|
method: 'get',
|
|
handler,
|
|
}
|