@byline/host-tanstack-start 4.14.0 → 4.15.0
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/dist/admin-shell/chrome/admin-layout_module.css +1 -1
- package/dist/admin-shell/chrome/admin-menu-drawer.d.ts +3 -1
- package/dist/admin-shell/chrome/admin-menu-drawer.js +14 -2
- package/dist/admin-shell/chrome/admin-menu-drawer_module.css +7 -6
- package/dist/admin-shell/chrome/dashboard.js +2 -2
- package/dist/admin-shell/collections/edit.js +142 -2
- package/dist/admin-shell/scheduled-publications/list.d.ts +4 -0
- package/dist/admin-shell/scheduled-publications/list.js +295 -0
- package/dist/admin-shell/scheduled-publications/list.module.js +25 -0
- package/dist/admin-shell/scheduled-publications/list_module.css +97 -0
- package/dist/routes/create-admin-layout-route.js +8 -3
- package/dist/routes/create-admin-scheduled-publications-route.d.ts +8 -0
- package/dist/routes/create-admin-scheduled-publications-route.js +66 -0
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +1 -0
- package/dist/server-fns/collections/get.d.ts +5 -0
- package/dist/server-fns/collections/get.js +19 -3
- package/dist/server-fns/collections/index.d.ts +1 -0
- package/dist/server-fns/collections/index.js +1 -0
- package/dist/server-fns/collections/scheduled-publication-response.d.ts +11 -0
- package/dist/server-fns/collections/scheduled-publication-response.js +5 -0
- package/dist/server-fns/collections/scheduled-publication.d.ts +111 -0
- package/dist/server-fns/collections/scheduled-publication.js +157 -0
- package/package.json +8 -8
- package/src/admin-shell/chrome/admin-layout.module.css +6 -1
- package/src/admin-shell/chrome/admin-menu-drawer.module.css +19 -6
- package/src/admin-shell/chrome/admin-menu-drawer.tsx +23 -1
- package/src/admin-shell/chrome/dashboard.tsx +11 -4
- package/src/admin-shell/collections/edit.tsx +140 -1
- package/src/admin-shell/scheduled-publications/list.module.css +105 -0
- package/src/admin-shell/scheduled-publications/list.tsx +292 -0
- package/src/routes/create-admin-layout-route.tsx +8 -3
- package/src/routes/create-admin-scheduled-publications-route.tsx +83 -0
- package/src/routes/index.ts +1 -0
- package/src/server-fns/collections/get.ts +30 -1
- package/src/server-fns/collections/index.ts +1 -0
- package/src/server-fns/collections/scheduled-publication-response.test.node.ts +45 -0
- package/src/server-fns/collections/scheduled-publication-response.ts +22 -0
- package/src/server-fns/collections/scheduled-publication.ts +270 -0
|
@@ -6,4 +6,6 @@
|
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
8
|
import type React from 'react';
|
|
9
|
-
export declare function AdminMenuDrawer(
|
|
9
|
+
export declare function AdminMenuDrawer({ scheduledPublicationEnabled, }: {
|
|
10
|
+
scheduledPublicationEnabled?: boolean;
|
|
11
|
+
}): React.JSX.Element | null;
|
|
@@ -4,8 +4,9 @@ import { ADMIN_ACTIVITY_ABILITIES } from "@byline/admin/admin-activity";
|
|
|
4
4
|
import { ADMIN_PERMISSIONS_ABILITIES } from "@byline/admin/admin-permissions";
|
|
5
5
|
import { ADMIN_ROLES_ABILITIES } from "@byline/admin/admin-roles";
|
|
6
6
|
import { ADMIN_USERS_ABILITIES } from "@byline/admin/admin-users";
|
|
7
|
+
import { collectionAbilityKey, getAdminConfig } from "@byline/core";
|
|
7
8
|
import { useTranslation } from "@byline/i18n/react";
|
|
8
|
-
import { ActivityIcon, HomeIcon, RolesIcon, SettingsSlidersIcon, Tooltip, UserIcon, UsersIcon } from "@byline/ui/react";
|
|
9
|
+
import { ActivityIcon, CalendarIcon, HomeIcon, RolesIcon, SettingsSlidersIcon, Tooltip, UserIcon, UsersIcon } from "@byline/ui/react";
|
|
9
10
|
import clsx from "clsx";
|
|
10
11
|
import { useSwipeable } from "react-swipeable";
|
|
11
12
|
import { useAbilities } from "../../integrations/abilities.js";
|
|
@@ -45,7 +46,7 @@ function MenuItem({ to, label, icon, pathname, compact }) {
|
|
|
45
46
|
})
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
function AdminMenuDrawer() {
|
|
49
|
+
function AdminMenuDrawer({ scheduledPublicationEnabled = false }) {
|
|
49
50
|
const pathname = useRouterState({
|
|
50
51
|
select: (s)=>s.location.pathname
|
|
51
52
|
});
|
|
@@ -56,6 +57,7 @@ function AdminMenuDrawer() {
|
|
|
56
57
|
const canReadRoles = has(ADMIN_ROLES_ABILITIES.read);
|
|
57
58
|
const canReadPermissions = has(ADMIN_PERMISSIONS_ABILITIES.read);
|
|
58
59
|
const canReadActivity = has(ADMIN_ACTIVITY_ABILITIES.read);
|
|
60
|
+
const canSeeScheduledPublications = scheduledPublicationEnabled && getAdminConfig().collections.some((collection)=>has(collectionAbilityKey(collection.path, 'changeStatus')) && has(collectionAbilityKey(collection.path, 'publish')));
|
|
59
61
|
const showAdminSection = canReadUsers || canReadRoles || canReadPermissions || canReadActivity;
|
|
60
62
|
const handlers = useSwipeable({
|
|
61
63
|
onSwipedLeft: ()=>{
|
|
@@ -94,6 +96,16 @@ function AdminMenuDrawer() {
|
|
|
94
96
|
pathname: pathname,
|
|
95
97
|
compact: compact
|
|
96
98
|
}),
|
|
99
|
+
canSeeScheduledPublications && /*#__PURE__*/ jsx(MenuItem, {
|
|
100
|
+
to: getAdminRoutePath('scheduled-publications'),
|
|
101
|
+
label: t('chrome.menu.scheduledPublications'),
|
|
102
|
+
icon: /*#__PURE__*/ jsx(CalendarIcon, {
|
|
103
|
+
width: "18px",
|
|
104
|
+
height: "18px"
|
|
105
|
+
}),
|
|
106
|
+
pathname: pathname,
|
|
107
|
+
compact: compact
|
|
108
|
+
}),
|
|
97
109
|
showAdminSection && /*#__PURE__*/ jsxs(Fragment, {
|
|
98
110
|
children: [
|
|
99
111
|
/*#__PURE__*/ jsx("li", {
|
|
@@ -30,8 +30,10 @@
|
|
|
30
30
|
|
|
31
31
|
:is(.asideDesktop-uFlpwO, .byline-admin-menu-drawer-aside-desktop) {
|
|
32
32
|
flex-shrink: 0;
|
|
33
|
-
align-self:
|
|
34
|
-
|
|
33
|
+
align-self: flex-start;
|
|
34
|
+
height: calc(100vh - 45px);
|
|
35
|
+
position: sticky;
|
|
36
|
+
top: 45px;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
:is(.asideDesktopOpen-kPyJOg, .byline-admin-menu-drawer-aside-desktop-open) {
|
|
@@ -43,10 +45,9 @@
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
:is(.nav-dDjqu7, .byline-admin-menu-drawer) {
|
|
46
|
-
|
|
48
|
+
flex: auto;
|
|
49
|
+
min-height: 0;
|
|
47
50
|
margin: 0;
|
|
48
|
-
position: sticky;
|
|
49
|
-
top: 0;
|
|
50
51
|
overflow-y: auto;
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
:is(.nav-dDjqu7 ul li.menu-item .label, .byline-admin-menu-drawer ul li.menu-item .label) {
|
|
73
|
-
line-height:
|
|
74
|
+
line-height: 1.2;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
:is(.nav-dDjqu7 ul li.menu-item.compact .label, .byline-admin-menu-drawer ul li.menu-item.compact .label) {
|
|
@@ -53,7 +53,7 @@ function StatTile({ ws, count, collectionPath }) {
|
|
|
53
53
|
}
|
|
54
54
|
function CollectionCard({ collection, stats }) {
|
|
55
55
|
const { t } = useTranslation('byline-admin');
|
|
56
|
-
const total = stats
|
|
56
|
+
const total = void 0 !== stats ? stats.reduce((sum, s)=>sum + s.count, 0) : void 0;
|
|
57
57
|
const workflowStatuses = getWorkflowStatuses(collection);
|
|
58
58
|
return /*#__PURE__*/ jsxs(Card, {
|
|
59
59
|
children: [
|
|
@@ -74,7 +74,7 @@ function CollectionCard({ collection, stats }) {
|
|
|
74
74
|
className: clsx('byline-dashboard-title-text', dashboard_module.titleText),
|
|
75
75
|
children: collection.labels.plural
|
|
76
76
|
}),
|
|
77
|
-
/*#__PURE__*/ jsx("span", {
|
|
77
|
+
void 0 !== total && /*#__PURE__*/ jsx("span", {
|
|
78
78
|
className: clsx('muted byline-dashboard-title-meta', dashboard_module.titleMeta),
|
|
79
79
|
children: t('dashboard.totalCount', {
|
|
80
80
|
count: total
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { FormRenderer } from "@byline/admin/react";
|
|
4
|
-
import { getDefaultStatus, getWorkflowStatuses } from "@byline/core";
|
|
4
|
+
import { getDefaultStatus, getWorkflow, getWorkflowStatuses, validateStatusTransition } from "@byline/core";
|
|
5
5
|
import { useTranslation } from "@byline/i18n/react";
|
|
6
6
|
import { Container, Section, useToastManager } from "@byline/ui/react";
|
|
7
7
|
import { getAdminRoutePath } from "../../routes/admin-path.js";
|
|
8
8
|
import { clearListReturnState } from "../../routes/list-return-storage.js";
|
|
9
|
-
import { copyDocumentToLocale, deleteDocument, deleteDocumentLocale, duplicateCollectionDocument, hasDeleteSideEffectFailures, unpublishDocument, updateCollectionDocumentSystemFields, updateCollectionDocumentWithPatches, updateDocumentStatus } from "../../server-fns/collections/index.js";
|
|
9
|
+
import { cancelCollectionDocumentScheduledPublish, confirmCollectionDocumentScheduledPublish, copyDocumentToLocale, deleteDocument, deleteDocumentLocale, duplicateCollectionDocument, hasDeleteSideEffectFailures, scheduleCollectionDocumentPublish, unpublishDocument, updateCollectionDocumentSystemFields, updateCollectionDocumentWithPatches, updateDocumentStatus } from "../../server-fns/collections/index.js";
|
|
10
10
|
import { useNavigate } from "../chrome/loose-router.js";
|
|
11
11
|
import { useTanStackNavigationGuard } from "./tanstack-navigation-guard.js";
|
|
12
12
|
import { ViewMenu } from "./view-menu.js";
|
|
@@ -25,6 +25,24 @@ const EditView = ({ collectionDefinition, adminConfig, initialData, locale, cont
|
|
|
25
25
|
const currentStatus = initialData?.status ?? getDefaultStatus(collectionDefinition);
|
|
26
26
|
const currentIndex = workflowStatuses.findIndex((s)=>s.name === currentStatus);
|
|
27
27
|
const nextStatus = -1 !== currentIndex && currentIndex < workflowStatuses.length - 1 ? workflowStatuses[currentIndex + 1] : void 0;
|
|
28
|
+
const scheduledPublicationEnabled = initialData?._scheduledPublicationEnabled === true;
|
|
29
|
+
const canSchedulePublication = initialData?._canSchedulePublication === true;
|
|
30
|
+
const scheduledPublication = initialData?._scheduledPublish ?? null;
|
|
31
|
+
const publishTransitionValid = 'published' !== currentStatus && getWorkflowStatuses(collectionDefinition).length > 1 && validateStatusTransition(getWorkflow(collectionDefinition), currentStatus, 'published').valid;
|
|
32
|
+
const canArmSchedule = scheduledPublicationEnabled && canSchedulePublication && publishTransitionValid;
|
|
33
|
+
const notifyScheduleSuspended = ()=>{
|
|
34
|
+
if (scheduledPublication?.state !== 'armed') return;
|
|
35
|
+
toastManager.add({
|
|
36
|
+
title: t('scheduledPublication.toast.suspendedTitle'),
|
|
37
|
+
description: t("scheduledPublication.toast.suspendedDescription"),
|
|
38
|
+
data: {
|
|
39
|
+
intent: 'warning',
|
|
40
|
+
iconType: 'warning',
|
|
41
|
+
icon: true,
|
|
42
|
+
close: true
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
28
46
|
const handleLocaleChange = (newLocale)=>{
|
|
29
47
|
navigate({
|
|
30
48
|
to: getAdminRoutePath('collections', '$collection', '$id'),
|
|
@@ -99,6 +117,121 @@ const EditView = ({ collectionDefinition, adminConfig, initialData, locale, cont
|
|
|
99
117
|
});
|
|
100
118
|
}
|
|
101
119
|
};
|
|
120
|
+
const reloadDocument = ()=>{
|
|
121
|
+
navigate({
|
|
122
|
+
to: getAdminRoutePath('collections', '$collection', '$id'),
|
|
123
|
+
params: {
|
|
124
|
+
collection: path,
|
|
125
|
+
id: String(initialData.id)
|
|
126
|
+
},
|
|
127
|
+
search: (prev)=>({
|
|
128
|
+
...prev
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const handleSchedulePublication = async ({ publishAt })=>{
|
|
133
|
+
try {
|
|
134
|
+
await scheduleCollectionDocumentPublish({
|
|
135
|
+
data: {
|
|
136
|
+
collection: path,
|
|
137
|
+
id: String(initialData.id),
|
|
138
|
+
publishAt,
|
|
139
|
+
expectedVersionId: String(initialData.versionId)
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
toastManager.add({
|
|
143
|
+
title: t('scheduledPublication.toast.scheduledTitle'),
|
|
144
|
+
description: t("scheduledPublication.toast.scheduledDescription"),
|
|
145
|
+
data: {
|
|
146
|
+
intent: 'success',
|
|
147
|
+
iconType: 'success',
|
|
148
|
+
icon: true,
|
|
149
|
+
close: true
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
reloadDocument();
|
|
153
|
+
} catch (err) {
|
|
154
|
+
toastManager.add({
|
|
155
|
+
title: t('scheduledPublication.toast.failedTitle'),
|
|
156
|
+
description: err.message,
|
|
157
|
+
data: {
|
|
158
|
+
intent: 'danger',
|
|
159
|
+
iconType: 'danger',
|
|
160
|
+
icon: true,
|
|
161
|
+
close: true
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
throw err;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const handleConfirmScheduledPublication = async ()=>{
|
|
168
|
+
try {
|
|
169
|
+
await confirmCollectionDocumentScheduledPublish({
|
|
170
|
+
data: {
|
|
171
|
+
collection: path,
|
|
172
|
+
id: String(initialData.id),
|
|
173
|
+
expectedVersionId: String(initialData.versionId)
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
toastManager.add({
|
|
177
|
+
title: t('scheduledPublication.toast.confirmedTitle'),
|
|
178
|
+
description: t("scheduledPublication.toast.confirmedDescription"),
|
|
179
|
+
data: {
|
|
180
|
+
intent: 'success',
|
|
181
|
+
iconType: 'success',
|
|
182
|
+
icon: true,
|
|
183
|
+
close: true
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
reloadDocument();
|
|
187
|
+
} catch (err) {
|
|
188
|
+
toastManager.add({
|
|
189
|
+
title: t('scheduledPublication.toast.failedTitle'),
|
|
190
|
+
description: err.message,
|
|
191
|
+
data: {
|
|
192
|
+
intent: 'danger',
|
|
193
|
+
iconType: 'danger',
|
|
194
|
+
icon: true,
|
|
195
|
+
close: true
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
throw err;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const handleCancelScheduledPublication = async ()=>{
|
|
202
|
+
try {
|
|
203
|
+
const result = await cancelCollectionDocumentScheduledPublish({
|
|
204
|
+
data: {
|
|
205
|
+
collection: path,
|
|
206
|
+
id: String(initialData.id)
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
const cancelled = 'cancelled' === result.status;
|
|
210
|
+
toastManager.add({
|
|
211
|
+
title: cancelled ? t('scheduledPublication.toast.cancelledTitle') : t('scheduledPublication.toast.cancelLostTitle'),
|
|
212
|
+
description: cancelled ? t("scheduledPublication.toast.cancelledDescription") : t("scheduledPublication.toast.cancelLostDescription"),
|
|
213
|
+
data: {
|
|
214
|
+
intent: cancelled ? 'success' : 'warning',
|
|
215
|
+
iconType: cancelled ? 'success' : 'warning',
|
|
216
|
+
icon: true,
|
|
217
|
+
close: true
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
reloadDocument();
|
|
221
|
+
} catch (err) {
|
|
222
|
+
toastManager.add({
|
|
223
|
+
title: t('scheduledPublication.toast.failedTitle'),
|
|
224
|
+
description: err.message,
|
|
225
|
+
data: {
|
|
226
|
+
intent: 'danger',
|
|
227
|
+
iconType: 'danger',
|
|
228
|
+
icon: true,
|
|
229
|
+
close: true
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
throw err;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
102
235
|
const publishedVersion = initialData?._publishedVersion ?? null;
|
|
103
236
|
const restoreWarnings = initialData?._restoreWarnings;
|
|
104
237
|
const handleUnpublish = async ()=>{
|
|
@@ -256,6 +389,7 @@ const EditView = ({ collectionDefinition, adminConfig, initialData, locale, cont
|
|
|
256
389
|
close: true
|
|
257
390
|
}
|
|
258
391
|
});
|
|
392
|
+
notifyScheduleSuspended();
|
|
259
393
|
setEditState({
|
|
260
394
|
status: 'success',
|
|
261
395
|
message: t('collections.edit.copiedSuccessMessage', {
|
|
@@ -323,6 +457,7 @@ const EditView = ({ collectionDefinition, adminConfig, initialData, locale, cont
|
|
|
323
457
|
close: true
|
|
324
458
|
}
|
|
325
459
|
});
|
|
460
|
+
notifyScheduleSuspended();
|
|
326
461
|
setEditState({
|
|
327
462
|
status: 'success',
|
|
328
463
|
message: description
|
|
@@ -446,6 +581,7 @@ const EditView = ({ collectionDefinition, adminConfig, initialData, locale, cont
|
|
|
446
581
|
locale
|
|
447
582
|
}
|
|
448
583
|
});
|
|
584
|
+
if (contentDirty && scheduledPublication?.state === 'armed') notifyScheduleSuspended();
|
|
449
585
|
const description = t("collections.edit.updatedDescription", {
|
|
450
586
|
label: singularLower
|
|
451
587
|
});
|
|
@@ -526,6 +662,10 @@ const EditView = ({ collectionDefinition, adminConfig, initialData, locale, cont
|
|
|
526
662
|
}),
|
|
527
663
|
onStatusChange: handleStatusChange,
|
|
528
664
|
onUnpublish: publishedVersion ? handleUnpublish : void 0,
|
|
665
|
+
scheduledPublication: scheduledPublication,
|
|
666
|
+
onSchedulePublication: canArmSchedule ? handleSchedulePublication : void 0,
|
|
667
|
+
onConfirmScheduledPublication: canArmSchedule && scheduledPublication?.state === 'needs_reconfirm' ? handleConfirmScheduledPublication : void 0,
|
|
668
|
+
onCancelScheduledPublication: null != scheduledPublication ? handleCancelScheduledPublication : void 0,
|
|
529
669
|
onDelete: handleDelete,
|
|
530
670
|
onDuplicate: handleDuplicate,
|
|
531
671
|
onCopyToLocale: handleCopyToLocale,
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import { useRouterState } from "@tanstack/react-router";
|
|
5
|
+
import { deriveScheduledPublicationState } from "@byline/admin/react";
|
|
6
|
+
import { useTranslation } from "@byline/i18n/react";
|
|
7
|
+
import { Alert, Badge, Button, Container, Section, Select, Table, useToastManager } from "@byline/ui/react";
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
import { getAdminRoutePath } from "../../routes/admin-path.js";
|
|
10
|
+
import { cancelCollectionDocumentScheduledPublish } from "../../server-fns/collections/index.js";
|
|
11
|
+
import { Link, useNavigate } from "../chrome/loose-router.js";
|
|
12
|
+
import { RouterPager } from "../chrome/router-pager.js";
|
|
13
|
+
import list_module from "./list.module.js";
|
|
14
|
+
const STATE_INTENT = {
|
|
15
|
+
none: 'noeffect',
|
|
16
|
+
armed: 'info',
|
|
17
|
+
needs_reconfirm: 'warning',
|
|
18
|
+
overdue: 'warning'
|
|
19
|
+
};
|
|
20
|
+
function ScheduledPublicationsView({ data }) {
|
|
21
|
+
const { t, locale } = useTranslation('byline-admin');
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
const timeZone = useMemo(()=>Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC', []);
|
|
24
|
+
const instantFormat = useMemo(()=>new Intl.DateTimeFormat(locale, {
|
|
25
|
+
dateStyle: 'medium',
|
|
26
|
+
timeStyle: 'short',
|
|
27
|
+
timeZone
|
|
28
|
+
}), [
|
|
29
|
+
locale,
|
|
30
|
+
timeZone
|
|
31
|
+
]);
|
|
32
|
+
const navigate = useNavigate();
|
|
33
|
+
const toastManager = useToastManager();
|
|
34
|
+
const location = useRouterState({
|
|
35
|
+
select: (state)=>state.location
|
|
36
|
+
});
|
|
37
|
+
const search = location.search;
|
|
38
|
+
const [cancelling, setCancelling] = useState(null);
|
|
39
|
+
const applySearch = (patch)=>{
|
|
40
|
+
navigate({
|
|
41
|
+
to: getAdminRoutePath('scheduled-publications'),
|
|
42
|
+
search: {
|
|
43
|
+
...location.search,
|
|
44
|
+
...patch,
|
|
45
|
+
page: void 0
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const cancel = async (collection, documentId)=>{
|
|
50
|
+
setCancelling(documentId);
|
|
51
|
+
try {
|
|
52
|
+
const result = await cancelCollectionDocumentScheduledPublish({
|
|
53
|
+
data: {
|
|
54
|
+
collection,
|
|
55
|
+
id: documentId
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const cancelled = 'cancelled' === result.status;
|
|
59
|
+
toastManager.add({
|
|
60
|
+
title: cancelled ? t('scheduledPublication.toast.cancelledTitle') : t('scheduledPublication.toast.cancelLostTitle'),
|
|
61
|
+
description: cancelled ? t("scheduledPublication.toast.cancelledDescription") : t("scheduledPublication.toast.cancelLostDescription"),
|
|
62
|
+
data: {
|
|
63
|
+
intent: cancelled ? 'success' : 'warning',
|
|
64
|
+
iconType: cancelled ? 'success' : 'warning',
|
|
65
|
+
icon: true,
|
|
66
|
+
close: true
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
navigate({
|
|
70
|
+
to: getAdminRoutePath('scheduled-publications'),
|
|
71
|
+
search: location.search
|
|
72
|
+
});
|
|
73
|
+
} catch (error) {
|
|
74
|
+
toastManager.add({
|
|
75
|
+
title: t('scheduledPublication.toast.failedTitle'),
|
|
76
|
+
description: error.message,
|
|
77
|
+
data: {
|
|
78
|
+
intent: 'danger',
|
|
79
|
+
iconType: 'danger',
|
|
80
|
+
icon: true,
|
|
81
|
+
close: true
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
} finally{
|
|
85
|
+
setCancelling(null);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const unhealthy = data.runtime.health?.status !== 'healthy';
|
|
89
|
+
return /*#__PURE__*/ jsx(Section, {
|
|
90
|
+
children: /*#__PURE__*/ jsxs(Container, {
|
|
91
|
+
children: [
|
|
92
|
+
/*#__PURE__*/ jsxs("div", {
|
|
93
|
+
className: clsx('byline-scheduled-list-head', list_module.head),
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ jsx("h1", {
|
|
96
|
+
className: list_module.title,
|
|
97
|
+
children: t('scheduledPublication.list.title')
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ jsx("p", {
|
|
100
|
+
className: list_module.intro,
|
|
101
|
+
children: t('scheduledPublication.list.intro')
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
unhealthy && /*#__PURE__*/ jsx(Alert, {
|
|
106
|
+
className: list_module.health,
|
|
107
|
+
intent: "warning",
|
|
108
|
+
icon: true,
|
|
109
|
+
close: false,
|
|
110
|
+
title: t('scheduledPublication.list.schedulerWarningTitle'),
|
|
111
|
+
children: t('scheduledPublication.list.schedulerWarningBody', {
|
|
112
|
+
status: data.runtime.health?.status ?? 'not_started'
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ jsxs("div", {
|
|
116
|
+
className: list_module.controls,
|
|
117
|
+
children: [
|
|
118
|
+
/*#__PURE__*/ jsx("div", {
|
|
119
|
+
className: list_module.filters,
|
|
120
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
121
|
+
className: list_module.filter,
|
|
122
|
+
children: /*#__PURE__*/ jsx(Select, {
|
|
123
|
+
id: "scheduled-publication-state",
|
|
124
|
+
name: "scheduled-publication-state",
|
|
125
|
+
ariaLabel: t('scheduledPublication.list.filters.state'),
|
|
126
|
+
size: "sm",
|
|
127
|
+
value: search.state ?? '_all',
|
|
128
|
+
items: [
|
|
129
|
+
{
|
|
130
|
+
value: '_all',
|
|
131
|
+
label: t('scheduledPublication.list.filters.allStates')
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
value: 'armed',
|
|
135
|
+
label: t('scheduledPublication.list.states.armed')
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
value: 'needs_reconfirm',
|
|
139
|
+
label: t('scheduledPublication.list.states.needsReconfirm')
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
onValueChange: (value)=>applySearch({
|
|
143
|
+
state: '_all' === value ? void 0 : value
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ jsx(RouterPager, {
|
|
149
|
+
page: data.meta.page,
|
|
150
|
+
count: data.meta.totalPages,
|
|
151
|
+
showFirstButton: true,
|
|
152
|
+
showLastButton: true,
|
|
153
|
+
componentName: "scheduledPublicationsPagerTop",
|
|
154
|
+
"aria-label": t('scheduledPublication.list.pagerAriaLabel')
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
}),
|
|
158
|
+
0 === data.schedules.length ? /*#__PURE__*/ jsx("p", {
|
|
159
|
+
className: list_module.empty,
|
|
160
|
+
children: t('scheduledPublication.list.empty')
|
|
161
|
+
}) : /*#__PURE__*/ jsx(Table.Container, {
|
|
162
|
+
className: list_module.tableWrap,
|
|
163
|
+
children: /*#__PURE__*/ jsxs(Table, {
|
|
164
|
+
children: [
|
|
165
|
+
/*#__PURE__*/ jsx(Table.Header, {
|
|
166
|
+
children: /*#__PURE__*/ jsxs(Table.Row, {
|
|
167
|
+
children: [
|
|
168
|
+
/*#__PURE__*/ jsx(Table.HeadingCell, {
|
|
169
|
+
scope: "col",
|
|
170
|
+
children: t('scheduledPublication.list.columns.document')
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ jsx(Table.HeadingCell, {
|
|
173
|
+
scope: "col",
|
|
174
|
+
children: t('scheduledPublication.list.columns.publishAt')
|
|
175
|
+
}),
|
|
176
|
+
/*#__PURE__*/ jsx(Table.HeadingCell, {
|
|
177
|
+
scope: "col",
|
|
178
|
+
children: t('scheduledPublication.list.columns.state')
|
|
179
|
+
}),
|
|
180
|
+
/*#__PURE__*/ jsx(Table.HeadingCell, {
|
|
181
|
+
scope: "col",
|
|
182
|
+
children: t('scheduledPublication.list.columns.authorizer')
|
|
183
|
+
}),
|
|
184
|
+
/*#__PURE__*/ jsx(Table.HeadingCell, {
|
|
185
|
+
scope: "col",
|
|
186
|
+
children: t('scheduledPublication.list.columns.attempt')
|
|
187
|
+
}),
|
|
188
|
+
/*#__PURE__*/ jsx(Table.HeadingCell, {
|
|
189
|
+
scope: "col",
|
|
190
|
+
children: t('scheduledPublication.list.columns.actions')
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
})
|
|
194
|
+
}),
|
|
195
|
+
/*#__PURE__*/ jsx(Table.Body, {
|
|
196
|
+
children: data.schedules.map((schedule)=>{
|
|
197
|
+
const state = deriveScheduledPublicationState(schedule, {
|
|
198
|
+
canSchedule: false,
|
|
199
|
+
canConfirm: false,
|
|
200
|
+
canCancel: true
|
|
201
|
+
}, now);
|
|
202
|
+
const publishAt = new Date(schedule.publishAt);
|
|
203
|
+
return /*#__PURE__*/ jsxs(Table.Row, {
|
|
204
|
+
children: [
|
|
205
|
+
/*#__PURE__*/ jsxs(Table.Cell, {
|
|
206
|
+
children: [
|
|
207
|
+
/*#__PURE__*/ jsx(Link, {
|
|
208
|
+
to: getAdminRoutePath('collections', '$collection', '$id'),
|
|
209
|
+
params: {
|
|
210
|
+
collection: schedule.collectionPath,
|
|
211
|
+
id: schedule.documentId
|
|
212
|
+
},
|
|
213
|
+
children: schedule.documentPath || schedule.documentId
|
|
214
|
+
}),
|
|
215
|
+
/*#__PURE__*/ jsx("span", {
|
|
216
|
+
className: list_module.collection,
|
|
217
|
+
children: schedule.collectionLabel
|
|
218
|
+
})
|
|
219
|
+
]
|
|
220
|
+
}),
|
|
221
|
+
/*#__PURE__*/ jsxs(Table.Cell, {
|
|
222
|
+
children: [
|
|
223
|
+
/*#__PURE__*/ jsx("time", {
|
|
224
|
+
className: list_module.instant,
|
|
225
|
+
dateTime: publishAt.toISOString(),
|
|
226
|
+
children: instantFormat.format(publishAt)
|
|
227
|
+
}),
|
|
228
|
+
/*#__PURE__*/ jsx("span", {
|
|
229
|
+
className: list_module.zone,
|
|
230
|
+
children: timeZone
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
}),
|
|
234
|
+
/*#__PURE__*/ jsx(Table.Cell, {
|
|
235
|
+
children: /*#__PURE__*/ jsx(Badge, {
|
|
236
|
+
intent: STATE_INTENT[state.kind],
|
|
237
|
+
children: 'needs_reconfirm' === state.kind ? t('scheduledPublication.list.states.needsReconfirm') : 'overdue' === state.kind ? t('scheduledPublication.list.states.overdue') : t('scheduledPublication.list.states.armed')
|
|
238
|
+
})
|
|
239
|
+
}),
|
|
240
|
+
/*#__PURE__*/ jsx(Table.Cell, {
|
|
241
|
+
children: null != schedule.lastAuthorizedByName ? /*#__PURE__*/ jsx("span", {
|
|
242
|
+
children: schedule.lastAuthorizedByName
|
|
243
|
+
}) : null != schedule.lastAuthorizedBy ? /*#__PURE__*/ jsx("span", {
|
|
244
|
+
className: list_module.authorizer,
|
|
245
|
+
title: t('scheduledPublication.list.authorizerMissing'),
|
|
246
|
+
children: schedule.lastAuthorizedBy
|
|
247
|
+
}) : /*#__PURE__*/ jsx("span", {
|
|
248
|
+
children: "—"
|
|
249
|
+
})
|
|
250
|
+
}),
|
|
251
|
+
/*#__PURE__*/ jsxs(Table.Cell, {
|
|
252
|
+
children: [
|
|
253
|
+
/*#__PURE__*/ jsx("span", {
|
|
254
|
+
children: schedule.attemptCount
|
|
255
|
+
}),
|
|
256
|
+
null != schedule.lastError && /*#__PURE__*/ jsx("span", {
|
|
257
|
+
className: list_module.error,
|
|
258
|
+
children: schedule.lastError
|
|
259
|
+
})
|
|
260
|
+
]
|
|
261
|
+
}),
|
|
262
|
+
/*#__PURE__*/ jsx(Table.Cell, {
|
|
263
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
264
|
+
size: "xs",
|
|
265
|
+
type: "button",
|
|
266
|
+
intent: "danger",
|
|
267
|
+
disabled: cancelling === schedule.documentId,
|
|
268
|
+
"aria-label": t('scheduledPublication.actions.cancel'),
|
|
269
|
+
onClick: ()=>cancel(schedule.collectionPath, schedule.documentId),
|
|
270
|
+
children: t('common.actions.cancel')
|
|
271
|
+
})
|
|
272
|
+
})
|
|
273
|
+
]
|
|
274
|
+
}, schedule.documentId);
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
})
|
|
279
|
+
}),
|
|
280
|
+
/*#__PURE__*/ jsx("div", {
|
|
281
|
+
className: list_module.pagerBottom,
|
|
282
|
+
children: /*#__PURE__*/ jsx(RouterPager, {
|
|
283
|
+
page: data.meta.page,
|
|
284
|
+
count: data.meta.totalPages,
|
|
285
|
+
showFirstButton: true,
|
|
286
|
+
showLastButton: true,
|
|
287
|
+
componentName: "scheduledPublicationsPagerBottom",
|
|
288
|
+
"aria-label": t('scheduledPublication.list.pagerAriaLabel')
|
|
289
|
+
})
|
|
290
|
+
})
|
|
291
|
+
]
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
export { ScheduledPublicationsView };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./list_module.css";
|
|
2
|
+
const list_module = {
|
|
3
|
+
head: "head-oj4QbV",
|
|
4
|
+
title: "title-lm1z74",
|
|
5
|
+
intro: "intro-clPFM7",
|
|
6
|
+
health: "health-KAg5x5",
|
|
7
|
+
controls: "controls-dRon5S",
|
|
8
|
+
"filters-help": "filters-help-DWQ3Wy",
|
|
9
|
+
filtersHelp: "filters-help-DWQ3Wy",
|
|
10
|
+
filters: "filters-x7PuG5",
|
|
11
|
+
filter: "filter-TXeSAI",
|
|
12
|
+
"filter-authorizer": "filter-authorizer-rDbHwh",
|
|
13
|
+
filterAuthorizer: "filter-authorizer-rDbHwh",
|
|
14
|
+
"filter-actions": "filter-actions-dbQWCO",
|
|
15
|
+
filterActions: "filter-actions-dbQWCO",
|
|
16
|
+
tableWrap: "tableWrap-wqdsOy",
|
|
17
|
+
collection: "collection-sBqska",
|
|
18
|
+
zone: "zone-ikRViN",
|
|
19
|
+
error: "error-frhrx4",
|
|
20
|
+
instant: "instant-PTgCBK",
|
|
21
|
+
authorizer: "authorizer-orWXlf",
|
|
22
|
+
empty: "empty-K7NcOV",
|
|
23
|
+
pagerBottom: "pagerBottom-Sf0_9J"
|
|
24
|
+
};
|
|
25
|
+
export default list_module;
|