@rapidmx/web-client 0.4.0 → 0.5.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 (169) hide show
  1. package/apps/admin/audit-log/index.tsx +35 -8
  2. package/apps/admin/data-requests/index.tsx +480 -485
  3. package/apps/admin/distribution-lists/[uid].tsx +19 -1
  4. package/apps/admin/escrow-scopes/[uid].tsx +348 -237
  5. package/apps/admin/escrow-scopes/new/index.tsx +8 -2
  6. package/apps/admin/index.tsx +19 -1
  7. package/apps/admin/ingest-queue/index.tsx +44 -5
  8. package/apps/admin/mailboxes/[uid].tsx +211 -184
  9. package/apps/admin/quarantine/index.tsx +46 -14
  10. package/apps/admin/transport-rules/[uid].tsx +30 -1
  11. package/apps/admin/transport-rules/_transportRuleConfig.tsx +38 -2
  12. package/apps/admin/transport-rules/index.tsx +24 -6
  13. package/apps/admin/transport-rules/new/index.tsx +30 -1
  14. package/apps/escrow/_layout.tsx +2 -3
  15. package/apps/escrow/audit-log/index.tsx +196 -168
  16. package/apps/escrow/matters/[uid].tsx +621 -521
  17. package/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.tsx +22 -1
  18. package/apps/shared/components/admin/layout/AdminShell.tsx +3 -1
  19. package/apps/shared/components/admin/mailboxes/EscrowScopeCard.tsx +152 -0
  20. package/apps/shared/components/admin/mailboxes/ResourceSettingsCard.tsx +3 -3
  21. package/apps/shared/components/admin/mailboxes/ShareAccessCard.tsx +55 -11
  22. package/apps/shared/components/admin/settings/BrandingForm.tsx +15 -4
  23. package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +18 -7
  24. package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +10 -2
  25. package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +6 -0
  26. package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +45 -12
  27. package/apps/shared/components/admin/settings/PluginsManager.tsx +1235 -595
  28. package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +174 -98
  29. package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +49 -13
  30. package/apps/shared/components/admin/setup/SetupWizard.tsx +150 -34
  31. package/apps/shared/components/admin/signOut.ts +79 -0
  32. package/apps/shared/components/admin/usePagedList.tsx +129 -0
  33. package/apps/shared/components/calendar/EventModal.tsx +717 -549
  34. package/apps/shared/components/calendar/MonthView.tsx +173 -139
  35. package/apps/shared/components/calendar/RecurrenceEditor.tsx +222 -180
  36. package/apps/shared/components/calendar/SplitDayView.tsx +143 -137
  37. package/apps/shared/components/calendar/TimeGridView.tsx +244 -198
  38. package/apps/shared/components/calendar/allDay.ts +124 -0
  39. package/apps/shared/components/calendar/layout/CalendarShell.tsx +1 -1
  40. package/apps/shared/components/contacts/ContactDetailPane.tsx +100 -21
  41. package/apps/shared/components/contacts/ContactForm.tsx +377 -348
  42. package/apps/shared/components/contacts/ContactsSidebar.tsx +6 -2
  43. package/apps/shared/components/contacts/KeyChangeReview.tsx +192 -0
  44. package/apps/shared/components/contacts/contactKeys.ts +78 -0
  45. package/apps/shared/components/escrow/layout/EscrowShell.tsx +148 -134
  46. package/apps/shared/components/layout/AppShell.tsx +87 -15
  47. package/apps/shared/components/layout/BrandingChrome.tsx +48 -10
  48. package/apps/shared/components/layout/KeyEnrollmentGate.tsx +389 -298
  49. package/apps/shared/components/layout/MailboxProvisioning.tsx +19 -3
  50. package/apps/shared/components/layout/RecoveryCodeUnlock.tsx +350 -0
  51. package/apps/shared/components/layout/UnlockPromptProvider.tsx +257 -128
  52. package/apps/shared/components/mail/ConversationThreadPane.tsx +216 -181
  53. package/apps/shared/components/mail/MessageDetailPane.tsx +1318 -630
  54. package/apps/shared/components/mail/compose/ComposeContext.tsx +20 -15
  55. package/apps/shared/components/mail/compose/ComposeWindow.tsx +854 -132
  56. package/apps/shared/components/mail/compose/composeFlushRegistry.ts +60 -0
  57. package/apps/shared/components/mail/layout/MailShell.tsx +12 -2
  58. package/apps/shared/components/mail/pinnedSigners.ts +124 -0
  59. package/apps/shared/components/mail/verificationSeals.ts +125 -0
  60. package/apps/shared/components/mail/writableMailboxes.ts +101 -0
  61. package/apps/shared/components/rules/RuleBuilder.tsx +311 -276
  62. package/apps/shared/mail/listAllPages.ts +39 -0
  63. package/apps/shared/search/LocalIndexLifecycle.tsx +64 -55
  64. package/apps/shared/search/localIndexBuilder.ts +481 -179
  65. package/apps/shared/search/localIndexRpcClient.ts +228 -28
  66. package/apps/shared/search/localIndexSchema.ts +15 -6
  67. package/apps/shared/search/localIndexStorage.ts +98 -0
  68. package/apps/shared/search/localIndexVFS.ts +32 -1
  69. package/apps/shared/search/localIndexWorker.ts +648 -186
  70. package/apps/www/calendar/index.tsx +438 -417
  71. package/apps/www/contacts/[uid].tsx +21 -2
  72. package/apps/www/contacts/index.tsx +116 -12
  73. package/apps/www/index.tsx +1314 -1041
  74. package/apps/www/messages/[uid].tsx +18 -6
  75. package/apps/www/settings/auto-reply/index.tsx +134 -129
  76. package/apps/www/settings/booking-types/[uid].tsx +306 -300
  77. package/apps/www/settings/encryption/index.tsx +739 -216
  78. package/apps/www/settings/filters/[uid].tsx +171 -155
  79. package/apps/www/settings/filters/new/index.tsx +8 -1
  80. package/apps/www/settings/focused-inbox/index.tsx +150 -148
  81. package/apps/www/settings/privacy/index.tsx +494 -436
  82. package/apps/www/settings/read-receipts/index.tsx +148 -125
  83. package/apps/www/settings/sharing/index.tsx +17 -14
  84. package/apps/www/tasks/index.tsx +638 -579
  85. package/dist/apps/admin/audit-log/index.js +38 -8
  86. package/dist/apps/admin/data-requests/index.js +52 -72
  87. package/dist/apps/admin/distribution-lists/[uid].js +1 -1
  88. package/dist/apps/admin/escrow-scopes/[uid].js +91 -12
  89. package/dist/apps/admin/escrow-scopes/new/index.js +8 -3
  90. package/dist/apps/admin/index.js +4 -1
  91. package/dist/apps/admin/ingest-queue/index.js +24 -6
  92. package/dist/apps/admin/mailboxes/[uid].js +20 -4
  93. package/dist/apps/admin/quarantine/index.js +20 -11
  94. package/dist/apps/admin/transport-rules/[uid].js +18 -2
  95. package/dist/apps/admin/transport-rules/_transportRuleConfig.js +19 -0
  96. package/dist/apps/admin/transport-rules/index.js +22 -6
  97. package/dist/apps/admin/transport-rules/new/index.js +18 -2
  98. package/dist/apps/escrow/_layout.js +3 -3
  99. package/dist/apps/escrow/audit-log/index.js +26 -1
  100. package/dist/apps/escrow/matters/[uid].js +77 -42
  101. package/dist/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.js +11 -2
  102. package/dist/apps/shared/components/admin/layout/AdminShell.js +3 -1
  103. package/dist/apps/shared/components/admin/mailboxes/EscrowScopeCard.js +72 -0
  104. package/dist/apps/shared/components/admin/mailboxes/ResourceSettingsCard.js +3 -3
  105. package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.js +22 -4
  106. package/dist/apps/shared/components/admin/settings/BrandingForm.js +15 -4
  107. package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +13 -7
  108. package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.js +7 -2
  109. package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +6 -0
  110. package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.js +34 -12
  111. package/dist/apps/shared/components/admin/settings/PluginsManager.js +390 -78
  112. package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.js +40 -11
  113. package/dist/apps/shared/components/admin/setup/EscrowSetupStep.js +29 -13
  114. package/dist/apps/shared/components/admin/setup/SetupWizard.js +87 -21
  115. package/dist/apps/shared/components/admin/signOut.js +75 -0
  116. package/dist/apps/shared/components/admin/usePagedList.js +99 -0
  117. package/dist/apps/shared/components/calendar/EventModal.js +142 -21
  118. package/dist/apps/shared/components/calendar/MonthView.js +12 -5
  119. package/dist/apps/shared/components/calendar/RecurrenceEditor.js +40 -5
  120. package/dist/apps/shared/components/calendar/SplitDayView.js +10 -4
  121. package/dist/apps/shared/components/calendar/TimeGridView.js +23 -7
  122. package/dist/apps/shared/components/calendar/allDay.js +111 -0
  123. package/dist/apps/shared/components/calendar/layout/CalendarShell.js +1 -1
  124. package/dist/apps/shared/components/contacts/ContactDetailPane.js +43 -5
  125. package/dist/apps/shared/components/contacts/ContactForm.js +32 -10
  126. package/dist/apps/shared/components/contacts/ContactsSidebar.js +2 -2
  127. package/dist/apps/shared/components/contacts/KeyChangeReview.js +63 -0
  128. package/dist/apps/shared/components/contacts/contactKeys.js +64 -0
  129. package/dist/apps/shared/components/escrow/layout/EscrowShell.js +24 -5
  130. package/dist/apps/shared/components/layout/AppShell.js +83 -14
  131. package/dist/apps/shared/components/layout/BrandingChrome.js +45 -10
  132. package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +49 -12
  133. package/dist/apps/shared/components/layout/MailboxProvisioning.js +10 -2
  134. package/dist/apps/shared/components/layout/RecoveryCodeUnlock.js +174 -0
  135. package/dist/apps/shared/components/layout/UnlockPromptProvider.js +73 -14
  136. package/dist/apps/shared/components/mail/ConversationThreadPane.js +50 -12
  137. package/dist/apps/shared/components/mail/MessageDetailPane.js +441 -36
  138. package/dist/apps/shared/components/mail/compose/ComposeContext.js +9 -6
  139. package/dist/apps/shared/components/mail/compose/ComposeWindow.js +699 -128
  140. package/dist/apps/shared/components/mail/compose/composeFlushRegistry.js +50 -0
  141. package/dist/apps/shared/components/mail/layout/MailShell.js +12 -3
  142. package/dist/apps/shared/components/mail/pinnedSigners.js +98 -0
  143. package/dist/apps/shared/components/mail/verificationSeals.js +112 -0
  144. package/dist/apps/shared/components/mail/writableMailboxes.js +87 -0
  145. package/dist/apps/shared/components/rules/RuleBuilder.js +34 -6
  146. package/dist/apps/shared/mail/listAllPages.js +25 -0
  147. package/dist/apps/shared/search/LocalIndexLifecycle.js +58 -54
  148. package/dist/apps/shared/search/localIndexBuilder.js +292 -37
  149. package/dist/apps/shared/search/localIndexRpcClient.js +188 -25
  150. package/dist/apps/shared/search/localIndexSchema.js +12 -6
  151. package/dist/apps/shared/search/localIndexStorage.js +86 -0
  152. package/dist/apps/shared/search/localIndexVFS.js +68 -40
  153. package/dist/apps/shared/search/localIndexWorker.js +519 -173
  154. package/dist/apps/www/calendar/index.js +28 -10
  155. package/dist/apps/www/contacts/[uid].js +13 -2
  156. package/dist/apps/www/contacts/index.js +80 -10
  157. package/dist/apps/www/index.js +339 -108
  158. package/dist/apps/www/messages/[uid].js +18 -6
  159. package/dist/apps/www/settings/auto-reply/index.js +9 -4
  160. package/dist/apps/www/settings/booking-types/[uid].js +17 -12
  161. package/dist/apps/www/settings/encryption/index.js +514 -97
  162. package/dist/apps/www/settings/filters/[uid].js +22 -7
  163. package/dist/apps/www/settings/filters/new/index.js +8 -2
  164. package/dist/apps/www/settings/focused-inbox/index.js +3 -1
  165. package/dist/apps/www/settings/privacy/index.js +57 -22
  166. package/dist/apps/www/settings/read-receipts/index.js +10 -3
  167. package/dist/apps/www/settings/sharing/index.js +7 -11
  168. package/dist/apps/www/tasks/index.js +50 -10
  169. package/package.json +2 -2
@@ -8,6 +8,8 @@ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
8
8
  import { listIngestQueue } from "@rapidmx/react-shared/mail/mailApi.js";
9
9
  import AdminShell from "../../shared/components/admin/layout/AdminShell.js";
10
10
  import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
11
+ import Button from "@rapidmx/react-shared/components/buttons/Button.js";
12
+ const PAGE_SIZE = 25;
11
13
  export function readMailboxUid() {
12
14
  if (typeof window === "undefined")
13
15
  return null;
@@ -24,6 +26,7 @@ export default function IngestQueuePage(props) {
24
26
  }
25
27
  function IngestQueueContent() {
26
28
  const [mailboxUid, setMailboxUid] = useState(null);
29
+ const [page, setPage] = useState(0);
27
30
  const [entries, setEntries] = useState([]);
28
31
  const [loading, setLoading] = useState(true);
29
32
  const [error, setError] = useState(null);
@@ -34,15 +37,30 @@ function IngestQueueContent() {
34
37
  if (!mailboxUid) {
35
38
  return;
36
39
  }
40
+ // Paging quickly can leave an older page's response landing last - only the latest request's is applied.
41
+ let cancelled = false;
37
42
  setLoading(true);
38
43
  setError(null);
39
- listIngestQueue(mailboxUid)
40
- .then(setEntries)
41
- .catch((err) => setError(err instanceof ApiRequestError ? err.message : "Could not load the ingest queue."))
42
- .finally(() => setLoading(false));
43
- }, [mailboxUid]);
44
+ listIngestQueue(mailboxUid, { page, limit: PAGE_SIZE })
45
+ .then((data) => {
46
+ if (!cancelled)
47
+ setEntries(data);
48
+ })
49
+ .catch((err) => {
50
+ if (!cancelled)
51
+ setError(err instanceof ApiRequestError ? err.message : "Could not load the ingest queue.");
52
+ })
53
+ .finally(() => {
54
+ if (!cancelled)
55
+ setLoading(false);
56
+ });
57
+ return () => {
58
+ cancelled = true;
59
+ };
60
+ }, [mailboxUid, page]);
61
+ const hasNextPage = entries.length === PAGE_SIZE;
44
62
  if (!mailboxUid) {
45
63
  return _jsx(Alert, { children: "No mailbox specified. Open a mailbox's detail page and choose \"View ingest queue\"." });
46
64
  }
47
- return (_jsxs("div", { className: "max-w-4xl flex flex-col gap-4", children: [_jsxs("div", { children: [_jsx("a", { href: `/admin/mailboxes/${encodeURIComponent(mailboxUid)}`, className: "text-sm text-primary-dark hover:underline", children: "\u2190 Back to mailbox" }), _jsx("h1", { className: "text-xl font-bold uppercase tracking-wide mt-1", children: "Ingest queue" })] }), error && _jsx(Alert, { children: error }), loading ? (_jsx("p", { className: "text-sm text-text-muted", children: "Loading\u2026" })) : entries.length === 0 ? (_jsx("p", { className: "text-sm text-text-muted", children: "Nothing pending or failed for this mailbox." })) : (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm border-collapse", children: [_jsx("thead", { children: _jsx("tr", { children: ["From", "To", "Received", "Status", "Error"].map((h) => (_jsx("th", { className: "text-left text-xs uppercase tracking-wide text-text-muted py-2 px-2.5 border-b border-border", children: h }, h))) }) }), _jsx("tbody", { children: entries.map((entry) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.envelopeFrom }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.envelopeTo.join(", ") }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: new Date(entry.dateCreated).toLocaleString() }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: _jsx("span", { className: `inline-block text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill ${STATUS_STYLES[entry.status]}`, children: entry.status }) }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border text-text-muted", children: entry.errorMessage ?? "" })] }, entry.uid))) })] }) }))] }));
65
+ return (_jsxs("div", { className: "max-w-4xl flex flex-col gap-4", children: [_jsxs("div", { children: [_jsx("a", { href: `/admin/mailboxes/${encodeURIComponent(mailboxUid)}`, className: "text-sm text-primary-dark hover:underline", children: "\u2190 Back to mailbox" }), _jsx("h1", { className: "text-xl font-bold uppercase tracking-wide mt-1", children: "Ingest queue" })] }), error && _jsx(Alert, { children: error }), loading ? (_jsx("p", { className: "text-sm text-text-muted", children: "Loading\u2026" })) : entries.length === 0 ? (_jsx("p", { className: "text-sm text-text-muted", children: "Nothing pending or failed for this mailbox." })) : (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm border-collapse", children: [_jsx("thead", { children: _jsx("tr", { children: ["From", "To", "Received", "Status", "Error"].map((h) => (_jsx("th", { className: "text-left text-xs uppercase tracking-wide text-text-muted py-2 px-2.5 border-b border-border", children: h }, h))) }) }), _jsx("tbody", { children: entries.map((entry) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.envelopeFrom }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.envelopeTo.join(", ") }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: new Date(entry.dateCreated).toLocaleString() }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: _jsx("span", { className: `inline-block text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill ${STATUS_STYLES[entry.status]}`, children: entry.status }) }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border text-text-muted", children: entry.errorMessage ?? "" })] }, entry.uid))) })] }) })), _jsxs("div", { className: "flex gap-3 items-center", children: [_jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: page === 0 || loading, onClick: () => setPage((p) => Math.max(0, p - 1)), children: "Previous" }), _jsxs("span", { className: "text-sm text-text-muted", children: ["Page ", page + 1] }), _jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: !hasNextPage || loading, onClick: () => setPage((p) => p + 1), children: "Next" })] })] }));
48
66
  }
@@ -9,6 +9,7 @@ import { deleteMailbox, getMailbox, impersonateUser } from "@rapidmx/react-share
9
9
  import AdminShell from "../../shared/components/admin/layout/AdminShell.js";
10
10
  import ShareAccessCard from "../../shared/components/admin/mailboxes/ShareAccessCard.js";
11
11
  import ResourceSettingsCard from "../../shared/components/admin/mailboxes/ResourceSettingsCard.js";
12
+ import EscrowScopeCard from "../../shared/components/admin/mailboxes/EscrowScopeCard.js";
12
13
  import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
13
14
  import Button from "@rapidmx/react-shared/components/buttons/Button.js";
14
15
  import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
@@ -28,22 +29,37 @@ function MailboxDetailContent({ uid, impersonationBaseUrl }) {
28
29
  const [mailbox, setMailbox] = useState(null);
29
30
  const [loading, setLoading] = useState(true);
30
31
  const [error, setError] = useState(null);
32
+ const [confirmingAccess, setConfirmingAccess] = useState(false);
31
33
  const [impersonating, setImpersonating] = useState(false);
34
+ const [accessError, setAccessError] = useState(null);
32
35
  const [confirmingDelete, setConfirmingDelete] = useState(false);
33
36
  const [deleting, setDeleting] = useState(false);
34
37
  const [deleteError, setDeleteError] = useState(null);
35
- async function handleAccessMailbox(ownerUserUid) {
38
+ // Ignored while the action is under way (Escape/Close; Cancel is disabled then too), so its result or error
39
+ // can't land on a modal reopened afterwards.
40
+ function closeAccessModal() {
41
+ if (impersonating)
42
+ return;
43
+ setConfirmingAccess(false);
44
+ setAccessError(null);
45
+ }
46
+ // Only ever invoked from the access-confirmation modal below, which only renders for a loaded mailbox that has
47
+ // an owner. A failure stays in the modal rather than replacing the whole page.
48
+ async function handleAccessMailbox() {
36
49
  setImpersonating(true);
50
+ setAccessError(null);
37
51
  try {
38
- await impersonateUser(impersonationBaseUrl ?? "", ownerUserUid);
52
+ await impersonateUser(impersonationBaseUrl ?? "", mailbox.ownerUserUid);
39
53
  window.location.href = "/";
40
54
  }
41
55
  catch (err) {
42
- setError(err instanceof ApiRequestError ? err.message : "Could not access this mailbox.");
56
+ setAccessError(err instanceof ApiRequestError ? err.message : "Could not access this mailbox.");
43
57
  setImpersonating(false);
44
58
  }
45
59
  }
46
60
  function closeDeleteModal() {
61
+ if (deleting)
62
+ return;
47
63
  setConfirmingDelete(false);
48
64
  }
49
65
  // Only ever invoked from the delete-confirmation modal below, which itself only renders once
@@ -79,5 +95,5 @@ function MailboxDetailContent({ uid, impersonationBaseUrl }) {
79
95
  }
80
96
  const quarantineHref = `/admin/quarantine?mailboxUid=${encodeURIComponent(mailbox.uid)}`;
81
97
  const ingestQueueHref = `/admin/ingest-queue?mailboxUid=${encodeURIComponent(mailbox.uid)}`;
82
- return (_jsxs("div", { className: "max-w-3xl flex flex-col gap-5", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { children: [_jsx("a", { href: "/admin", className: "text-sm text-primary-dark hover:underline", children: "\u2190 All mailboxes" }), _jsx("h1", { className: "text-xl font-bold tracking-tight mt-1", children: mailbox.primarySmtpAddress })] }), _jsxs("div", { className: "flex gap-3 shrink-0", children: [mailbox.ownerUserUid && (_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", loading: impersonating, disabled: impersonating, onClick: () => handleAccessMailbox(mailbox.ownerUserUid), children: "Access this mailbox" })), _jsx(Button, { type: "button", variant: "secondary", className: "!w-auto !border-danger !text-danger hover:!border-danger hover:!text-danger", onClick: () => setConfirmingDelete(true), children: "Delete mailbox" })] })] }), _jsxs("div", { className: "bg-surface border border-border rounded-md p-6", children: [_jsxs("dl", { className: "grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3 text-sm", children: [_jsx("dt", { className: "text-text-muted", children: "Display name" }), _jsx("dd", { children: mailbox.displayName }), _jsx("dt", { className: "text-text-muted", children: "Owner" }), _jsx("dd", { children: mailbox.ownerUserUid ?? "None (shared mailbox)" }), _jsx("dt", { className: "text-text-muted", children: "Timezone" }), _jsx("dd", { children: mailbox.timezone }), _jsx("dt", { className: "text-text-muted", children: "Quota" }), _jsxs("dd", { children: [formatBytes(mailbox.usedBytes), " / ", formatBytes(mailbox.quotaBytes)] }), _jsx("dt", { className: "text-text-muted", children: "Alias addresses" }), _jsx("dd", { children: mailbox.aliasAddresses.length > 0 ? mailbox.aliasAddresses.join(", ") : "None" }), mailbox.isResource && (_jsxs(_Fragment, { children: [_jsx("dt", { className: "text-text-muted", children: "Resource type" }), _jsx("dd", { className: "capitalize", children: mailbox.resourceType ?? "room" })] })), _jsx("dt", { className: "text-text-muted", children: "Created" }), _jsx("dd", { children: new Date(mailbox.dateCreated).toLocaleString() })] }), _jsxs("div", { className: "flex gap-4 mt-5 pt-5 border-t border-border text-sm font-medium", children: [_jsx("a", { href: quarantineHref, className: "text-primary-dark hover:underline", children: "View quarantine" }), _jsx("a", { href: ingestQueueHref, className: "text-primary-dark hover:underline", children: "View ingest queue" })] })] }), _jsx(ShareAccessCard, { mailboxUid: mailbox.uid }), mailbox.isResource && _jsx(ResourceSettingsCard, { mailbox: mailbox, onUpdate: setMailbox }), _jsxs(Modal, { open: confirmingDelete, onClose: closeDeleteModal, title: "Delete mailbox", children: [_jsxs("p", { className: "text-sm mb-5", children: ["Are you sure you want to delete ", _jsx("strong", { children: mailbox.primarySmtpAddress }), "? This permanently deletes the mailbox and everything in it, and cannot be undone. It fails if this mailbox is a custodian on an active legal hold."] }), deleteError && _jsx(Alert, { children: deleteError }), _jsxs("div", { className: "flex gap-3 justify-end mt-5", children: [_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", disabled: deleting, onClick: closeDeleteModal, children: "Cancel" }), _jsx(Button, { type: "button", className: "!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger", loading: deleting, disabled: deleting, onClick: handleDelete, children: "Delete" })] })] })] }));
98
+ return (_jsxs("div", { className: "max-w-3xl flex flex-col gap-5", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { children: [_jsx("a", { href: "/admin", className: "text-sm text-primary-dark hover:underline", children: "\u2190 All mailboxes" }), _jsx("h1", { className: "text-xl font-bold tracking-tight mt-1", children: mailbox.primarySmtpAddress })] }), _jsxs("div", { className: "flex gap-3 shrink-0", children: [mailbox.ownerUserUid && (_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", onClick: () => setConfirmingAccess(true), children: "Access this mailbox" })), _jsx(Button, { type: "button", variant: "secondary", className: "!w-auto !border-danger !text-danger hover:!border-danger hover:!text-danger", onClick: () => setConfirmingDelete(true), children: "Delete mailbox" })] })] }), _jsxs("div", { className: "bg-surface border border-border rounded-md p-6", children: [_jsxs("dl", { className: "grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3 text-sm", children: [_jsx("dt", { className: "text-text-muted", children: "Display name" }), _jsx("dd", { children: mailbox.displayName }), _jsx("dt", { className: "text-text-muted", children: "Owner" }), _jsx("dd", { children: mailbox.ownerUserUid ?? "None (shared mailbox)" }), _jsx("dt", { className: "text-text-muted", children: "Timezone" }), _jsx("dd", { children: mailbox.timezone }), _jsx("dt", { className: "text-text-muted", children: "Quota" }), _jsxs("dd", { children: [formatBytes(mailbox.usedBytes), " / ", formatBytes(mailbox.quotaBytes)] }), _jsx("dt", { className: "text-text-muted", children: "Alias addresses" }), _jsx("dd", { children: mailbox.aliasAddresses.length > 0 ? mailbox.aliasAddresses.join(", ") : "None" }), mailbox.isResource && (_jsxs(_Fragment, { children: [_jsx("dt", { className: "text-text-muted", children: "Resource type" }), _jsx("dd", { className: "capitalize", children: mailbox.resourceType ?? "room" })] })), _jsx("dt", { className: "text-text-muted", children: "Created" }), _jsx("dd", { children: new Date(mailbox.dateCreated).toLocaleString() })] }), _jsxs("div", { className: "flex gap-4 mt-5 pt-5 border-t border-border text-sm font-medium", children: [_jsx("a", { href: quarantineHref, className: "text-primary-dark hover:underline", children: "View quarantine" }), _jsx("a", { href: ingestQueueHref, className: "text-primary-dark hover:underline", children: "View ingest queue" })] })] }), _jsx(ShareAccessCard, { mailboxUid: mailbox.uid, ownerUserUid: mailbox.ownerUserUid }), _jsx(EscrowScopeCard, { mailbox: mailbox, onUpdate: setMailbox }), mailbox.isResource && _jsx(ResourceSettingsCard, { mailbox: mailbox, onUpdate: setMailbox }), _jsxs(Modal, { open: confirmingAccess, onClose: closeAccessModal, title: "Access this mailbox", children: [_jsxs("p", { className: "text-sm mb-3", children: ["You\u2019ll be signed in as ", _jsx("strong", { className: "break-all", children: mailbox.ownerUserUid }), ", the owner of ", _jsx("strong", { className: "break-all", children: mailbox.primarySmtpAddress }), ", and see everything they can - and act as them, until you stop impersonating."] }), accessError && _jsx(Alert, { children: accessError }), _jsxs("div", { className: "flex gap-3 justify-end mt-5", children: [_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", disabled: impersonating, onClick: closeAccessModal, children: "Cancel" }), _jsx(Button, { type: "button", className: "!w-auto", loading: impersonating, disabled: impersonating, onClick: handleAccessMailbox, children: "Access mailbox" })] })] }), _jsxs(Modal, { open: confirmingDelete, onClose: closeDeleteModal, title: "Delete mailbox", children: [_jsxs("p", { className: "text-sm mb-5", children: ["Are you sure you want to delete ", _jsx("strong", { children: mailbox.primarySmtpAddress }), "? This permanently deletes the mailbox and everything in it, and cannot be undone. It fails if this mailbox is a custodian on an active legal hold."] }), deleteError && _jsx(Alert, { children: deleteError }), _jsxs("div", { className: "flex gap-3 justify-end mt-5", children: [_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", disabled: deleting, onClick: closeDeleteModal, children: "Cancel" }), _jsx(Button, { type: "button", className: "!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger", loading: deleting, disabled: deleting, onClick: handleDelete, children: "Delete" })] })] })] }));
83
99
  }
@@ -9,6 +9,7 @@ import { listQuarantine, releaseQuarantineEntry } from "@rapidmx/react-shared/ma
9
9
  import AdminShell from "../../shared/components/admin/layout/AdminShell.js";
10
10
  import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
11
11
  import Button from "@rapidmx/react-shared/components/buttons/Button.js";
12
+ import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
12
13
  const PAGE_SIZE = 25;
13
14
  export function readMailboxUid() {
14
15
  if (typeof window === "undefined")
@@ -24,7 +25,9 @@ function QuarantineContent({ userUid }) {
24
25
  const [entries, setEntries] = useState([]);
25
26
  const [loading, setLoading] = useState(true);
26
27
  const [error, setError] = useState(null);
27
- const [releasing, setReleasing] = useState(null);
28
+ const [releaseTarget, setReleaseTarget] = useState(null);
29
+ const [releasing, setReleasing] = useState(false);
30
+ const [releaseError, setReleaseError] = useState(null);
28
31
  useEffect(() => {
29
32
  setMailboxUid(readMailboxUid());
30
33
  }, []);
@@ -42,25 +45,31 @@ function QuarantineContent({ userUid }) {
42
45
  }
43
46
  }, [mailboxUid, page]);
44
47
  const hasNextPage = entries.length === PAGE_SIZE;
45
- // Only ever invoked from the "Release" button below, which itself only renders once `mailboxUid` is
46
- // known and `AdminShell` has already confirmed `userUid` (children only render once authorized) — both
47
- // non-null assertions reflect that real invariant, not an unchecked assumption.
48
- async function handleRelease(entry) {
49
- setReleasing(entry.uid);
50
- setError(null);
48
+ function closeReleaseModal() {
49
+ setReleaseTarget(null);
50
+ setReleaseError(null);
51
+ }
52
+ // Only ever invoked from the confirmation modal below, which only renders once `releaseTarget` is set, once
53
+ // `mailboxUid` is known, and once `AdminShell` has confirmed `userUid` (children only render once authorized).
54
+ // `releaseQuarantineEntry()` still sends its own `releasedAt`/`releasedByUserUid`; the server now stamps both
55
+ // itself and ignores the client's values, so what's displayed afterwards comes from the reloaded list.
56
+ async function handleRelease() {
57
+ setReleasing(true);
58
+ setReleaseError(null);
51
59
  try {
52
- await releaseQuarantineEntry(entry.uid, entry.version, userUid);
60
+ await releaseQuarantineEntry(releaseTarget.uid, releaseTarget.version, userUid);
61
+ closeReleaseModal();
53
62
  reload(mailboxUid);
54
63
  }
55
64
  catch (err) {
56
- setError(err instanceof ApiRequestError ? err.message : "Could not release this message.");
65
+ setReleaseError(err instanceof ApiRequestError ? err.message : "Could not mark this message released.");
57
66
  }
58
67
  finally {
59
- setReleasing(null);
68
+ setReleasing(false);
60
69
  }
61
70
  }
62
71
  if (!mailboxUid) {
63
72
  return _jsx(Alert, { children: "No mailbox specified. Open a mailbox's detail page and choose \"View quarantine\"." });
64
73
  }
65
- return (_jsxs("div", { className: "max-w-4xl flex flex-col gap-4", children: [_jsxs("div", { children: [_jsx("a", { href: `/admin/mailboxes/${encodeURIComponent(mailboxUid)}`, className: "text-sm text-primary-dark hover:underline", children: "\u2190 Back to mailbox" }), _jsx("h1", { className: "text-xl font-bold uppercase tracking-wide mt-1", children: "Quarantine" })] }), error && _jsx(Alert, { children: error }), loading ? (_jsx("p", { className: "text-sm text-text-muted", children: "Loading\u2026" })) : entries.length === 0 ? (_jsx("p", { className: "text-sm text-text-muted", children: "Nothing quarantined for this mailbox." })) : (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm border-collapse", children: [_jsx("thead", { children: _jsx("tr", { children: ["Reason", "Quarantined", "Status", ""].map((h) => (_jsx("th", { className: "text-left text-xs uppercase tracking-wide text-text-muted py-2 px-2.5 border-b border-border", children: h }, h))) }) }), _jsx("tbody", { children: entries.map((entry) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.reason }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: new Date(entry.dateCreated).toLocaleString() }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.releasedAt ? (_jsx("span", { className: "text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill bg-success text-white", children: "Released" })) : (_jsx("span", { className: "text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill bg-surface-alt text-text-muted", children: "Held" })) }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border text-right", children: !entry.releasedAt && (_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", loading: releasing === entry.uid, disabled: releasing === entry.uid, onClick: () => handleRelease(entry), children: "Release" })) })] }, entry.uid))) })] }) })), _jsxs("div", { className: "flex gap-3 items-center mt-4", children: [_jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: page === 0 || loading, onClick: () => setPage((p) => Math.max(0, p - 1)), children: "Previous" }), _jsxs("span", { className: "text-sm text-text-muted", children: ["Page ", page + 1] }), _jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: !hasNextPage || loading, onClick: () => setPage((p) => p + 1), children: "Next" })] })] }));
74
+ return (_jsxs("div", { className: "max-w-4xl flex flex-col gap-4", children: [_jsxs("div", { children: [_jsx("a", { href: `/admin/mailboxes/${encodeURIComponent(mailboxUid)}`, className: "text-sm text-primary-dark hover:underline", children: "\u2190 Back to mailbox" }), _jsx("h1", { className: "text-xl font-bold uppercase tracking-wide mt-1", children: "Quarantine" })] }), error && _jsx(Alert, { children: error }), loading ? (_jsx("p", { className: "text-sm text-text-muted", children: "Loading\u2026" })) : entries.length === 0 ? (_jsx("p", { className: "text-sm text-text-muted", children: "Nothing quarantined for this mailbox." })) : (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm border-collapse", children: [_jsx("thead", { children: _jsx("tr", { children: ["Reason", "Quarantined", "Status", ""].map((h) => (_jsx("th", { className: "text-left text-xs uppercase tracking-wide text-text-muted py-2 px-2.5 border-b border-border", children: h }, h))) }) }), _jsx("tbody", { children: entries.map((entry) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.reason }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: new Date(entry.dateCreated).toLocaleString() }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.releasedAt ? (_jsx("span", { className: "text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill bg-success text-white", children: "Released" })) : (_jsx("span", { className: "text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill bg-surface-alt text-text-muted", children: "Held" })) }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border text-right", children: !entry.releasedAt && (_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", onClick: () => setReleaseTarget(entry), children: "Mark released" })) })] }, entry.uid))) })] }) })), _jsxs("div", { className: "flex gap-3 items-center mt-4", children: [_jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: page === 0 || loading, onClick: () => setPage((p) => Math.max(0, p - 1)), children: "Previous" }), _jsxs("span", { className: "text-sm text-text-muted", children: ["Page ", page + 1] }), _jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: !hasNextPage || loading, onClick: () => setPage((p) => p + 1), children: "Next" })] }), _jsxs(Modal, { open: releaseTarget !== null, onClose: closeReleaseModal, title: "Mark message released", children: [_jsxs("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm mb-4", children: [_jsx("dt", { className: "text-text-muted", children: "Reason" }), _jsx("dd", { children: releaseTarget?.reason }), _jsx("dt", { className: "text-text-muted", children: "Quarantined" }), _jsx("dd", { children: releaseTarget && new Date(releaseTarget.dateCreated).toLocaleString() }), _jsx("dt", { className: "text-text-muted", children: "Message" }), _jsx("dd", { className: "break-all", children: releaseTarget?.originalMessageUid ?? "Not delivered to the mailbox" })] }), _jsx("p", { className: "text-sm mb-4", children: "This only records the entry as released (with you as the releaser). It does not deliver the message - if it\u2019s infected or unwanted, leave it held." }), releaseError && _jsx(Alert, { children: releaseError }), _jsxs("div", { className: "flex gap-3 justify-end", children: [_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", disabled: releasing, onClick: closeReleaseModal, children: "Cancel" }), _jsx(Button, { type: "button", className: "!w-auto", loading: releasing, disabled: releasing, onClick: handleRelease, children: "Mark released" })] })] })] }));
66
75
  }
@@ -8,7 +8,7 @@ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
8
8
  import { getTransportRule, updateTransportRule, } from "@rapidmx/react-shared/admin/transportRulesApi.js";
9
9
  import AdminShell from "../../shared/components/admin/layout/AdminShell.js";
10
10
  import RuleBuilder from "../../shared/components/rules/RuleBuilder.js";
11
- import { TRANSPORT_RULE_ACTION_TYPES, TRANSPORT_RULE_CONDITION_FIELDS } from "./_transportRuleConfig.js";
11
+ import { checkRuleConditions, NO_CONDITIONS_BLOCKED_MESSAGE, NoConditionsConfirmModal, TRANSPORT_RULE_ACTION_TYPES, TRANSPORT_RULE_CONDITION_FIELDS, } from "./_transportRuleConfig.js";
12
12
  import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
13
13
  import Button from "@rapidmx/react-shared/components/buttons/Button.js";
14
14
  import FormField from "@rapidmx/react-shared/components/forms/FormField.js";
@@ -24,6 +24,8 @@ function TransportRuleDetailContent({ uid }) {
24
24
  const [error, setError] = useState(null);
25
25
  const [saving, setSaving] = useState(false);
26
26
  const [saved, setSaved] = useState(false);
27
+ const [showValidation, setShowValidation] = useState(false);
28
+ const [confirmingNoConditions, setConfirmingNoConditions] = useState(false);
27
29
  useEffect(() => {
28
30
  setLoading(true);
29
31
  setError(null);
@@ -55,6 +57,20 @@ function TransportRuleDetailContent({ uid }) {
55
57
  setError("A name is required.");
56
58
  return;
57
59
  }
60
+ const check = checkRuleConditions(rule);
61
+ if (check === "blocked") {
62
+ setShowValidation(true);
63
+ setError(NO_CONDITIONS_BLOCKED_MESSAGE);
64
+ return;
65
+ }
66
+ if (check === "confirm") {
67
+ setConfirmingNoConditions(true);
68
+ return;
69
+ }
70
+ await save();
71
+ }
72
+ async function save() {
73
+ setConfirmingNoConditions(false);
58
74
  setSaving(true);
59
75
  setSaved(false);
60
76
  try {
@@ -83,5 +99,5 @@ function TransportRuleDetailContent({ uid }) {
83
99
  if (!original || !rule) {
84
100
  return _jsx(Alert, { children: "Transport rule not found." });
85
101
  }
86
- return (_jsxs("div", { className: "max-w-3xl", children: [_jsx("a", { href: "/admin/transport-rules", className: "text-sm text-primary-dark hover:underline", children: "\u2190 All transport rules" }), _jsx("h1", { className: "text-xl font-bold tracking-tight mt-1 mb-5", children: original.name }), error && _jsx(Alert, { children: error }), saved && !error && (_jsx("div", { className: "mb-4 text-sm text-success font-medium", children: "Saved." })), _jsxs("form", { onSubmit: handleSubmit, className: "flex flex-col gap-5", children: [_jsx("div", { className: "bg-surface border border-border rounded-md p-6", children: _jsx(FormField, { label: "Name", htmlFor: "name", children: _jsx("input", { id: "name", type: "text", className: INPUT_CLASS, value: name, onChange: (e) => setName(e.target.value) }) }) }), _jsx(RuleBuilder, { value: rule, onChange: setRule, conditionFields: TRANSPORT_RULE_CONDITION_FIELDS, actionTypes: TRANSPORT_RULE_ACTION_TYPES }), _jsx("div", { children: _jsx(Button, { type: "submit", loading: saving, disabled: saving, className: "!w-auto", children: "Save changes" }) })] })] }));
102
+ return (_jsxs("div", { className: "max-w-3xl", children: [_jsx("a", { href: "/admin/transport-rules", className: "text-sm text-primary-dark hover:underline", children: "\u2190 All transport rules" }), _jsx("h1", { className: "text-xl font-bold tracking-tight mt-1 mb-5", children: original.name }), error && _jsx(Alert, { children: error }), saved && !error && (_jsx("div", { className: "mb-4 text-sm text-success font-medium", children: "Saved." })), _jsxs("form", { onSubmit: handleSubmit, className: "flex flex-col gap-5", children: [_jsx("div", { className: "bg-surface border border-border rounded-md p-6", children: _jsx(FormField, { label: "Name", htmlFor: "name", children: _jsx("input", { id: "name", type: "text", className: INPUT_CLASS, value: name, onChange: (e) => setName(e.target.value) }) }) }), _jsx(RuleBuilder, { value: rule, onChange: setRule, conditionFields: TRANSPORT_RULE_CONDITION_FIELDS, actionTypes: TRANSPORT_RULE_ACTION_TYPES, showValidation: showValidation }), _jsx("div", { children: _jsx(Button, { type: "submit", loading: saving, disabled: saving, className: "!w-auto", children: "Save changes" }) })] }), _jsx(NoConditionsConfirmModal, { open: confirmingNoConditions, onCancel: () => setConfirmingNoConditions(false), onConfirm: () => void save() })] }));
87
103
  }
@@ -1,4 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Button from "@rapidmx/react-shared/components/buttons/Button.js";
3
+ import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
4
+ import { hasConditions } from "../../shared/components/rules/RuleBuilder.js";
5
+ /** Refused outright when a rule has no conditions: it would reject or quarantine every message the server receives. */
6
+ export const NO_CONDITIONS_BLOCKED_MESSAGE = "Add at least one condition. A rule without conditions that rejects or quarantines mail would do so for every message.";
7
+ /**
8
+ * How a save should proceed given a rule's conditions: `"ok"` with at least one condition, `"blocked"` with none and a
9
+ * reject/quarantine action, or `"confirm"` with none and only other actions (which then apply to every message).
10
+ */
11
+ export function checkRuleConditions(rule) {
12
+ if (hasConditions(rule.conditions)) {
13
+ return "ok";
14
+ }
15
+ return rule.actions.some((action) => action.type === "reject" || action.type === "quarantine") ? "blocked" : "confirm";
16
+ }
17
+ /** Asks before saving a rule with no conditions whose actions will run on every message. */
18
+ export function NoConditionsConfirmModal({ open, onCancel, onConfirm }) {
19
+ return (_jsxs(Modal, { open: open, onClose: onCancel, title: "Apply to every message?", children: [_jsx("p", { className: "text-sm mb-5", children: "This rule has no conditions, so its actions will run on every message this server receives or sends." }), _jsxs("div", { className: "flex gap-3 justify-end", children: [_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", onClick: onCancel, children: "Cancel" }), _jsx(Button, { type: "button", className: "!w-auto", onClick: onConfirm, children: "Save anyway" })] })] }));
20
+ }
2
21
  const FIELD_INPUT_CLASS = "w-full text-sm py-2 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
3
22
  export const TRANSPORT_RULE_CONDITION_FIELDS = [
4
23
  { key: "fromContains", label: "From contains", kind: "list" },
@@ -10,6 +10,24 @@ import AdminShell from "../../shared/components/admin/layout/AdminShell.js";
10
10
  import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
11
11
  import Button from "@rapidmx/react-shared/components/buttons/Button.js";
12
12
  const PAGE_SIZE = 25;
13
+ /** The server's largest page (`limit` is capped at 1000). */
14
+ const FETCH_PAGE_SIZE = 1000;
15
+ /**
16
+ * Every transport rule, in evaluation order. `listTransportRules()` can't ask the server to sort, and sorting one
17
+ * server page at a time would order rules only within that page - so every page is fetched and sorted here (an
18
+ * organisation has few transport rules). Ties keep a stable order by name.
19
+ */
20
+ async function listAllTransportRules() {
21
+ const all = [];
22
+ for (let page = 0;; page++) {
23
+ const batch = await listTransportRules({ page, limit: FETCH_PAGE_SIZE });
24
+ all.push(...batch);
25
+ if (batch.length < FETCH_PAGE_SIZE) {
26
+ break;
27
+ }
28
+ }
29
+ return all.sort((a, b) => a.sequence - b.sequence || a.name.localeCompare(b.name));
30
+ }
13
31
  export default function TransportRulesPage(props) {
14
32
  return (_jsx(AdminShell, { ...props, active: "transportRules", children: _jsx(TransportRulesContent, {}) }));
15
33
  }
@@ -19,14 +37,12 @@ function TransportRulesContent() {
19
37
  const [loading, setLoading] = useState(true);
20
38
  const [error, setError] = useState(null);
21
39
  useEffect(() => {
22
- setLoading(true);
23
- setError(null);
24
- listTransportRules({ page, limit: PAGE_SIZE })
40
+ listAllTransportRules()
25
41
  .then(setRules)
26
42
  .catch((err) => setError(err instanceof ApiRequestError ? err.message : "Could not load transport rules."))
27
43
  .finally(() => setLoading(false));
28
- }, [page]);
29
- const hasNextPage = rules.length === PAGE_SIZE;
30
- const sorted = [...rules].sort((a, b) => a.sequence - b.sequence);
44
+ }, []);
45
+ const hasNextPage = (page + 1) * PAGE_SIZE < rules.length;
46
+ const sorted = rules.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE);
31
47
  return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-between mb-5", children: [_jsx("h1", { className: "text-xl font-bold uppercase tracking-wide", children: "Transport rules" }), _jsx("a", { href: "/admin/transport-rules/new", children: _jsx(Button, { type: "button", className: "!w-auto", children: "+ New transport rule" }) })] }), error && _jsx(Alert, { children: error }), loading ? (_jsx("p", { className: "text-sm text-text-muted", children: "Loading\u2026" })) : sorted.length === 0 ? (_jsx("p", { className: "text-sm text-text-muted", children: "No transport rules yet." })) : (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm border-collapse", children: [_jsx("thead", { children: _jsx("tr", { children: ["Sequence", "Name", "Enabled", "Actions", ""].map((h) => (_jsx("th", { className: "text-left text-xs uppercase tracking-wide text-text-muted py-2 px-2.5 border-b border-border", children: h }, h))) }) }), _jsx("tbody", { children: sorted.map((rule) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: rule.sequence }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: rule.name }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: rule.enabled ? "Yes" : "No" }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: rule.actions.length }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border text-right", children: _jsx("a", { href: `/admin/transport-rules/${encodeURIComponent(rule.uid)}`, className: "text-primary-dark hover:underline font-medium", children: "View" }) })] }, rule.uid))) })] }) })), _jsxs("div", { className: "flex gap-3 items-center mt-4", children: [_jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: page === 0 || loading, onClick: () => setPage((p) => Math.max(0, p - 1)), children: "Previous" }), _jsxs("span", { className: "text-sm text-text-muted", children: ["Page ", page + 1] }), _jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: !hasNextPage || loading, onClick: () => setPage((p) => p + 1), children: "Next" })] })] }));
32
48
  }
@@ -8,7 +8,7 @@ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
8
8
  import { createTransportRule, } from "@rapidmx/react-shared/admin/transportRulesApi.js";
9
9
  import AdminShell from "../../../shared/components/admin/layout/AdminShell.js";
10
10
  import RuleBuilder from "../../../shared/components/rules/RuleBuilder.js";
11
- import { TRANSPORT_RULE_ACTION_TYPES, TRANSPORT_RULE_CONDITION_FIELDS } from "../_transportRuleConfig.js";
11
+ import { checkRuleConditions, NO_CONDITIONS_BLOCKED_MESSAGE, NoConditionsConfirmModal, TRANSPORT_RULE_ACTION_TYPES, TRANSPORT_RULE_CONDITION_FIELDS, } from "../_transportRuleConfig.js";
12
12
  import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
13
13
  import Button from "@rapidmx/react-shared/components/buttons/Button.js";
14
14
  import FormField from "@rapidmx/react-shared/components/forms/FormField.js";
@@ -27,6 +27,8 @@ function NewTransportRuleForm() {
27
27
  });
28
28
  const [error, setError] = useState(null);
29
29
  const [saving, setSaving] = useState(false);
30
+ const [showValidation, setShowValidation] = useState(false);
31
+ const [confirmingNoConditions, setConfirmingNoConditions] = useState(false);
30
32
  async function handleSubmit(e) {
31
33
  e.preventDefault();
32
34
  setError(null);
@@ -34,6 +36,20 @@ function NewTransportRuleForm() {
34
36
  setError("A name is required.");
35
37
  return;
36
38
  }
39
+ const check = checkRuleConditions(rule);
40
+ if (check === "blocked") {
41
+ setShowValidation(true);
42
+ setError(NO_CONDITIONS_BLOCKED_MESSAGE);
43
+ return;
44
+ }
45
+ if (check === "confirm") {
46
+ setConfirmingNoConditions(true);
47
+ return;
48
+ }
49
+ await create();
50
+ }
51
+ async function create() {
52
+ setConfirmingNoConditions(false);
37
53
  setSaving(true);
38
54
  try {
39
55
  const created = await createTransportRule({ name: name.trim(), ...rule });
@@ -46,5 +62,5 @@ function NewTransportRuleForm() {
46
62
  setSaving(false);
47
63
  }
48
64
  }
49
- return (_jsxs("div", { className: "max-w-3xl", children: [_jsx("h1", { className: "text-xl font-bold uppercase tracking-wide mb-1", children: "New transport rule" }), _jsx("p", { className: "text-sm text-text-muted mb-5", children: "Evaluated once per SMTP transaction, before any message is resolved to an individual mailbox." }), error && _jsx(Alert, { children: error }), _jsxs("form", { onSubmit: handleSubmit, className: "flex flex-col gap-5", children: [_jsx("div", { className: "bg-surface border border-border rounded-md p-6", children: _jsx(FormField, { label: "Name", htmlFor: "name", children: _jsx("input", { id: "name", type: "text", className: INPUT_CLASS, value: name, onChange: (e) => setName(e.target.value), placeholder: "Flag external senders" }) }) }), _jsx(RuleBuilder, { value: rule, onChange: setRule, conditionFields: TRANSPORT_RULE_CONDITION_FIELDS, actionTypes: TRANSPORT_RULE_ACTION_TYPES }), _jsxs("div", { className: "flex gap-3", children: [_jsx(Button, { type: "submit", loading: saving, disabled: saving, className: "!w-auto", children: "Create transport rule" }), _jsx("a", { href: "/admin/transport-rules", children: _jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", children: "Cancel" }) })] })] })] }));
65
+ return (_jsxs("div", { className: "max-w-3xl", children: [_jsx("h1", { className: "text-xl font-bold uppercase tracking-wide mb-1", children: "New transport rule" }), _jsx("p", { className: "text-sm text-text-muted mb-5", children: "Evaluated once per SMTP transaction, before any message is resolved to an individual mailbox." }), error && _jsx(Alert, { children: error }), _jsxs("form", { onSubmit: handleSubmit, className: "flex flex-col gap-5", children: [_jsx("div", { className: "bg-surface border border-border rounded-md p-6", children: _jsx(FormField, { label: "Name", htmlFor: "name", children: _jsx("input", { id: "name", type: "text", className: INPUT_CLASS, value: name, onChange: (e) => setName(e.target.value), placeholder: "Flag external senders" }) }) }), _jsx(RuleBuilder, { value: rule, onChange: setRule, conditionFields: TRANSPORT_RULE_CONDITION_FIELDS, actionTypes: TRANSPORT_RULE_ACTION_TYPES, showValidation: showValidation }), _jsxs("div", { className: "flex gap-3", children: [_jsx(Button, { type: "submit", loading: saving, disabled: saving, className: "!w-auto", children: "Create transport rule" }), _jsx("a", { href: "/admin/transport-rules", children: _jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", children: "Cancel" }) })] })] }), _jsx(NoConditionsConfirmModal, { open: confirmingNoConditions, onCancel: () => setConfirmingNoConditions(false), onConfirm: () => void create() })] }));
50
66
  }
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CUSTOM_STYLESHEET_LINK_ID } from "@rapidmx/react-shared/branding/useBranding.js";
2
+ /** Unlike the other apps, never links the admin-configured custom stylesheet: the escrow console handles escrow
3
+ * key material, so no admin-supplied CSS is loaded on it. */
3
4
  export default function Layout({ children, branding }) {
4
5
  const title = branding?.title || branding?.companyName
5
6
  ? `${branding?.title || branding?.companyName}: Escrow Console`
6
7
  : "RapidMX: Escrow Console";
7
8
  const iconHref = branding?.iconUrl || branding?.logoUrl || "/images/logo.svg";
8
- const stylesheetHref = branding?.stylesheetUrl;
9
- return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charSet: "utf-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), _jsx("title", { children: title }), _jsx("link", { rel: "icon", type: "image/svg+xml", href: iconHref }), _jsx("link", { rel: "alternate icon", href: "/favicon.ico" }), _jsx("link", { rel: "preconnect", href: "https://fonts.googleapis.com" }), _jsx("link", { rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "anonymous" }), _jsx("link", { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" }), stylesheetHref && _jsx("link", { rel: "stylesheet", href: stylesheetHref, id: CUSTOM_STYLESHEET_LINK_ID })] }), _jsx("body", { children: children })] }));
9
+ return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charSet: "utf-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), _jsx("title", { children: title }), _jsx("link", { rel: "icon", type: "image/svg+xml", href: iconHref }), _jsx("link", { rel: "alternate icon", href: "/favicon.ico" }), _jsx("link", { rel: "preconnect", href: "https://fonts.googleapis.com" }), _jsx("link", { rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "anonymous" }), _jsx("link", { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" })] }), _jsx("body", { children: children })] }));
10
10
  }
@@ -14,7 +14,32 @@ const ACTION_LABELS = {
14
14
  "escrow_access_request.created": "Access request created",
15
15
  "escrow_access_request.approved": "Access request approved",
16
16
  "escrow_access_request.material_read": "Material read",
17
+ "matter_export.requested": "Matter export requested",
18
+ "matter_export.ready": "Matter export ready",
19
+ "matter_export.failed": "Matter export failed",
17
20
  };
21
+ /** The label for an audit action - the raw action name for one this console doesn't know yet (a newer server). */
22
+ export function actionLabel(action) {
23
+ return ACTION_LABELS[action] ?? action;
24
+ }
25
+ const VERIFICATION_FAILURES = {
26
+ link_mismatch: "An entry was deleted, inserted or reordered.",
27
+ hash_mismatch: "An entry was edited after it was written.",
28
+ unknown_algorithm: "An entry uses a hash algorithm this server doesn't recognize.",
29
+ algorithm_downgrade: "An unkeyed entry follows keyed ones, which suggests a forged entry.",
30
+ hmac_key_unavailable: "Audit key not configured: this server can't check keyed entries, so the chain couldn't be verified.",
31
+ truncated: "Entries missing at the end: entries were deleted from the end of the chain.",
32
+ head_mismatch: "The chain's head record doesn't match its last entry.",
33
+ head_mac_mismatch: "The chain's head record was forged or edited.",
34
+ head_missing: "The chain's head record is missing.",
35
+ };
36
+ /** Explains a failed chain verification by its `reason` (plus where it broke, when known). An unrecognized or missing
37
+ * reason (a newer or older server) reads as a generic failure. */
38
+ export function describeVerificationFailure(result) {
39
+ const where = result.brokenAtSequence === undefined ? "" : ` (at sequence ${result.brokenAtSequence})`;
40
+ const known = result.reason === undefined ? undefined : VERIFICATION_FAILURES[result.reason];
41
+ return known ? `Chain integrity check failed${where}. ${known}` : `Chain integrity check failed${where}.`;
42
+ }
18
43
  export default function EscrowAuditLogPage(props) {
19
44
  return (_jsx(EscrowShell, { ...props, active: "auditLog", children: _jsx(EscrowAuditLogContent, {}) }));
20
45
  }
@@ -62,5 +87,5 @@ function EscrowAuditLogContent() {
62
87
  }
63
88
  const hasNextPage = entries.length === PAGE_SIZE;
64
89
  return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-between mb-5", children: [_jsx("h1", { className: "text-xl font-bold uppercase tracking-wide", children: "Escrow audit log" }), isTrustedAdmin && (_jsx(Button, { type: "button", className: "!w-auto", loading: verifying, disabled: verifying, onClick: handleVerify, children: "Verify chain integrity" }))] }), _jsx("p", { className: "text-sm text-text-muted mb-5", children: "Every escrow access lifecycle event visible to you \u2014 matters under a scope you hold. A trusted administrator sees every entry across every scope instead." }), verifyError && _jsx(Alert, { children: verifyError }), verifyResult &&
65
- (verifyResult.valid ? (_jsx("div", { className: "mb-5 py-3 px-3.5 rounded-sm text-sm bg-success/10 text-success font-medium", children: "Chain verified \u2014 no tampering detected." })) : (_jsxs(Alert, { children: ["Chain integrity broken at sequence ", verifyResult.brokenAtSequence, "."] }))), error && _jsx(Alert, { children: error }), loading ? (_jsx("p", { className: "text-sm text-text-muted", children: "Loading\u2026" })) : entries.length === 0 ? (_jsx("p", { className: "text-sm text-text-muted", children: "No audit log entries visible to you yet." })) : (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm border-collapse", children: [_jsx("thead", { children: _jsx("tr", { children: ["Sequence", "Action", "Holder", "Mailbox", "Occurred"].map((h) => (_jsx("th", { className: "text-left text-xs uppercase tracking-wide text-text-muted py-2 px-2.5 border-b border-border", children: h }, h))) }) }), _jsx("tbody", { children: entries.map((entry) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.sequence }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: ACTION_LABELS[entry.action] }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.holderUserUid }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.mailboxUid }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: new Date(entry.occurredAt).toLocaleString() })] }, entry.uid))) })] }) })), _jsxs("div", { className: "flex gap-3 items-center mt-4", children: [_jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: page === 0 || loading, onClick: () => setPage((p) => Math.max(0, p - 1)), children: "Previous" }), _jsxs("span", { className: "text-sm text-text-muted", children: ["Page ", page + 1] }), _jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: !hasNextPage || loading, onClick: () => setPage((p) => p + 1), children: "Next" })] })] }));
90
+ (verifyResult.valid ? (_jsx("div", { className: "mb-5 py-3 px-3.5 rounded-sm text-sm bg-success/10 text-success font-medium", children: "Chain verified \u2014 no tampering detected." })) : (_jsx(Alert, { children: describeVerificationFailure(verifyResult) }))), error && _jsx(Alert, { children: error }), loading ? (_jsx("p", { className: "text-sm text-text-muted", children: "Loading\u2026" })) : entries.length === 0 ? (_jsx("p", { className: "text-sm text-text-muted", children: "No audit log entries visible to you yet." })) : (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm border-collapse", children: [_jsx("thead", { children: _jsx("tr", { children: ["Sequence", "Action", "Holder", "Mailbox", "Occurred"].map((h) => (_jsx("th", { className: "text-left text-xs uppercase tracking-wide text-text-muted py-2 px-2.5 border-b border-border", children: h }, h))) }) }), _jsx("tbody", { children: entries.map((entry) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.sequence }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: actionLabel(entry.action) }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.holderUserUid }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: entry.mailboxUid }), _jsx("td", { className: "py-2.5 px-2.5 border-b border-border", children: new Date(entry.occurredAt).toLocaleString() })] }, entry.uid))) })] }) })), _jsxs("div", { className: "flex gap-3 items-center mt-4", children: [_jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: page === 0 || loading, onClick: () => setPage((p) => Math.max(0, p - 1)), children: "Previous" }), _jsxs("span", { className: "text-sm text-text-muted", children: ["Page ", page + 1] }), _jsx(Button, { variant: "secondary", type: "button", className: "!w-auto", disabled: !hasNextPage || loading, onClick: () => setPage((p) => p + 1), children: "Next" })] })] }));
66
91
  }