@byline/host-tanstack-start 1.0.6 → 1.2.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.
Files changed (79) hide show
  1. package/dist/admin-shell/admin-roles/container.js +1 -3
  2. package/dist/admin-shell/admin-roles/delete.js +1 -1
  3. package/dist/admin-shell/admin-roles/list.js +1 -3
  4. package/dist/admin-shell/admin-users/container.js +1 -3
  5. package/dist/admin-shell/admin-users/delete.js +1 -1
  6. package/dist/admin-shell/admin-users/list.js +1 -3
  7. package/dist/admin-shell/chrome/admin-app-bar.js +1 -1
  8. package/dist/admin-shell/chrome/dashboard.js +1 -1
  9. package/dist/admin-shell/chrome/drawer-toggle.js +1 -1
  10. package/dist/admin-shell/chrome/menu-drawer.js +1 -1
  11. package/dist/admin-shell/chrome/preview-toggle.js +1 -1
  12. package/dist/admin-shell/chrome/route-error.js +1 -1
  13. package/dist/admin-shell/chrome/router-pager.d.ts +1 -1
  14. package/dist/admin-shell/chrome/router-pager.js +1 -1
  15. package/dist/admin-shell/chrome/sign-in-page.js +1 -1
  16. package/dist/admin-shell/chrome/th-sortable.js +1 -1
  17. package/dist/admin-shell/collections/api.js +1 -1
  18. package/dist/admin-shell/collections/create.js +1 -2
  19. package/dist/admin-shell/collections/edit.js +1 -2
  20. package/dist/admin-shell/collections/history.js +83 -8
  21. package/dist/admin-shell/collections/history.module.js +5 -0
  22. package/dist/admin-shell/collections/history_module.css +46 -0
  23. package/dist/admin-shell/collections/list.js +1 -3
  24. package/dist/admin-shell/collections/preview-link.js +1 -1
  25. package/dist/admin-shell/collections/restore-version-modal.d.ts +10 -0
  26. package/dist/admin-shell/collections/restore-version-modal.js +118 -0
  27. package/dist/admin-shell/collections/restore-version-modal.module.js +10 -0
  28. package/dist/admin-shell/collections/restore-version-modal_module.css +31 -0
  29. package/dist/admin-shell/collections/tanstack-navigation-guard.d.ts +1 -1
  30. package/dist/admin-shell/collections/view-menu.js +1 -1
  31. package/dist/integrations/byline-admin-services.d.ts +1 -1
  32. package/dist/integrations/byline-field-services.d.ts +1 -1
  33. package/dist/routes/create-admin-account-route.js +1 -2
  34. package/dist/routes/create-admin-layout-route.js +1 -2
  35. package/dist/routes/create-admin-permissions-route.js +1 -1
  36. package/dist/routes/create-admin-role-edit-route.js +1 -1
  37. package/dist/routes/create-admin-user-edit-route.js +1 -1
  38. package/dist/routes/create-collection-list-route.js +1 -1
  39. package/dist/server-fns/collections/index.d.ts +1 -0
  40. package/dist/server-fns/collections/index.js +1 -0
  41. package/dist/server-fns/collections/restore-version.d.ts +21 -0
  42. package/dist/server-fns/collections/restore-version.js +41 -0
  43. package/package.json +10 -10
  44. package/src/admin-shell/admin-roles/container.tsx +2 -3
  45. package/src/admin-shell/admin-roles/delete.tsx +1 -1
  46. package/src/admin-shell/admin-roles/list.tsx +2 -3
  47. package/src/admin-shell/admin-users/container.tsx +2 -3
  48. package/src/admin-shell/admin-users/delete.tsx +1 -1
  49. package/src/admin-shell/admin-users/list.tsx +2 -3
  50. package/src/admin-shell/chrome/admin-app-bar.tsx +1 -1
  51. package/src/admin-shell/chrome/dashboard.tsx +1 -1
  52. package/src/admin-shell/chrome/drawer-toggle.tsx +1 -1
  53. package/src/admin-shell/chrome/menu-drawer.tsx +1 -1
  54. package/src/admin-shell/chrome/preview-toggle.tsx +1 -1
  55. package/src/admin-shell/chrome/route-error.tsx +1 -1
  56. package/src/admin-shell/chrome/router-pager.tsx +2 -2
  57. package/src/admin-shell/chrome/sign-in-page.tsx +1 -1
  58. package/src/admin-shell/chrome/th-sortable.tsx +1 -1
  59. package/src/admin-shell/collections/api.tsx +1 -1
  60. package/src/admin-shell/collections/create.tsx +2 -2
  61. package/src/admin-shell/collections/edit.tsx +2 -2
  62. package/src/admin-shell/collections/history.module.css +50 -1
  63. package/src/admin-shell/collections/history.tsx +151 -72
  64. package/src/admin-shell/collections/list.tsx +2 -3
  65. package/src/admin-shell/collections/preview-link.tsx +1 -1
  66. package/src/admin-shell/collections/restore-version-modal.module.css +48 -0
  67. package/src/admin-shell/collections/restore-version-modal.tsx +131 -0
  68. package/src/admin-shell/collections/tanstack-navigation-guard.ts +1 -1
  69. package/src/admin-shell/collections/view-menu.tsx +1 -1
  70. package/src/integrations/byline-admin-services.ts +1 -1
  71. package/src/integrations/byline-field-services.ts +1 -5
  72. package/src/routes/create-admin-account-route.tsx +2 -2
  73. package/src/routes/create-admin-layout-route.tsx +1 -2
  74. package/src/routes/create-admin-permissions-route.tsx +1 -1
  75. package/src/routes/create-admin-role-edit-route.tsx +1 -1
  76. package/src/routes/create-admin-user-edit-route.tsx +1 -1
  77. package/src/routes/create-collection-list-route.tsx +1 -1
  78. package/src/server-fns/collections/index.ts +1 -0
  79. package/src/server-fns/collections/restore-version.ts +59 -0
@@ -2,9 +2,7 @@
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useState } from "react";
4
4
  import { useRouter } from "@tanstack/react-router";
5
- import { Button, CloseIcon, Drawer, IconButton, Modal, useToastManager } from "@byline/ui";
6
- import { RolePermissions, UpdateRole } from "@byline/ui/react/admin";
7
- import { LocalDateTime } from "@byline/ui/react/fields";
5
+ import { Button, CloseIcon, Drawer, IconButton, LocalDateTime, Modal, RolePermissions, UpdateRole, useToastManager } from "@byline/ui/react";
8
6
  import classnames from "classnames";
9
7
  import container_module from "./container.module.js";
10
8
  import { DeleteRole } from "./delete.js";
@@ -2,7 +2,7 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useState } from "react";
4
4
  import { useRouter } from "@tanstack/react-router";
5
- import { Alert, Button, LoaderEllipsis, Modal } from "@byline/ui";
5
+ import { Alert, Button, LoaderEllipsis, Modal } from "@byline/ui/react";
6
6
  import classnames from "classnames";
7
7
  import { deleteAdminRole } from "../../server-fns/admin-roles/index.js";
8
8
  import { useNavigate } from "../chrome/loose-router.js";
@@ -2,9 +2,7 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from "react";
4
4
  import { useRouter } from "@tanstack/react-router";
5
- import { Button, CloseIcon, Container, DraggableSortable, Drawer, GripperVerticalIcon, IconButton, LoaderEllipsis, PlusIcon, Section, Table, moveItem, useSortable, useToastManager } from "@byline/ui";
6
- import { CreateAdminRole } from "@byline/ui/react/admin";
7
- import { LocalDateTime } from "@byline/ui/react/fields";
5
+ import { Button, CloseIcon, Container, CreateAdminRole, DraggableSortable, Drawer, GripperVerticalIcon, IconButton, LoaderEllipsis, LocalDateTime, PlusIcon, Section, Table, moveItem, useSortable, useToastManager } from "@byline/ui/react";
8
6
  import classnames from "classnames";
9
7
  import { reorderAdminRoles } from "../../server-fns/admin-roles/reorder.js";
10
8
  import { Link } from "../chrome/loose-router.js";
@@ -2,9 +2,7 @@
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useState } from "react";
4
4
  import { useRouter } from "@tanstack/react-router";
5
- import { Button, CloseIcon, Drawer, EditIcon, IconButton, Modal, useToastManager } from "@byline/ui";
6
- import { SetPassword, UpdateUser, UserRoles } from "@byline/ui/react/admin";
7
- import { LocalDateTime } from "@byline/ui/react/fields";
5
+ import { Button, CloseIcon, Drawer, EditIcon, IconButton, LocalDateTime, Modal, SetPassword, UpdateUser, UserRoles, useToastManager } from "@byline/ui/react";
8
6
  import classnames from "classnames";
9
7
  import container_module from "./container.module.js";
10
8
  import { DeleteUser } from "./delete.js";
@@ -2,7 +2,7 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useState } from "react";
4
4
  import { useRouter } from "@tanstack/react-router";
5
- import { Alert, Button, LoaderEllipsis, Modal } from "@byline/ui";
5
+ import { Alert, Button, LoaderEllipsis, Modal } from "@byline/ui/react";
6
6
  import classnames from "classnames";
7
7
  import { deleteAdminUser } from "../../server-fns/admin-users/index.js";
8
8
  import { useNavigate } from "../chrome/loose-router.js";
@@ -2,9 +2,7 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useState } from "react";
4
4
  import { useRouter, useRouterState } from "@tanstack/react-router";
5
- import { CloseIcon, Container, Drawer, IconButton, PlusIcon, Search, Section, Select, Table, useToastManager } from "@byline/ui";
6
- import { CreateAdminUser } from "@byline/ui/react/admin";
7
- import { LocalDateTime } from "@byline/ui/react/fields";
5
+ import { CloseIcon, Container, CreateAdminUser, Drawer, IconButton, LocalDateTime, PlusIcon, Search, Section, Select, Table, useToastManager } from "@byline/ui/react";
8
6
  import classnames from "classnames";
9
7
  import { Link, useNavigate } from "../chrome/loose-router.js";
10
8
  import { RouterPager } from "../chrome/router-pager.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useState } from "react";
4
- import { Button } from "@byline/ui";
4
+ import { Button } from "@byline/ui/react";
5
5
  import classnames from "classnames";
6
6
  import { adminSignOut } from "../../server-fns/auth/index.js";
7
7
  import admin_app_bar_module from "./admin-app-bar.module.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { getClientConfig, getWorkflowStatuses } from "@byline/core";
3
- import { Card, Container, Section } from "@byline/ui";
3
+ import { Card, Container, Section } from "@byline/ui/react";
4
4
  import classnames from "classnames";
5
5
  import dashboard_module from "./dashboard.module.js";
6
6
  import { Link } from "./loose-router.js";
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { IconButton, Tooltip } from "@byline/ui";
2
+ import { IconButton, Tooltip } from "@byline/ui/react";
3
3
  import classnames from "classnames";
4
4
  import drawer_toggle_module from "./drawer-toggle.module.js";
5
5
  import { useAdminMenu } from "./menu-provider.js";
@@ -3,7 +3,7 @@ import { useRouterState } from "@tanstack/react-router";
3
3
  import { ADMIN_PERMISSIONS_ABILITIES } from "@byline/admin/admin-permissions";
4
4
  import { ADMIN_ROLES_ABILITIES } from "@byline/admin/admin-roles";
5
5
  import { ADMIN_USERS_ABILITIES } from "@byline/admin/admin-users";
6
- import { HomeIcon, RolesIcon, SettingsSlidersIcon, UserIcon, UsersIcon } from "@byline/ui";
6
+ import { HomeIcon, RolesIcon, SettingsSlidersIcon, UserIcon, UsersIcon } from "@byline/ui/react";
7
7
  import classnames from "classnames";
8
8
  import { useSwipeable } from "react-swipeable";
9
9
  import { useAbilities } from "../../integrations/abilities.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
- import { EyeClosedIcon, EyeOpenIcon } from "@byline/ui";
3
+ import { EyeClosedIcon, EyeOpenIcon } from "@byline/ui/react";
4
4
  import classnames from "classnames";
5
5
  import { disablePreviewModeFn, enablePreviewModeFn, getPreviewStateFn } from "../../server-fns/preview/index.js";
6
6
  function PreviewToggle({ compact }) {
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useRouter } from "@tanstack/react-router";
3
3
  import { BylineError, ErrorCodes } from "@byline/core";
4
- import { Alert, Button, Container, Section } from "@byline/ui";
4
+ import { Alert, Button, Container, Section } from "@byline/ui/react";
5
5
  import classnames from "classnames";
6
6
  import route_error_module from "./route-error.module.js";
7
7
  const ERROR_TITLES = {
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Copyright (c) Infonomic Company Limited
7
7
  */
8
- import type { PaginationProps } from '@byline/ui';
8
+ import type { PaginationProps } from '@byline/ui/react';
9
9
  interface RouterPageProps extends PaginationProps {
10
10
  smoothScrollToTop?: boolean;
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useRouterState } from "@tanstack/react-router";
3
- import { ChevronLeftDoubleIcon, ChevronLeftIcon, ChevronRightDoubleIcon, ChevronRightIcon, Pagination } from "@byline/ui";
3
+ import { ChevronLeftDoubleIcon, ChevronLeftIcon, ChevronRightDoubleIcon, ChevronRightIcon, Pagination } from "@byline/ui/react";
4
4
  import { Link } from "./loose-router.js";
5
5
  function RouterPager({ className, smoothScrollToTop, 'aria-label': ariaLabel, ...rest }) {
6
6
  const location = useRouterState({
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { BylineAdminServicesProvider, SignInForm } from "@byline/ui/react/admin";
2
+ import { BylineAdminServicesProvider, SignInForm } from "@byline/ui/react";
3
3
  import classnames from "classnames";
4
4
  import { bylineAdminServices } from "../../integrations/byline-admin-services.js";
5
5
  import sign_in_page_module from "./sign-in-page.module.js";
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import { useRouterState } from "@tanstack/react-router";
4
- import { Table } from "@byline/ui";
4
+ import { Table } from "@byline/ui/react";
5
5
  import classnames from "classnames";
6
6
  import { useNavigate } from "./loose-router.js";
7
7
  import { SortAscendingIcon, SortDescendingIcon, SortNeutralIcon } from "./sort-icons.js";
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Container, Section } from "@byline/ui";
2
+ import { Container, Section } from "@byline/ui/react";
3
3
  import classnames from "classnames";
4
4
  import { JsonView, allExpanded, darkStyles } from "react-json-view-lite";
5
5
  import api_module from "./api.module.js";
@@ -1,7 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
- import { Container, Section, useToastManager } from "@byline/ui";
4
- import { FormRenderer } from "@byline/ui/react/forms";
3
+ import { Container, FormRenderer, Section, useToastManager } from "@byline/ui/react";
5
4
  import { createCollectionDocument } from "../../server-fns/collections/index.js";
6
5
  import { useNavigate } from "../chrome/loose-router.js";
7
6
  import { useTanStackNavigationGuard } from "./tanstack-navigation-guard.js";
@@ -1,8 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
3
  import { getDefaultStatus, getWorkflowStatuses } from "@byline/core";
4
- import { Container, Section, useToastManager } from "@byline/ui";
5
- import { FormRenderer } from "@byline/ui/react/forms";
4
+ import { Container, FormRenderer, Section, useToastManager } from "@byline/ui/react";
6
5
  import { deleteDocument, unpublishDocument, updateCollectionDocumentWithPatches, updateDocumentStatus } from "../../server-fns/collections/index.js";
7
6
  import { useNavigate } from "../chrome/loose-router.js";
8
7
  import { useTanStackNavigationGuard } from "./tanstack-navigation-guard.js";
@@ -1,21 +1,20 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Suspense, lazy, useState } from "react";
3
3
  import { useParams, useRouterState } from "@tanstack/react-router";
4
- import { Container, IconButton, Section, Select, Table } from "@byline/ui";
5
- import { StatusBadge } from "@byline/ui/react/admin";
6
- import { renderFormatted } from "@byline/ui/react/fields";
4
+ import { Button, CloseIcon, Container, IconButton, Modal, Section, Select, StatusBadge, Table, renderFormatted } from "@byline/ui/react";
7
5
  import classnames from "classnames";
8
6
  import { Link, useNavigate } from "../chrome/loose-router.js";
9
7
  import { RouterPager } from "../chrome/router-pager.js";
10
8
  import { TableHeadingCellSortable } from "../chrome/th-sortable.js";
11
9
  import { formatNumber } from "../chrome/utils.js";
12
10
  import history_module from "./history.module.js";
11
+ import { RestoreVersionModal } from "./restore-version-modal.js";
13
12
  import { ViewMenu } from "./view-menu.js";
14
13
  function getColumnValue(document, fieldName) {
15
14
  if (document.fields && fieldName in document.fields) return document.fields[fieldName];
16
15
  return document[fieldName];
17
16
  }
18
- const DiffModal = /*#__PURE__*/ lazy(()=>import("@byline/ui/react/admin").then((m)=>({
17
+ const DiffModal = /*#__PURE__*/ lazy(()=>import("@byline/ui/react").then((m)=>({
19
18
  default: m.DiffModal
20
19
  })));
21
20
  function resolveDisplayValue(value, locale, defaultContentLocale) {
@@ -53,6 +52,8 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, workflowStatuses
53
52
  });
54
53
  const locale = location.search.locale;
55
54
  const [selectedVersion, setSelectedVersion] = useState(null);
55
+ const [restoreTarget, setRestoreTarget] = useState(null);
56
+ const currentVersionId = currentDocument && 'string' == typeof currentDocument.versionId ? currentDocument.versionId : null;
56
57
  function handleOnPageSizeChange(value) {
57
58
  if ('string' != typeof value || 0 === value.length) return;
58
59
  const params = structuredClone(location.search);
@@ -121,14 +122,26 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, workflowStatuses
121
122
  scope: "col",
122
123
  className: classnames('byline-coll-history-col-version', history_module.colVersion)
123
124
  }),
124
- columns.map((column)=>/*#__PURE__*/ jsx(TableHeadingCellSortable, {
125
+ columns.flatMap((column)=>{
126
+ const cell = /*#__PURE__*/ jsx(TableHeadingCellSortable, {
125
127
  fieldName: String(column.fieldName),
126
128
  label: column.label,
127
129
  sortable: column.sortable,
128
130
  scope: "col",
129
131
  align: column.align,
130
132
  className: column.className
131
- }, String(column.fieldName)))
133
+ }, String(column.fieldName));
134
+ if ('title' === column.fieldName) return [
135
+ cell,
136
+ /*#__PURE__*/ jsx("th", {
137
+ scope: "col",
138
+ className: classnames('byline-coll-history-col-restore', history_module.colRestore)
139
+ }, "__restore")
140
+ ];
141
+ return [
142
+ cell
143
+ ];
144
+ })
132
145
  ]
133
146
  })
134
147
  }),
@@ -155,7 +168,8 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, workflowStatuses
155
168
  children: versionNumber
156
169
  }) : null
157
170
  }),
158
- columns.map((column)=>/*#__PURE__*/ jsx(Table.Cell, {
171
+ columns.flatMap((column)=>{
172
+ const dataCell = /*#__PURE__*/ jsx(Table.Cell, {
159
173
  className: classnames({
160
174
  'byline-coll-history-cell-right': 'right' === column.align,
161
175
  [history_module.cellRight]: 'right' === column.align,
@@ -181,7 +195,31 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, workflowStatuses
181
195
  status: document.status,
182
196
  workflowStatuses: workflowStatuses
183
197
  }) : resolveDisplayValue(getColumnValue(document, column.fieldName), locale, defaultContentLocale) || ''
184
- }, String(column.fieldName)))
198
+ }, String(column.fieldName));
199
+ if ('title' === column.fieldName) return [
200
+ dataCell,
201
+ /*#__PURE__*/ jsx(Table.Cell, {
202
+ className: classnames('byline-coll-history-restore-cell', history_module.restoreCell),
203
+ children: versionId && versionId !== currentVersionId ? /*#__PURE__*/ jsx(Button, {
204
+ type: "button",
205
+ variant: "outlined",
206
+ size: "xs",
207
+ intent: "noeffect",
208
+ onClick: ()=>setRestoreTarget({
209
+ versionId,
210
+ label: new Date(document.createdAt).toLocaleString(),
211
+ versionNumber
212
+ }),
213
+ className: classnames('byline-coll-history-restore-button', history_module.restoreButton),
214
+ title: "Restore this version as the current draft",
215
+ children: "Restore"
216
+ }) : null
217
+ }, "__restore")
218
+ ];
219
+ return [
220
+ dataCell
221
+ ];
222
+ })
185
223
  ]
186
224
  }, versionId ?? document.id);
187
225
  })
@@ -246,6 +284,43 @@ const HistoryView = ({ collectionDefinition, adminConfig, data, workflowStatuses
246
284
  currentDocument: currentDocument,
247
285
  locale: locale
248
286
  })
287
+ }),
288
+ /*#__PURE__*/ jsx(Modal, {
289
+ isOpen: null != restoreTarget,
290
+ onDismiss: ()=>setRestoreTarget(null),
291
+ closeOnOverlayClick: false,
292
+ children: /*#__PURE__*/ jsxs(Modal.Container, {
293
+ className: classnames('byline-coll-history-restore-modal', history_module.restoreModal),
294
+ children: [
295
+ /*#__PURE__*/ jsxs(Modal.Header, {
296
+ className: classnames('byline-coll-history-restore-modal-head', history_module.restoreModalHead),
297
+ children: [
298
+ /*#__PURE__*/ jsx("h3", {
299
+ className: "m-0",
300
+ children: "Restore version"
301
+ }),
302
+ /*#__PURE__*/ jsx(IconButton, {
303
+ "aria-label": "Close",
304
+ size: "xs",
305
+ onClick: ()=>setRestoreTarget(null),
306
+ children: /*#__PURE__*/ jsx(CloseIcon, {
307
+ width: "14px",
308
+ height: "14px",
309
+ svgClassName: "white-icon"
310
+ })
311
+ })
312
+ ]
313
+ }),
314
+ restoreTarget ? /*#__PURE__*/ jsx(RestoreVersionModal, {
315
+ collection: collection,
316
+ documentId: id,
317
+ versionId: restoreTarget.versionId,
318
+ versionLabel: restoreTarget.label,
319
+ versionNumber: restoreTarget.versionNumber,
320
+ onClose: ()=>setRestoreTarget(null)
321
+ }) : null
322
+ ]
323
+ })
249
324
  })
250
325
  ]
251
326
  });
@@ -13,6 +13,11 @@ const history_module = {
13
13
  colVersion: "colVersion-xGf5qV",
14
14
  versionButton: "versionButton-DXCZwj",
15
15
  titleButton: "titleButton-RPuvJm",
16
+ colRestore: "colRestore-D3b2hI",
17
+ restoreCell: "restoreCell-Exf1wn",
18
+ restoreButton: "restoreButton-axrnAL",
19
+ restoreModal: "restoreModal-tNkjf6",
20
+ restoreModalHead: "restoreModalHead-cJAc46",
16
21
  pageSize: "pageSize-yT2Yee"
17
22
  };
18
23
  export default history_module;
@@ -113,6 +113,52 @@
113
113
  opacity: .75;
114
114
  }
115
115
 
116
+ :is(.colRestore-D3b2hI, .byline-coll-history-col-restore) {
117
+ white-space: nowrap;
118
+ background-color: var(--gray-50);
119
+ width: 1%;
120
+ }
121
+
122
+ :is(:is([data-theme="dark"], .dark) .colRestore-D3b2hI, :is([data-theme="dark"], .dark) .byline-coll-history-col-restore) {
123
+ background-color: oklch(from var(--canvas-800) calc(l * 1.1) c h);
124
+ }
125
+
126
+ :is(.restoreCell-Exf1wn, .byline-coll-history-restore-cell) {
127
+ white-space: nowrap;
128
+ }
129
+
130
+ :is(.restoreButton-axrnAL, .byline-coll-history-restore-button) {
131
+ opacity: 0;
132
+ transition: opacity .15s;
133
+ }
134
+
135
+ tr:hover .restoreButton-axrnAL {
136
+ opacity: 1;
137
+ }
138
+
139
+ tr:hover .byline-coll-history-restore-button {
140
+ opacity: 1;
141
+ }
142
+
143
+ .restoreButton-axrnAL:focus {
144
+ opacity: 1;
145
+ }
146
+
147
+ .byline-coll-history-restore-button:focus {
148
+ opacity: 1;
149
+ }
150
+
151
+ :is(.restoreModal-tNkjf6, .byline-coll-history-restore-modal) {
152
+ max-width: 32rem;
153
+ }
154
+
155
+ :is(.restoreModalHead-cJAc46, .byline-coll-history-restore-modal-head) {
156
+ justify-content: space-between;
157
+ align-items: center;
158
+ margin-bottom: 1rem;
159
+ display: flex;
160
+ }
161
+
116
162
  @media (min-width: 40rem) {
117
163
  :is(.pageSize-yT2Yee, .byline-coll-history-page-size) {
118
164
  margin-left: auto;
@@ -1,9 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useMemo, useState } from "react";
3
3
  import { useRouterState } from "@tanstack/react-router";
4
- import { Container, IconButton, LoaderRing, PlusIcon, Search, Section, Select, Table } from "@byline/ui";
5
- import { StatusBadge } from "@byline/ui/react/admin";
6
- import { renderFormatted } from "@byline/ui/react/fields";
4
+ import { Container, IconButton, LoaderRing, PlusIcon, Search, Section, Select, StatusBadge, Table, renderFormatted } from "@byline/ui/react";
7
5
  import classnames from "classnames";
8
6
  import { Link, useNavigate } from "../chrome/loose-router.js";
9
7
  import { RouterPager } from "../chrome/router-pager.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
- import { ExternalLinkIcon, IconButton, useToastManager } from "@byline/ui";
3
+ import { ExternalLinkIcon, IconButton, useToastManager } from "@byline/ui/react";
4
4
  import classnames from "classnames";
5
5
  import { enablePreviewModeFn } from "../../server-fns/preview/index.js";
6
6
  function resolvePreviewUrl(doc, collectionPath, adminConfig, locale) {
@@ -0,0 +1,10 @@
1
+ interface RestoreVersionModalProps {
2
+ collection: string;
3
+ documentId: string;
4
+ versionId: string;
5
+ versionLabel: string;
6
+ versionNumber: number;
7
+ onClose: () => void;
8
+ }
9
+ export declare function RestoreVersionModal({ collection, documentId, versionId, versionLabel, versionNumber, onClose, }: RestoreVersionModalProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,118 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { useRouter } from "@tanstack/react-router";
5
+ import { Alert, Button, LoaderEllipsis, Modal } from "@byline/ui/react";
6
+ import classnames from "classnames";
7
+ import { restoreDocumentVersion } from "../../server-fns/collections/index.js";
8
+ import { useNavigate } from "../chrome/loose-router.js";
9
+ import restore_version_modal_module from "./restore-version-modal.module.js";
10
+ function RestoreVersionModal({ collection, documentId, versionId, versionLabel, versionNumber, onClose }) {
11
+ const navigate = useNavigate();
12
+ const router = useRouter();
13
+ const [error, setError] = useState(null);
14
+ const [pending, setPending] = useState(false);
15
+ async function handleRestore() {
16
+ if (pending) return;
17
+ setPending(true);
18
+ setError(null);
19
+ try {
20
+ await restoreDocumentVersion({
21
+ data: {
22
+ collection,
23
+ id: documentId,
24
+ versionId
25
+ }
26
+ });
27
+ onClose();
28
+ await router.invalidate();
29
+ navigate({
30
+ to: '/admin/collections/$collection/$id',
31
+ params: {
32
+ collection,
33
+ id: documentId
34
+ }
35
+ });
36
+ } catch (err) {
37
+ const code = getErrorCode(err);
38
+ if ('ERR_INVALID_TRANSITION' === code) setError('This version is already the current version of the document.');
39
+ else if ('ERR_NOT_FOUND' === code) setError('The selected version could not be found. The history may be out of date.');
40
+ else 'ERR_FORBIDDEN' === code || 'ERR_UNAUTHENTICATED' === code ? setError('You do not have permission to restore versions for this collection.') : setError('Could not restore this version. Please try again.');
41
+ setPending(false);
42
+ }
43
+ }
44
+ return /*#__PURE__*/ jsxs(Modal.Content, {
45
+ className: classnames('byline-coll-restore-content', restore_version_modal_module.content),
46
+ children: [
47
+ /*#__PURE__*/ jsxs("div", {
48
+ className: classnames('byline-coll-restore-body', restore_version_modal_module.body),
49
+ children: [
50
+ error ? /*#__PURE__*/ jsx(Alert, {
51
+ intent: "danger",
52
+ close: false,
53
+ children: error
54
+ }) : null,
55
+ /*#__PURE__*/ jsxs("p", {
56
+ className: classnames('byline-coll-restore-row', restore_version_modal_module.row),
57
+ children: [
58
+ /*#__PURE__*/ jsx("span", {
59
+ className: "muted",
60
+ children: "Version:"
61
+ }),
62
+ " ",
63
+ versionNumber
64
+ ]
65
+ }),
66
+ /*#__PURE__*/ jsxs("p", {
67
+ className: classnames('byline-coll-restore-row', restore_version_modal_module.row),
68
+ children: [
69
+ /*#__PURE__*/ jsx("span", {
70
+ className: "muted",
71
+ children: "Created:"
72
+ }),
73
+ " ",
74
+ versionLabel
75
+ ]
76
+ }),
77
+ /*#__PURE__*/ jsxs("p", {
78
+ className: classnames('byline-coll-restore-warning', restore_version_modal_module.warning),
79
+ children: [
80
+ "This will create a new draft version of this document with the content from version",
81
+ ' ',
82
+ versionNumber,
83
+ ", and that draft will become the current version. The existing versions (including any published version) are preserved in history. The restored draft will need to be published through the normal workflow."
84
+ ]
85
+ })
86
+ ]
87
+ }),
88
+ /*#__PURE__*/ jsxs("div", {
89
+ className: classnames('byline-coll-restore-actions', restore_version_modal_module.actions),
90
+ children: [
91
+ /*#__PURE__*/ jsx(Button, {
92
+ type: "button",
93
+ intent: "secondary",
94
+ size: "sm",
95
+ onClick: onClose,
96
+ disabled: pending,
97
+ className: classnames('byline-coll-restore-button', restore_version_modal_module.button),
98
+ children: "Cancel"
99
+ }),
100
+ /*#__PURE__*/ jsx(Button, {
101
+ size: "sm",
102
+ intent: "primary",
103
+ onClick: handleRestore,
104
+ disabled: pending,
105
+ className: classnames('byline-coll-restore-button', restore_version_modal_module.button),
106
+ children: true === pending ? /*#__PURE__*/ jsx(LoaderEllipsis, {
107
+ size: 42
108
+ }) : 'Restore as Draft'
109
+ })
110
+ ]
111
+ })
112
+ ]
113
+ });
114
+ }
115
+ function getErrorCode(err) {
116
+ return 'string' == typeof err?.code ? err.code : null;
117
+ }
118
+ export { RestoreVersionModal };
@@ -0,0 +1,10 @@
1
+ import "./restore-version-modal_module.css";
2
+ const restore_version_modal_module = {
3
+ content: "content-uRNWdJ",
4
+ body: "body-Ob50BW",
5
+ row: "row-UfzCHH",
6
+ warning: "warning-OXVE7o",
7
+ actions: "actions-w8VRuc",
8
+ button: "button-oKxXB5"
9
+ };
10
+ export default restore_version_modal_module;
@@ -0,0 +1,31 @@
1
+ :is(.content-uRNWdJ, .byline-coll-restore-content) {
2
+ gap: .25rem;
3
+ }
4
+
5
+ :is(.body-Ob50BW, .byline-coll-restore-body) {
6
+ flex-direction: column;
7
+ gap: 0;
8
+ display: flex;
9
+ }
10
+
11
+ :is(.row-UfzCHH, .byline-coll-restore-row) {
12
+ margin: 0;
13
+ }
14
+
15
+ :is(.warning-OXVE7o, .byline-coll-restore-warning) {
16
+ margin-top: .75rem;
17
+ }
18
+
19
+ :is(.actions-w8VRuc, .byline-coll-restore-actions) {
20
+ justify-content: flex-end;
21
+ align-items: center;
22
+ gap: .5rem;
23
+ margin-top: 1.5rem;
24
+ margin-bottom: 1rem;
25
+ display: flex;
26
+ }
27
+
28
+ :is(.button-oKxXB5, .byline-coll-restore-button) {
29
+ min-width: 4rem;
30
+ }
31
+
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Copyright (c) Infonomic Company Limited
7
7
  */
8
- import type { UseNavigationGuard } from '@byline/ui/react/forms';
8
+ import type { UseNavigationGuard } from '@byline/ui/react';
9
9
  /**
10
10
  * Navigation guard backed by TanStack Router's `useBlocker`.
11
11
  *
@@ -1,6 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect } from "react";
3
- import { Button, HistoryIcon, IconButton, Label, Select } from "@byline/ui";
3
+ import { Button, HistoryIcon, IconButton, Label, Select } from "@byline/ui/react";
4
4
  import classnames from "classnames";
5
5
  import { useNavigate } from "../chrome/loose-router.js";
6
6
  import { PreviewLink } from "./preview-link.js";
@@ -20,5 +20,5 @@
20
20
  * Page-container reads (list/edit) stay on direct server-fn imports
21
21
  * inside the host's deferred router-coupled containers.
22
22
  */
23
- import type { BylineAdminServices } from '@byline/ui/react/admin';
23
+ import type { BylineAdminServices } from '@byline/ui/react';
24
24
  export declare const bylineAdminServices: BylineAdminServices;