@rapidmx/web-client 0.6.0 → 0.7.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/shared/components/admin/settings/BrandingForm.tsx +398 -385
- package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +119 -112
- package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +159 -152
- package/apps/shared/components/admin/settings/PluginsManager.tsx +1288 -1235
- package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +9 -1
- package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +288 -290
- package/apps/shared/components/admin/setup/SetupWizard.tsx +443 -416
- package/apps/shared/components/layout/AppShell.tsx +288 -288
- package/apps/shared/components/mail/ConversationList.tsx +225 -33
- package/apps/shared/components/mail/ConversationThreadPane.tsx +434 -216
- package/apps/shared/components/mail/MailListToolbar.tsx +265 -0
- package/apps/shared/components/mail/MailSelectionBar.tsx +222 -0
- package/apps/shared/components/mail/MenuButton.tsx +384 -0
- package/apps/shared/components/mail/MessageDetailPane.tsx +280 -215
- package/apps/shared/components/mail/MoveToFolderDialog.tsx +263 -0
- package/apps/shared/components/mail/compose/ComposeContext.tsx +29 -2
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +1700 -1652
- package/apps/shared/components/mail/compose/RecipientInput.tsx +356 -0
- package/apps/shared/components/mail/compose/RichTextEditor.tsx +38 -3
- package/apps/shared/components/mail/compose/quotedBody.ts +100 -0
- package/apps/shared/components/mail/compose/recipients.ts +104 -0
- package/apps/shared/components/mail/labelMenu.tsx +278 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +445 -420
- package/apps/shared/components/mail/listPreferences.ts +228 -0
- package/apps/shared/components/settings/layout/SettingsShell.tsx +0 -1
- package/apps/shared/styles/app.css +28 -5
- package/apps/www/index.tsx +1854 -1314
- package/apps/www/messages/[uid].tsx +5 -4
- package/dist/apps/shared/components/admin/settings/BrandingForm.d.ts +7 -3
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +6 -5
- package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.d.ts +4 -1
- package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.js +2 -2
- package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.d.ts +4 -1
- package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.js +2 -2
- package/dist/apps/shared/components/admin/settings/PluginsManager.d.ts +8 -1
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +33 -14
- package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.d.ts +4 -1
- package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.js +2 -2
- package/dist/apps/shared/components/admin/setup/EscrowSetupStep.js +1 -1
- package/dist/apps/shared/components/admin/setup/SetupWizard.js +14 -10
- package/dist/apps/shared/components/mail/ConversationList.d.ts +42 -6
- package/dist/apps/shared/components/mail/ConversationList.js +84 -10
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +52 -13
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +217 -60
- package/dist/apps/shared/components/mail/MailListToolbar.d.ts +55 -0
- package/dist/apps/shared/components/mail/MailListToolbar.js +149 -0
- package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +59 -0
- package/dist/apps/shared/components/mail/MailSelectionBar.js +48 -0
- package/dist/apps/shared/components/mail/MenuButton.d.ts +71 -0
- package/dist/apps/shared/components/mail/MenuButton.js +211 -0
- package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +27 -19
- package/dist/apps/shared/components/mail/MessageDetailPane.js +126 -129
- package/dist/apps/shared/components/mail/MoveToFolderDialog.d.ts +57 -0
- package/dist/apps/shared/components/mail/MoveToFolderDialog.js +138 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +16 -1
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +3 -1
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +52 -20
- package/dist/apps/shared/components/mail/compose/RecipientInput.d.ts +36 -0
- package/dist/apps/shared/components/mail/compose/RecipientInput.js +203 -0
- package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +10 -1
- package/dist/apps/shared/components/mail/compose/RichTextEditor.js +21 -3
- package/dist/apps/shared/components/mail/compose/quotedBody.d.ts +37 -0
- package/dist/apps/shared/components/mail/compose/quotedBody.js +85 -0
- package/dist/apps/shared/components/mail/compose/recipients.d.ts +24 -0
- package/dist/apps/shared/components/mail/compose/recipients.js +87 -0
- package/dist/apps/shared/components/mail/labelMenu.d.ts +97 -0
- package/dist/apps/shared/components/mail/labelMenu.js +134 -0
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +8 -0
- package/dist/apps/shared/components/mail/layout/MailShell.js +15 -3
- package/dist/apps/shared/components/mail/listPreferences.d.ts +101 -0
- package/dist/apps/shared/components/mail/listPreferences.js +186 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +0 -1
- package/dist/apps/shared/styles/app.css +28 -5
- package/dist/apps/www/index.js +506 -112
- package/dist/apps/www/messages/[uid].js +2 -3
- package/package.json +2 -2
- package/apps/www/settings/focused-inbox/index.tsx +0 -150
- package/dist/apps/www/settings/focused-inbox/index.d.ts +0 -4
- package/dist/apps/www/settings/focused-inbox/index.js +0 -71
|
@@ -2,57 +2,249 @@
|
|
|
2
2
|
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
3
|
// SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import React from "react";
|
|
6
|
-
import {
|
|
5
|
+
import React, { useState } from "react";
|
|
6
|
+
import { HiChevronDown, HiChevronRight, HiOutlineFlag, HiOutlinePaperClip } from "react-icons/hi2";
|
|
7
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
8
|
+
import { Message } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
9
|
+
import { ConversationSummary, listConversationMessages } from "@rapidmx/react-shared/mail/conversationsApi.js";
|
|
7
10
|
|
|
8
11
|
export interface ConversationListProps {
|
|
9
12
|
conversations: ConversationSummary[];
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
/** The mailbox the conversations were listed from - `listConversationMessages()` is mailbox-scoped. */
|
|
14
|
+
mailboxUid: string;
|
|
15
|
+
/** The message currently open in the reading pane, so the row standing for it can be marked. */
|
|
16
|
+
selectedUid: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Opens a conversation in the reading pane, positioned at one of its messages: the one a child row
|
|
19
|
+
* stands for, or the conversation's own `latestMessageUid` for a parent row. The conversation goes
|
|
20
|
+
* with the uid because the pane shows the whole thread, not just that message.
|
|
21
|
+
*/
|
|
22
|
+
onOpenMessage: (conversation: ConversationSummary, uid: string) => void;
|
|
23
|
+
/** Newer copies of messages this list already fetched - the reading pane marks the message it opens as
|
|
24
|
+
* read, which this list would otherwise keep showing as unread until the thread is collapsed and
|
|
25
|
+
* expanded again. */
|
|
26
|
+
messageOverrides?: Record<string, Message>;
|
|
27
|
+
/** Turns each parent row into a checkbox row: select mode here ticks whole conversations, since a
|
|
28
|
+
* conversation is what this list's rows are. A child row stays a plain "open this message" button - a
|
|
29
|
+
* mixed conversation/message selection has no sensible bulk semantics (see `MailListToolbar`). */
|
|
30
|
+
selectMode?: boolean;
|
|
31
|
+
/** The `conversationId`s currently ticked. */
|
|
32
|
+
selectedConversationIds?: Set<string>;
|
|
33
|
+
onToggleSelected?: (conversation: ConversationSummary) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a conversation's own messages read newest first, matching the order sense the rows themselves
|
|
36
|
+
* are in ("Newest on top"). `listConversationMessages()` always answers oldest first - the order a
|
|
37
|
+
* thread is read in - so this reverses that copy for display rather than asking for it differently.
|
|
38
|
+
*/
|
|
39
|
+
newestFirst?: boolean;
|
|
12
40
|
}
|
|
13
41
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
42
|
+
function participantNames(conversation: ConversationSummary): string {
|
|
43
|
+
return conversation.participants.map((participant) => participant.displayName || participant.address).join(", ");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The nested, Outlook-style conversation list: one parent row per conversation - its participants, subject,
|
|
48
|
+
* message count, unread count, flag/attachment hints and the latest message's preview - expanding via its
|
|
49
|
+
* own chevron into the conversation's individual messages as child rows, fetched on first expand with
|
|
50
|
+
* `listConversationMessages()` (one request for the whole thread, across folders, oldest first).
|
|
51
|
+
*
|
|
52
|
+
* Opening a row opens the whole conversation in `ConversationThreadPane`, positioned at the message the row
|
|
53
|
+
* stands for: the latest one for a parent row, that one for a child row.
|
|
54
|
+
*
|
|
55
|
+
* The chevron is a button of its own beside the row's own button rather than inside it (a button can't
|
|
56
|
+
* nest inside a button), so expanding and opening are separately reachable by keyboard and each carries
|
|
57
|
+
* its own name.
|
|
58
|
+
*/
|
|
59
|
+
export default function ConversationList({
|
|
60
|
+
conversations,
|
|
61
|
+
mailboxUid,
|
|
62
|
+
selectedUid,
|
|
63
|
+
onOpenMessage,
|
|
64
|
+
messageOverrides,
|
|
65
|
+
selectMode,
|
|
66
|
+
selectedConversationIds,
|
|
67
|
+
onToggleSelected,
|
|
68
|
+
newestFirst,
|
|
69
|
+
}: ConversationListProps) {
|
|
70
|
+
const [expanded, setExpanded] = useState<Set<string>>(new Set());
|
|
71
|
+
const [messagesById, setMessagesById] = useState<Record<string, Message[]>>({});
|
|
72
|
+
const [loadingIds, setLoadingIds] = useState<Set<string>>(new Set());
|
|
73
|
+
const [errorsById, setErrorsById] = useState<Record<string, string>>({});
|
|
74
|
+
|
|
75
|
+
function toggle(conversation: ConversationSummary) {
|
|
76
|
+
const id = conversation.conversationId;
|
|
77
|
+
setExpanded((prev) => {
|
|
78
|
+
const next = new Set(prev);
|
|
79
|
+
if (next.has(id)) {
|
|
80
|
+
next.delete(id);
|
|
81
|
+
} else {
|
|
82
|
+
next.add(id);
|
|
83
|
+
}
|
|
84
|
+
return next;
|
|
85
|
+
});
|
|
86
|
+
if (expanded.has(id) || messagesById[id] || loadingIds.has(id)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
setLoadingIds((prev) => new Set(prev).add(id));
|
|
90
|
+
setErrorsById((prev) => {
|
|
91
|
+
const next = { ...prev };
|
|
92
|
+
delete next[id];
|
|
93
|
+
return next;
|
|
94
|
+
});
|
|
95
|
+
listConversationMessages(mailboxUid, id)
|
|
96
|
+
.then((loaded) => setMessagesById((prev) => ({ ...prev, [id]: loaded })))
|
|
97
|
+
.catch((err) =>
|
|
98
|
+
setErrorsById((prev) => ({
|
|
99
|
+
...prev,
|
|
100
|
+
[id]: err instanceof ApiRequestError ? err.message : "Could not load this conversation's messages.",
|
|
101
|
+
}))
|
|
102
|
+
)
|
|
103
|
+
.finally(() =>
|
|
104
|
+
setLoadingIds((prev) => {
|
|
105
|
+
const next = new Set(prev);
|
|
106
|
+
next.delete(id);
|
|
107
|
+
return next;
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
18
112
|
if (conversations.length === 0) {
|
|
19
|
-
return <p className="p-4 text-sm text-text-muted">No conversations in this
|
|
113
|
+
return <p className="p-4 text-sm text-text-muted">No conversations in this folder.</p>;
|
|
20
114
|
}
|
|
21
115
|
|
|
22
116
|
return (
|
|
23
117
|
<ul>
|
|
24
118
|
{conversations.map((conversation) => {
|
|
119
|
+
const id = conversation.conversationId;
|
|
120
|
+
const isExpanded = expanded.has(id);
|
|
25
121
|
const unread = conversation.unreadCount > 0;
|
|
122
|
+
const loaded = messagesById[id];
|
|
123
|
+
// `listConversationMessages()` answers oldest first; the rows read in whichever sense the
|
|
124
|
+
// list itself is arranged in. Copied before reversing - the fetched array is cached.
|
|
125
|
+
const children = loaded && newestFirst ? [...loaded].reverse() : loaded;
|
|
126
|
+
const panelId = `conversation-messages-${id}`;
|
|
127
|
+
const ticked = selectedConversationIds?.has(id) ?? false;
|
|
26
128
|
return (
|
|
27
|
-
<li key={
|
|
28
|
-
<
|
|
29
|
-
type="button"
|
|
30
|
-
onClick={() => onSelect(conversation)}
|
|
129
|
+
<li key={id}>
|
|
130
|
+
<div
|
|
31
131
|
className={[
|
|
32
|
-
"
|
|
33
|
-
conversation.
|
|
34
|
-
|
|
132
|
+
"flex items-stretch border-b border-border",
|
|
133
|
+
conversation.latestMessageUid === selectedUid || ticked
|
|
134
|
+
? "bg-primary/10"
|
|
135
|
+
: "hover:bg-surface-alt",
|
|
35
136
|
].join(" ")}
|
|
36
137
|
>
|
|
37
|
-
|
|
38
|
-
<span className="
|
|
39
|
-
|
|
138
|
+
{selectMode && (
|
|
139
|
+
<span className="shrink-0 flex items-center pl-3">
|
|
140
|
+
<input
|
|
141
|
+
type="checkbox"
|
|
142
|
+
checked={ticked}
|
|
143
|
+
onChange={() => onToggleSelected?.(conversation)}
|
|
144
|
+
aria-label={`Select conversation: ${conversation.subject || "(no subject)"}`}
|
|
145
|
+
className="w-4 h-4 accent-primary"
|
|
146
|
+
/>
|
|
40
147
|
</span>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
148
|
+
)}
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
onClick={() => toggle(conversation)}
|
|
152
|
+
aria-expanded={isExpanded}
|
|
153
|
+
aria-controls={panelId}
|
|
154
|
+
aria-label={`${isExpanded ? "Collapse" : "Expand"} conversation: ${conversation.subject || "(no subject)"}`}
|
|
155
|
+
className="shrink-0 px-2 text-text-muted hover:text-text"
|
|
156
|
+
>
|
|
157
|
+
{isExpanded ? (
|
|
158
|
+
<HiChevronDown size={16} aria-hidden="true" />
|
|
159
|
+
) : (
|
|
160
|
+
<HiChevronRight size={16} aria-hidden="true" />
|
|
52
161
|
)}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
162
|
+
</button>
|
|
163
|
+
<button
|
|
164
|
+
type="button"
|
|
165
|
+
onClick={() => onOpenMessage(conversation, conversation.latestMessageUid)}
|
|
166
|
+
className={["flex-1 min-w-0 text-left pr-4 py-3", unread ? "font-semibold" : ""].join(
|
|
167
|
+
" "
|
|
168
|
+
)}
|
|
169
|
+
>
|
|
170
|
+
<div className="flex items-center justify-between gap-2 text-sm">
|
|
171
|
+
<span className="truncate">{participantNames(conversation)}</span>
|
|
172
|
+
<span className="text-xs text-text-muted shrink-0">
|
|
173
|
+
{new Date(conversation.latestDate).toLocaleDateString()}
|
|
174
|
+
</span>
|
|
175
|
+
</div>
|
|
176
|
+
<div className="text-sm truncate">{conversation.subject || "(no subject)"}</div>
|
|
177
|
+
<div className="text-xs text-text-muted truncate font-normal">
|
|
178
|
+
{conversation.latestPreview}
|
|
179
|
+
</div>
|
|
180
|
+
<div className="flex items-center gap-2 mt-1 text-xs text-text-muted font-normal">
|
|
181
|
+
{conversation.messageCount > 1 && <span>{conversation.messageCount} messages</span>}
|
|
182
|
+
{/* A one-message conversation's unread state is already the row's own
|
|
183
|
+
bolding - counting it "1 unread" on every such row is just noise. */}
|
|
184
|
+
{unread && conversation.messageCount > 1 && (
|
|
185
|
+
<span className="py-0.5 px-2 rounded-pill bg-primary/10 text-primary-dark font-semibold">
|
|
186
|
+
{conversation.unreadCount} unread
|
|
187
|
+
</span>
|
|
188
|
+
)}
|
|
189
|
+
{conversation.hasAttachments && (
|
|
190
|
+
<HiOutlinePaperClip size={13} aria-label="Has attachments" />
|
|
191
|
+
)}
|
|
192
|
+
{conversation.flagged && (
|
|
193
|
+
<HiOutlineFlag size={13} aria-label="Flagged" className="text-danger" />
|
|
194
|
+
)}
|
|
195
|
+
</div>
|
|
196
|
+
</button>
|
|
197
|
+
</div>
|
|
198
|
+
<ul id={panelId} hidden={!isExpanded}>
|
|
199
|
+
{errorsById[id] && (
|
|
200
|
+
<li role="alert" className="pl-8 pr-4 py-2 text-xs text-danger border-b border-border">
|
|
201
|
+
{errorsById[id]}
|
|
202
|
+
</li>
|
|
203
|
+
)}
|
|
204
|
+
{loadingIds.has(id) && (
|
|
205
|
+
<li className="pl-8 pr-4 py-2 text-xs text-text-muted border-b border-border">
|
|
206
|
+
Loading messages…
|
|
207
|
+
</li>
|
|
208
|
+
)}
|
|
209
|
+
{children?.map((fetched) => {
|
|
210
|
+
const message = messageOverrides?.[fetched.uid] ?? fetched;
|
|
211
|
+
return (
|
|
212
|
+
<li key={message.uid}>
|
|
213
|
+
<button
|
|
214
|
+
type="button"
|
|
215
|
+
onClick={() => onOpenMessage(conversation, message.uid)}
|
|
216
|
+
className={[
|
|
217
|
+
"w-full text-left pl-8 pr-4 py-2 border-b border-border",
|
|
218
|
+
message.uid === selectedUid ? "bg-primary/10" : "hover:bg-surface-alt",
|
|
219
|
+
message.flags.read ? "" : "font-semibold",
|
|
220
|
+
].join(" ")}
|
|
221
|
+
>
|
|
222
|
+
<div className="flex items-center justify-between gap-2 text-sm">
|
|
223
|
+
<span className="truncate">
|
|
224
|
+
{message.from.displayName || message.from.address}
|
|
225
|
+
</span>
|
|
226
|
+
<span className="text-xs text-text-muted shrink-0">
|
|
227
|
+
{new Date(message.receivedDate).toLocaleDateString()}
|
|
228
|
+
</span>
|
|
229
|
+
</div>
|
|
230
|
+
<div className="flex items-center gap-2 text-xs text-text-muted font-normal">
|
|
231
|
+
<span className="truncate">{message.bodyPreview}</span>
|
|
232
|
+
{message.hasAttachments && (
|
|
233
|
+
<HiOutlinePaperClip size={12} aria-label="Has attachments" />
|
|
234
|
+
)}
|
|
235
|
+
{message.flags.flagged && (
|
|
236
|
+
<HiOutlineFlag
|
|
237
|
+
size={12}
|
|
238
|
+
aria-label="Flagged"
|
|
239
|
+
className="text-danger"
|
|
240
|
+
/>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
243
|
+
</button>
|
|
244
|
+
</li>
|
|
245
|
+
);
|
|
246
|
+
})}
|
|
247
|
+
</ul>
|
|
56
248
|
</li>
|
|
57
249
|
);
|
|
58
250
|
})}
|