@anthusai/papyrus 5.135.0-next.1 → 5.135.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/news-desk-taxonomy-client.ts +9 -2
- package/components/newsroom-schedule-page.tsx +79 -17
- package/components/schedule-calendar.css +1 -0
- package/components/schedule-calendar.tsx +22 -7
- package/components/story-schedule.css +4 -0
- package/lib/local-preview-seed.ts +19 -0
- package/lib/story-schedule-query.ts +49 -1
- package/package.json +2 -2
- package/routes.manifest.json +1 -1
|
@@ -10,7 +10,7 @@ import { hasEditorRights } from "../lib/staff-groups";
|
|
|
10
10
|
import { isEditorialWorkAssignment } from "../lib/newsroom-assignments";
|
|
11
11
|
import { isLocalPreviewEnabled } from "../lib/local-preview";
|
|
12
12
|
import { AUTO_ACCEPTED_PAGE_SIZE, autoAcceptedFromRecords, autoAcceptedServerFilter, collectAutoAcceptedPage, type AutoAcceptedPage } from "../lib/auto-accepted-references";
|
|
13
|
-
import { createLocalPreviewAssignments, createLocalPreviewContentItemVersions, createLocalPreviewReferences, createLocalPreviewScheduledVersions } from "../lib/local-preview-seed";
|
|
13
|
+
import { createLocalPreviewAssignments, createLocalPreviewContentItemVersions, createLocalPreviewPublishedStories, createLocalPreviewReferences, createLocalPreviewScheduledVersions } from "../lib/local-preview-seed";
|
|
14
14
|
import { generateClient } from "aws-amplify/data";
|
|
15
15
|
import { testEditorOverrideAllowed } from "../lib/test-editor-override";
|
|
16
16
|
import { downloadData, getUrl } from "aws-amplify/storage";
|
|
@@ -69,7 +69,8 @@ import {
|
|
|
69
69
|
} from "../lib/conversation";
|
|
70
70
|
import { LINK_MESSAGE_HASHTAGS_MUTATION, messageHasHashtag, postMessageArguments, postMessageMutation } from "../lib/post-message";
|
|
71
71
|
import { isStoryItemType, legacyStageKeysToLoad, type ContentItemVersionRecord } from "../lib/content-item-lifecycle";
|
|
72
|
-
import { readScheduledRange, SCHEDULE_PAGE_STATES, type ScheduleQueryFetch } from "../lib/story-schedule-query";
|
|
72
|
+
import { readPublishedRange, readScheduledRange, SCHEDULE_PAGE_STATES, type PublishedQueryFetch, type PublishedStoryRow, type ScheduleQueryFetch } from "../lib/story-schedule-query";
|
|
73
|
+
import { ALWAYS_PROJECTED, siteStoryTypes } from "../lib/site-story-types";
|
|
73
74
|
import { readStoryStageChangesSince, readStoryStagePage, STORY_STAGE_PAGE_LIMIT, type StageQueryFetch } from "../lib/story-stage-query";
|
|
74
75
|
import { readWithStoryStageIndex } from "../lib/story-stage-mode";
|
|
75
76
|
import { getContentItemStageDefinitions } from "../lib/site-brand";
|
|
@@ -2560,6 +2561,12 @@ export async function loadNewsroomScheduledStories(from: string, to: string): Pr
|
|
|
2560
2561
|
return readScheduledRange(contentItemStageFetch() as ScheduleQueryFetch, from, to);
|
|
2561
2562
|
}
|
|
2562
2563
|
|
|
2564
|
+
/** Every Story first published between two UTC instants, read from the PublishedItem `typeStatus` + `publishedAt` index (lib/story-schedule-query.ts). */
|
|
2565
|
+
export async function loadNewsroomPublishedStories(from: string, to: string): Promise<PublishedStoryRow[]> {
|
|
2566
|
+
if (isLocalPreviewEnabled()) return createLocalPreviewPublishedStories(from, to);
|
|
2567
|
+
return readPublishedRange(contentItemStageFetch() as unknown as PublishedQueryFetch, [...siteStoryTypes().types, ...ALWAYS_PROJECTED], from, to);
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2563
2570
|
export async function loadModelPayloadsForOwner(
|
|
2564
2571
|
ownerKind: string,
|
|
2565
2572
|
ownerId: string,
|
|
@@ -4,7 +4,7 @@ import dynamic from "next/dynamic";
|
|
|
4
4
|
import Link from "next/link";
|
|
5
5
|
import { useRouter } from "next/navigation";
|
|
6
6
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
7
|
-
import { CalendarClock } from "lucide-react";
|
|
7
|
+
import { CalendarClock, TriangleAlert, Undo2 } from "lucide-react";
|
|
8
8
|
import "./newsroom-theme";
|
|
9
9
|
import { canReadNewsroomBoard, contentItemBoardPathSegment } from "../lib/newsroom-board";
|
|
10
10
|
import { displayNewsroomSectionShortTitle } from "../lib/newsroom-sections";
|
|
@@ -13,14 +13,16 @@ import { newsroomHref } from "../lib/newsroom-base-path";
|
|
|
13
13
|
import { SITE_BRAND } from "../lib/site-brand";
|
|
14
14
|
import { useScheduleZone } from "../lib/schedule-zone";
|
|
15
15
|
import { formatScheduleTime, scheduleFromFields, scheduleWording, zoneCity } from "../lib/story-schedule";
|
|
16
|
+
import { isLocalPreviewEnabled } from "../lib/local-preview";
|
|
17
|
+
import { resolveArticlesBackend } from "../lib/newsroom-articles";
|
|
18
|
+
import type { PublishedStoryRow } from "../lib/story-schedule-query";
|
|
16
19
|
import type { ContentItemVersionRecord } from "../lib/content-item-lifecycle";
|
|
17
20
|
import type { NewsroomSectionRecord } from "../lib/category-repository";
|
|
18
|
-
import { loadNewsroomScheduledStories } from "./news-desk-taxonomy-client";
|
|
21
|
+
import { loadNewsroomPublishedStories, loadNewsroomScheduledStories } from "./news-desk-taxonomy-client";
|
|
19
22
|
import { NewsDeskAccessGate } from "./newsroom-access-gate";
|
|
20
23
|
import { useOptionalNewsDeskClient } from "./news-desk-client-provider";
|
|
21
24
|
import { NewsroomOpsShell, NewsroomOpsStatusBanner } from "./newsroom-ops-shell";
|
|
22
|
-
import {
|
|
23
|
-
import type { ScheduleCalendarItem, ScheduleView } from "./schedule-calendar";
|
|
25
|
+
import { SCHEDULE_ITEM_ICONS, canDrag, type RescheduleOutcome, type ScheduleCalendarItem, type ScheduleView } from "./schedule-calendar";
|
|
24
26
|
|
|
25
27
|
/** FullCalendar is about 80 kB; it loads here and nowhere else. */
|
|
26
28
|
const ScheduleCalendar = dynamic(() => import("./schedule-calendar"), {
|
|
@@ -29,6 +31,9 @@ const ScheduleCalendar = dynamic(() => import("./schedule-calendar"), {
|
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
const STATE_WORD = { scheduled: "Scheduled", overdue: "Overdue", superseded: "Superseded" } as const;
|
|
34
|
+
/** The backend's own words for a time that has passed; the drop is refused here first, so nothing is sent. */
|
|
35
|
+
const PAST_DROP_MESSAGE = "That time has passed.";
|
|
36
|
+
type Notice = { tone: "done" | "problem"; text: string; undo?: () => void };
|
|
32
37
|
const EMPTY_TEXT: Record<ScheduleView, string> = { day: "Nothing is scheduled today.", week: "Nothing is scheduled this week.", month: "Nothing is scheduled this month." };
|
|
33
38
|
|
|
34
39
|
/** A phone shows the lists: the seven-day grid does not fit 375 pixels. */
|
|
@@ -45,8 +50,9 @@ function usePhone(): boolean | null {
|
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
|
-
* The Schedule page: the Stories that are scheduled, overdue or superseded, by day, week or month in the publication's
|
|
49
|
-
* plain list of the same items under the calendar for keyboard and screen-reader use. It reads one time range of the schedule index
|
|
53
|
+
* The Schedule page: the Stories that are scheduled, overdue or superseded, and the ones published in the same range, by day, week or month in the publication's
|
|
54
|
+
* time zone, with a plain list of the same items under the calendar for keyboard and screen-reader use. It reads one time range of the schedule index and of the
|
|
55
|
+
* published index at a time. Dragging a scheduled Story to a new time reschedules it through the same operation as the drawer and offers Undo.
|
|
50
56
|
*/
|
|
51
57
|
export function NewsroomSchedulePage() {
|
|
52
58
|
const session = useOptionalNewsDeskClient();
|
|
@@ -57,20 +63,55 @@ export function NewsroomSchedulePage() {
|
|
|
57
63
|
const [range, setRange] = useState<{ from: string; to: string; view: ScheduleView } | null>(null);
|
|
58
64
|
const [rows, setRows] = useState<ReturnType<typeof scheduleRows> | null>(null);
|
|
59
65
|
const [error, setError] = useState<string | null>(null);
|
|
66
|
+
const [notice, setNotice] = useState<Notice | null>(null);
|
|
60
67
|
const request = useRef(0);
|
|
68
|
+
const shown = useRef<ReturnType<typeof scheduleRows> | null>(null);
|
|
69
|
+
shown.current = rows;
|
|
61
70
|
|
|
62
71
|
useEffect(() => {
|
|
63
72
|
if (!allowed || !zone || !range) return;
|
|
64
|
-
const
|
|
73
|
+
const mine = ++request.current;
|
|
65
74
|
setError(null);
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
setNotice(null);
|
|
76
|
+
Promise.all([loadNewsroomScheduledStories(range.from, range.to), loadNewsroomPublishedStories(range.from, range.to)]).then(([versions, published]) => {
|
|
77
|
+
if (request.current === mine) setRows(scheduleRows(versions, published, zone));
|
|
68
78
|
}, reason => {
|
|
69
|
-
if (request.current ===
|
|
79
|
+
if (request.current === mine) setError(reason instanceof Error ? reason.message : "The schedule could not be loaded.");
|
|
70
80
|
});
|
|
71
81
|
}, [allowed, zone, range]);
|
|
72
82
|
|
|
73
83
|
const onRange = useCallback((next: { from: string; to: string; view: ScheduleView }) => setRange(previous => previous && previous.from === next.from && previous.to === next.to && previous.view === next.view ? previous : next), []);
|
|
84
|
+
/** Moves one scheduled Story to a UTC instant and shows the result in the calendar and the list; a refusal changes nothing. */
|
|
85
|
+
const move = useCallback(async (id: string, at: string): Promise<{ ok: true; from: string } | { ok: false; message: string }> => {
|
|
86
|
+
const item = shown.current?.items.find(candidate => candidate.id === id);
|
|
87
|
+
if (!item || !canDrag(item)) return { ok: false, message: "That Story cannot be moved here." };
|
|
88
|
+
if (Date.parse(at) <= Date.now()) return { ok: false, message: PAST_DROP_MESSAGE };
|
|
89
|
+
try {
|
|
90
|
+
await resolveArticlesBackend(isLocalPreviewEnabled()).actions.scheduleStory({ itemId: id, lineageId: item.lineageId, scheduledPublishAt: at });
|
|
91
|
+
} catch (reason) {
|
|
92
|
+
return { ok: false, message: reason instanceof Error ? reason.message : "The schedule could not be saved." };
|
|
93
|
+
}
|
|
94
|
+
setRows(previous => previous && zone ? { items: moveItem(previous.items, id, at, zone) } : previous);
|
|
95
|
+
return { ok: true, from: item.at };
|
|
96
|
+
}, [zone]);
|
|
97
|
+
|
|
98
|
+
const reschedule = useCallback(async (id: string, at: string): Promise<RescheduleOutcome> => {
|
|
99
|
+
const item = shown.current?.items.find(candidate => candidate.id === id);
|
|
100
|
+
const outcome = await move(id, at);
|
|
101
|
+
if (!zone || !item) return { ok: false, message: "That Story cannot be moved here." };
|
|
102
|
+
if (!outcome.ok) {
|
|
103
|
+
setNotice({ tone: "problem", text: `${outcome.message} “${item.title}” stays at ${formatScheduleTime(item.at, zone)}.` });
|
|
104
|
+
return outcome;
|
|
105
|
+
}
|
|
106
|
+
setNotice({
|
|
107
|
+
tone: "done", text: `Rescheduled “${item.title}” for ${formatScheduleTime(at, zone)}.`,
|
|
108
|
+
undo: () => { void move(id, outcome.from).then(back => setNotice(back.ok
|
|
109
|
+
? { tone: "done", text: `“${item.title}” is back at ${formatScheduleTime(outcome.from, zone)}.` }
|
|
110
|
+
: { tone: "problem", text: `${back.message} “${item.title}” stays at ${formatScheduleTime(at, zone)}.` })); },
|
|
111
|
+
});
|
|
112
|
+
return { ok: true };
|
|
113
|
+
}, [move, zone]);
|
|
114
|
+
|
|
74
115
|
const storyHref = (itemId: string) => getNewsroomNavHref(`/newsroom/articles/${encodeURIComponent(itemId)}`);
|
|
75
116
|
|
|
76
117
|
if (!allowed) return <NewsDeskAccessGate shell={session?.shell ?? null} />;
|
|
@@ -82,8 +123,13 @@ export function NewsroomSchedulePage() {
|
|
|
82
123
|
: <>
|
|
83
124
|
<p className="schedule-zone-note" data-schedule-zone>All times are {zoneCity(zone)} time.</p>
|
|
84
125
|
{error ? <NewsroomOpsStatusBanner tone="error">{error}</NewsroomOpsStatusBanner> : null}
|
|
85
|
-
{phone === null ? null : <ScheduleCalendar items={rows?.items ?? []} zone={zone} phone={phone} onRange={onRange} onOpen={id => { const row = rows?.items.find(item => item.id === id); if (row) router.push(storyHref(id)); }} />}
|
|
86
|
-
{
|
|
126
|
+
{phone === null ? null : <ScheduleCalendar items={rows?.items ?? []} zone={zone} phone={phone} onRange={onRange} onOpen={id => { const row = rows?.items.find(item => item.id === id); if (row) router.push(storyHref(id)); }} onReschedule={reschedule} />}
|
|
127
|
+
{notice ? <p className="schedule-notice" data-schedule-notice data-schedule-notice-tone={notice.tone} role={notice.tone === "problem" ? "alert" : "status"}>
|
|
128
|
+
{notice.tone === "problem" ? <TriangleAlert aria-hidden size={14} /> : <CalendarClock aria-hidden size={14} />}
|
|
129
|
+
<span>{notice.text}</span>
|
|
130
|
+
{notice.undo ? <button type="button" data-schedule-undo onClick={notice.undo}><Undo2 aria-hidden size={14} />Undo</button> : null}
|
|
131
|
+
</p> : null}
|
|
132
|
+
{rows && rows.items.every(item => item.kind === "published") && range ? <p className="schedule-empty" data-schedule-empty role="status">
|
|
87
133
|
{EMPTY_TEXT[range.view]}
|
|
88
134
|
<Link href={newsroomHref(contentItemBoardPathSegment())}><CalendarClock aria-hidden size={14} />Schedule a Story</Link>
|
|
89
135
|
</p> : null}
|
|
@@ -91,7 +137,7 @@ export function NewsroomSchedulePage() {
|
|
|
91
137
|
<h2 id="schedule-list-heading">Everything in this view, as a list</h2>
|
|
92
138
|
<ol className="schedule-list">
|
|
93
139
|
{rows.items.map(item => {
|
|
94
|
-
const Icon =
|
|
140
|
+
const Icon = SCHEDULE_ITEM_ICONS[item.kind];
|
|
95
141
|
return <li className="schedule-list-item" key={item.id} data-schedule-item={item.id} data-schedule-kind={item.kind}>
|
|
96
142
|
<Link href={storyHref(item.id)}>{item.title}</Link>
|
|
97
143
|
<small><Icon aria-hidden size={12} /><span>{item.state}: {formatScheduleTime(item.at, zone, true)}{item.section ? ` · ${item.section}` : ""}</span></small>
|
|
@@ -104,7 +150,10 @@ export function NewsroomSchedulePage() {
|
|
|
104
150
|
</NewsroomOpsShell>;
|
|
105
151
|
}
|
|
106
152
|
|
|
107
|
-
|
|
153
|
+
const sectionTitle = (section: string | null | undefined) => section ? displayNewsroomSectionShortTitle({ id: section } as NewsroomSectionRecord) : null;
|
|
154
|
+
|
|
155
|
+
/** Scheduled, overdue and superseded Stories from the schedule index, with the Stories published in the same range, earliest first. */
|
|
156
|
+
function scheduleRows(versions: readonly ContentItemVersionRecord[], published: readonly PublishedStoryRow[], zone: string): { items: ScheduleCalendarItem[] } {
|
|
108
157
|
const now = new Date();
|
|
109
158
|
const items: ScheduleCalendarItem[] = [];
|
|
110
159
|
for (const version of versions) {
|
|
@@ -112,11 +161,24 @@ function scheduleRows(versions: readonly ContentItemVersionRecord[], zone: strin
|
|
|
112
161
|
if (!schedule) continue;
|
|
113
162
|
const wording = scheduleWording(schedule, zone, now);
|
|
114
163
|
items.push({
|
|
115
|
-
id: version.id,
|
|
164
|
+
id: version.id, lineageId: version.lineageId ?? version.id,
|
|
116
165
|
title: version.headline || version.title || version.slug,
|
|
117
|
-
section:
|
|
166
|
+
section: sectionTitle(version.section),
|
|
118
167
|
at: schedule.at, kind: wording.kind, state: STATE_WORD[wording.kind], label: wording.label,
|
|
119
168
|
});
|
|
120
169
|
}
|
|
121
|
-
|
|
170
|
+
for (const story of published) {
|
|
171
|
+
items.push({
|
|
172
|
+
id: story.id, lineageId: story.lineageId, title: story.title, section: sectionTitle(story.section),
|
|
173
|
+
at: story.publishedAt, kind: "published", state: "Published", label: `Published ${formatScheduleTime(story.publishedAt, zone)}`,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return { items: items.sort((left, right) => left.at.localeCompare(right.at) || left.id.localeCompare(right.id)) };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** The same items with one scheduled Story at its new time, worded again for it. */
|
|
180
|
+
function moveItem(items: readonly ScheduleCalendarItem[], id: string, at: string, zone: string): ScheduleCalendarItem[] {
|
|
181
|
+
const wording = scheduleWording({ at, state: "scheduled", by: null, scheduledAt: null }, zone, new Date());
|
|
182
|
+
return items.map(item => item.id !== id ? item : { ...item, at, kind: wording.kind, state: STATE_WORD[wording.kind], label: wording.label })
|
|
183
|
+
.sort((left, right) => left.at.localeCompare(right.at) || left.id.localeCompare(right.id));
|
|
122
184
|
}
|
|
@@ -28,3 +28,4 @@
|
|
|
28
28
|
.schedule-calendar .schedule-event[data-schedule-kind=overdue]{background:color-mix(in oklab,var(--org-ink) 22%,var(--org-paper))}
|
|
29
29
|
.schedule-calendar .schedule-event[data-schedule-kind=scheduled]{background:color-mix(in oklab,var(--org-accent) 22%,var(--org-paper))}
|
|
30
30
|
.schedule-calendar :focus-visible{outline:2px solid var(--org-ink);outline-offset:1px}
|
|
31
|
+
.schedule-calendar .schedule-event[data-schedule-kind=published]{background:color-mix(in oklab,var(--org-ink) 7%,var(--org-paper))}
|
|
@@ -5,19 +5,26 @@ import classicTheme from "@fullcalendar/react/themes/classic";
|
|
|
5
5
|
import dayGrid from "@fullcalendar/react/daygrid";
|
|
6
6
|
import timeGrid from "@fullcalendar/react/timegrid";
|
|
7
7
|
import list from "@fullcalendar/react/list";
|
|
8
|
+
import interaction from "@fullcalendar/react/interaction";
|
|
8
9
|
import "@fullcalendar/react/skeleton.css";
|
|
9
10
|
import "@fullcalendar/react/themes/classic/theme.css";
|
|
10
11
|
import "./schedule-calendar.css";
|
|
12
|
+
import { CircleCheck, type LucideIcon } from "lucide-react";
|
|
11
13
|
import { SCHEDULE_ICONS } from "./story-schedule-badge";
|
|
12
14
|
import type { ScheduleKind } from "../lib/story-schedule";
|
|
13
15
|
|
|
16
|
+
/** What an item on the page is: a schedule state, or a Story that already went out. */
|
|
17
|
+
export type ScheduleItemKind = ScheduleKind | "published";
|
|
18
|
+
export const SCHEDULE_ITEM_ICONS: Record<ScheduleItemKind, LucideIcon> = { ...SCHEDULE_ICONS, published: CircleCheck };
|
|
19
|
+
|
|
14
20
|
export type ScheduleCalendarItem = {
|
|
15
21
|
id: string;
|
|
16
22
|
title: string;
|
|
17
23
|
section: string | null;
|
|
18
|
-
|
|
24
|
+
lineageId: string;
|
|
25
|
+
/** The UTC instant: when it goes live, or when it went live. */
|
|
19
26
|
at: string;
|
|
20
|
-
kind:
|
|
27
|
+
kind: ScheduleItemKind;
|
|
21
28
|
/** The state in one or two words: Scheduled, Overdue, Superseded, Published. */
|
|
22
29
|
state: string;
|
|
23
30
|
/** Every fact, for a screen reader. */
|
|
@@ -25,6 +32,9 @@ export type ScheduleCalendarItem = {
|
|
|
25
32
|
};
|
|
26
33
|
|
|
27
34
|
export type ScheduleView = "day" | "week" | "month";
|
|
35
|
+
export type RescheduleOutcome = { ok: true } | { ok: false; message: string };
|
|
36
|
+
/** Only a Story that is still waiting for its time moves by dragging; an overdue, superseded or published one is changed in its drawer or not at all. */
|
|
37
|
+
export const canDrag = (item: Pick<ScheduleCalendarItem, "kind">): boolean => item.kind === "scheduled";
|
|
28
38
|
const VIEWS = {
|
|
29
39
|
wide: { initial: "timeGridWeek", right: "timeGridDay,timeGridWeek,dayGridMonth", of: { timeGridDay: "day", timeGridWeek: "week", dayGridMonth: "month" } },
|
|
30
40
|
phone: { initial: "listWeek", right: "listDay,listWeek,listMonth", of: { listDay: "day", listWeek: "week", listMonth: "month" } },
|
|
@@ -35,26 +45,31 @@ const clockTime = (iso: string, zone: string) => new Intl.DateTimeFormat("en-US"
|
|
|
35
45
|
/**
|
|
36
46
|
* FullCalendar 7 in the publication's named time zone, loaded only on the Schedule page. Week is the default; Day and Month switch; a phone gets the lists of
|
|
37
47
|
* the same three spans because the seven-day grid does not fit 375 pixels. Events are focusable (`eventInteractive`) and open the Story. The page owns the data:
|
|
38
|
-
* the calendar reports the range on screen and shows the items it is given.
|
|
48
|
+
* the calendar reports the range on screen and shows the items it is given. A scheduled Story can be dragged in the week, day and month grids: the drop asks the
|
|
49
|
+
* page to reschedule it (which revalidates the time with the backend) and the calendar puts it back when the page says no.
|
|
39
50
|
*/
|
|
40
|
-
export default function ScheduleCalendar({ items, zone, phone, onRange, onOpen }: {
|
|
51
|
+
export default function ScheduleCalendar({ items, zone, phone, onRange, onOpen, onReschedule }: {
|
|
41
52
|
items: readonly ScheduleCalendarItem[];
|
|
42
53
|
zone: string;
|
|
43
54
|
phone: boolean;
|
|
44
55
|
onRange: (range: { from: string; to: string; view: ScheduleView }) => void;
|
|
45
56
|
onOpen: (id: string) => void;
|
|
57
|
+
/** Asks to move a Story to a UTC instant; the calendar reverts the drop on a refusal. */
|
|
58
|
+
onReschedule: (id: string, at: string) => Promise<RescheduleOutcome>;
|
|
46
59
|
}) {
|
|
47
60
|
const views = phone ? VIEWS.phone : VIEWS.wide;
|
|
48
61
|
return <div className="schedule-calendar" data-schedule-calendar data-schedule-layout={phone ? "list" : "grid"}>
|
|
49
62
|
<FullCalendar
|
|
50
63
|
key={phone ? "phone" : "wide"}
|
|
51
|
-
plugins={[classicTheme, dayGrid, timeGrid, list]}
|
|
64
|
+
plugins={[classicTheme, dayGrid, timeGrid, list, interaction]}
|
|
52
65
|
timeZone={zone}
|
|
53
66
|
initialView={views.initial}
|
|
54
67
|
headerToolbar={{ left: "prev,next today", center: "title", right: views.right }}
|
|
55
68
|
buttons={{ today: { text: "Today" }, ...Object.fromEntries(Object.entries(views.of).map(([view, span]) => [view, { text: span[0].toUpperCase() + span.slice(1) }])) }}
|
|
56
|
-
events={items.map(item => ({ id: item.id, title: item.title, start: item.at, extendedProps: item }))}
|
|
69
|
+
events={items.map(item => ({ id: item.id, title: item.title, start: item.at, startEditable: canDrag(item), extendedProps: item }))}
|
|
57
70
|
eventInteractive
|
|
71
|
+
eventDurationEditable={false}
|
|
72
|
+
eventDrop={arg => { void onReschedule(arg.event.id, new Date(arg.event.startStr).toISOString()).then(outcome => { if (!outcome.ok) arg.revert(); }); }}
|
|
58
73
|
eventDisplay="block"
|
|
59
74
|
defaultTimedEventDuration="02:00"
|
|
60
75
|
height="auto"
|
|
@@ -62,7 +77,7 @@ export default function ScheduleCalendar({ items, zone, phone, onRange, onOpen }
|
|
|
62
77
|
eventClick={arg => { arg.jsEvent.preventDefault(); onOpen(arg.event.id); }}
|
|
63
78
|
eventContent={arg => {
|
|
64
79
|
const item = arg.event.extendedProps as ScheduleCalendarItem;
|
|
65
|
-
const Icon =
|
|
80
|
+
const Icon = SCHEDULE_ITEM_ICONS[item.kind];
|
|
66
81
|
return <span className="schedule-event" data-schedule-kind={item.kind} title={item.label}>
|
|
67
82
|
<Icon aria-hidden size={13} />
|
|
68
83
|
<span className="schedule-event-text">
|
|
@@ -35,3 +35,7 @@
|
|
|
35
35
|
.story-schedule-button{display:inline-flex;align-items:center;gap:6px;min-height:36px;padding:2px 12px;border:0;border-radius:8px;background:var(--card,var(--org-paper));color:var(--org-ink);font:600 12px var(--kb-theme-ui-font);cursor:pointer}
|
|
36
36
|
.story-schedule-button:disabled{opacity:.6;cursor:default}
|
|
37
37
|
.newsroom-organizer .story-schedule-button,.newsroom-organizer .story-schedule-fields input,.newsroom-organizer .story-schedule-badge{border-radius:8px !important}
|
|
38
|
+
.schedule-page .schedule-notice{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0;padding:10px 14px;border-radius:12px;background:color-mix(in oklab,var(--org-accent) 18%,var(--org-paper));font-size:14px}
|
|
39
|
+
.schedule-page .schedule-notice[data-schedule-notice-tone=problem]{background:color-mix(in oklab,var(--org-ink) 12%,var(--org-paper))}
|
|
40
|
+
.schedule-page .schedule-notice svg{flex:none}
|
|
41
|
+
.schedule-page .schedule-notice button{display:inline-flex;align-items:center;gap:6px;min-height:36px;padding:6px 12px;border:0;border-radius:8px;background:var(--org-ink);color:var(--org-paper);font:600 14px/1 var(--kb-theme-ui-font);cursor:pointer}
|
|
@@ -10,6 +10,7 @@ import { getContentItemStageDefinitions } from "./site-brand";
|
|
|
10
10
|
import { noteProblem, stepChangeProblem, summarizeStoryChecklist, type StoryStepNote, type StoryStepRecord } from "./story-checklist";
|
|
11
11
|
import { LOCAL_PREVIEW_TENANTS, getLocalPreviewTenantId } from "./local-preview-tenant";
|
|
12
12
|
import type { ScheduleFields } from "./story-schedule";
|
|
13
|
+
import type { PublishedStoryRow } from "./story-schedule-query";
|
|
13
14
|
|
|
14
15
|
const SEED_TIMESTAMP_BASE = Date.parse("2026-10-01T12:00:00.000Z");
|
|
15
16
|
const ONE_HOUR_IN_MILLISECONDS = 60 * 60 * 1000;
|
|
@@ -210,6 +211,24 @@ export function resetLocalPreviewSchedules(): void {
|
|
|
210
211
|
previewScheduleTouchedAt.clear();
|
|
211
212
|
}
|
|
212
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Fake first-publication times for the sample published Stories, placed relative to the start of today (UTC) like the schedules: two went out three days ago,
|
|
216
|
+
* so the Schedule page shows what went out beside what is coming.
|
|
217
|
+
*/
|
|
218
|
+
function seededPublishedAt(now: Date = new Date()): Record<string, string> {
|
|
219
|
+
const today = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
|
|
220
|
+
const at = (days: number, hours: number) => new Date(today + days * DAY + hours * HOUR).toISOString();
|
|
221
|
+
return { "preview-item-lineage-published-0": at(-3, 14), "preview-item-lineage-published-1": at(-3, 18) };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Every sample published Story first published in [from, to), for the Schedule page. */
|
|
225
|
+
export function createLocalPreviewPublishedStories(from: string, to: string): PublishedStoryRow[] {
|
|
226
|
+
const publishedAt = seededPublishedAt();
|
|
227
|
+
return createLocalPreviewContentItemVersions()
|
|
228
|
+
.filter(version => version.lineageId && publishedAt[version.lineageId] && publishedAt[version.lineageId] >= from && publishedAt[version.lineageId] < to)
|
|
229
|
+
.map(version => ({ id: version.id, lineageId: version.lineageId!, title: version.headline || version.title || version.slug, section: version.section ?? null, publishedAt: publishedAt[version.lineageId!] }));
|
|
230
|
+
}
|
|
231
|
+
|
|
213
232
|
/** Every sample Story that has a schedule, for the Schedule page: the rows whose scheduled time falls in [from, to) and whose state is one of `states`. */
|
|
214
233
|
export function createLocalPreviewScheduledVersions(from: string, to: string, states: readonly string[]): ContentItemVersionRecord[] {
|
|
215
234
|
return createLocalPreviewContentItemVersions().filter(version => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* only versions that are or were scheduled, and nothing reads a table to show a few items. Pure, with the GraphQL call passed in, so the paging is tested against
|
|
5
5
|
* synthetic rows (scripts/test-story-schedule.ts).
|
|
6
6
|
*/
|
|
7
|
-
import { storyItemTypeFilter, type ContentItemVersionRecord } from "./content-item-lifecycle";
|
|
7
|
+
import { isStoryItemType, storyItemTypeFilter, type ContentItemVersionRecord } from "./content-item-lifecycle";
|
|
8
8
|
import { SCHEDULE_ROW_FIELDS } from "./story-schedule";
|
|
9
9
|
|
|
10
10
|
/** The stored states, each one partition of the sparse index. Overdue is a scheduled or publishing row whose time has passed, so it is read with them. */
|
|
@@ -39,3 +39,51 @@ export async function readScheduledRange(fetch: ScheduleQueryFetch, from: string
|
|
|
39
39
|
}));
|
|
40
40
|
return perState.flat().sort((left, right) => String(left.scheduledPublishAt).localeCompare(String(right.scheduledPublishAt)) || left.id.localeCompare(right.id));
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
/** One published Story as the Schedule page shows it: the live version of a Story, with the moment it first went live. */
|
|
44
|
+
export type PublishedStoryRow = {
|
|
45
|
+
/** The Item version that is live; it opens the Story in the editor. */
|
|
46
|
+
id: string;
|
|
47
|
+
lineageId: string;
|
|
48
|
+
title: string;
|
|
49
|
+
section: string | null;
|
|
50
|
+
/** The UTC instant the Story was first published (`publishedAt` carries the first publication forward, so a republish does not move it). */
|
|
51
|
+
publishedAt: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type PublishedItemRecord = { sourceItemId?: string | null; itemLineageId?: string | null; title?: string | null; headline?: string | null; slug?: string | null; section?: string | null; publishedAt?: string | null };
|
|
55
|
+
export type PublishedQueryFetch = (request: { query: string; field: string; variables: Record<string, unknown> }) => Promise<{ items: PublishedItemRecord[]; nextToken: string | null }>;
|
|
56
|
+
|
|
57
|
+
const PUBLISHED_FIELD = "listPublishedItemsByTypeStatusAndPublishedAt";
|
|
58
|
+
const PUBLISHED_QUERY = `
|
|
59
|
+
query ListPublishedItemsByTypeStatusAndPublishedAt($typeStatus: String!, $publishedAt: ModelStringKeyConditionInput, $limit: Int, $nextToken: String) {
|
|
60
|
+
${PUBLISHED_FIELD}(typeStatus: $typeStatus, publishedAt: $publishedAt, sortDirection: ASC, limit: $limit, nextToken: $nextToken) {
|
|
61
|
+
items { sourceItemId itemLineageId title headline slug section publishedAt }
|
|
62
|
+
nextToken
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Every Story first published in [from, to] (UTC instants), from the existing `typeStatus` + `publishedAt` index of PublishedItem: one key-conditioned query per
|
|
69
|
+
* Story type of the site (`<type>#published`), so only the range on screen is read. Pages and the other system types are not Stories and are left out.
|
|
70
|
+
*/
|
|
71
|
+
export async function readPublishedRange(fetch: PublishedQueryFetch, types: readonly string[], from: string, to: string): Promise<PublishedStoryRow[]> {
|
|
72
|
+
const perType = await Promise.all([...new Set(types)].filter(isStoryItemType).map(async type => {
|
|
73
|
+
const rows: PublishedStoryRow[] = [];
|
|
74
|
+
let nextToken: string | null = null;
|
|
75
|
+
do {
|
|
76
|
+
const page: { items: PublishedItemRecord[]; nextToken: string | null } = await fetch({
|
|
77
|
+
query: PUBLISHED_QUERY, field: PUBLISHED_FIELD,
|
|
78
|
+
variables: { typeStatus: `${type}#published`, publishedAt: { between: [from, to] }, limit: 100, nextToken },
|
|
79
|
+
});
|
|
80
|
+
for (const item of page.items) {
|
|
81
|
+
if (!item.sourceItemId || !item.publishedAt) continue;
|
|
82
|
+
rows.push({ id: item.sourceItemId, lineageId: item.itemLineageId ?? item.sourceItemId, title: item.headline || item.title || item.slug || "Untitled", section: item.section ?? null, publishedAt: item.publishedAt });
|
|
83
|
+
}
|
|
84
|
+
nextToken = page.nextToken;
|
|
85
|
+
} while (nextToken);
|
|
86
|
+
return rows;
|
|
87
|
+
}));
|
|
88
|
+
return perType.flat().sort((left, right) => left.publishedAt.localeCompare(right.publishedAt) || left.id.localeCompare(right.id));
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -650,7 +650,7 @@
|
|
|
650
650
|
"optional": true
|
|
651
651
|
}
|
|
652
652
|
},
|
|
653
|
-
"version": "5.135.0-next.
|
|
653
|
+
"version": "5.135.0-next.2",
|
|
654
654
|
"dependencies": {
|
|
655
655
|
"@aws-amplify/adapter-nextjs": "^1.7.3",
|
|
656
656
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
@@ -677,7 +677,7 @@
|
|
|
677
677
|
"@fontsource-variable/source-serif-4": "5.3.1",
|
|
678
678
|
"@fontsource/ibm-plex-mono": "5.3.0",
|
|
679
679
|
"@fontsource/ibm-plex-sans": "5.3.0",
|
|
680
|
-
"@fullcalendar/react": "
|
|
680
|
+
"@fullcalendar/react": "7.1.4",
|
|
681
681
|
"@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.5.1/kanbus-ui-0.5.1.tgz",
|
|
682
682
|
"@lezer/highlight": "^1.2.5",
|
|
683
683
|
"@radix-ui/colors": "3.0.0",
|
package/routes.manifest.json
CHANGED