@rapidmx/web-client 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +381 -381
- package/apps/admin/branding/index.tsx +39 -39
- package/apps/admin/data-requests/index.tsx +482 -482
- package/apps/admin/domains/[uid].tsx +166 -166
- package/apps/admin/escrow-scopes/[uid].tsx +350 -350
- package/apps/admin/index.tsx +129 -129
- package/apps/admin/mailboxes/[uid].tsx +271 -271
- package/apps/admin/mailboxes/new/index.tsx +30 -30
- package/apps/admin/plugins/index.tsx +15 -15
- package/apps/admin/retention-policy/index.tsx +39 -39
- package/apps/admin/signing-certificates/index.tsx +343 -343
- package/apps/escrow/audit-log/index.tsx +196 -196
- package/apps/escrow/matters/[uid].tsx +621 -621
- package/apps/shared/auth/adminAccess.ts +99 -99
- package/apps/shared/components/admin/diagnostics/HostCard.tsx +2 -0
- package/apps/shared/components/admin/diagnostics/PressureTiles.tsx +108 -0
- package/apps/shared/components/admin/diagnostics/PvcTable.tsx +20 -6
- package/apps/shared/components/admin/diagnostics/diagnosticsApi.ts +21 -2
- package/apps/shared/components/admin/layout/AdminShell.tsx +384 -384
- package/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.tsx +238 -238
- package/apps/shared/components/admin/mailboxes/EscrowScopeCard.tsx +152 -152
- package/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.tsx +194 -194
- package/apps/shared/components/admin/settings/BrandingForm.tsx +423 -423
- package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +119 -119
- package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +198 -198
- package/apps/shared/components/admin/settings/PluginsManager.tsx +2093 -1545
- package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +182 -182
- package/apps/shared/components/admin/settings/pluginPreferences.ts +34 -0
- package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +288 -288
- package/apps/shared/components/admin/setup/SetupWizard.tsx +446 -446
- package/apps/shared/components/admin/usePagedList.tsx +129 -129
- package/apps/shared/components/calendar/EventModal.tsx +206 -206
- package/apps/shared/components/calendar/MonthView.tsx +185 -185
- package/apps/shared/components/calendar/RecurrenceEditor.tsx +227 -227
- package/apps/shared/components/calendar/SplitDayView.tsx +144 -144
- package/apps/shared/components/calendar/TimeGridView.tsx +246 -246
- package/apps/shared/components/calendar/allDay.ts +124 -124
- package/apps/shared/components/contacts/ContactForm.tsx +383 -383
- package/apps/shared/components/contacts/ContactsToolbar.tsx +103 -103
- package/apps/shared/components/escrow/layout/EscrowShell.tsx +155 -155
- package/apps/shared/components/layout/AppShell.tsx +461 -461
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -398
- package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -168
- package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -315
- package/apps/shared/components/layout/ThemeSwitch.tsx +84 -84
- package/apps/shared/components/layout/UserMenu.tsx +439 -439
- package/apps/shared/components/mail/ConversationList.tsx +332 -323
- package/apps/shared/components/mail/ConversationThreadPane.tsx +613 -613
- package/apps/shared/components/mail/MailSelectionBar.tsx +240 -240
- package/apps/shared/components/mail/MenuButton.tsx +404 -404
- package/apps/shared/components/mail/MessageDetailPane.tsx +1757 -1757
- package/apps/shared/components/mail/compose/ComposeContext.tsx +312 -312
- package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -422
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +1681 -1681
- package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -147
- package/apps/shared/components/mail/compose/composeFlushRegistry.ts +60 -60
- package/apps/shared/components/mail/compose/quotedBody.ts +161 -161
- package/apps/shared/components/mail/listPreferences.ts +3 -3
- package/apps/shared/components/mail/reading/MessageMoreMenu.tsx +258 -258
- package/apps/shared/components/mail/reading/MessageSourceDialog.tsx +79 -79
- package/apps/shared/components/mail/reading/messageExport.ts +59 -59
- package/apps/shared/components/mail/reading/printMessage.ts +99 -99
- package/apps/shared/components/mail/reading/useMessageActions.ts +443 -443
- package/apps/shared/components/mail/verificationSeals.ts +125 -125
- package/apps/shared/components/rules/RuleBuilder.tsx +311 -311
- package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -344
- package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -51
- package/apps/shared/keyboard/ShortcutProvider.tsx +62 -62
- package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -84
- package/apps/shared/keyboard/dispatch.ts +124 -124
- package/apps/shared/keyboard/format.ts +89 -89
- package/apps/shared/keyboard/keymap.ts +114 -114
- package/apps/shared/keyboard/registry.ts +65 -65
- package/apps/shared/keyboard/targets.ts +79 -79
- package/apps/shared/mail/folderOfType.ts +49 -49
- package/apps/shared/mail/folderTree.ts +143 -143
- package/apps/shared/mail/listAllPages.ts +39 -39
- package/apps/shared/mail/newMailNotifications.ts +171 -171
- package/apps/shared/mail/outbox/sendJob.ts +445 -445
- package/apps/shared/mail/outbox/sendOutcomes.ts +155 -155
- package/apps/shared/mail/reportNotices.ts +66 -66
- package/apps/shared/mail/senderBlocking.ts +141 -141
- package/apps/shared/mail/useMailConnection.ts +205 -205
- package/apps/shared/mail/useMailLiveUpdates.ts +277 -277
- package/apps/shared/mail/useMailboxUpdateAccess.ts +60 -60
- package/apps/shared/mail/useMarkMessageRead.ts +47 -47
- package/apps/shared/mail/useNewMailNotifications.ts +178 -178
- package/apps/shared/notifications/store.ts +560 -560
- package/apps/shared/search/LocalIndexLifecycle.tsx +114 -114
- package/apps/shared/search/localIndexBuilder.ts +481 -481
- package/apps/shared/signing/enrollmentStorage.ts +33 -33
- package/apps/shared/signing/enrollmentTracker.ts +385 -385
- package/apps/shared/signing/enrollmentView.ts +251 -251
- package/apps/shared/signing/useNow.ts +19 -19
- package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -90
- package/apps/shared/styles/app.css +396 -396
- package/apps/www/calendar/index.tsx +581 -581
- package/apps/www/contacts/[uid].tsx +112 -112
- package/apps/www/index.tsx +3012 -2962
- package/apps/www/messages/[uid].tsx +139 -139
- package/apps/www/settings/auto-reply/index.tsx +136 -136
- package/apps/www/settings/blocked-senders/index.tsx +303 -303
- package/apps/www/settings/encryption/index.tsx +1290 -1290
- package/apps/www/settings/filters/[uid].tsx +179 -179
- package/apps/www/settings/filters/index.tsx +105 -105
- package/apps/www/settings/filters/new/index.tsx +165 -165
- package/apps/www/settings/labels/index.tsx +207 -207
- package/apps/www/settings/privacy/index.tsx +495 -495
- package/apps/www/settings/profile/index.tsx +251 -251
- package/apps/www/settings/read-receipts/index.tsx +150 -150
- package/apps/www/settings/sharing/index.tsx +259 -259
- package/apps/www/settings/signatures/[uid].tsx +175 -175
- package/apps/www/settings/signatures/index.tsx +91 -91
- package/apps/www/settings/signatures/new/index.tsx +138 -138
- package/apps/www/tasks/index.tsx +654 -654
- package/dist/apps/shared/components/admin/diagnostics/HostCard.js +2 -1
- package/dist/apps/shared/components/admin/diagnostics/PressureTiles.d.ts +22 -0
- package/dist/apps/shared/components/admin/diagnostics/PressureTiles.js +52 -0
- package/dist/apps/shared/components/admin/diagnostics/PvcTable.js +9 -4
- package/dist/apps/shared/components/admin/diagnostics/diagnosticsApi.d.ts +35 -2
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +3 -3
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +328 -48
- package/dist/apps/shared/components/admin/settings/pluginPreferences.d.ts +2 -0
- package/dist/apps/shared/components/admin/settings/pluginPreferences.js +35 -0
- package/dist/apps/shared/components/mail/ConversationList.d.ts +10 -3
- package/dist/apps/shared/components/mail/ConversationList.js +9 -5
- package/dist/apps/shared/components/mail/listPreferences.d.ts +1 -1
- package/dist/apps/shared/components/mail/reading/printMessage.js +11 -11
- package/dist/apps/shared/styles/app.css +396 -396
- package/dist/apps/www/index.js +51 -10
- package/package.json +2 -2
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import React, { FormEvent, useEffect, useState } from "react";
|
|
6
|
-
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
-
import { MIN_AUDIT_LOG_RETENTION_DAYS, RetentionPolicy, RetentionPolicyUpdate, updateRetentionPolicy } from "@rapidmx/react-shared/admin/retentionPolicyApi.js";
|
|
8
|
-
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
9
|
-
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
10
|
-
import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
|
|
11
|
-
|
|
12
|
-
const INPUT_CLASS =
|
|
13
|
-
"w-full text-sm py-2 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
|
|
14
|
-
|
|
15
|
-
/** Whether saving `next` days newly starts purging (nothing was configured) or purges sooner than `saved` days. */
|
|
16
|
-
function shortensRetention(next: number | null | undefined, saved: number | null | undefined): boolean {
|
|
17
|
-
return next != null && (saved == null || next < saved);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** The retention policy editor, shared by the Retention Policy page and the setup wizard. */
|
|
21
|
-
export default function RetentionPolicyForm({
|
|
22
|
-
policy,
|
|
23
|
-
onChange,
|
|
24
|
-
onDirtyChange,
|
|
25
|
-
embedded = false,
|
|
26
|
-
}: {
|
|
27
|
-
policy: RetentionPolicy;
|
|
28
|
-
onChange: (p: RetentionPolicy) => void;
|
|
29
|
-
/** Told whether the form has edits that haven't been saved. */
|
|
30
|
-
onDirtyChange?: (dirty: boolean) => void;
|
|
31
|
-
/** Set when shown as one section of a page with its own heading (the setup wizard), so the title is a smaller,
|
|
32
|
-
* lower-level heading. */
|
|
33
|
-
embedded?: boolean;
|
|
34
|
-
}) {
|
|
35
|
-
const [messageRetentionDays, setMessageRetentionDays] = useState(policy.messageRetentionDays?.toString() ?? "");
|
|
36
|
-
const [auditLogRetentionDays, setAuditLogRetentionDays] = useState(policy.auditLogRetentionDays?.toString() ?? "");
|
|
37
|
-
const [error, setError] = useState<string | null>(null);
|
|
38
|
-
const [saving, setSaving] = useState(false);
|
|
39
|
-
const [saved, setSaved] = useState(false);
|
|
40
|
-
|
|
41
|
-
// Edits are unsaved until they match what was loaded or last saved.
|
|
42
|
-
const snapshot = JSON.stringify([messageRetentionDays, auditLogRetentionDays]);
|
|
43
|
-
const [savedSnapshot, setSavedSnapshot] = useState(snapshot);
|
|
44
|
-
const dirty: boolean = snapshot !== savedSnapshot;
|
|
45
|
-
useEffect(() => onDirtyChange?.(dirty), [dirty]);
|
|
46
|
-
|
|
47
|
-
// The retention currently in effect, and a pending save that would newly start or shorten either period - which
|
|
48
|
-
// permanently deletes existing mail or audit-log entries on the next purge run, so it's confirmed first.
|
|
49
|
-
const [savedMessageDays, setSavedMessageDays] = useState(policy.messageRetentionDays);
|
|
50
|
-
const [savedAuditDays, setSavedAuditDays] = useState(policy.auditLogRetentionDays);
|
|
51
|
-
const [pendingPatch, setPendingPatch] = useState<RetentionPolicyUpdate | null>(null);
|
|
52
|
-
|
|
53
|
-
function handleSubmit(e: FormEvent) {
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
// A blank field is sent as `null`, which clears a configured age back to no automatic purge.
|
|
56
|
-
const patch: RetentionPolicyUpdate = {
|
|
57
|
-
messageRetentionDays: messageRetentionDays.trim() === "" ? null : Number(messageRetentionDays),
|
|
58
|
-
auditLogRetentionDays: auditLogRetentionDays.trim() === "" ? null : Number(auditLogRetentionDays),
|
|
59
|
-
};
|
|
60
|
-
if (
|
|
61
|
-
shortensRetention(patch.messageRetentionDays, savedMessageDays) ||
|
|
62
|
-
shortensRetention(patch.auditLogRetentionDays, savedAuditDays)
|
|
63
|
-
) {
|
|
64
|
-
setPendingPatch(patch);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
void save(patch);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function save(patch: RetentionPolicyUpdate) {
|
|
71
|
-
setPendingPatch(null);
|
|
72
|
-
setError(null);
|
|
73
|
-
setSaved(false);
|
|
74
|
-
setSaving(true);
|
|
75
|
-
try {
|
|
76
|
-
const updated = await updateRetentionPolicy(patch);
|
|
77
|
-
setSavedMessageDays(updated.messageRetentionDays);
|
|
78
|
-
setSavedAuditDays(updated.auditLogRetentionDays);
|
|
79
|
-
onChange(updated);
|
|
80
|
-
setSavedSnapshot(snapshot);
|
|
81
|
-
setSaved(true);
|
|
82
|
-
} catch (err) {
|
|
83
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not save the retention policy.");
|
|
84
|
-
} finally {
|
|
85
|
-
setSaving(false);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<div className="max-w-xl">
|
|
91
|
-
{embedded ? (
|
|
92
|
-
<h3 className="text-base font-bold uppercase tracking-wide mb-1">Retention policy</h3>
|
|
93
|
-
) : (
|
|
94
|
-
<h1 className="text-xl font-bold uppercase tracking-wide mb-1">Retention Policy</h1>
|
|
95
|
-
)}
|
|
96
|
-
<p className="text-sm text-text-muted mb-5">
|
|
97
|
-
Automatically and permanently deletes mail/audit-log entries older than the configured age.
|
|
98
|
-
Leave a field blank for no automatic purge. This does not apply to a mailbox that is a
|
|
99
|
-
custodian on an active legal hold — a held message is skipped and retried on a later run once
|
|
100
|
-
the hold is lifted.
|
|
101
|
-
</p>
|
|
102
|
-
|
|
103
|
-
{error && <Alert>{error}</Alert>}
|
|
104
|
-
{saved && !error && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
|
|
105
|
-
|
|
106
|
-
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
107
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
108
|
-
<span className="font-semibold">Message retention (days)</span>
|
|
109
|
-
<input
|
|
110
|
-
aria-label="Message retention (days)"
|
|
111
|
-
type="number"
|
|
112
|
-
min={1}
|
|
113
|
-
className={INPUT_CLASS}
|
|
114
|
-
value={messageRetentionDays}
|
|
115
|
-
onChange={(e) => setMessageRetentionDays(e.target.value)}
|
|
116
|
-
placeholder="No automatic purge"
|
|
117
|
-
/>
|
|
118
|
-
<span className="text-xs text-text-muted">
|
|
119
|
-
Applies to any message, in any folder, regardless of age.
|
|
120
|
-
</span>
|
|
121
|
-
</label>
|
|
122
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
123
|
-
<span className="font-semibold">Audit log retention (days)</span>
|
|
124
|
-
<input
|
|
125
|
-
aria-label="Audit log retention (days)"
|
|
126
|
-
type="number"
|
|
127
|
-
min={MIN_AUDIT_LOG_RETENTION_DAYS}
|
|
128
|
-
className={INPUT_CLASS}
|
|
129
|
-
value={auditLogRetentionDays}
|
|
130
|
-
onChange={(e) => setAuditLogRetentionDays(e.target.value)}
|
|
131
|
-
placeholder="Keep forever"
|
|
132
|
-
/>
|
|
133
|
-
<span className="text-xs text-text-muted">
|
|
134
|
-
Cannot be set below {MIN_AUDIT_LOG_RETENTION_DAYS} days. Never applies to the
|
|
135
|
-
tamper-evident escrow audit chain.
|
|
136
|
-
</span>
|
|
137
|
-
</label>
|
|
138
|
-
<div>
|
|
139
|
-
<Button type="submit" loading={saving} disabled={saving} className="!w-auto">
|
|
140
|
-
Save
|
|
141
|
-
</Button>
|
|
142
|
-
</div>
|
|
143
|
-
</form>
|
|
144
|
-
|
|
145
|
-
<Modal open={pendingPatch !== null} onClose={() => setPendingPatch(null)} title="Delete older data?">
|
|
146
|
-
{shortensRetention(pendingPatch?.messageRetentionDays, savedMessageDays) && (
|
|
147
|
-
<p className="text-sm mb-3">
|
|
148
|
-
{savedMessageDays == null
|
|
149
|
-
? "Mail isn't deleted automatically today."
|
|
150
|
-
: `Mail is currently kept for ${savedMessageDays} days.`}{" "}
|
|
151
|
-
With this change, every message older than <strong>{pendingPatch?.messageRetentionDays} days</strong>,
|
|
152
|
-
in every mailbox and folder, is permanently deleted on the next purge run - and so on from then on.
|
|
153
|
-
Mailboxes on an active legal hold are skipped.
|
|
154
|
-
</p>
|
|
155
|
-
)}
|
|
156
|
-
{shortensRetention(pendingPatch?.auditLogRetentionDays, savedAuditDays) && (
|
|
157
|
-
<p className="text-sm mb-3">
|
|
158
|
-
{savedAuditDays == null
|
|
159
|
-
? "Audit-log entries are kept forever today."
|
|
160
|
-
: `Audit-log entries are currently kept for ${savedAuditDays} days.`}{" "}
|
|
161
|
-
With this change, every audit-log entry older than{" "}
|
|
162
|
-
<strong>{pendingPatch?.auditLogRetentionDays} days</strong> is permanently deleted on the next purge
|
|
163
|
-
run. The escrow audit chain is never purged.
|
|
164
|
-
</p>
|
|
165
|
-
)}
|
|
166
|
-
<p className="text-sm font-semibold text-danger mb-4">Deleted data can’t be recovered.</p>
|
|
167
|
-
<div className="flex gap-3 justify-end">
|
|
168
|
-
<Button type="button" variant="secondary" className="!w-auto" onClick={() => setPendingPatch(null)}>
|
|
169
|
-
Cancel
|
|
170
|
-
</Button>
|
|
171
|
-
<Button
|
|
172
|
-
type="button"
|
|
173
|
-
className="!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger"
|
|
174
|
-
onClick={() => void save(pendingPatch!)}
|
|
175
|
-
>
|
|
176
|
-
Save and delete older data
|
|
177
|
-
</Button>
|
|
178
|
-
</div>
|
|
179
|
-
</Modal>
|
|
180
|
-
</div>
|
|
181
|
-
);
|
|
182
|
-
}
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { FormEvent, useEffect, useState } from "react";
|
|
6
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
+
import { MIN_AUDIT_LOG_RETENTION_DAYS, RetentionPolicy, RetentionPolicyUpdate, updateRetentionPolicy } from "@rapidmx/react-shared/admin/retentionPolicyApi.js";
|
|
8
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
9
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
10
|
+
import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
|
|
11
|
+
|
|
12
|
+
const INPUT_CLASS =
|
|
13
|
+
"w-full text-sm py-2 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
|
|
14
|
+
|
|
15
|
+
/** Whether saving `next` days newly starts purging (nothing was configured) or purges sooner than `saved` days. */
|
|
16
|
+
function shortensRetention(next: number | null | undefined, saved: number | null | undefined): boolean {
|
|
17
|
+
return next != null && (saved == null || next < saved);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The retention policy editor, shared by the Retention Policy page and the setup wizard. */
|
|
21
|
+
export default function RetentionPolicyForm({
|
|
22
|
+
policy,
|
|
23
|
+
onChange,
|
|
24
|
+
onDirtyChange,
|
|
25
|
+
embedded = false,
|
|
26
|
+
}: {
|
|
27
|
+
policy: RetentionPolicy;
|
|
28
|
+
onChange: (p: RetentionPolicy) => void;
|
|
29
|
+
/** Told whether the form has edits that haven't been saved. */
|
|
30
|
+
onDirtyChange?: (dirty: boolean) => void;
|
|
31
|
+
/** Set when shown as one section of a page with its own heading (the setup wizard), so the title is a smaller,
|
|
32
|
+
* lower-level heading. */
|
|
33
|
+
embedded?: boolean;
|
|
34
|
+
}) {
|
|
35
|
+
const [messageRetentionDays, setMessageRetentionDays] = useState(policy.messageRetentionDays?.toString() ?? "");
|
|
36
|
+
const [auditLogRetentionDays, setAuditLogRetentionDays] = useState(policy.auditLogRetentionDays?.toString() ?? "");
|
|
37
|
+
const [error, setError] = useState<string | null>(null);
|
|
38
|
+
const [saving, setSaving] = useState(false);
|
|
39
|
+
const [saved, setSaved] = useState(false);
|
|
40
|
+
|
|
41
|
+
// Edits are unsaved until they match what was loaded or last saved.
|
|
42
|
+
const snapshot = JSON.stringify([messageRetentionDays, auditLogRetentionDays]);
|
|
43
|
+
const [savedSnapshot, setSavedSnapshot] = useState(snapshot);
|
|
44
|
+
const dirty: boolean = snapshot !== savedSnapshot;
|
|
45
|
+
useEffect(() => onDirtyChange?.(dirty), [dirty]);
|
|
46
|
+
|
|
47
|
+
// The retention currently in effect, and a pending save that would newly start or shorten either period - which
|
|
48
|
+
// permanently deletes existing mail or audit-log entries on the next purge run, so it's confirmed first.
|
|
49
|
+
const [savedMessageDays, setSavedMessageDays] = useState(policy.messageRetentionDays);
|
|
50
|
+
const [savedAuditDays, setSavedAuditDays] = useState(policy.auditLogRetentionDays);
|
|
51
|
+
const [pendingPatch, setPendingPatch] = useState<RetentionPolicyUpdate | null>(null);
|
|
52
|
+
|
|
53
|
+
function handleSubmit(e: FormEvent) {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
// A blank field is sent as `null`, which clears a configured age back to no automatic purge.
|
|
56
|
+
const patch: RetentionPolicyUpdate = {
|
|
57
|
+
messageRetentionDays: messageRetentionDays.trim() === "" ? null : Number(messageRetentionDays),
|
|
58
|
+
auditLogRetentionDays: auditLogRetentionDays.trim() === "" ? null : Number(auditLogRetentionDays),
|
|
59
|
+
};
|
|
60
|
+
if (
|
|
61
|
+
shortensRetention(patch.messageRetentionDays, savedMessageDays) ||
|
|
62
|
+
shortensRetention(patch.auditLogRetentionDays, savedAuditDays)
|
|
63
|
+
) {
|
|
64
|
+
setPendingPatch(patch);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
void save(patch);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function save(patch: RetentionPolicyUpdate) {
|
|
71
|
+
setPendingPatch(null);
|
|
72
|
+
setError(null);
|
|
73
|
+
setSaved(false);
|
|
74
|
+
setSaving(true);
|
|
75
|
+
try {
|
|
76
|
+
const updated = await updateRetentionPolicy(patch);
|
|
77
|
+
setSavedMessageDays(updated.messageRetentionDays);
|
|
78
|
+
setSavedAuditDays(updated.auditLogRetentionDays);
|
|
79
|
+
onChange(updated);
|
|
80
|
+
setSavedSnapshot(snapshot);
|
|
81
|
+
setSaved(true);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not save the retention policy.");
|
|
84
|
+
} finally {
|
|
85
|
+
setSaving(false);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div className="max-w-xl">
|
|
91
|
+
{embedded ? (
|
|
92
|
+
<h3 className="text-base font-bold uppercase tracking-wide mb-1">Retention policy</h3>
|
|
93
|
+
) : (
|
|
94
|
+
<h1 className="text-xl font-bold uppercase tracking-wide mb-1">Retention Policy</h1>
|
|
95
|
+
)}
|
|
96
|
+
<p className="text-sm text-text-muted mb-5">
|
|
97
|
+
Automatically and permanently deletes mail/audit-log entries older than the configured age.
|
|
98
|
+
Leave a field blank for no automatic purge. This does not apply to a mailbox that is a
|
|
99
|
+
custodian on an active legal hold — a held message is skipped and retried on a later run once
|
|
100
|
+
the hold is lifted.
|
|
101
|
+
</p>
|
|
102
|
+
|
|
103
|
+
{error && <Alert>{error}</Alert>}
|
|
104
|
+
{saved && !error && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
|
|
105
|
+
|
|
106
|
+
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
107
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
108
|
+
<span className="font-semibold">Message retention (days)</span>
|
|
109
|
+
<input
|
|
110
|
+
aria-label="Message retention (days)"
|
|
111
|
+
type="number"
|
|
112
|
+
min={1}
|
|
113
|
+
className={INPUT_CLASS}
|
|
114
|
+
value={messageRetentionDays}
|
|
115
|
+
onChange={(e) => setMessageRetentionDays(e.target.value)}
|
|
116
|
+
placeholder="No automatic purge"
|
|
117
|
+
/>
|
|
118
|
+
<span className="text-xs text-text-muted">
|
|
119
|
+
Applies to any message, in any folder, regardless of age.
|
|
120
|
+
</span>
|
|
121
|
+
</label>
|
|
122
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
123
|
+
<span className="font-semibold">Audit log retention (days)</span>
|
|
124
|
+
<input
|
|
125
|
+
aria-label="Audit log retention (days)"
|
|
126
|
+
type="number"
|
|
127
|
+
min={MIN_AUDIT_LOG_RETENTION_DAYS}
|
|
128
|
+
className={INPUT_CLASS}
|
|
129
|
+
value={auditLogRetentionDays}
|
|
130
|
+
onChange={(e) => setAuditLogRetentionDays(e.target.value)}
|
|
131
|
+
placeholder="Keep forever"
|
|
132
|
+
/>
|
|
133
|
+
<span className="text-xs text-text-muted">
|
|
134
|
+
Cannot be set below {MIN_AUDIT_LOG_RETENTION_DAYS} days. Never applies to the
|
|
135
|
+
tamper-evident escrow audit chain.
|
|
136
|
+
</span>
|
|
137
|
+
</label>
|
|
138
|
+
<div>
|
|
139
|
+
<Button type="submit" loading={saving} disabled={saving} className="!w-auto">
|
|
140
|
+
Save
|
|
141
|
+
</Button>
|
|
142
|
+
</div>
|
|
143
|
+
</form>
|
|
144
|
+
|
|
145
|
+
<Modal open={pendingPatch !== null} onClose={() => setPendingPatch(null)} title="Delete older data?">
|
|
146
|
+
{shortensRetention(pendingPatch?.messageRetentionDays, savedMessageDays) && (
|
|
147
|
+
<p className="text-sm mb-3">
|
|
148
|
+
{savedMessageDays == null
|
|
149
|
+
? "Mail isn't deleted automatically today."
|
|
150
|
+
: `Mail is currently kept for ${savedMessageDays} days.`}{" "}
|
|
151
|
+
With this change, every message older than <strong>{pendingPatch?.messageRetentionDays} days</strong>,
|
|
152
|
+
in every mailbox and folder, is permanently deleted on the next purge run - and so on from then on.
|
|
153
|
+
Mailboxes on an active legal hold are skipped.
|
|
154
|
+
</p>
|
|
155
|
+
)}
|
|
156
|
+
{shortensRetention(pendingPatch?.auditLogRetentionDays, savedAuditDays) && (
|
|
157
|
+
<p className="text-sm mb-3">
|
|
158
|
+
{savedAuditDays == null
|
|
159
|
+
? "Audit-log entries are kept forever today."
|
|
160
|
+
: `Audit-log entries are currently kept for ${savedAuditDays} days.`}{" "}
|
|
161
|
+
With this change, every audit-log entry older than{" "}
|
|
162
|
+
<strong>{pendingPatch?.auditLogRetentionDays} days</strong> is permanently deleted on the next purge
|
|
163
|
+
run. The escrow audit chain is never purged.
|
|
164
|
+
</p>
|
|
165
|
+
)}
|
|
166
|
+
<p className="text-sm font-semibold text-danger mb-4">Deleted data can’t be recovered.</p>
|
|
167
|
+
<div className="flex gap-3 justify-end">
|
|
168
|
+
<Button type="button" variant="secondary" className="!w-auto" onClick={() => setPendingPatch(null)}>
|
|
169
|
+
Cancel
|
|
170
|
+
</Button>
|
|
171
|
+
<Button
|
|
172
|
+
type="button"
|
|
173
|
+
className="!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger"
|
|
174
|
+
onClick={() => void save(pendingPatch!)}
|
|
175
|
+
>
|
|
176
|
+
Save and delete older data
|
|
177
|
+
</Button>
|
|
178
|
+
</div>
|
|
179
|
+
</Modal>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
/**
|
|
6
|
+
* Whether the Plugins page offers prerelease versions (`1.0.0-beta.2`) of plugins - for an update, in the version lists
|
|
7
|
+
* and in a plugin search. Stored in `localStorage`, so it is a preference of this browser, not a setting the server
|
|
8
|
+
* keeps: it only decides what the administrator is shown, since an administrator can already install any published
|
|
9
|
+
* version by name. Off unless it was turned on.
|
|
10
|
+
*
|
|
11
|
+
* A read that finds nothing, or a `localStorage` that throws (private-browsing/storage-blocked contexts), is off, and a
|
|
12
|
+
* write that fails is swallowed, so a blocked store only means the choice doesn't survive a reload.
|
|
13
|
+
*/
|
|
14
|
+
const STORAGE_KEY = "rapidmx:plugins-allow-prerelease";
|
|
15
|
+
|
|
16
|
+
export function getAllowPrerelease(): boolean {
|
|
17
|
+
try {
|
|
18
|
+
return localStorage.getItem(STORAGE_KEY) === "true";
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function setAllowPrerelease(allow: boolean): void {
|
|
25
|
+
try {
|
|
26
|
+
if (allow) {
|
|
27
|
+
localStorage.setItem(STORAGE_KEY, "true");
|
|
28
|
+
} else {
|
|
29
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
// Not persisted; the choice still applies until the page is reloaded.
|
|
33
|
+
}
|
|
34
|
+
}
|