@byline/host-tanstack-start 4.16.0 → 4.18.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-menu-drawer.js +14 -14
- package/dist/admin-shell/chrome/dashboard.js +41 -5
- package/dist/admin-shell/chrome/dashboard.test.d.ts +8 -0
- package/dist/admin-shell/chrome/router-pager.d.ts +7 -0
- package/dist/admin-shell/chrome/router-pager.js +13 -0
- package/dist/admin-shell/chrome/scroll-to-top.d.ts +20 -0
- package/dist/admin-shell/chrome/scroll-to-top.js +9 -0
- package/dist/admin-shell/collections/api.d.ts +2 -2
- package/dist/admin-shell/collections/create.d.ts +2 -2
- package/dist/admin-shell/collections/create.js +1 -0
- package/dist/admin-shell/collections/edit.d.ts +2 -2
- package/dist/admin-shell/collections/edit.js +1 -0
- package/dist/admin-shell/collections/history.d.ts +4 -12
- package/dist/admin-shell/collections/history.js +112 -303
- package/dist/admin-shell/collections/reindex-button.d.ts +1 -1
- package/dist/admin-shell/collections/reindex-button.js +5 -1
- package/dist/admin-shell/collections/restore-version-modal.d.ts +4 -4
- package/dist/admin-shell/collections/restore-version-modal.js +8 -24
- package/dist/admin-shell/collections/version-history.d.ts +72 -0
- package/dist/admin-shell/collections/version-history.js +259 -0
- package/dist/admin-shell/singletons/history.d.ts +19 -0
- package/dist/admin-shell/singletons/history.js +170 -0
- package/dist/admin-shell/singletons/history.test.d.ts +8 -0
- package/dist/admin-shell/singletons/preview-link.d.ts +12 -0
- package/dist/admin-shell/singletons/preview-link.js +54 -0
- package/dist/admin-shell/singletons/view-menu.d.ts +13 -0
- package/dist/admin-shell/singletons/view-menu.js +116 -0
- package/dist/admin-shell/singletons/view.d.ts +18 -0
- package/dist/admin-shell/singletons/view.js +259 -0
- package/dist/admin-shell/singletons/view.test.d.ts +8 -0
- package/dist/integrations/api-utils.d.ts +18 -4
- package/dist/integrations/api-utils.js +10 -3
- package/dist/routes/create-admin-dashboard-route.js +2 -2
- package/dist/routes/create-collection-api-route.js +3 -3
- package/dist/routes/create-collection-create-route.js +4 -3
- package/dist/routes/create-collection-edit-route.js +4 -3
- package/dist/routes/create-collection-history-route.js +4 -3
- package/dist/routes/create-collection-list-route.js +4 -3
- package/dist/routes/create-singleton-history-route.d.ts +8 -0
- package/dist/routes/create-singleton-history-route.js +99 -0
- package/dist/routes/create-singleton-route.d.ts +35 -0
- package/dist/routes/create-singleton-route.js +130 -0
- package/dist/routes/get-multi-collection-definition.d.ts +10 -0
- package/dist/routes/get-multi-collection-definition.js +6 -0
- package/dist/routes/get-singleton-definition.d.ts +10 -0
- package/dist/routes/get-singleton-definition.js +6 -0
- package/dist/routes/index.d.ts +2 -0
- package/dist/routes/index.js +2 -0
- package/dist/server-fns/actors.d.ts +16 -0
- package/dist/server-fns/actors.js +25 -0
- package/dist/server-fns/admin-document-presentation.d.ts +30 -0
- package/dist/server-fns/admin-document-presentation.js +32 -0
- package/dist/server-fns/collections/actors.d.ts +1 -10
- package/dist/server-fns/collections/actors.js +1 -25
- package/dist/server-fns/collections/get.js +9 -26
- package/dist/server-fns/collections/reorder.js +1 -1
- package/dist/server-fns/collections/scheduled-publication.js +2 -2
- package/dist/server-fns/collections/upload.js +3 -3
- package/dist/server-fns/collections/utils.d.ts +1 -7
- package/dist/server-fns/collections/utils.js +1 -4
- package/dist/server-fns/serialise.d.ts +14 -0
- package/dist/server-fns/serialise.js +4 -0
- package/dist/server-fns/singleton-document-read.d.ts +20 -0
- package/dist/server-fns/singleton-document-read.js +10 -0
- package/dist/server-fns/singletons/cancel-scheduled-publish.d.ts +12 -0
- package/dist/server-fns/singletons/cancel-scheduled-publish.js +7 -0
- package/dist/server-fns/singletons/change-status.d.ts +14 -0
- package/dist/server-fns/singletons/change-status.js +7 -0
- package/dist/server-fns/singletons/confirm-scheduled-publish.d.ts +14 -0
- package/dist/server-fns/singletons/confirm-scheduled-publish.js +9 -0
- package/dist/server-fns/singletons/copy-to-locale.d.ts +18 -0
- package/dist/server-fns/singletons/copy-to-locale.js +11 -0
- package/dist/server-fns/singletons/find-by-version.d.ts +16 -0
- package/dist/server-fns/singletons/find-by-version.js +9 -0
- package/dist/server-fns/singletons/get-scheduled-publish.d.ts +12 -0
- package/dist/server-fns/singletons/get-scheduled-publish.js +7 -0
- package/dist/server-fns/singletons/get.d.ts +24 -0
- package/dist/server-fns/singletons/get.js +6 -0
- package/dist/server-fns/singletons/history.d.ts +31 -0
- package/dist/server-fns/singletons/history.js +22 -0
- package/dist/server-fns/singletons/index.d.ts +19 -0
- package/dist/server-fns/singletons/index.js +12 -0
- package/dist/server-fns/singletons/restore-version.d.ts +14 -0
- package/dist/server-fns/singletons/restore-version.js +7 -0
- package/dist/server-fns/singletons/schedule-publish.d.ts +16 -0
- package/dist/server-fns/singletons/schedule-publish.js +10 -0
- package/dist/server-fns/singletons/unpublish.d.ts +12 -0
- package/dist/server-fns/singletons/unpublish.js +7 -0
- package/dist/server-fns/singletons/update.d.ts +14 -0
- package/dist/server-fns/singletons/update.js +14 -0
- package/dist/vitest-jsdom.test.d.ts +8 -0
- package/package.json +24 -18
- package/src/admin-shell/chrome/admin-menu-drawer.tsx +13 -13
- package/src/admin-shell/chrome/dashboard.test.tsx +199 -0
- package/src/admin-shell/chrome/dashboard.tsx +43 -9
- package/src/admin-shell/chrome/router-pager.tsx +22 -0
- package/src/admin-shell/chrome/scroll-to-top.test.ts +56 -0
- package/src/admin-shell/chrome/scroll-to-top.ts +28 -0
- package/src/admin-shell/collections/api.tsx +2 -2
- package/src/admin-shell/collections/create.tsx +6 -2
- package/src/admin-shell/collections/edit.tsx +6 -2
- package/src/admin-shell/collections/history.module.css +1 -1
- package/src/admin-shell/collections/history.tsx +162 -442
- package/src/admin-shell/collections/reindex-button.tsx +4 -2
- package/src/admin-shell/collections/restore-version-modal.tsx +19 -25
- package/src/admin-shell/collections/version-history.tsx +349 -0
- package/src/admin-shell/singletons/history.test.tsx +407 -0
- package/src/admin-shell/singletons/history.tsx +185 -0
- package/src/admin-shell/singletons/preview-link.tsx +75 -0
- package/src/admin-shell/singletons/view-menu.tsx +136 -0
- package/src/admin-shell/singletons/view.test.tsx +400 -0
- package/src/admin-shell/singletons/view.tsx +351 -0
- package/src/integrations/api-utils.ts +34 -9
- package/src/routes/create-admin-dashboard-route.test.node.ts +70 -0
- package/src/routes/create-admin-dashboard-route.tsx +10 -2
- package/src/routes/create-collection-api-route.tsx +4 -4
- package/src/routes/create-collection-create-route.tsx +5 -8
- package/src/routes/create-collection-edit-route.tsx +5 -4
- package/src/routes/create-collection-history-route.tsx +5 -8
- package/src/routes/create-collection-list-route.tsx +5 -8
- package/src/routes/create-singleton-history-route.test.node.ts +148 -0
- package/src/routes/create-singleton-history-route.tsx +116 -0
- package/src/routes/create-singleton-route.test.node.ts +172 -0
- package/src/routes/create-singleton-route.tsx +176 -0
- package/src/routes/get-multi-collection-definition.ts +16 -0
- package/src/routes/get-singleton-definition.ts +16 -0
- package/src/routes/index.ts +2 -0
- package/src/server-fns/actors.ts +43 -0
- package/src/server-fns/admin-document-presentation.ts +78 -0
- package/src/server-fns/collections/actors.ts +1 -52
- package/src/server-fns/collections/get.ts +10 -49
- package/src/server-fns/collections/reorder.ts +1 -1
- package/src/server-fns/collections/scheduled-publication.ts +7 -1
- package/src/server-fns/collections/upload-singleton.test.node.ts +164 -0
- package/src/server-fns/collections/upload.ts +7 -3
- package/src/server-fns/collections/utils.ts +1 -9
- package/src/server-fns/serialise.ts +17 -0
- package/src/server-fns/singleton-document-read.ts +32 -0
- package/src/server-fns/singletons/cancel-scheduled-publish.ts +19 -0
- package/src/server-fns/singletons/change-status.ts +19 -0
- package/src/server-fns/singletons/confirm-scheduled-publish.ts +23 -0
- package/src/server-fns/singletons/copy-to-locale.ts +32 -0
- package/src/server-fns/singletons/find-by-version.ts +23 -0
- package/src/server-fns/singletons/get-scheduled-publish.ts +19 -0
- package/src/server-fns/singletons/get.ts +32 -0
- package/src/server-fns/singletons/history.ts +41 -0
- package/src/server-fns/singletons/index.ts +20 -0
- package/src/server-fns/singletons/restore-version.ts +19 -0
- package/src/server-fns/singletons/schedule-publish.ts +24 -0
- package/src/server-fns/singletons/singletons.test.node.ts +298 -0
- package/src/server-fns/singletons/unpublish.ts +19 -0
- package/src/server-fns/singletons/update.ts +31 -0
- package/src/vitest-jsdom.test.tsx +27 -0
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useParams, useRouterState } from "@tanstack/react-router";
|
|
2
|
+
import { useParams, useRouter, useRouterState } from "@tanstack/react-router";
|
|
4
3
|
import { AdminTabs, StatusBadge, renderFormatted } from "@byline/admin/react";
|
|
5
4
|
import { useBylineAdminServices } from "@byline/admin/services";
|
|
6
5
|
import { useTranslation } from "@byline/i18n/react";
|
|
7
|
-
import { Button,
|
|
6
|
+
import { Button, Container, Section, Table } from "@byline/ui/react";
|
|
8
7
|
import clsx from "clsx";
|
|
9
8
|
import { getAdminRouteId, getAdminRoutePath } from "../../routes/admin-path.js";
|
|
9
|
+
import { restoreDocumentVersion } from "../../server-fns/collections/index.js";
|
|
10
10
|
import { Link, useNavigate } from "../chrome/loose-router.js";
|
|
11
|
-
import { RouterPager } from "../chrome/router-pager.js";
|
|
12
11
|
import { TableHeadingCellSortable } from "../chrome/th-sortable.js";
|
|
13
|
-
import { formatNumber } from "../chrome/utils.js";
|
|
14
12
|
import { DocumentHistoryView } from "./document-history.js";
|
|
15
13
|
import history_module from "./history.module.js";
|
|
16
|
-
import {
|
|
14
|
+
import { HistoryStats, VersionHistoryCore } from "./version-history.js";
|
|
17
15
|
import { ViewMenu } from "./view-menu.js";
|
|
18
16
|
function getColumnValue(document, fieldName) {
|
|
19
|
-
if (document.fields && fieldName in document.fields) return document.fields[fieldName];
|
|
17
|
+
if (document.fields && 'object' == typeof document.fields && fieldName in document.fields) return document.fields[fieldName];
|
|
20
18
|
return document[fieldName];
|
|
21
19
|
}
|
|
22
|
-
const DiffModal = /*#__PURE__*/ lazy(()=>import("@byline/admin/react").then((m)=>({
|
|
23
|
-
default: m.DiffModal
|
|
24
|
-
})));
|
|
25
20
|
function resolveDisplayValue(value, locale, defaultContentLocale) {
|
|
26
21
|
if (null == value) return '';
|
|
27
22
|
if ('object' == typeof value && !Array.isArray(value)) {
|
|
@@ -31,45 +26,23 @@ function resolveDisplayValue(value, locale, defaultContentLocale) {
|
|
|
31
26
|
}
|
|
32
27
|
return String(value);
|
|
33
28
|
}
|
|
34
|
-
function Stats({ total }) {
|
|
35
|
-
return /*#__PURE__*/ jsx("span", {
|
|
36
|
-
className: clsx('byline-coll-history-stats', history_module.stats),
|
|
37
|
-
children: formatNumber(total, 0)
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function padRows(value) {
|
|
41
|
-
return Array.from({
|
|
42
|
-
length: value
|
|
43
|
-
}).map((_, index)=>/*#__PURE__*/ jsx("div", {
|
|
44
|
-
className: clsx('byline-coll-history-pad-row', history_module.padRow),
|
|
45
|
-
children: "\xa0"
|
|
46
|
-
}, `empty-row-${index}`));
|
|
47
|
-
}
|
|
48
|
-
const AUDIT_ACTION_KEYS = {
|
|
49
|
-
create: 'collections.history.audit.actionCreate',
|
|
50
|
-
update: 'collections.history.audit.actionUpdate',
|
|
51
|
-
restore: 'collections.history.audit.actionRestore',
|
|
52
|
-
copy_to_locale: 'collections.history.audit.actionCopyToLocale',
|
|
53
|
-
delete_locale: 'collections.history.audit.actionDeleteLocale'
|
|
54
|
-
};
|
|
55
29
|
const HistoryView = ({ collectionDefinition, adminConfig, data, auditLog, workflowStatuses, currentDocument, contentLocales, defaultContentLocale })=>{
|
|
56
30
|
const { id, collection } = useParams({
|
|
57
31
|
from: getAdminRouteId('collections', '$collection', '$id', 'history')
|
|
58
32
|
});
|
|
59
33
|
const navigate = useNavigate();
|
|
34
|
+
const router = useRouter();
|
|
60
35
|
const { getCollectionDocumentVersion } = useBylineAdminServices();
|
|
61
36
|
const { t } = useTranslation('byline-admin');
|
|
62
37
|
const columns = adminConfig?.columns || [];
|
|
63
38
|
const { labels } = collectionDefinition;
|
|
64
39
|
const titleFieldName = collectionDefinition.useAsTitle;
|
|
40
|
+
const hasRestoreColumn = null != titleFieldName && columns.some((column)=>column.fieldName === titleFieldName);
|
|
65
41
|
const location = useRouterState({
|
|
66
|
-
select: (
|
|
42
|
+
select: (state)=>state.location
|
|
67
43
|
});
|
|
68
44
|
const locale = location.search.locale;
|
|
69
45
|
const activeTab = 'document' === location.search.tab ? 'document' : 'versions';
|
|
70
|
-
const [selectedVersion, setSelectedVersion] = useState(null);
|
|
71
|
-
const [restoreTarget, setRestoreTarget] = useState(null);
|
|
72
|
-
const currentVersionId = currentDocument && 'string' == typeof currentDocument.versionId ? currentDocument.versionId : null;
|
|
73
46
|
function handleTabChange(name) {
|
|
74
47
|
const params = structuredClone(location.search);
|
|
75
48
|
delete params.page;
|
|
@@ -84,11 +57,10 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, auditLog, workfl
|
|
|
84
57
|
search: params
|
|
85
58
|
});
|
|
86
59
|
}
|
|
87
|
-
function
|
|
88
|
-
if ('string' != typeof value || 0 === value.length) return;
|
|
60
|
+
function handlePageSizeChange(pageSize) {
|
|
89
61
|
const params = structuredClone(location.search);
|
|
90
62
|
delete params.page;
|
|
91
|
-
params.page_size =
|
|
63
|
+
params.page_size = pageSize;
|
|
92
64
|
navigate({
|
|
93
65
|
to: getAdminRoutePath('collections', '$collection', '$id', 'history'),
|
|
94
66
|
params: {
|
|
@@ -98,6 +70,75 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, auditLog, workfl
|
|
|
98
70
|
search: params
|
|
99
71
|
});
|
|
100
72
|
}
|
|
73
|
+
const rowPresentation = {
|
|
74
|
+
headers: columns.flatMap((column)=>{
|
|
75
|
+
const cell = /*#__PURE__*/ jsx(TableHeadingCellSortable, {
|
|
76
|
+
fieldName: String(column.fieldName),
|
|
77
|
+
label: column.label,
|
|
78
|
+
sortable: column.sortable,
|
|
79
|
+
scope: "col",
|
|
80
|
+
align: column.align,
|
|
81
|
+
className: column.className
|
|
82
|
+
}, String(column.fieldName));
|
|
83
|
+
return null != titleFieldName && column.fieldName === titleFieldName ? [
|
|
84
|
+
cell,
|
|
85
|
+
/*#__PURE__*/ jsx("th", {
|
|
86
|
+
scope: "col",
|
|
87
|
+
className: clsx('byline-coll-history-col-restore', history_module.colRestore)
|
|
88
|
+
}, "__restore")
|
|
89
|
+
] : [
|
|
90
|
+
cell
|
|
91
|
+
];
|
|
92
|
+
}),
|
|
93
|
+
auditColSpan: columns.length + (hasRestoreColumn ? 1 : 0),
|
|
94
|
+
renderCells: ({ document, versionId, versionNumber, currentVersionId, restoreStatusLabel, openCompare, openRestore })=>columns.flatMap((column)=>{
|
|
95
|
+
const value = getColumnValue(document, String(column.fieldName));
|
|
96
|
+
const dataCell = /*#__PURE__*/ jsx(Table.Cell, {
|
|
97
|
+
className: clsx({
|
|
98
|
+
'byline-coll-history-cell-right': 'right' === column.align,
|
|
99
|
+
[history_module.cellRight]: 'right' === column.align,
|
|
100
|
+
'byline-coll-history-cell-center': 'center' === column.align,
|
|
101
|
+
[history_module.cellCenter]: 'center' === column.align
|
|
102
|
+
}),
|
|
103
|
+
children: null != titleFieldName && column.fieldName === titleFieldName ? versionId && currentDocument ? /*#__PURE__*/ jsx("button", {
|
|
104
|
+
type: "button",
|
|
105
|
+
className: clsx('byline-coll-history-title-button', history_module.titleButton),
|
|
106
|
+
onClick: openCompare,
|
|
107
|
+
children: column.formatter ? renderFormatted(value, document, column.formatter) : resolveDisplayValue(value, locale, defaultContentLocale) || '------'
|
|
108
|
+
}) : /*#__PURE__*/ jsx(Link, {
|
|
109
|
+
to: getAdminRoutePath('collections', '$collection', '$id'),
|
|
110
|
+
params: {
|
|
111
|
+
collection,
|
|
112
|
+
id: document.id
|
|
113
|
+
},
|
|
114
|
+
children: column.formatter ? renderFormatted(value, document, column.formatter) : resolveDisplayValue(value, locale, defaultContentLocale) || '------'
|
|
115
|
+
}) : column.formatter ? renderFormatted(value, document, column.formatter) : 'status' === column.fieldName && workflowStatuses ? /*#__PURE__*/ jsx(StatusBadge, {
|
|
116
|
+
status: document.status,
|
|
117
|
+
workflowStatuses: workflowStatuses
|
|
118
|
+
}) : resolveDisplayValue(value, locale, defaultContentLocale) || ''
|
|
119
|
+
}, String(column.fieldName));
|
|
120
|
+
return null != titleFieldName && column.fieldName === titleFieldName ? [
|
|
121
|
+
dataCell,
|
|
122
|
+
/*#__PURE__*/ jsx(Table.Cell, {
|
|
123
|
+
className: clsx('byline-coll-history-restore-cell', history_module.restoreCell),
|
|
124
|
+
children: versionId && versionId !== currentVersionId ? /*#__PURE__*/ jsx(Button, {
|
|
125
|
+
type: "button",
|
|
126
|
+
variant: "outlined",
|
|
127
|
+
size: "xs",
|
|
128
|
+
intent: "noeffect",
|
|
129
|
+
onClick: openRestore,
|
|
130
|
+
className: clsx('byline-coll-history-restore-button', history_module.restoreButton),
|
|
131
|
+
title: t('collections.history.restoreButtonTitle', {
|
|
132
|
+
status: restoreStatusLabel
|
|
133
|
+
}),
|
|
134
|
+
children: t('collections.history.restoreButton')
|
|
135
|
+
}) : null
|
|
136
|
+
}, "__restore")
|
|
137
|
+
] : [
|
|
138
|
+
dataCell
|
|
139
|
+
];
|
|
140
|
+
})
|
|
141
|
+
};
|
|
101
142
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
102
143
|
children: [
|
|
103
144
|
/*#__PURE__*/ jsx(Section, {
|
|
@@ -113,8 +154,8 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, auditLog, workfl
|
|
|
113
154
|
label: labels.singular
|
|
114
155
|
}),
|
|
115
156
|
' ',
|
|
116
|
-
/*#__PURE__*/ jsx(
|
|
117
|
-
total: 'document' === activeTab ? auditLog?.meta.total ?? 0 : data
|
|
157
|
+
/*#__PURE__*/ jsx(HistoryStats, {
|
|
158
|
+
total: 'document' === activeTab ? auditLog?.meta.total ?? 0 : data.meta.total
|
|
118
159
|
})
|
|
119
160
|
]
|
|
120
161
|
}),
|
|
@@ -146,7 +187,7 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, auditLog, workfl
|
|
|
146
187
|
]
|
|
147
188
|
})
|
|
148
189
|
}),
|
|
149
|
-
'document' === activeTab
|
|
190
|
+
'document' === activeTab ? /*#__PURE__*/ jsx(DocumentHistoryView, {
|
|
150
191
|
data: auditLog ?? {
|
|
151
192
|
entries: [],
|
|
152
193
|
meta: {
|
|
@@ -156,268 +197,36 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, auditLog, workfl
|
|
|
156
197
|
totalPages: 0
|
|
157
198
|
}
|
|
158
199
|
}
|
|
159
|
-
}),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
label: column.label,
|
|
190
|
-
sortable: column.sortable,
|
|
191
|
-
scope: "col",
|
|
192
|
-
align: column.align,
|
|
193
|
-
className: column.className
|
|
194
|
-
}, String(column.fieldName));
|
|
195
|
-
if (null != titleFieldName && column.fieldName === titleFieldName) return [
|
|
196
|
-
cell,
|
|
197
|
-
/*#__PURE__*/ jsx("th", {
|
|
198
|
-
scope: "col",
|
|
199
|
-
className: clsx('byline-coll-history-col-restore', history_module.colRestore)
|
|
200
|
-
}, "__restore")
|
|
201
|
-
];
|
|
202
|
-
return [
|
|
203
|
-
cell
|
|
204
|
-
];
|
|
205
|
-
})
|
|
206
|
-
]
|
|
207
|
-
})
|
|
208
|
-
}),
|
|
209
|
-
/*#__PURE__*/ jsx(Table.Body, {
|
|
210
|
-
children: data?.docs?.map((document, rowIndex)=>{
|
|
211
|
-
const versionId = document.versionId;
|
|
212
|
-
const { total, page, pageSize, desc } = data.meta;
|
|
213
|
-
const versionNumber = desc ? total - (page - 1) * pageSize - rowIndex : (page - 1) * pageSize + rowIndex + 1;
|
|
214
|
-
const actorLabel = document.createdBy ? data.actors?.[document.createdBy]?.label ?? t('collections.history.audit.formerUser') : t('collections.history.audit.unknown');
|
|
215
|
-
const actionKey = document.eventType ? AUDIT_ACTION_KEYS[document.eventType] : void 0;
|
|
216
|
-
const actionLabel = actionKey ? t(actionKey) : document.eventType ?? '';
|
|
217
|
-
const auditColSpan = columns.length + (null != titleFieldName && columns.some((c)=>c.fieldName === titleFieldName) ? 1 : 0);
|
|
218
|
-
return /*#__PURE__*/ jsxs(external_react_Fragment, {
|
|
219
|
-
children: [
|
|
220
|
-
/*#__PURE__*/ jsxs(Table.Row, {
|
|
221
|
-
className: clsx('byline-coll-history-row', history_module.historyRow),
|
|
222
|
-
children: [
|
|
223
|
-
/*#__PURE__*/ jsx(Table.Cell, {
|
|
224
|
-
className: clsx('byline-coll-history-version-cell', history_module.versionCell),
|
|
225
|
-
children: versionId && currentDocument ? /*#__PURE__*/ jsx(IconButton, {
|
|
226
|
-
size: "xs",
|
|
227
|
-
variant: "outlined",
|
|
228
|
-
intent: "noeffect",
|
|
229
|
-
"aria-label": t('collections.history.compareAriaLabel'),
|
|
230
|
-
title: t('collections.history.compareTitle'),
|
|
231
|
-
className: clsx('byline-coll-history-version-button', history_module.versionButton),
|
|
232
|
-
onClick: ()=>setSelectedVersion({
|
|
233
|
-
versionId,
|
|
234
|
-
label: new Date(document.createdAt).toLocaleString()
|
|
235
|
-
}),
|
|
236
|
-
children: versionNumber
|
|
237
|
-
}) : null
|
|
238
|
-
}),
|
|
239
|
-
columns.flatMap((column)=>{
|
|
240
|
-
const dataCell = /*#__PURE__*/ jsx(Table.Cell, {
|
|
241
|
-
className: clsx({
|
|
242
|
-
'byline-coll-history-cell-right': 'right' === column.align,
|
|
243
|
-
[history_module.cellRight]: 'right' === column.align,
|
|
244
|
-
'byline-coll-history-cell-center': 'center' === column.align,
|
|
245
|
-
[history_module.cellCenter]: 'center' === column.align
|
|
246
|
-
}),
|
|
247
|
-
children: null != titleFieldName && column.fieldName === titleFieldName ? versionId && currentDocument ? /*#__PURE__*/ jsx("button", {
|
|
248
|
-
type: "button",
|
|
249
|
-
className: clsx('byline-coll-history-title-button', history_module.titleButton),
|
|
250
|
-
onClick: ()=>setSelectedVersion({
|
|
251
|
-
versionId,
|
|
252
|
-
label: new Date(document.createdAt).toLocaleString()
|
|
253
|
-
}),
|
|
254
|
-
children: column.formatter ? renderFormatted(getColumnValue(document, column.fieldName), document, column.formatter) : resolveDisplayValue(getColumnValue(document, column.fieldName), locale, defaultContentLocale) || '------'
|
|
255
|
-
}) : /*#__PURE__*/ jsx(Link, {
|
|
256
|
-
to: getAdminRoutePath('collections', '$collection', '$id'),
|
|
257
|
-
params: {
|
|
258
|
-
collection,
|
|
259
|
-
id: document.id
|
|
260
|
-
},
|
|
261
|
-
children: column.formatter ? renderFormatted(getColumnValue(document, column.fieldName), document, column.formatter) : resolveDisplayValue(getColumnValue(document, column.fieldName), locale, defaultContentLocale) || '------'
|
|
262
|
-
}) : column.formatter ? renderFormatted(getColumnValue(document, column.fieldName), document, column.formatter) : 'status' === column.fieldName && workflowStatuses ? /*#__PURE__*/ jsx(StatusBadge, {
|
|
263
|
-
status: document.status,
|
|
264
|
-
workflowStatuses: workflowStatuses
|
|
265
|
-
}) : resolveDisplayValue(getColumnValue(document, column.fieldName), locale, defaultContentLocale) || ''
|
|
266
|
-
}, String(column.fieldName));
|
|
267
|
-
if (null != titleFieldName && column.fieldName === titleFieldName) return [
|
|
268
|
-
dataCell,
|
|
269
|
-
/*#__PURE__*/ jsx(Table.Cell, {
|
|
270
|
-
className: clsx('byline-coll-history-restore-cell', history_module.restoreCell),
|
|
271
|
-
children: versionId && versionId !== currentVersionId ? /*#__PURE__*/ jsx(Button, {
|
|
272
|
-
type: "button",
|
|
273
|
-
variant: "outlined",
|
|
274
|
-
size: "xs",
|
|
275
|
-
intent: "noeffect",
|
|
276
|
-
onClick: ()=>setRestoreTarget({
|
|
277
|
-
versionId,
|
|
278
|
-
label: new Date(document.createdAt).toLocaleString(),
|
|
279
|
-
versionNumber
|
|
280
|
-
}),
|
|
281
|
-
className: clsx('byline-coll-history-restore-button', history_module.restoreButton),
|
|
282
|
-
title: t('collections.history.restoreButtonTitle'),
|
|
283
|
-
children: t('collections.history.restoreButton')
|
|
284
|
-
}) : null
|
|
285
|
-
}, "__restore")
|
|
286
|
-
];
|
|
287
|
-
return [
|
|
288
|
-
dataCell
|
|
289
|
-
];
|
|
290
|
-
})
|
|
291
|
-
]
|
|
292
|
-
}),
|
|
293
|
-
/*#__PURE__*/ jsxs(Table.Row, {
|
|
294
|
-
className: clsx('byline-coll-history-audit-row', history_module.auditRow),
|
|
295
|
-
"aria-label": t('collections.history.audit.createdBy', {
|
|
296
|
-
label: actorLabel
|
|
297
|
-
}),
|
|
298
|
-
children: [
|
|
299
|
-
/*#__PURE__*/ jsx(Table.Cell, {
|
|
300
|
-
className: clsx('byline-coll-history-audit-spacer-cell', history_module.auditSpacerCell)
|
|
301
|
-
}),
|
|
302
|
-
/*#__PURE__*/ jsx(Table.Cell, {
|
|
303
|
-
colSpan: auditColSpan,
|
|
304
|
-
className: clsx('byline-coll-history-audit-cell', history_module.auditCell),
|
|
305
|
-
children: /*#__PURE__*/ jsxs("span", {
|
|
306
|
-
className: clsx('byline-coll-history-audit', history_module.audit),
|
|
307
|
-
children: [
|
|
308
|
-
actionLabel,
|
|
309
|
-
' · ',
|
|
310
|
-
t('collections.history.audit.createdBy', {
|
|
311
|
-
label: actorLabel
|
|
312
|
-
}),
|
|
313
|
-
' · ',
|
|
314
|
-
new Date(document.createdAt).toLocaleString()
|
|
315
|
-
]
|
|
316
|
-
})
|
|
317
|
-
})
|
|
318
|
-
]
|
|
319
|
-
})
|
|
320
|
-
]
|
|
321
|
-
}, versionId ?? document.id);
|
|
322
|
-
})
|
|
323
|
-
})
|
|
324
|
-
]
|
|
325
|
-
}),
|
|
326
|
-
padRows(6 - (data?.docs?.length ?? 0))
|
|
327
|
-
]
|
|
328
|
-
}),
|
|
329
|
-
/*#__PURE__*/ jsxs("div", {
|
|
330
|
-
className: clsx('byline-coll-history-options byline-coll-history-options-bottom', history_module.options, history_module.optionsBottom),
|
|
331
|
-
children: [
|
|
332
|
-
/*#__PURE__*/ jsx(Select, {
|
|
333
|
-
containerClassName: clsx('byline-coll-history-page-size', history_module.pageSize),
|
|
334
|
-
id: "page_size",
|
|
335
|
-
name: "page_size",
|
|
336
|
-
size: "sm",
|
|
337
|
-
defaultValue: "15",
|
|
338
|
-
items: [
|
|
339
|
-
{
|
|
340
|
-
value: '15',
|
|
341
|
-
label: '15'
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
value: '30',
|
|
345
|
-
label: '30'
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
value: '50',
|
|
349
|
-
label: '50'
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
value: '100',
|
|
353
|
-
label: '100'
|
|
354
|
-
}
|
|
355
|
-
],
|
|
356
|
-
onValueChange: handleOnPageSizeChange
|
|
357
|
-
}),
|
|
358
|
-
/*#__PURE__*/ jsx(RouterPager, {
|
|
359
|
-
smoothScrollToTop: true,
|
|
360
|
-
page: data?.meta.page,
|
|
361
|
-
count: data?.meta.totalPages,
|
|
362
|
-
showFirstButton: true,
|
|
363
|
-
showLastButton: true,
|
|
364
|
-
componentName: "pagerBottom",
|
|
365
|
-
"aria-label": t('collections.list.pagerBottomAriaLabel')
|
|
366
|
-
})
|
|
367
|
-
]
|
|
368
|
-
})
|
|
369
|
-
]
|
|
370
|
-
})
|
|
371
|
-
}),
|
|
372
|
-
selectedVersion && currentDocument && /*#__PURE__*/ jsx(Suspense, {
|
|
373
|
-
fallback: null,
|
|
374
|
-
children: /*#__PURE__*/ jsx(DiffModal, {
|
|
375
|
-
isOpen: true,
|
|
376
|
-
onDismiss: ()=>setSelectedVersion(null),
|
|
377
|
-
collection: collection,
|
|
378
|
-
documentId: id,
|
|
379
|
-
versionId: selectedVersion.versionId,
|
|
380
|
-
versionLabel: selectedVersion.label,
|
|
381
|
-
currentDocument: currentDocument,
|
|
382
|
-
locale: locale,
|
|
383
|
-
loadHistoricalVersion: getCollectionDocumentVersion
|
|
384
|
-
})
|
|
385
|
-
}),
|
|
386
|
-
/*#__PURE__*/ jsx(Modal, {
|
|
387
|
-
isOpen: null != restoreTarget,
|
|
388
|
-
onDismiss: ()=>setRestoreTarget(null),
|
|
389
|
-
closeOnOverlayClick: false,
|
|
390
|
-
children: /*#__PURE__*/ jsxs(Modal.Container, {
|
|
391
|
-
className: clsx('byline-coll-history-restore-modal', history_module.restoreModal),
|
|
392
|
-
children: [
|
|
393
|
-
/*#__PURE__*/ jsxs(Modal.Header, {
|
|
394
|
-
className: clsx('byline-coll-history-restore-modal-head', history_module.restoreModalHead),
|
|
395
|
-
children: [
|
|
396
|
-
/*#__PURE__*/ jsx("h3", {
|
|
397
|
-
className: "m-0",
|
|
398
|
-
children: t('collections.history.restoreModalTitle')
|
|
399
|
-
}),
|
|
400
|
-
/*#__PURE__*/ jsx(IconButton, {
|
|
401
|
-
"aria-label": t('common.actions.close'),
|
|
402
|
-
size: "xs",
|
|
403
|
-
onClick: ()=>setRestoreTarget(null),
|
|
404
|
-
children: /*#__PURE__*/ jsx(CloseIcon, {
|
|
405
|
-
width: "14px",
|
|
406
|
-
height: "14px",
|
|
407
|
-
svgClassName: "white-icon"
|
|
408
|
-
})
|
|
409
|
-
})
|
|
410
|
-
]
|
|
411
|
-
}),
|
|
412
|
-
restoreTarget ? /*#__PURE__*/ jsx(RestoreVersionModal, {
|
|
413
|
-
collection: collection,
|
|
414
|
-
documentId: id,
|
|
415
|
-
versionId: restoreTarget.versionId,
|
|
416
|
-
versionLabel: restoreTarget.label,
|
|
417
|
-
versionNumber: restoreTarget.versionNumber,
|
|
418
|
-
onClose: ()=>setRestoreTarget(null)
|
|
419
|
-
}) : null
|
|
420
|
-
]
|
|
200
|
+
}) : /*#__PURE__*/ jsx(Section, {
|
|
201
|
+
children: /*#__PURE__*/ jsx(Container, {
|
|
202
|
+
children: /*#__PURE__*/ jsx(VersionHistoryCore, {
|
|
203
|
+
data: data,
|
|
204
|
+
resourceDefinition: collectionDefinition,
|
|
205
|
+
resourcePath: collection,
|
|
206
|
+
documentId: id,
|
|
207
|
+
currentDocument: currentDocument,
|
|
208
|
+
locale: locale,
|
|
209
|
+
rowPresentation: rowPresentation,
|
|
210
|
+
loadHistoricalVersion: getCollectionDocumentVersion,
|
|
211
|
+
onPageSizeChange: handlePageSizeChange,
|
|
212
|
+
restoreVersion: (versionId)=>restoreDocumentVersion({
|
|
213
|
+
data: {
|
|
214
|
+
collection,
|
|
215
|
+
id,
|
|
216
|
+
versionId
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
219
|
+
onRestoreComplete: async ()=>{
|
|
220
|
+
await router.invalidate();
|
|
221
|
+
navigate({
|
|
222
|
+
to: getAdminRoutePath('collections', '$collection', '$id'),
|
|
223
|
+
params: {
|
|
224
|
+
collection,
|
|
225
|
+
id
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
})
|
|
421
230
|
})
|
|
422
231
|
})
|
|
423
232
|
]
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
* backgrounded job (see docs/06-search/02-indexing-and-reindexing.md).
|
|
22
22
|
*/
|
|
23
23
|
import type React from 'react';
|
|
24
|
-
import type
|
|
24
|
+
import { type ListActionComponentProps } from '@byline/core';
|
|
25
25
|
export declare function ReindexButton({ collectionPath, }: ListActionComponentProps): React.JSX.Element | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
+
import { documentAbilityKey } from "@byline/core";
|
|
3
4
|
import { useTranslation } from "@byline/i18n/react";
|
|
4
5
|
import { Button, useToastManager } from "@byline/ui/react";
|
|
5
6
|
import { useAbility } from "../../integrations/abilities.js";
|
|
@@ -7,7 +8,10 @@ import { reindexCollection } from "../../server-fns/collections/reindex.js";
|
|
|
7
8
|
function ReindexButton({ collectionPath }) {
|
|
8
9
|
const { t } = useTranslation('byline-admin');
|
|
9
10
|
const toastManager = useToastManager();
|
|
10
|
-
const canReindex = useAbility(
|
|
11
|
+
const canReindex = useAbility(documentAbilityKey({
|
|
12
|
+
kind: 'collection',
|
|
13
|
+
path: collectionPath
|
|
14
|
+
}, 'reindex'));
|
|
11
15
|
const [pending, setPending] = useState(false);
|
|
12
16
|
if (!canReindex) return null;
|
|
13
17
|
const onClick = async ()=>{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
interface RestoreVersionModalProps {
|
|
2
|
-
collection: string;
|
|
3
|
-
documentId: string;
|
|
4
|
-
versionId: string;
|
|
5
2
|
versionLabel: string;
|
|
6
3
|
versionNumber: number;
|
|
4
|
+
restoreStatusLabel: string;
|
|
7
5
|
onClose: () => void;
|
|
6
|
+
restoreVersion: () => Promise<unknown>;
|
|
7
|
+
onRestoreComplete: () => void | Promise<void>;
|
|
8
8
|
}
|
|
9
|
-
export declare function RestoreVersionModal({
|
|
9
|
+
export declare function RestoreVersionModal({ versionLabel, versionNumber, restoreStatusLabel, onClose, restoreVersion, onRestoreComplete, }: RestoreVersionModalProps): import("react").JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { useRouter } from "@tanstack/react-router";
|
|
5
4
|
import { useTranslation } from "@byline/i18n/react";
|
|
6
5
|
import { Alert, Button, LoaderEllipsis, Modal } from "@byline/ui/react";
|
|
7
6
|
import clsx from "clsx";
|
|
8
|
-
import { getAdminRoutePath } from "../../routes/admin-path.js";
|
|
9
|
-
import { restoreDocumentVersion } from "../../server-fns/collections/index.js";
|
|
10
|
-
import { useNavigate } from "../chrome/loose-router.js";
|
|
11
7
|
import restore_version_modal_module from "./restore-version-modal.module.js";
|
|
12
|
-
function RestoreVersionModal({
|
|
13
|
-
const navigate = useNavigate();
|
|
14
|
-
const router = useRouter();
|
|
8
|
+
function RestoreVersionModal({ versionLabel, versionNumber, restoreStatusLabel, onClose, restoreVersion, onRestoreComplete }) {
|
|
15
9
|
const { t } = useTranslation('byline-admin');
|
|
16
10
|
const [error, setError] = useState(null);
|
|
17
11
|
const [pending, setPending] = useState(false);
|
|
@@ -20,22 +14,9 @@ function RestoreVersionModal({ collection, documentId, versionId, versionLabel,
|
|
|
20
14
|
setPending(true);
|
|
21
15
|
setError(null);
|
|
22
16
|
try {
|
|
23
|
-
await
|
|
24
|
-
data: {
|
|
25
|
-
collection,
|
|
26
|
-
id: documentId,
|
|
27
|
-
versionId
|
|
28
|
-
}
|
|
29
|
-
});
|
|
17
|
+
await restoreVersion();
|
|
30
18
|
onClose();
|
|
31
|
-
await
|
|
32
|
-
navigate({
|
|
33
|
-
to: getAdminRoutePath('collections', '$collection', '$id'),
|
|
34
|
-
params: {
|
|
35
|
-
collection,
|
|
36
|
-
id: documentId
|
|
37
|
-
}
|
|
38
|
-
});
|
|
19
|
+
await onRestoreComplete();
|
|
39
20
|
} catch (err) {
|
|
40
21
|
const code = getErrorCode(err);
|
|
41
22
|
if ('ERR_INVALID_TRANSITION' === code) setError(t('collections.restore.errors.alreadyCurrent'));
|
|
@@ -80,7 +61,8 @@ function RestoreVersionModal({ collection, documentId, versionId, versionLabel,
|
|
|
80
61
|
/*#__PURE__*/ jsx("p", {
|
|
81
62
|
className: clsx('byline-coll-restore-warning', restore_version_modal_module.warning),
|
|
82
63
|
children: t('collections.restore.warning', {
|
|
83
|
-
version: versionNumber
|
|
64
|
+
version: versionNumber,
|
|
65
|
+
status: restoreStatusLabel
|
|
84
66
|
})
|
|
85
67
|
})
|
|
86
68
|
]
|
|
@@ -118,7 +100,9 @@ function RestoreVersionModal({ collection, documentId, versionId, versionLabel,
|
|
|
118
100
|
className: clsx('byline-coll-restore-button', restore_version_modal_module.button),
|
|
119
101
|
children: true === pending ? /*#__PURE__*/ jsx(LoaderEllipsis, {
|
|
120
102
|
size: 42
|
|
121
|
-
}) : t('collections.restore.confirmButton'
|
|
103
|
+
}) : t('collections.restore.confirmButton', {
|
|
104
|
+
status: restoreStatusLabel
|
|
105
|
+
})
|
|
122
106
|
})
|
|
123
107
|
]
|
|
124
108
|
})
|