@rapidmx/web-client 0.2.0 → 0.3.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/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
|
@@ -1,287 +1,302 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import React, { createContext, PropsWithChildren, ReactNode, useContext, useEffect, useMemo, useState } from "react";
|
|
6
|
-
import { HiOutlineBars3 } from "react-icons/hi2";
|
|
7
|
-
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
8
|
-
import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
|
|
9
|
-
import { Folder, Mailbox, listFolders, listMailboxes } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
10
|
-
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
11
|
-
import Skeleton, { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
|
|
12
|
-
import AppShell, { AppShellProps } from "../../layout/AppShell.js";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
mailboxUid
|
|
21
|
-
|
|
22
|
-
folderUid
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const [
|
|
101
|
-
const [
|
|
102
|
-
const [
|
|
103
|
-
const [
|
|
104
|
-
const [
|
|
105
|
-
const [
|
|
106
|
-
const [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
//
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { createContext, PropsWithChildren, ReactNode, useContext, useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { HiOutlineBars3 } from "react-icons/hi2";
|
|
7
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
8
|
+
import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
|
|
9
|
+
import { Folder, Mailbox, listFolders, listMailboxes } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
10
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
11
|
+
import Skeleton, { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
|
|
12
|
+
import AppShell, { AppShellProps } from "../../layout/AppShell.js";
|
|
13
|
+
import KeyEnrollmentGate from "../../layout/KeyEnrollmentGate.js";
|
|
14
|
+
import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
|
|
15
|
+
import { useCompose } from "../compose/ComposeContext.js";
|
|
16
|
+
|
|
17
|
+
export type MailShellProps = Omit<AppShellProps, "active">;
|
|
18
|
+
|
|
19
|
+
export interface MailShellContextValue {
|
|
20
|
+
/** The mailbox currently selected (`?mailboxUid=`, or the caller's first accessible mailbox). */
|
|
21
|
+
mailboxUid?: string;
|
|
22
|
+
/** The folder currently selected (`?folderUid=`, or the selected mailbox's Inbox). */
|
|
23
|
+
folderUid?: string;
|
|
24
|
+
mailboxes: Mailbox[];
|
|
25
|
+
folders: Folder[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const MailShellContext = createContext<MailShellContextValue>({ mailboxes: [], folders: [] });
|
|
29
|
+
|
|
30
|
+
/** Reads the mailbox/folder a page is currently showing, as resolved by the enclosing `MailShell`. */
|
|
31
|
+
export function useMailShell(): MailShellContextValue {
|
|
32
|
+
return useContext(MailShellContext);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const FOLDER_LABELS: Record<string, string> = {
|
|
36
|
+
inbox: "Inbox",
|
|
37
|
+
sent_items: "Sent Items",
|
|
38
|
+
drafts: "Drafts",
|
|
39
|
+
outbox: "Outbox",
|
|
40
|
+
junk: "Junk Email",
|
|
41
|
+
archive: "Archive",
|
|
42
|
+
deleted_items: "Deleted Items",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Well-known folders sort first, in Gmail/Outlook's conventional order; anything else (incl. `user`) sorts after, alphabetically. */
|
|
46
|
+
const FOLDER_ORDER = ["inbox", "drafts", "outbox", "sent_items", "junk", "archive", "deleted_items"];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A mailbox's `calendar`/`contacts`/`tasks`/`notes` folders back their own dedicated apps (see
|
|
50
|
+
* `CalendarShell`/`ContactsShell`/`TasksShell`), not Mail — `listFolders()` returns every well-known
|
|
51
|
+
* folder for the mailbox regardless of which app owns it, so Mail's own folder tree must filter down
|
|
52
|
+
* to just the mail ones itself, or those other apps' folders leak into this sidebar.
|
|
53
|
+
*/
|
|
54
|
+
const MAIL_FOLDER_TYPES = new Set([...FOLDER_ORDER, "user"]);
|
|
55
|
+
|
|
56
|
+
function folderSortKey(folder: Folder): number {
|
|
57
|
+
const idx = FOLDER_ORDER.indexOf(folder.type);
|
|
58
|
+
return idx === -1 ? FOLDER_ORDER.length : idx;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type Status = "checking" | "error" | "ready";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A separate component (not inlined into `MailShell`'s own render) so `useCompose()` resolves against
|
|
65
|
+
* `ComposeProvider` correctly: that provider is rendered *inside* the `AppShell` that `MailShell` itself
|
|
66
|
+
* returns, i.e. a descendant of `MailShell`, not an ancestor — a hook call made directly in `MailShell`'s
|
|
67
|
+
* own function body would see only whatever context exists *above* `MailShell`, never a provider one of
|
|
68
|
+
* its own descendants creates. This button, rendered as part of `AppShell`'s `children`, sits correctly
|
|
69
|
+
* inside that subtree.
|
|
70
|
+
*/
|
|
71
|
+
function ComposeButton({ mailboxUid }: { mailboxUid: string }) {
|
|
72
|
+
const { openCompose } = useCompose();
|
|
73
|
+
return (
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
onClick={() => openCompose({ mailboxUid })}
|
|
77
|
+
className="block text-center w-full py-2.5 px-4 rounded-sm font-semibold text-sm bg-primary text-white hover:bg-primary-dark"
|
|
78
|
+
>
|
|
79
|
+
Compose
|
|
80
|
+
</button>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Mail's own contextual sidebar (mailbox switcher + folder tree) + content area, rendered inside the shared
|
|
86
|
+
* `AppShell` chrome (icon rail, header, impersonation banner — see that component). There is no client-side
|
|
87
|
+
* router in this framework (see `ReactRoute`'s file-convention resolver) — the selected mailbox/folder live
|
|
88
|
+
* in the URL's `?mailboxUid=`/`?folderUid=` query params, read once on mount (never during the initial
|
|
89
|
+
* render itself, matching every other query-param reader in this codebase — e.g. `apps/admin/quarantine`'s
|
|
90
|
+
* `readMailboxUid()` — so the server-rendered and just-hydrated client markup match).
|
|
91
|
+
*/
|
|
92
|
+
export default function MailShell({
|
|
93
|
+
userUid,
|
|
94
|
+
authServerUrl,
|
|
95
|
+
impersonating,
|
|
96
|
+
impersonationBaseUrl,
|
|
97
|
+
trusted,
|
|
98
|
+
children,
|
|
99
|
+
}: PropsWithChildren<MailShellProps>) {
|
|
100
|
+
const [status, setStatus] = useState<Status>("checking");
|
|
101
|
+
const [error, setError] = useState<string | null>(null);
|
|
102
|
+
const [mailboxes, setMailboxes] = useState<Mailbox[]>([]);
|
|
103
|
+
const [folders, setFolders] = useState<Folder[]>([]);
|
|
104
|
+
const [foldersLoading, setFoldersLoading] = useState(true);
|
|
105
|
+
const [folderError, setFolderError] = useState<string | null>(null);
|
|
106
|
+
const [requestedMailboxUid, setRequestedMailboxUid] = useState<string | null>(null);
|
|
107
|
+
const [requestedFolderUid, setRequestedFolderUid] = useState<string | null>(null);
|
|
108
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const params = new URLSearchParams(window.location.search);
|
|
112
|
+
setRequestedMailboxUid(params.get("mailboxUid"));
|
|
113
|
+
setRequestedFolderUid(params.get("folderUid"));
|
|
114
|
+
}, []);
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!userUid) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
listMailboxes({ limit: 100 })
|
|
121
|
+
.then((result) => {
|
|
122
|
+
setMailboxes(result);
|
|
123
|
+
setStatus("ready");
|
|
124
|
+
})
|
|
125
|
+
.catch((err) => {
|
|
126
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not load your mailboxes.");
|
|
127
|
+
setStatus("error");
|
|
128
|
+
});
|
|
129
|
+
}, [userUid]);
|
|
130
|
+
|
|
131
|
+
const mailboxUid: string | undefined =
|
|
132
|
+
(requestedMailboxUid && mailboxes.some((mb) => mb.uid === requestedMailboxUid) ? requestedMailboxUid : undefined) ??
|
|
133
|
+
mailboxes[0]?.uid;
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (!mailboxUid) {
|
|
137
|
+
setFolders([]);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
setFolderError(null);
|
|
141
|
+
setFoldersLoading(true);
|
|
142
|
+
listFolders(mailboxUid)
|
|
143
|
+
.then((result) => setFolders(result.filter((f) => MAIL_FOLDER_TYPES.has(f.type))))
|
|
144
|
+
.catch((err) => setFolderError(err instanceof ApiRequestError ? err.message : "Could not load folders."))
|
|
145
|
+
.finally(() => setFoldersLoading(false));
|
|
146
|
+
}, [mailboxUid]);
|
|
147
|
+
|
|
148
|
+
const folderUid: string | undefined =
|
|
149
|
+
(requestedFolderUid && folders.some((f) => f.uid === requestedFolderUid) ? requestedFolderUid : undefined) ??
|
|
150
|
+
folders.find((f) => f.type === "inbox")?.uid;
|
|
151
|
+
|
|
152
|
+
const contextValue = useMemo<MailShellContextValue>(
|
|
153
|
+
() => ({ mailboxUid, folderUid, mailboxes, folders }),
|
|
154
|
+
[mailboxUid, folderUid, mailboxes, folders],
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const sortedFolders = useMemo(
|
|
158
|
+
() => [...folders].sort((a, b) => folderSortKey(a) - folderSortKey(b) || a.name.localeCompare(b.name)),
|
|
159
|
+
[folders],
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
// A full-screen takeover, not nested inside the rest of the app's chrome — there's nothing else
|
|
163
|
+
// for a mailbox-less caller to do here yet, so the icon rail/header/folder tree don't render at all.
|
|
164
|
+
if (userUid && status === "ready" && !mailboxUid) {
|
|
165
|
+
return <MailboxProvisioning />;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let inner: ReactNode = null;
|
|
169
|
+
if (userUid && status === "checking") {
|
|
170
|
+
// Renders immediately (no network round trip needed) so switching into Mail never shows a blank
|
|
171
|
+
// pane while `listMailboxes()` is in flight — the outline below mirrors the real sidebar's shape.
|
|
172
|
+
inner = (
|
|
173
|
+
<aside className="w-64 shrink-0 bg-surface border-r border-border flex flex-col p-3 gap-4">
|
|
174
|
+
<Skeleton height="h-9" className="rounded-sm" />
|
|
175
|
+
<SkeletonList count={6} />
|
|
176
|
+
</aside>
|
|
177
|
+
);
|
|
178
|
+
} else if (userUid && status === "error") {
|
|
179
|
+
inner = (
|
|
180
|
+
<div className="flex-1 flex items-center justify-center p-8">
|
|
181
|
+
<div className="w-full max-w-md">
|
|
182
|
+
<Alert>{error}</Alert>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
} else if (userUid && status === "ready") {
|
|
187
|
+
// A function, not a plain JSX constant — it's rendered twice (desktop `<aside>` + mobile
|
|
188
|
+
// `Drawer`), possibly *simultaneously* mounted (the aside is only CSS-hidden below `md`, not
|
|
189
|
+
// unmounted), so the mailbox-switcher `<select>`'s `id`/its `<label>`'s `htmlFor` need a distinct
|
|
190
|
+
// value per instance. Two elements sharing one id breaks label association (and is invalid HTML).
|
|
191
|
+
const sidebarContent = (idPrefix: string) => (
|
|
192
|
+
<>
|
|
193
|
+
<div className="p-3">
|
|
194
|
+
<ComposeButton mailboxUid={mailboxUid} />
|
|
195
|
+
</div>
|
|
196
|
+
{mailboxes.length > 1 && (
|
|
197
|
+
<div className="px-3 pb-2">
|
|
198
|
+
<label
|
|
199
|
+
className="block text-xs font-bold uppercase tracking-wide text-text-muted mb-1"
|
|
200
|
+
htmlFor={`${idPrefix}-mailbox-switcher`}
|
|
201
|
+
>
|
|
202
|
+
Mailbox
|
|
203
|
+
</label>
|
|
204
|
+
<select
|
|
205
|
+
id={`${idPrefix}-mailbox-switcher`}
|
|
206
|
+
className="w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
207
|
+
value={mailboxUid}
|
|
208
|
+
onChange={(e) => {
|
|
209
|
+
window.location.href = `/?mailboxUid=${encodeURIComponent(e.target.value)}`;
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
{mailboxes.map((mb) => (
|
|
213
|
+
<option key={mb.uid} value={mb.uid}>
|
|
214
|
+
{mb.displayName}
|
|
215
|
+
{mb.ownerUserUid ? "" : " (shared)"}
|
|
216
|
+
</option>
|
|
217
|
+
))}
|
|
218
|
+
</select>
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
221
|
+
{folderError && (
|
|
222
|
+
<div className="px-3 pb-2">
|
|
223
|
+
<Alert>{folderError}</Alert>
|
|
224
|
+
</div>
|
|
225
|
+
)}
|
|
226
|
+
<nav className="flex-1 overflow-y-auto px-3 pb-3 flex flex-col gap-0.5">
|
|
227
|
+
{foldersLoading ? (
|
|
228
|
+
<SkeletonList count={5} className="pt-1" />
|
|
229
|
+
) : (
|
|
230
|
+
sortedFolders.map((folder) => (
|
|
231
|
+
<a
|
|
232
|
+
key={folder.uid}
|
|
233
|
+
href={`/?mailboxUid=${encodeURIComponent(mailboxUid)}&folderUid=${encodeURIComponent(folder.uid)}`}
|
|
234
|
+
className={[
|
|
235
|
+
"flex items-center justify-between text-sm rounded-sm py-1.5 px-2.5",
|
|
236
|
+
folder.uid === folderUid
|
|
237
|
+
? "bg-primary/10 text-primary-dark font-semibold"
|
|
238
|
+
: "text-text hover:bg-surface-alt",
|
|
239
|
+
].join(" ")}
|
|
240
|
+
>
|
|
241
|
+
<span>{FOLDER_LABELS[folder.type] ?? folder.name}</span>
|
|
242
|
+
{folder.unreadCount > 0 && (
|
|
243
|
+
<span className="text-xs font-bold rounded-pill py-0.5 px-1.5 bg-surface-alt text-text-muted">
|
|
244
|
+
{folder.unreadCount}
|
|
245
|
+
</span>
|
|
246
|
+
)}
|
|
247
|
+
</a>
|
|
248
|
+
))
|
|
249
|
+
)}
|
|
250
|
+
</nav>
|
|
251
|
+
</>
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
inner = (
|
|
255
|
+
<>
|
|
256
|
+
<aside className="hidden md:flex w-64 shrink-0 bg-surface border-r border-border flex-col">
|
|
257
|
+
{sidebarContent("desktop")}
|
|
258
|
+
</aside>
|
|
259
|
+
<Drawer open={drawerOpen} onClose={() => setDrawerOpen(false)} title="Folders">
|
|
260
|
+
<div className="flex flex-col">{sidebarContent("mobile")}</div>
|
|
261
|
+
</Drawer>
|
|
262
|
+
<main className="flex-1 min-w-0 overflow-y-auto">
|
|
263
|
+
<button
|
|
264
|
+
type="button"
|
|
265
|
+
className="md:hidden m-3 w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text"
|
|
266
|
+
aria-label="Open folders"
|
|
267
|
+
onClick={() => setDrawerOpen(true)}
|
|
268
|
+
>
|
|
269
|
+
<HiOutlineBars3 size={20} aria-hidden="true" />
|
|
270
|
+
</button>
|
|
271
|
+
<MailShellContext.Provider value={contextValue}>{children}</MailShellContext.Provider>
|
|
272
|
+
</main>
|
|
273
|
+
</>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Wraps AppShell unconditionally, at a stable tree position regardless of whether mailboxUid has
|
|
278
|
+
// resolved yet - KeyEnrollmentGate itself passes `children` through untouched until a real
|
|
279
|
+
// mailboxUid is supplied (see its own doc comment). Wrapping only once ready (a conditional tree
|
|
280
|
+
// position) would make AppShell itself remount the moment mailboxUid resolves, tearing down
|
|
281
|
+
// whatever state/effects it had already started (confirmed by direct reproduction: the
|
|
282
|
+
// impersonation banner's own internal state was lost exactly at that transition).
|
|
283
|
+
const selectedMailbox = mailboxes.find((mb) => mb.uid === mailboxUid);
|
|
284
|
+
return (
|
|
285
|
+
<KeyEnrollmentGate
|
|
286
|
+
mailboxUid={mailboxUid}
|
|
287
|
+
mailboxAddress={selectedMailbox?.primarySmtpAddress}
|
|
288
|
+
mailboxKeys={selectedMailbox?.keys}
|
|
289
|
+
>
|
|
290
|
+
<AppShell
|
|
291
|
+
active="mail"
|
|
292
|
+
userUid={userUid}
|
|
293
|
+
authServerUrl={authServerUrl}
|
|
294
|
+
impersonating={impersonating}
|
|
295
|
+
impersonationBaseUrl={impersonationBaseUrl}
|
|
296
|
+
trusted={trusted}
|
|
297
|
+
>
|
|
298
|
+
{inner}
|
|
299
|
+
</AppShell>
|
|
300
|
+
</KeyEnrollmentGate>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
@@ -23,9 +23,12 @@ export const SETTINGS_SECTIONS: SettingsSectionDef[] = [
|
|
|
23
23
|
{ id: "auto-reply", href: "/settings/auto-reply", label: "Automatic Replies" },
|
|
24
24
|
{ id: "filters", href: "/settings/filters", label: "Mail Filters" },
|
|
25
25
|
{ id: "signatures", href: "/settings/signatures", label: "Signatures" },
|
|
26
|
+
{ id: "labels", href: "/settings/labels", label: "Labels" },
|
|
26
27
|
{ id: "focused-inbox", href: "/settings/focused-inbox", label: "Focused Inbox" },
|
|
27
28
|
{ id: "read-receipts", href: "/settings/read-receipts", label: "Read Receipts" },
|
|
28
29
|
{ id: "booking-types", href: "/settings/booking-types", label: "Booking Links" },
|
|
30
|
+
{ id: "encryption", href: "/settings/encryption", label: "Encryption" },
|
|
31
|
+
{ id: "privacy", href: "/settings/privacy", label: "Privacy & Data" },
|
|
29
32
|
];
|
|
30
33
|
|
|
31
34
|
export type SettingsSectionId = (typeof SETTINGS_SECTIONS)[number]["id"];
|