@rapidmx/web-client 0.2.0 → 0.3.1
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/apps/admin/data-requests/index.tsx +485 -0
- package/apps/admin/escrow-scopes/[uid].tsx +237 -0
- package/apps/admin/escrow-scopes/index.tsx +124 -0
- package/apps/admin/escrow-scopes/new/index.tsx +128 -0
- package/apps/admin/mailboxes/[uid].tsx +66 -8
- package/apps/admin/retention-policy/index.tsx +132 -0
- package/apps/escrow/_layout.tsx +41 -0
- package/apps/escrow/audit-log/index.tsx +168 -0
- package/apps/escrow/index.tsx +139 -0
- package/apps/escrow/matters/[uid].tsx +521 -0
- package/apps/escrow/matters/new/index.tsx +173 -0
- package/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.tsx +171 -0
- package/apps/shared/components/admin/layout/AdminShell.tsx +24 -0
- package/apps/shared/components/contacts/ContactDetailPane.tsx +44 -0
- package/apps/shared/components/escrow/layout/EscrowShell.tsx +134 -0
- package/apps/shared/components/forms/StringListField.tsx +104 -0
- package/apps/shared/components/layout/AppShell.tsx +4 -0
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +265 -0
- package/apps/shared/components/mail/ConversationThreadPane.tsx +8 -1
- package/apps/shared/components/mail/MessageDetailPane.tsx +214 -9
- package/apps/shared/components/mail/compose/ComposeContext.tsx +10 -1
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +271 -24
- package/apps/shared/components/mail/layout/MailShell.tsx +302 -287
- package/apps/shared/components/settings/layout/SettingsShell.tsx +3 -0
- package/apps/www/index.tsx +122 -11
- package/apps/www/messages/[uid].tsx +15 -1
- package/apps/www/settings/encryption/index.tsx +664 -0
- package/apps/www/settings/labels/index.tsx +201 -0
- package/apps/www/settings/privacy/index.tsx +436 -0
- package/dist/apps/admin/data-requests/index.js +197 -0
- package/dist/apps/admin/escrow-scopes/[uid].js +141 -0
- package/dist/apps/admin/escrow-scopes/index.js +31 -0
- package/dist/apps/admin/escrow-scopes/new/index.js +69 -0
- package/dist/apps/admin/mailboxes/[uid].js +26 -2
- package/dist/apps/admin/retention-policy/index.js +65 -0
- package/dist/apps/escrow/_layout.js +10 -0
- package/dist/apps/escrow/audit-log/index.js +66 -0
- package/dist/apps/escrow/index.js +31 -0
- package/dist/apps/escrow/matters/[uid].js +234 -0
- package/dist/apps/escrow/matters/new/index.js +75 -0
- package/dist/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.js +26 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.js +19 -1
- package/dist/apps/shared/components/contacts/ContactDetailPane.js +10 -1
- package/dist/apps/shared/components/escrow/layout/EscrowShell.js +75 -0
- package/dist/apps/shared/components/forms/StringListField.js +39 -0
- package/dist/apps/shared/components/layout/AppShell.js +4 -0
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +142 -0
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +2 -2
- package/dist/apps/shared/components/mail/MessageDetailPane.js +105 -6
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +2 -1
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +184 -21
- package/dist/apps/shared/components/mail/layout/MailShell.js +11 -2
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +3 -0
- package/dist/apps/www/index.js +110 -10
- package/dist/apps/www/messages/[uid].js +12 -2
- package/dist/apps/www/settings/encryption/index.js +330 -0
- package/dist/apps/www/settings/labels/index.js +95 -0
- package/dist/apps/www/settings/privacy/index.js +167 -0
- package/package.json +9 -3
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { ChangeEvent, FormEvent, useEffect, useRef, useState } from "react";
|
|
6
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
+
import {
|
|
8
|
+
DataExportFormat,
|
|
9
|
+
DataExportRequest,
|
|
10
|
+
createExportRequest,
|
|
11
|
+
exportRequestDownloadUrl,
|
|
12
|
+
listExportRequests,
|
|
13
|
+
} from "@rapidmx/react-shared/mail/dataExportApi.js";
|
|
14
|
+
import {
|
|
15
|
+
MailboxImportFormat,
|
|
16
|
+
MailboxImportRequest,
|
|
17
|
+
listImportRequests,
|
|
18
|
+
uploadMailboxImport,
|
|
19
|
+
} from "@rapidmx/react-shared/mail/mailboxImportApi.js";
|
|
20
|
+
import {
|
|
21
|
+
DataSubjectErasureRequest,
|
|
22
|
+
approveErasureRequest,
|
|
23
|
+
denyErasureRequest,
|
|
24
|
+
listErasureRequests,
|
|
25
|
+
} from "@rapidmx/react-shared/mail/erasureRequestApi.js";
|
|
26
|
+
import { Folder, listFolders } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
27
|
+
import AdminShell, { AdminShellProps } from "../../shared/components/admin/layout/AdminShell.js";
|
|
28
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
29
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
30
|
+
import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
|
|
31
|
+
|
|
32
|
+
const INPUT_CLASS = "text-sm border border-border rounded-sm py-1.5 px-2 bg-surface";
|
|
33
|
+
const NON_MAIL_FOLDER_TYPES = new Set(["calendar", "contacts", "tasks", "notes"]);
|
|
34
|
+
|
|
35
|
+
function importFormatFromFilename(filename: string): MailboxImportFormat {
|
|
36
|
+
return filename.toLowerCase().endsWith(".pst") ? "pst" : "mbox";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function statusBadgeClass(status: string): string {
|
|
40
|
+
if (status === "failed" || status === "denied") return "bg-danger-bg text-danger";
|
|
41
|
+
if (status === "pending" || status === "processing") return "bg-surface-alt text-text-muted";
|
|
42
|
+
return "bg-success text-white";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default function DataRequestsPage(props: Omit<AdminShellProps, "active">) {
|
|
46
|
+
return (
|
|
47
|
+
<AdminShell {...props} active="dataRequests">
|
|
48
|
+
<div className="flex flex-col gap-8">
|
|
49
|
+
<div>
|
|
50
|
+
<h1 className="text-xl font-bold uppercase tracking-wide mb-1">Data Requests</h1>
|
|
51
|
+
<p className="text-sm text-text-muted">
|
|
52
|
+
Every GDPR export, mailbox-import, and account-erasure request across every mailbox.
|
|
53
|
+
</p>
|
|
54
|
+
</div>
|
|
55
|
+
<ExportRequestsSection />
|
|
56
|
+
<ImportRequestsSection />
|
|
57
|
+
<ErasureRequestsSection />
|
|
58
|
+
</div>
|
|
59
|
+
</AdminShell>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function ExportRequestsSection() {
|
|
64
|
+
const [requests, setRequests] = useState<DataExportRequest[]>([]);
|
|
65
|
+
const [loading, setLoading] = useState(true);
|
|
66
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
67
|
+
const [mailboxUid, setMailboxUid] = useState("");
|
|
68
|
+
const [format, setFormat] = useState<DataExportFormat>("json");
|
|
69
|
+
const [creating, setCreating] = useState(false);
|
|
70
|
+
const [createError, setCreateError] = useState<string | null>(null);
|
|
71
|
+
|
|
72
|
+
// The create form below isn't gated behind `loading`, so a fast create-then-reload can resolve before
|
|
73
|
+
// the initial mount fetch does; without this guard the mount fetch's now-stale response would land
|
|
74
|
+
// last and silently revert the list. Only the most-recently-issued load's response is ever applied.
|
|
75
|
+
const loadSeq = useRef(0);
|
|
76
|
+
function loadRequests() {
|
|
77
|
+
const seq = ++loadSeq.current;
|
|
78
|
+
return listExportRequests()
|
|
79
|
+
.then((data) => {
|
|
80
|
+
if (seq === loadSeq.current) setRequests(data);
|
|
81
|
+
})
|
|
82
|
+
.catch((err) => {
|
|
83
|
+
if (seq === loadSeq.current) setLoadError(err instanceof ApiRequestError ? err.message : "Could not load export requests.");
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
loadRequests().finally(() => setLoading(false));
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
async function handleCreate(e: FormEvent) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
setCreateError(null);
|
|
95
|
+
setCreating(true);
|
|
96
|
+
try {
|
|
97
|
+
await createExportRequest({ format, mailboxUid: mailboxUid.trim() });
|
|
98
|
+
setMailboxUid("");
|
|
99
|
+
await loadRequests();
|
|
100
|
+
} catch (err) {
|
|
101
|
+
setCreateError(err instanceof ApiRequestError ? err.message : "Could not start this export.");
|
|
102
|
+
} finally {
|
|
103
|
+
setCreating(false);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<section>
|
|
109
|
+
<h2 className="text-sm font-bold uppercase tracking-wide text-text-muted mb-3">Export requests</h2>
|
|
110
|
+
|
|
111
|
+
<form onSubmit={handleCreate} className="flex items-end gap-3 mb-4 flex-wrap">
|
|
112
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
113
|
+
<span className="font-semibold">Mailbox UID</span>
|
|
114
|
+
<input
|
|
115
|
+
aria-label="Export mailbox UID"
|
|
116
|
+
className={INPUT_CLASS}
|
|
117
|
+
value={mailboxUid}
|
|
118
|
+
onChange={(e) => setMailboxUid(e.target.value)}
|
|
119
|
+
/>
|
|
120
|
+
</label>
|
|
121
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
122
|
+
<span className="font-semibold">Format</span>
|
|
123
|
+
<select
|
|
124
|
+
aria-label="Export format"
|
|
125
|
+
className={INPUT_CLASS}
|
|
126
|
+
value={format}
|
|
127
|
+
onChange={(e) => setFormat(e.target.value as DataExportFormat)}
|
|
128
|
+
>
|
|
129
|
+
<option value="json">JSON</option>
|
|
130
|
+
<option value="mbox">Mbox</option>
|
|
131
|
+
</select>
|
|
132
|
+
</label>
|
|
133
|
+
<Button type="submit" variant="secondary" className="!w-auto" loading={creating} disabled={creating || !mailboxUid.trim()}>
|
|
134
|
+
Create export
|
|
135
|
+
</Button>
|
|
136
|
+
</form>
|
|
137
|
+
|
|
138
|
+
{createError && <Alert>{createError}</Alert>}
|
|
139
|
+
{loadError && <Alert>{loadError}</Alert>}
|
|
140
|
+
|
|
141
|
+
{loading ? (
|
|
142
|
+
<p className="text-sm text-text-muted">Loading…</p>
|
|
143
|
+
) : requests.length === 0 ? (
|
|
144
|
+
<p className="text-sm text-text-muted">No export requests.</p>
|
|
145
|
+
) : (
|
|
146
|
+
<ul className="flex flex-col gap-2">
|
|
147
|
+
{requests.map((request) => (
|
|
148
|
+
<li
|
|
149
|
+
key={request.uid}
|
|
150
|
+
className="flex items-center justify-between gap-3 text-sm py-1.5 px-3 bg-surface-alt rounded-sm"
|
|
151
|
+
>
|
|
152
|
+
<span>
|
|
153
|
+
{request.mailboxUid} · {request.format.toUpperCase()} ·{" "}
|
|
154
|
+
{new Date(request.dateCreated).toLocaleString()}
|
|
155
|
+
{request.status === "failed" && request.errorMessage && (
|
|
156
|
+
<span className="text-danger"> — {request.errorMessage}</span>
|
|
157
|
+
)}
|
|
158
|
+
</span>
|
|
159
|
+
<span className="flex items-center gap-3">
|
|
160
|
+
<span
|
|
161
|
+
className={`text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill ${statusBadgeClass(request.status)}`}
|
|
162
|
+
>
|
|
163
|
+
{request.status}
|
|
164
|
+
</span>
|
|
165
|
+
{request.status === "ready" && (
|
|
166
|
+
<a href={exportRequestDownloadUrl(request.uid)} className="text-primary-dark hover:underline font-medium">
|
|
167
|
+
Download
|
|
168
|
+
</a>
|
|
169
|
+
)}
|
|
170
|
+
</span>
|
|
171
|
+
</li>
|
|
172
|
+
))}
|
|
173
|
+
</ul>
|
|
174
|
+
)}
|
|
175
|
+
</section>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function ImportRequestsSection() {
|
|
180
|
+
const [requests, setRequests] = useState<MailboxImportRequest[]>([]);
|
|
181
|
+
const [loading, setLoading] = useState(true);
|
|
182
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
183
|
+
const [mailboxUid, setMailboxUid] = useState("");
|
|
184
|
+
const [folders, setFolders] = useState<Folder[]>([]);
|
|
185
|
+
const [targetFolderUid, setTargetFolderUid] = useState("");
|
|
186
|
+
const [folderError, setFolderError] = useState<string | null>(null);
|
|
187
|
+
const [uploading, setUploading] = useState(false);
|
|
188
|
+
const [uploadError, setUploadError] = useState<string | null>(null);
|
|
189
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
190
|
+
|
|
191
|
+
// Same stale-response guard as ExportRequestsSection's loadRequests() - the Upload button is enabled
|
|
192
|
+
// independently of this section's own `loading`, so a fast upload-then-reload can resolve before the
|
|
193
|
+
// initial mount fetch does.
|
|
194
|
+
const loadSeq = useRef(0);
|
|
195
|
+
function loadRequests() {
|
|
196
|
+
const seq = ++loadSeq.current;
|
|
197
|
+
return listImportRequests()
|
|
198
|
+
.then((data) => {
|
|
199
|
+
if (seq === loadSeq.current) setRequests(data);
|
|
200
|
+
})
|
|
201
|
+
.catch((err) => {
|
|
202
|
+
if (seq === loadSeq.current) setLoadError(err instanceof ApiRequestError ? err.message : "Could not load import requests.");
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
loadRequests().finally(() => setLoading(false));
|
|
208
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
209
|
+
}, []);
|
|
210
|
+
|
|
211
|
+
function handleLoadFolders() {
|
|
212
|
+
const uid = mailboxUid.trim();
|
|
213
|
+
setTargetFolderUid("");
|
|
214
|
+
setFolders([]);
|
|
215
|
+
setFolderError(null);
|
|
216
|
+
if (!uid) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
listFolders(uid)
|
|
220
|
+
.then((all) => {
|
|
221
|
+
const mailFolders = all.filter((f) => !NON_MAIL_FOLDER_TYPES.has(f.type));
|
|
222
|
+
setFolders(mailFolders);
|
|
223
|
+
setTargetFolderUid(mailFolders[0]?.uid ?? "");
|
|
224
|
+
})
|
|
225
|
+
.catch((err) => setFolderError(err instanceof ApiRequestError ? err.message : "Could not load this mailbox's folders."));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function handleFileChange(e: ChangeEvent<HTMLInputElement>) {
|
|
229
|
+
const file = e.target.files?.[0];
|
|
230
|
+
e.target.value = "";
|
|
231
|
+
if (!file || !targetFolderUid || !mailboxUid.trim()) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
setUploadError(null);
|
|
235
|
+
setUploading(true);
|
|
236
|
+
uploadMailboxImport(file, { format: importFormatFromFilename(file.name), targetFolderUid, mailboxUid: mailboxUid.trim() })
|
|
237
|
+
.then(() => loadRequests())
|
|
238
|
+
.catch((err) => setUploadError(err instanceof ApiRequestError ? err.message : "Could not upload this file."))
|
|
239
|
+
.finally(() => setUploading(false));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<section>
|
|
244
|
+
<h2 className="text-sm font-bold uppercase tracking-wide text-text-muted mb-3">Import requests</h2>
|
|
245
|
+
|
|
246
|
+
<div className="flex items-end gap-3 mb-2 flex-wrap">
|
|
247
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
248
|
+
<span className="font-semibold">Mailbox UID</span>
|
|
249
|
+
<input
|
|
250
|
+
aria-label="Import mailbox UID"
|
|
251
|
+
className={INPUT_CLASS}
|
|
252
|
+
value={mailboxUid}
|
|
253
|
+
onChange={(e) => setMailboxUid(e.target.value)}
|
|
254
|
+
onBlur={handleLoadFolders}
|
|
255
|
+
/>
|
|
256
|
+
</label>
|
|
257
|
+
{folders.length > 0 && (
|
|
258
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
259
|
+
<span className="font-semibold">Destination folder</span>
|
|
260
|
+
<select
|
|
261
|
+
aria-label="Import destination folder"
|
|
262
|
+
className={INPUT_CLASS}
|
|
263
|
+
value={targetFolderUid}
|
|
264
|
+
onChange={(e) => setTargetFolderUid(e.target.value)}
|
|
265
|
+
>
|
|
266
|
+
{folders.map((folder) => (
|
|
267
|
+
<option key={folder.uid} value={folder.uid}>
|
|
268
|
+
{folder.name}
|
|
269
|
+
</option>
|
|
270
|
+
))}
|
|
271
|
+
</select>
|
|
272
|
+
</label>
|
|
273
|
+
)}
|
|
274
|
+
<Button
|
|
275
|
+
type="button"
|
|
276
|
+
variant="secondary"
|
|
277
|
+
className="!w-auto"
|
|
278
|
+
loading={uploading}
|
|
279
|
+
disabled={uploading || !targetFolderUid}
|
|
280
|
+
onClick={() => fileInputRef.current?.click()}
|
|
281
|
+
>
|
|
282
|
+
Upload Mbox or PST file
|
|
283
|
+
</Button>
|
|
284
|
+
<input
|
|
285
|
+
ref={fileInputRef}
|
|
286
|
+
type="file"
|
|
287
|
+
accept=".mbox,.pst"
|
|
288
|
+
aria-label="Upload mail archive"
|
|
289
|
+
className="hidden"
|
|
290
|
+
onChange={handleFileChange}
|
|
291
|
+
/>
|
|
292
|
+
</div>
|
|
293
|
+
|
|
294
|
+
{folderError && <Alert>{folderError}</Alert>}
|
|
295
|
+
{uploadError && <Alert>{uploadError}</Alert>}
|
|
296
|
+
{loadError && <Alert>{loadError}</Alert>}
|
|
297
|
+
|
|
298
|
+
{loading ? (
|
|
299
|
+
<p className="text-sm text-text-muted">Loading…</p>
|
|
300
|
+
) : requests.length === 0 ? (
|
|
301
|
+
<p className="text-sm text-text-muted">No import requests.</p>
|
|
302
|
+
) : (
|
|
303
|
+
<ul className="flex flex-col gap-2">
|
|
304
|
+
{requests.map((request) => (
|
|
305
|
+
<li
|
|
306
|
+
key={request.uid}
|
|
307
|
+
className="flex items-center justify-between gap-3 text-sm py-1.5 px-3 bg-surface-alt rounded-sm"
|
|
308
|
+
>
|
|
309
|
+
<span>
|
|
310
|
+
{request.mailboxUid} · {request.format.toUpperCase()} ·{" "}
|
|
311
|
+
{new Date(request.dateCreated).toLocaleString()}
|
|
312
|
+
{request.status === "completed" && (
|
|
313
|
+
<span className="text-text-muted">
|
|
314
|
+
{" "}
|
|
315
|
+
— {request.importedCount ?? 0} imported
|
|
316
|
+
{request.failedCount ? `, ${request.failedCount} failed` : ""}
|
|
317
|
+
</span>
|
|
318
|
+
)}
|
|
319
|
+
{request.status === "failed" && request.errorMessage && (
|
|
320
|
+
<span className="text-danger"> — {request.errorMessage}</span>
|
|
321
|
+
)}
|
|
322
|
+
</span>
|
|
323
|
+
<span
|
|
324
|
+
className={`text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill ${statusBadgeClass(request.status)}`}
|
|
325
|
+
>
|
|
326
|
+
{request.status}
|
|
327
|
+
</span>
|
|
328
|
+
</li>
|
|
329
|
+
))}
|
|
330
|
+
</ul>
|
|
331
|
+
)}
|
|
332
|
+
</section>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function ErasureRequestsSection() {
|
|
337
|
+
const [requests, setRequests] = useState<DataSubjectErasureRequest[]>([]);
|
|
338
|
+
const [loading, setLoading] = useState(true);
|
|
339
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
340
|
+
const [actionErrors, setActionErrors] = useState<Record<string, string>>({});
|
|
341
|
+
const [actingOn, setActingOn] = useState<Record<string, boolean>>({});
|
|
342
|
+
const [denyTarget, setDenyTarget] = useState<DataSubjectErasureRequest | null>(null);
|
|
343
|
+
const [denyReason, setDenyReason] = useState("");
|
|
344
|
+
const [denying, setDenying] = useState(false);
|
|
345
|
+
const [denyError, setDenyError] = useState<string | null>(null);
|
|
346
|
+
|
|
347
|
+
function loadRequests() {
|
|
348
|
+
return listErasureRequests()
|
|
349
|
+
.then(setRequests)
|
|
350
|
+
.catch((err) => setLoadError(err instanceof ApiRequestError ? err.message : "Could not load erasure requests."));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
loadRequests().finally(() => setLoading(false));
|
|
355
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
356
|
+
}, []);
|
|
357
|
+
|
|
358
|
+
async function handleApprove(request: DataSubjectErasureRequest) {
|
|
359
|
+
setActingOn((prev) => ({ ...prev, [request.uid]: true }));
|
|
360
|
+
setActionErrors((prev) => ({ ...prev, [request.uid]: "" }));
|
|
361
|
+
try {
|
|
362
|
+
await approveErasureRequest(request.uid);
|
|
363
|
+
await loadRequests();
|
|
364
|
+
} catch (err) {
|
|
365
|
+
setActionErrors((prev) => ({
|
|
366
|
+
...prev,
|
|
367
|
+
[request.uid]: err instanceof ApiRequestError ? err.message : "Could not approve this request.",
|
|
368
|
+
}));
|
|
369
|
+
} finally {
|
|
370
|
+
setActingOn((prev) => ({ ...prev, [request.uid]: false }));
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function closeDenyModal() {
|
|
375
|
+
setDenyTarget(null);
|
|
376
|
+
setDenyReason("");
|
|
377
|
+
setDenyError(null);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async function handleDeny() {
|
|
381
|
+
setDenyError(null);
|
|
382
|
+
setDenying(true);
|
|
383
|
+
try {
|
|
384
|
+
// Only invoked from the deny modal below, which only renders once denyTarget is set.
|
|
385
|
+
await denyErasureRequest(denyTarget!.uid, denyReason);
|
|
386
|
+
closeDenyModal();
|
|
387
|
+
await loadRequests();
|
|
388
|
+
} catch (err) {
|
|
389
|
+
setDenyError(err instanceof ApiRequestError ? err.message : "Could not deny this request.");
|
|
390
|
+
} finally {
|
|
391
|
+
setDenying(false);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return (
|
|
396
|
+
<section>
|
|
397
|
+
<h2 className="text-sm font-bold uppercase tracking-wide text-text-muted mb-3">Erasure requests</h2>
|
|
398
|
+
<p className="text-xs text-text-muted mb-3">
|
|
399
|
+
Self-service only — a mailbox owner requests their own account's erasure; there is no
|
|
400
|
+
admin-initiated path here, only review.
|
|
401
|
+
</p>
|
|
402
|
+
|
|
403
|
+
{loadError && <Alert>{loadError}</Alert>}
|
|
404
|
+
|
|
405
|
+
{loading ? (
|
|
406
|
+
<p className="text-sm text-text-muted">Loading…</p>
|
|
407
|
+
) : requests.length === 0 ? (
|
|
408
|
+
<p className="text-sm text-text-muted">No erasure requests.</p>
|
|
409
|
+
) : (
|
|
410
|
+
<ul className="flex flex-col gap-2">
|
|
411
|
+
{requests.map((request) => (
|
|
412
|
+
<li key={request.uid} className="border border-border rounded-sm p-3">
|
|
413
|
+
<div className="flex items-center justify-between gap-3">
|
|
414
|
+
<span className="text-sm">
|
|
415
|
+
{request.mailboxUid} · {new Date(request.dateCreated).toLocaleString()}
|
|
416
|
+
{request.status === "denied" && request.reason && (
|
|
417
|
+
<span className="text-danger"> — {request.reason}</span>
|
|
418
|
+
)}
|
|
419
|
+
{request.status === "completed" && request.purgedCount !== undefined && (
|
|
420
|
+
<span className="text-text-muted"> — {request.purgedCount} records purged</span>
|
|
421
|
+
)}
|
|
422
|
+
</span>
|
|
423
|
+
<span
|
|
424
|
+
className={`text-xs font-bold uppercase tracking-wide py-0.5 px-2 rounded-pill ${statusBadgeClass(request.status)}`}
|
|
425
|
+
>
|
|
426
|
+
{request.status}
|
|
427
|
+
</span>
|
|
428
|
+
</div>
|
|
429
|
+
{actionErrors[request.uid] && <Alert>{actionErrors[request.uid]}</Alert>}
|
|
430
|
+
{request.status === "pending" && (
|
|
431
|
+
<div className="flex gap-3 mt-2">
|
|
432
|
+
<Button
|
|
433
|
+
type="button"
|
|
434
|
+
className="!w-auto"
|
|
435
|
+
loading={actingOn[request.uid]}
|
|
436
|
+
disabled={actingOn[request.uid]}
|
|
437
|
+
onClick={() => handleApprove(request)}
|
|
438
|
+
>
|
|
439
|
+
Approve
|
|
440
|
+
</Button>
|
|
441
|
+
<Button
|
|
442
|
+
type="button"
|
|
443
|
+
variant="secondary"
|
|
444
|
+
className="!w-auto"
|
|
445
|
+
disabled={actingOn[request.uid]}
|
|
446
|
+
onClick={() => setDenyTarget(request)}
|
|
447
|
+
>
|
|
448
|
+
Deny
|
|
449
|
+
</Button>
|
|
450
|
+
</div>
|
|
451
|
+
)}
|
|
452
|
+
</li>
|
|
453
|
+
))}
|
|
454
|
+
</ul>
|
|
455
|
+
)}
|
|
456
|
+
|
|
457
|
+
<Modal open={denyTarget !== null} onClose={closeDenyModal} title="Deny erasure request">
|
|
458
|
+
<label className="flex flex-col gap-1.5 text-sm mb-4">
|
|
459
|
+
<span className="font-semibold">Reason</span>
|
|
460
|
+
<input
|
|
461
|
+
aria-label="Denial reason"
|
|
462
|
+
className={INPUT_CLASS}
|
|
463
|
+
value={denyReason}
|
|
464
|
+
onChange={(e) => setDenyReason(e.target.value)}
|
|
465
|
+
/>
|
|
466
|
+
</label>
|
|
467
|
+
{denyError && <Alert>{denyError}</Alert>}
|
|
468
|
+
<div className="flex gap-3 justify-end">
|
|
469
|
+
<Button type="button" variant="secondary" className="!w-auto" disabled={denying} onClick={closeDenyModal}>
|
|
470
|
+
Cancel
|
|
471
|
+
</Button>
|
|
472
|
+
<Button
|
|
473
|
+
type="button"
|
|
474
|
+
className="!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger"
|
|
475
|
+
loading={denying}
|
|
476
|
+
disabled={denying || !denyReason.trim()}
|
|
477
|
+
onClick={handleDeny}
|
|
478
|
+
>
|
|
479
|
+
Deny
|
|
480
|
+
</Button>
|
|
481
|
+
</div>
|
|
482
|
+
</Modal>
|
|
483
|
+
</section>
|
|
484
|
+
);
|
|
485
|
+
}
|