From 3cfea834f4534b355fc42f145b4a4bee2a2e21dc Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Fri, 10 Jan 2025 17:37:51 -0500 Subject: [PATCH 1/4] feat: delete scheduled published events --- .../payload/src/versions/schedule/types.ts | 2 +- .../ScheduleDrawer/buildUpcomingColumns.tsx | 27 +++++ .../PublishButton/ScheduleDrawer/index.scss | 4 + .../PublishButton/ScheduleDrawer/index.tsx | 37 +++++- .../src/utilities/schedulePublishHandler.ts | 26 +++- test/versions/int.spec.ts | 113 +++++++++++++++++- 6 files changed, 197 insertions(+), 12 deletions(-) diff --git a/packages/payload/src/versions/schedule/types.ts b/packages/payload/src/versions/schedule/types.ts index 3e16c10d995..4f747c8288f 100644 --- a/packages/payload/src/versions/schedule/types.ts +++ b/packages/payload/src/versions/schedule/types.ts @@ -7,6 +7,6 @@ export type SchedulePublishTaskInput = { } global?: GlobalSlug locale?: string - type: string + type?: string user?: number | string } diff --git a/packages/ui/src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx b/packages/ui/src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx index a808f37e05f..8f4d477a179 100644 --- a/packages/ui/src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx +++ b/packages/ui/src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx @@ -1,15 +1,18 @@ import type { ClientConfig } from 'payload' import { getTranslation, type I18nClient, type TFunction } from '@payloadcms/translations' +import React from 'react' import type { Column } from '../../Table/index.js' import type { UpcomingEvent } from './types.js' import { formatDate } from '../../../utilities/formatDate.js' +import { Button } from '../../Button/index.js' import { Pill } from '../../Pill/index.js' type Args = { dateFormat: string + deleteHandler: (id: number | string) => void docs: UpcomingEvent[] i18n: I18nClient localization: ClientConfig['localization'] @@ -18,6 +21,7 @@ type Args = { export const buildUpcomingColumns = ({ dateFormat, + deleteHandler, docs, i18n, localization, @@ -81,5 +85,28 @@ export const buildUpcomingColumns = ({ }) } + columns.push({ + accessor: 'delete', + active: true, + field: { + name: 'delete', + type: 'text', + }, + Heading: {t('general:delete')}, + renderedCells: docs.map((doc) => ( +