feat: add support for time format config on scheduled publish (#12073)
This PR adds a new `SchedulePublish` config type on our schedulePublish
configuration in versions from being just boolean.
Two new options are supported:
- `timeFormat` which controls the formatting of the time slots, allowing
users to change from a 12-hour clock to a 24-hour clock (default to 12
hour)
- `timeIntervals` which controls the generated time slots (default 5)
Example configuration:
```
versions: {
drafts: {
schedulePublish: {
timeFormat: 'HH:mm',
timeIntervals: 5,
},
},
},
```
This commit is contained in:
@@ -125,7 +125,9 @@ const DraftPosts: CollectionConfig = {
|
||||
],
|
||||
versions: {
|
||||
drafts: {
|
||||
schedulePublish: true,
|
||||
schedulePublish: {
|
||||
timeFormat: 'HH:mm',
|
||||
},
|
||||
},
|
||||
maxPerDoc: 0,
|
||||
},
|
||||
|
||||
@@ -691,6 +691,40 @@ describe('Versions', () => {
|
||||
page.locator('.payload-toast-item:has-text("Deleted successfully.")'),
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('schedule publish config is respected', async () => {
|
||||
await page.goto(url.create)
|
||||
await page.locator('#field-title').fill('scheduled publish')
|
||||
await page.locator('#field-description').fill('scheduled publish description')
|
||||
|
||||
// schedule publish should not be available before document has been saved
|
||||
await page.locator('#action-save-popup').click()
|
||||
await expect(page.locator('#schedule-publish')).toBeHidden()
|
||||
|
||||
// save draft then try to schedule publish
|
||||
await saveDocAndAssert(page)
|
||||
await page.locator('#action-save-popup').click()
|
||||
await page.locator('#schedule-publish').click()
|
||||
|
||||
// drawer should open
|
||||
await expect(page.locator('.schedule-publish__drawer-header')).toBeVisible()
|
||||
// nothing in scheduled
|
||||
await expect(page.locator('.drawer__content')).toContainText('No upcoming events scheduled.')
|
||||
|
||||
// set date and time
|
||||
await page.locator('.date-time-picker input').click()
|
||||
|
||||
const listItem = page
|
||||
.locator('.react-datepicker__time-list .react-datepicker__time-list-item')
|
||||
.first()
|
||||
|
||||
// We customised it in config to not contain a 12 hour clock
|
||||
await expect(async () => {
|
||||
await expect(listItem).toHaveText('00:00')
|
||||
}).toPass({
|
||||
timeout: POLL_TOPASS_TIMEOUT,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Collections - publish specific locale', () => {
|
||||
|
||||
Reference in New Issue
Block a user