Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): scheduled publish not showing related events in postgres #10481

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/payload/src/versions/schedule/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { CollectionSlug, GlobalSlug } from '../../index.js'
export type SchedulePublishTaskInput = {
doc?: {
relationTo: CollectionSlug
value: number | string
value: string
}
global?: GlobalSlug
locale?: string
Expand Down
23 changes: 15 additions & 8 deletions packages/ui/src/elements/PublishButton/ScheduleDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Where } from 'payload'

import { useModal } from '@faceless-ui/modal'
import { getTranslation } from '@payloadcms/translations'
import * as qs from 'qs-esm'
import React from 'react'
import { toast } from 'sonner'

Expand Down Expand Up @@ -78,7 +79,7 @@ export const ScheduleDrawer: React.FC<Props> = ({ slug }) => {
}, [localization, i18n])

const fetchUpcoming = React.useCallback(async () => {
const params: { sort: string; where: Where } = {
const query: { sort: string; where: Where } = {
sort: 'waitUntil',
where: {
and: [
Expand All @@ -97,29 +98,35 @@ export const ScheduleDrawer: React.FC<Props> = ({ slug }) => {
}

if (collectionSlug) {
params.where.and.push({
query.where.and.push({
'input.doc.value': {
equals: id,
equals: String(id),
},
})

params.where.and.push({
query.where.and.push({
'input.doc.relationTo': {
equals: collectionSlug,
},
})
}

if (globalSlug) {
params.where.and.push({
query.where.and.push({
'input.global': {
equals: globalSlug,
},
})
}

const { docs } = await requests
.get(`${serverURL}${api}/payload-jobs`, { params })
.post(`${serverURL}${api}/payload-jobs`, {
body: qs.stringify(query),
headers: {
'Accept-Language': i18n.language,
'Content-Type': 'application/x-www-form-urlencoded',
'X-HTTP-Method-Override': 'GET',
},
})
.then((res) => res.json())

setUpcomingColumns(buildUpcomingColumns({ dateFormat, docs, i18n, localization, t }))
Expand All @@ -146,7 +153,7 @@ export const ScheduleDrawer: React.FC<Props> = ({ slug }) => {
doc: collectionSlug
? {
relationTo: collectionSlug,
value: id,
value: String(id),
}
: undefined,
global: globalSlug || undefined,
Expand Down