@rapidmx/web-client 0.9.0 → 0.10.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 +192 -88
- package/apps/shared/auth/accountUrl.ts +9 -0
- package/apps/shared/auth/adminAccess.ts +99 -0
- package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +2 -1
- package/apps/shared/components/calendar/layout/CalendarShell.tsx +8 -2
- package/apps/shared/components/contacts/ContactsToolbar.tsx +125 -115
- package/apps/shared/components/contacts/layout/ContactsShell.tsx +15 -3
- package/apps/shared/components/layout/AppShell.tsx +411 -288
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -389
- package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -164
- package/apps/shared/components/layout/UserMenu.tsx +303 -185
- package/apps/shared/components/mail/ConversationList.tsx +269 -262
- package/apps/shared/components/mail/ConversationThreadPane.tsx +475 -434
- package/apps/shared/components/mail/LazyReadingPane.tsx +115 -0
- package/apps/shared/components/mail/MailSelectionBar.tsx +235 -222
- package/apps/shared/components/mail/MessageDetailPane.tsx +1458 -1387
- package/apps/shared/components/mail/NewMailToasts.tsx +141 -0
- package/apps/shared/components/mail/compose/ComposeContext.tsx +279 -160
- package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -418
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +1842 -1736
- package/apps/shared/components/mail/compose/ComposeWindowPlaceholder.tsx +111 -0
- package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -118
- package/apps/shared/components/mail/compose/composePerf.ts +46 -0
- package/apps/shared/components/mail/compose/quotedBody.ts +161 -100
- package/apps/shared/components/mail/layout/MailShell.tsx +476 -472
- package/apps/shared/components/mail/unreadStyle.tsx +75 -0
- package/apps/shared/components/settings/layout/SettingsShell.tsx +252 -240
- package/apps/shared/components/tasks/layout/TasksShell.tsx +15 -3
- package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -0
- package/apps/shared/keyboard/ShortcutProvider.tsx +62 -0
- package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -0
- package/apps/shared/keyboard/dispatch.ts +124 -0
- package/apps/shared/keyboard/format.ts +89 -0
- package/apps/shared/keyboard/keymap.ts +114 -0
- package/apps/shared/keyboard/match.ts +44 -0
- package/apps/shared/keyboard/parse.ts +136 -0
- package/apps/shared/keyboard/platform.ts +34 -0
- package/apps/shared/keyboard/registry.ts +65 -0
- package/apps/shared/keyboard/targets.ts +79 -0
- package/apps/shared/keyboard/useShortcut.ts +50 -0
- package/apps/shared/keyboard/useShortcutProps.ts +17 -0
- package/apps/shared/mail/folderCounts.ts +302 -0
- package/apps/shared/mail/listSnapshots.ts +87 -0
- package/apps/shared/mail/messageReadState.ts +85 -0
- package/apps/shared/mail/newMailNotifications.ts +183 -0
- package/apps/shared/mail/useMailConnection.ts +150 -0
- package/apps/shared/mail/useMailLiveUpdates.ts +232 -224
- package/apps/shared/mail/useMarkMessageRead.ts +47 -0
- package/apps/shared/mail/useNewMailNotifications.ts +163 -0
- package/apps/shared/mail/useUnreadTitle.ts +42 -0
- package/apps/shared/navigation/AppRouter.tsx +300 -0
- package/apps/shared/navigation/appHrefs.ts +23 -0
- package/apps/shared/navigation/frameContext.tsx +35 -0
- package/apps/shared/navigation/idle.ts +45 -0
- package/apps/shared/navigation/routerContext.tsx +83 -0
- package/apps/shared/navigation/routes.ts +72 -0
- package/apps/shared/search/LocalIndexLifecycle.tsx +114 -98
- package/apps/shared/styles/app.css +28 -10
- package/apps/www/_routedPage.tsx +24 -0
- package/apps/www/_routes.ts +35 -0
- package/apps/www/calendar/index.tsx +55 -19
- package/apps/www/contacts/[uid].tsx +112 -107
- package/apps/www/contacts/index.tsx +584 -567
- package/apps/www/index.tsx +2280 -1917
- package/apps/www/messages/[uid].tsx +106 -101
- package/apps/www/settings/auto-reply/index.tsx +4 -1
- package/apps/www/settings/encryption/index.tsx +1252 -1249
- package/apps/www/settings/filters/[uid].tsx +4 -1
- package/apps/www/settings/filters/index.tsx +102 -99
- package/apps/www/settings/filters/new/index.tsx +138 -133
- package/apps/www/settings/labels/index.tsx +204 -201
- package/apps/www/settings/privacy/index.tsx +4 -1
- package/apps/www/settings/read-receipts/index.tsx +4 -1
- package/apps/www/settings/sharing/index.tsx +277 -274
- package/apps/www/settings/signatures/[uid].tsx +170 -167
- package/apps/www/settings/signatures/index.tsx +88 -85
- package/apps/www/settings/signatures/new/index.tsx +134 -129
- package/apps/www/tasks/index.tsx +18 -2
- package/dist/apps/shared/auth/accountUrl.d.ts +2 -0
- package/dist/apps/shared/auth/accountUrl.js +8 -0
- package/dist/apps/shared/auth/adminAccess.d.ts +30 -0
- package/dist/apps/shared/auth/adminAccess.js +89 -0
- package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +1 -1
- package/dist/apps/shared/components/calendar/layout/CalendarShell.d.ts +1 -1
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +8 -4
- package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +3 -1
- package/dist/apps/shared/components/contacts/ContactsToolbar.js +7 -4
- package/dist/apps/shared/components/contacts/layout/ContactsShell.d.ts +1 -1
- package/dist/apps/shared/components/contacts/layout/ContactsShell.js +15 -5
- package/dist/apps/shared/components/layout/AppShell.d.ts +29 -4
- package/dist/apps/shared/components/layout/AppShell.js +73 -14
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +10 -9
- package/dist/apps/shared/components/layout/MailboxProvisioning.js +3 -1
- package/dist/apps/shared/components/layout/UserMenu.d.ts +19 -3
- package/dist/apps/shared/components/layout/UserMenu.js +52 -5
- package/dist/apps/shared/components/mail/ConversationList.js +4 -11
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +4 -1
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +52 -27
- package/dist/apps/shared/components/mail/LazyReadingPane.d.ts +9 -0
- package/dist/apps/shared/components/mail/LazyReadingPane.js +82 -0
- package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +4 -1
- package/dist/apps/shared/components/mail/MailSelectionBar.js +11 -3
- package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +7 -1
- package/dist/apps/shared/components/mail/MessageDetailPane.js +83 -34
- package/dist/apps/shared/components/mail/NewMailToasts.d.ts +19 -0
- package/dist/apps/shared/components/mail/NewMailToasts.js +55 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +30 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +71 -5
- package/dist/apps/shared/components/mail/compose/ComposeToolbar.js +4 -3
- package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +1 -1
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +98 -22
- package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.d.ts +19 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.js +33 -0
- package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +9 -1
- package/dist/apps/shared/components/mail/compose/RichTextEditor.js +20 -2
- package/dist/apps/shared/components/mail/compose/composePerf.d.ts +16 -0
- package/dist/apps/shared/components/mail/compose/composePerf.js +41 -0
- package/dist/apps/shared/components/mail/compose/quotedBody.d.ts +13 -0
- package/dist/apps/shared/components/mail/compose/quotedBody.js +67 -11
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +12 -4
- package/dist/apps/shared/components/mail/layout/MailShell.js +76 -96
- package/dist/apps/shared/components/mail/unreadStyle.d.ts +45 -0
- package/dist/apps/shared/components/mail/unreadStyle.js +61 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.d.ts +1 -1
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +15 -5
- package/dist/apps/shared/components/tasks/layout/TasksShell.d.ts +1 -1
- package/dist/apps/shared/components/tasks/layout/TasksShell.js +15 -5
- package/dist/apps/shared/keyboard/GlobalShortcuts.d.ts +14 -0
- package/dist/apps/shared/keyboard/GlobalShortcuts.js +37 -0
- package/dist/apps/shared/keyboard/ShortcutProvider.d.ts +20 -0
- package/dist/apps/shared/keyboard/ShortcutProvider.js +52 -0
- package/dist/apps/shared/keyboard/ShortcutsDialog.d.ts +14 -0
- package/dist/apps/shared/keyboard/ShortcutsDialog.js +42 -0
- package/dist/apps/shared/keyboard/dispatch.d.ts +16 -0
- package/dist/apps/shared/keyboard/dispatch.js +109 -0
- package/dist/apps/shared/keyboard/format.d.ts +12 -0
- package/dist/apps/shared/keyboard/format.js +74 -0
- package/dist/apps/shared/keyboard/keymap.d.ts +294 -0
- package/dist/apps/shared/keyboard/keymap.js +84 -0
- package/dist/apps/shared/keyboard/match.d.ts +20 -0
- package/dist/apps/shared/keyboard/match.js +31 -0
- package/dist/apps/shared/keyboard/parse.d.ts +31 -0
- package/dist/apps/shared/keyboard/parse.js +107 -0
- package/dist/apps/shared/keyboard/platform.d.ts +15 -0
- package/dist/apps/shared/keyboard/platform.js +22 -0
- package/dist/apps/shared/keyboard/registry.d.ts +39 -0
- package/dist/apps/shared/keyboard/registry.js +33 -0
- package/dist/apps/shared/keyboard/targets.d.ts +14 -0
- package/dist/apps/shared/keyboard/targets.js +67 -0
- package/dist/apps/shared/keyboard/useShortcut.d.ts +19 -0
- package/dist/apps/shared/keyboard/useShortcut.js +35 -0
- package/dist/apps/shared/keyboard/useShortcutProps.d.ts +10 -0
- package/dist/apps/shared/keyboard/useShortcutProps.js +15 -0
- package/dist/apps/shared/mail/folderCounts.d.ts +78 -0
- package/dist/apps/shared/mail/folderCounts.js +212 -0
- package/dist/apps/shared/mail/listSnapshots.d.ts +46 -0
- package/dist/apps/shared/mail/listSnapshots.js +43 -0
- package/dist/apps/shared/mail/messageReadState.d.ts +32 -0
- package/dist/apps/shared/mail/messageReadState.js +63 -0
- package/dist/apps/shared/mail/newMailNotifications.d.ts +62 -0
- package/dist/apps/shared/mail/newMailNotifications.js +138 -0
- package/dist/apps/shared/mail/useMailConnection.d.ts +55 -0
- package/dist/apps/shared/mail/useMailConnection.js +96 -0
- package/dist/apps/shared/mail/useMailLiveUpdates.d.ts +13 -6
- package/dist/apps/shared/mail/useMailLiveUpdates.js +28 -26
- package/dist/apps/shared/mail/useMarkMessageRead.d.ts +12 -0
- package/dist/apps/shared/mail/useMarkMessageRead.js +44 -0
- package/dist/apps/shared/mail/useNewMailNotifications.d.ts +41 -0
- package/dist/apps/shared/mail/useNewMailNotifications.js +110 -0
- package/dist/apps/shared/mail/useUnreadTitle.d.ts +18 -0
- package/dist/apps/shared/mail/useUnreadTitle.js +31 -0
- package/dist/apps/shared/navigation/AppRouter.d.ts +52 -0
- package/dist/apps/shared/navigation/AppRouter.js +242 -0
- package/dist/apps/shared/navigation/appHrefs.d.ts +14 -0
- package/dist/apps/shared/navigation/appHrefs.js +20 -0
- package/dist/apps/shared/navigation/frameContext.d.ts +19 -0
- package/dist/apps/shared/navigation/frameContext.js +24 -0
- package/dist/apps/shared/navigation/idle.d.ts +14 -0
- package/dist/apps/shared/navigation/idle.js +43 -0
- package/dist/apps/shared/navigation/routerContext.d.ts +37 -0
- package/dist/apps/shared/navigation/routerContext.js +56 -0
- package/dist/apps/shared/navigation/routes.d.ts +32 -0
- package/dist/apps/shared/navigation/routes.js +37 -0
- package/dist/apps/shared/search/LocalIndexLifecycle.js +17 -3
- package/dist/apps/shared/styles/app.css +28 -10
- package/dist/apps/www/_routedPage.d.ts +12 -0
- package/dist/apps/www/_routedPage.js +19 -0
- package/dist/apps/www/_routes.d.ts +11 -0
- package/dist/apps/www/_routes.js +29 -0
- package/dist/apps/www/calendar/index.d.ts +2 -2
- package/dist/apps/www/calendar/index.js +39 -8
- package/dist/apps/www/contacts/[uid].d.ts +3 -9
- package/dist/apps/www/contacts/[uid].js +6 -2
- package/dist/apps/www/contacts/index.d.ts +2 -2
- package/dist/apps/www/contacts/index.js +17 -4
- package/dist/apps/www/index.d.ts +2 -2
- package/dist/apps/www/index.js +301 -35
- package/dist/apps/www/messages/[uid].d.ts +3 -7
- package/dist/apps/www/messages/[uid].js +7 -4
- package/dist/apps/www/settings/auto-reply/index.d.ts +2 -2
- package/dist/apps/www/settings/auto-reply/index.js +3 -1
- package/dist/apps/www/settings/encryption/index.d.ts +2 -2
- package/dist/apps/www/settings/encryption/index.js +3 -1
- package/dist/apps/www/settings/filters/[uid].d.ts +2 -2
- package/dist/apps/www/settings/filters/[uid].js +3 -1
- package/dist/apps/www/settings/filters/index.d.ts +2 -2
- package/dist/apps/www/settings/filters/index.js +3 -1
- package/dist/apps/www/settings/filters/new/index.d.ts +2 -2
- package/dist/apps/www/settings/filters/new/index.js +6 -2
- package/dist/apps/www/settings/labels/index.d.ts +2 -2
- package/dist/apps/www/settings/labels/index.js +3 -1
- package/dist/apps/www/settings/privacy/index.d.ts +2 -2
- package/dist/apps/www/settings/privacy/index.js +3 -1
- package/dist/apps/www/settings/read-receipts/index.d.ts +2 -2
- package/dist/apps/www/settings/read-receipts/index.js +3 -1
- package/dist/apps/www/settings/sharing/index.d.ts +2 -2
- package/dist/apps/www/settings/sharing/index.js +3 -1
- package/dist/apps/www/settings/signatures/[uid].d.ts +2 -2
- package/dist/apps/www/settings/signatures/[uid].js +3 -1
- package/dist/apps/www/settings/signatures/index.d.ts +2 -2
- package/dist/apps/www/settings/signatures/index.js +3 -1
- package/dist/apps/www/settings/signatures/new/index.d.ts +2 -2
- package/dist/apps/www/settings/signatures/new/index.js +6 -2
- package/dist/apps/www/tasks/index.d.ts +2 -2
- package/dist/apps/www/tasks/index.js +15 -3
- package/package.json +2 -2
|
@@ -1,274 +1,277 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const [
|
|
49
|
-
const [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const [
|
|
53
|
-
const [
|
|
54
|
-
const [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const [
|
|
58
|
-
const [
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
<span className="
|
|
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
|
-
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { routedPage } from "../../_routedPage.js";
|
|
6
|
+
import React, { FormEvent, useEffect, useState } from "react";
|
|
7
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
8
|
+
import {
|
|
9
|
+
MailboxAccessMember,
|
|
10
|
+
MailboxAccessRole,
|
|
11
|
+
listMailboxAccess,
|
|
12
|
+
lookupMailboxOwnerByEmail,
|
|
13
|
+
removeMailboxAccess,
|
|
14
|
+
setMailboxAccess,
|
|
15
|
+
} from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
|
|
16
|
+
import SettingsShell, { SettingsShellProps, useSettingsShell } from "../../../shared/components/settings/layout/SettingsShell.js";
|
|
17
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
18
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
19
|
+
import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
|
|
20
|
+
import { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
|
|
21
|
+
|
|
22
|
+
const ROLE_LABELS: Record<MailboxAccessRole, string> = { viewer: "Can view", manager: "Can manage" };
|
|
23
|
+
|
|
24
|
+
export type SettingsSharingPageProps = Omit<SettingsShellProps, "active">;
|
|
25
|
+
|
|
26
|
+
function SettingsSharingPage(props: SettingsSharingPageProps) {
|
|
27
|
+
return (
|
|
28
|
+
<SettingsShell {...props} active="sharing">
|
|
29
|
+
<SharingContent />
|
|
30
|
+
</SettingsShell>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type Status = "loading" | "ready" | "forbidden" | "error";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Manages who else can access whichever mailbox Settings is currently scoped to (the ambient mailbox from
|
|
38
|
+
* `useSettingsShell()`'s own switcher, which already lists every mailbox the caller can reach, shared ones
|
|
39
|
+
* included) - not just for shared/ownerless mailboxes specifically, matching every other settings page's
|
|
40
|
+
* own mailbox-agnostic design. A single grant here already cascades to that mailbox's calendar/contacts/
|
|
41
|
+
* tasks/mail folders (see `@rapidmx/restapi`'s `BaseMailboxAccessRoute` doc comment), so there is nothing
|
|
42
|
+
* else to configure per data type.
|
|
43
|
+
*/
|
|
44
|
+
function SharingContent() {
|
|
45
|
+
const { mailboxUid, mailboxes } = useSettingsShell();
|
|
46
|
+
const mailbox = mailboxes.find((mb) => mb.uid === mailboxUid);
|
|
47
|
+
|
|
48
|
+
const [members, setMembers] = useState<MailboxAccessMember[]>([]);
|
|
49
|
+
const [status, setStatus] = useState<Status>("loading");
|
|
50
|
+
const [error, setError] = useState<string | null>(null);
|
|
51
|
+
|
|
52
|
+
const [emailInput, setEmailInput] = useState("");
|
|
53
|
+
const [newRole, setNewRole] = useState<MailboxAccessRole>("viewer");
|
|
54
|
+
const [adding, setAdding] = useState(false);
|
|
55
|
+
const [addError, setAddError] = useState<string | null>(null);
|
|
56
|
+
|
|
57
|
+
const [pendingRoleChange, setPendingRoleChange] = useState<string | null>(null);
|
|
58
|
+
const [removeTarget, setRemoveTarget] = useState<MailboxAccessMember | null>(null);
|
|
59
|
+
const [removing, setRemoving] = useState(false);
|
|
60
|
+
|
|
61
|
+
// `SettingsShell` only ever renders its children once `mailboxUid` has resolved (a mailbox-less caller
|
|
62
|
+
// gets `<MailboxProvisioning />` instead) - same established precedent as the Labels/Focused Inbox
|
|
63
|
+
// settings pages, so none of the handlers below need their own `!mailboxUid` guard.
|
|
64
|
+
function reload() {
|
|
65
|
+
setStatus("loading");
|
|
66
|
+
setError(null);
|
|
67
|
+
listMailboxAccess(mailboxUid!)
|
|
68
|
+
.then((result) => {
|
|
69
|
+
setMembers(result);
|
|
70
|
+
setStatus("ready");
|
|
71
|
+
})
|
|
72
|
+
.catch((err) => {
|
|
73
|
+
// A 403 here is the live, server-verified "can this caller manage this mailbox's sharing"
|
|
74
|
+
// signal - the same permission threshold (ACLAction.UPDATE) this route itself requires, so
|
|
75
|
+
// no separate probe call is needed to decide which state to render.
|
|
76
|
+
if (err instanceof ApiRequestError && err.status === 403) {
|
|
77
|
+
setStatus("forbidden");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not load sharing settings.");
|
|
81
|
+
setStatus("error");
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
useEffect(reload, [mailboxUid]);
|
|
86
|
+
|
|
87
|
+
async function handleAdd(e: FormEvent) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
const email = emailInput.trim();
|
|
90
|
+
if (!email) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
setAddError(null);
|
|
94
|
+
setAdding(true);
|
|
95
|
+
try {
|
|
96
|
+
const found = await lookupMailboxOwnerByEmail(email);
|
|
97
|
+
if (!found) {
|
|
98
|
+
setAddError("No one found with that email on this platform.");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
await setMailboxAccess(mailboxUid!, found.userUid, newRole);
|
|
102
|
+
setEmailInput("");
|
|
103
|
+
setNewRole("viewer");
|
|
104
|
+
reload();
|
|
105
|
+
} catch (err) {
|
|
106
|
+
setAddError(err instanceof ApiRequestError ? err.message : "Could not grant access.");
|
|
107
|
+
} finally {
|
|
108
|
+
setAdding(false);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function handleRoleChange(userOrRoleId: string, role: MailboxAccessRole) {
|
|
113
|
+
setPendingRoleChange(userOrRoleId);
|
|
114
|
+
setError(null);
|
|
115
|
+
try {
|
|
116
|
+
await setMailboxAccess(mailboxUid!, userOrRoleId, role);
|
|
117
|
+
reload();
|
|
118
|
+
} catch (err) {
|
|
119
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not update this member's role.");
|
|
120
|
+
} finally {
|
|
121
|
+
setPendingRoleChange(null);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function closeRemoveModal() {
|
|
126
|
+
setRemoveTarget(null);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function handleRemove() {
|
|
130
|
+
// Only reachable from the confirm modal's own "Remove" button, and `Modal` renders nothing at all
|
|
131
|
+
// unless `removeTarget` is set, so `removeTarget` is always non-null here.
|
|
132
|
+
setRemoving(true);
|
|
133
|
+
setError(null);
|
|
134
|
+
try {
|
|
135
|
+
await removeMailboxAccess(mailboxUid!, removeTarget!.userOrRoleId);
|
|
136
|
+
setRemoveTarget(null);
|
|
137
|
+
reload();
|
|
138
|
+
} catch (err) {
|
|
139
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not remove this member.");
|
|
140
|
+
} finally {
|
|
141
|
+
setRemoving(false);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div className="flex-1 min-w-0 overflow-y-auto p-6">
|
|
147
|
+
<div className="max-w-xl flex flex-col gap-6">
|
|
148
|
+
<div>
|
|
149
|
+
<h1 className="text-lg font-bold tracking-tight mb-1">Sharing</h1>
|
|
150
|
+
<p className="text-sm text-text-muted">
|
|
151
|
+
Manage who else can access {mailbox?.displayName ?? "this mailbox"}’s mail, calendar,
|
|
152
|
+
contacts, and tasks. Granting access here covers all of it at once - there’s nothing
|
|
153
|
+
else to configure per data type.
|
|
154
|
+
</p>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
{status === "loading" && <SkeletonList count={3} />}
|
|
158
|
+
|
|
159
|
+
{status === "forbidden" && (
|
|
160
|
+
<Alert>You don’t have permission to manage sharing for this mailbox.</Alert>
|
|
161
|
+
)}
|
|
162
|
+
|
|
163
|
+
{status === "error" && error && <Alert>{error}</Alert>}
|
|
164
|
+
|
|
165
|
+
{status === "ready" && (
|
|
166
|
+
<>
|
|
167
|
+
{error && <Alert>{error}</Alert>}
|
|
168
|
+
|
|
169
|
+
<div>
|
|
170
|
+
<h2 className="text-sm font-semibold mb-2">People with access</h2>
|
|
171
|
+
{members.length === 0 ? (
|
|
172
|
+
<p className="text-sm text-text-muted">No one else has access to this mailbox yet.</p>
|
|
173
|
+
) : (
|
|
174
|
+
<ul className="flex flex-col gap-2">
|
|
175
|
+
{members.map((member) => (
|
|
176
|
+
<li
|
|
177
|
+
key={member.userOrRoleId}
|
|
178
|
+
className="flex items-center justify-between gap-3 text-sm py-1.5 px-3 bg-surface-alt rounded-sm"
|
|
179
|
+
>
|
|
180
|
+
<span className="truncate">{member.userOrRoleId}</span>
|
|
181
|
+
<span className="flex items-center gap-2 shrink-0">
|
|
182
|
+
<select
|
|
183
|
+
aria-label={`Role for ${member.userOrRoleId}`}
|
|
184
|
+
className="text-sm border border-border rounded-sm py-1 px-2 bg-surface"
|
|
185
|
+
value={member.role}
|
|
186
|
+
disabled={pendingRoleChange === member.userOrRoleId}
|
|
187
|
+
onChange={(e) =>
|
|
188
|
+
handleRoleChange(member.userOrRoleId, e.target.value as MailboxAccessRole)
|
|
189
|
+
}
|
|
190
|
+
>
|
|
191
|
+
{/* Access granted outside this page can't be set here, only replaced by a
|
|
192
|
+
standard role. */}
|
|
193
|
+
{member.role === "custom" && (
|
|
194
|
+
<option value="custom" disabled>
|
|
195
|
+
Custom access
|
|
196
|
+
</option>
|
|
197
|
+
)}
|
|
198
|
+
{(Object.keys(ROLE_LABELS) as MailboxAccessRole[]).map((role) => (
|
|
199
|
+
<option key={role} value={role}>
|
|
200
|
+
{ROLE_LABELS[role]}
|
|
201
|
+
</option>
|
|
202
|
+
))}
|
|
203
|
+
</select>
|
|
204
|
+
<Button
|
|
205
|
+
type="button"
|
|
206
|
+
variant="text"
|
|
207
|
+
className="!w-auto text-danger"
|
|
208
|
+
onClick={() => setRemoveTarget(member)}
|
|
209
|
+
>
|
|
210
|
+
Remove
|
|
211
|
+
</Button>
|
|
212
|
+
</span>
|
|
213
|
+
</li>
|
|
214
|
+
))}
|
|
215
|
+
</ul>
|
|
216
|
+
)}
|
|
217
|
+
</div>
|
|
218
|
+
|
|
219
|
+
<form onSubmit={handleAdd} className="flex flex-col gap-2">
|
|
220
|
+
<h2 className="text-sm font-semibold">Add someone</h2>
|
|
221
|
+
{addError && <Alert>{addError}</Alert>}
|
|
222
|
+
<div className="flex gap-2">
|
|
223
|
+
<input
|
|
224
|
+
type="email"
|
|
225
|
+
aria-label="Email address"
|
|
226
|
+
placeholder="Email address"
|
|
227
|
+
className="flex-1 text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
228
|
+
value={emailInput}
|
|
229
|
+
onChange={(e) => setEmailInput(e.target.value)}
|
|
230
|
+
disabled={adding}
|
|
231
|
+
/>
|
|
232
|
+
<select
|
|
233
|
+
aria-label="Role to grant"
|
|
234
|
+
className="text-sm border border-border rounded-sm py-1.5 px-2 bg-surface"
|
|
235
|
+
value={newRole}
|
|
236
|
+
onChange={(e) => setNewRole(e.target.value as MailboxAccessRole)}
|
|
237
|
+
disabled={adding}
|
|
238
|
+
>
|
|
239
|
+
{(Object.keys(ROLE_LABELS) as MailboxAccessRole[]).map((role) => (
|
|
240
|
+
<option key={role} value={role}>
|
|
241
|
+
{ROLE_LABELS[role]}
|
|
242
|
+
</option>
|
|
243
|
+
))}
|
|
244
|
+
</select>
|
|
245
|
+
<Button type="submit" loading={adding} disabled={adding} className="!w-auto">
|
|
246
|
+
Add
|
|
247
|
+
</Button>
|
|
248
|
+
</div>
|
|
249
|
+
</form>
|
|
250
|
+
</>
|
|
251
|
+
)}
|
|
252
|
+
|
|
253
|
+
<Modal open={!!removeTarget} onClose={closeRemoveModal} title="Remove access">
|
|
254
|
+
<p className="text-sm mb-5">
|
|
255
|
+
{removeTarget?.userOrRoleId} will no longer be able to access {mailbox?.displayName ?? "this mailbox"}.
|
|
256
|
+
</p>
|
|
257
|
+
<div className="flex gap-3 justify-end">
|
|
258
|
+
<Button type="button" variant="secondary" className="!w-auto" disabled={removing} onClick={closeRemoveModal}>
|
|
259
|
+
Cancel
|
|
260
|
+
</Button>
|
|
261
|
+
<Button
|
|
262
|
+
type="button"
|
|
263
|
+
className="!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger"
|
|
264
|
+
loading={removing}
|
|
265
|
+
disabled={removing}
|
|
266
|
+
onClick={handleRemove}
|
|
267
|
+
>
|
|
268
|
+
Remove
|
|
269
|
+
</Button>
|
|
270
|
+
</div>
|
|
271
|
+
</Modal>
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export default routedPage("/settings/sharing", SettingsSharingPage);
|