@rapidmx/web-client 0.10.0 → 0.11.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 +183 -2
- package/apps/admin/_layout.tsx +8 -2
- package/apps/admin/index.tsx +7 -1
- package/apps/admin/ingest-queue/index.tsx +2 -1
- package/apps/admin/mailboxes/[uid].tsx +23 -10
- package/apps/admin/quarantine/index.tsx +2 -1
- package/apps/admin/signing-certificates/index.tsx +343 -0
- package/apps/escrow/_layout.tsx +8 -2
- package/apps/shared/appearance/AppearanceForm.tsx +392 -0
- package/apps/shared/appearance/AppearanceHead.tsx +49 -0
- package/apps/shared/appearance/AppearanceProvider.tsx +470 -0
- package/apps/shared/appearance/ColorField.tsx +107 -0
- package/apps/shared/appearance/appearanceCache.ts +106 -0
- package/apps/shared/appearance/appearanceContext.ts +77 -0
- package/apps/shared/appearance/bootScript.ts +35 -0
- package/apps/shared/appearance/color.ts +169 -0
- package/apps/shared/appearance/photo.ts +88 -0
- package/apps/shared/appearance/resolvedTheme.ts +67 -0
- package/apps/shared/appearance/theme.ts +355 -0
- package/apps/shared/components/admin/layout/AdminShell.tsx +22 -10
- package/apps/shared/components/admin/mailboxes/ShareAccessCard.tsx +107 -60
- package/apps/shared/components/admin/settings/BrandingForm.tsx +24 -0
- package/apps/shared/components/admin/settings/PluginsManager.tsx +228 -25
- package/apps/shared/components/admin/setup/SetupWizard.tsx +2 -1
- package/apps/shared/components/calendar/CalendarListSidebar.tsx +4 -5
- package/apps/shared/components/contacts/ContactForm.tsx +11 -5
- package/apps/shared/components/contacts/ContactsSidebar.tsx +5 -3
- package/apps/shared/components/contacts/ContactsToolbar.tsx +25 -52
- package/apps/shared/components/contacts/layout/ContactsShell.tsx +10 -5
- package/apps/shared/components/escrow/layout/EscrowShell.tsx +13 -6
- package/apps/shared/components/layout/AppShell.tsx +98 -32
- package/apps/shared/components/layout/BrandingChrome.tsx +200 -13
- package/apps/shared/components/layout/RailIcon.tsx +100 -0
- package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -0
- package/apps/shared/components/layout/ThemeSwitch.tsx +84 -0
- package/apps/shared/components/layout/UserMenu.tsx +75 -6
- package/apps/shared/components/mail/ConversationList.tsx +4 -2
- package/apps/shared/components/mail/ConversationThreadPane.tsx +487 -475
- package/apps/shared/components/mail/LazyReadingPane.tsx +14 -16
- package/apps/shared/components/mail/MailSelectionBar.tsx +2 -10
- package/apps/shared/components/mail/MessageDetailPane.tsx +366 -287
- package/apps/shared/components/mail/OutboxBadge.tsx +44 -0
- package/apps/shared/components/mail/OutboxRowStatus.tsx +31 -0
- package/apps/shared/components/mail/compose/ComposeContext.tsx +35 -2
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +239 -437
- package/apps/shared/components/mail/compose/encryptionRequirement.ts +86 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +39 -25
- package/apps/shared/components/mail/reading/EncryptedBody.tsx +65 -0
- package/apps/shared/components/mail/reading/EncryptedPreview.tsx +35 -0
- package/apps/shared/components/mail/reading/MessageBody.tsx +240 -0
- package/apps/shared/components/mail/reading/MessageCard.tsx +174 -0
- package/apps/shared/components/mail/reading/bodyContent.ts +100 -0
- package/apps/shared/components/mail/reading/bodyHtml.ts +298 -0
- package/apps/shared/components/mail/reading/color.ts +245 -0
- package/apps/shared/components/mail/reading/frameControl.ts +142 -0
- package/apps/shared/components/mail/reading/frameDocument.ts +123 -0
- package/apps/shared/components/mail/reading/safeDocument.ts +24 -0
- package/apps/shared/components/mail/reading/themeAdaptation.ts +221 -0
- package/apps/shared/components/mail/reading/themeSurface.ts +90 -0
- package/apps/shared/components/mail/reading/viewOriginal.ts +38 -0
- package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -0
- package/apps/shared/components/settings/layout/SettingsShell.tsx +1 -0
- package/apps/shared/components/sharing/PrincipalPicker.tsx +145 -0
- package/apps/shared/components/tasks/TasksSidebar.tsx +5 -3
- package/apps/shared/components/tasks/layout/TasksShell.tsx +9 -5
- package/apps/shared/mail/folderCounts.ts +9 -3
- package/apps/shared/mail/folderTree.ts +143 -0
- package/apps/shared/mail/outbox/UnlockBridge.tsx +23 -0
- package/apps/shared/mail/outbox/composeBridge.ts +69 -0
- package/apps/shared/mail/outbox/outboxState.ts +88 -0
- package/apps/shared/mail/outbox/pendingSends.ts +146 -0
- package/apps/shared/mail/outbox/sendDecision.ts +157 -0
- package/apps/shared/mail/outbox/sendJob.ts +427 -0
- package/apps/shared/mail/outbox/sendOutcomes.ts +146 -0
- package/apps/shared/mail/outbox/sendState.ts +35 -0
- package/apps/shared/mail/outbox/useOutboxStatus.ts +61 -0
- package/apps/shared/mail/useMailConnection.ts +81 -28
- package/apps/shared/mail/useMailLiveUpdates.ts +55 -10
- package/apps/shared/mail/useNewMailNotifications.ts +47 -32
- package/apps/shared/navigation/AppRouter.tsx +2 -2
- package/apps/shared/notifications/NotificationCenter.tsx +215 -0
- package/apps/shared/notifications/NotificationHistoryDialog.tsx +90 -0
- package/apps/shared/notifications/apiErrors.ts +98 -0
- package/apps/shared/notifications/headerOffset.ts +35 -0
- package/apps/shared/notifications/pushStatus.ts +56 -0
- package/apps/shared/notifications/store.ts +549 -0
- package/apps/shared/notifications/systemErrors.ts +63 -0
- package/apps/shared/notifications/useNotifications.ts +41 -0
- package/apps/shared/signing/enrollmentStorage.ts +33 -0
- package/apps/shared/signing/enrollmentTracker.ts +385 -0
- package/apps/shared/signing/enrollmentView.ts +251 -0
- package/apps/shared/signing/signingInfo.ts +58 -0
- package/apps/shared/signing/useNow.ts +19 -0
- package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -0
- package/apps/shared/styles/app.css +80 -0
- package/apps/www/_layout.tsx +8 -2
- package/apps/www/_routes.ts +1 -0
- package/apps/www/calendar/index.tsx +9 -14
- package/apps/www/contacts/[uid].tsx +5 -8
- package/apps/www/contacts/index.tsx +587 -584
- package/apps/www/index.tsx +38 -27
- package/apps/www/messages/[uid].tsx +3 -1
- package/apps/www/settings/appearance/index.tsx +21 -0
- package/apps/www/settings/auto-reply/index.tsx +3 -7
- package/apps/www/settings/encryption/index.tsx +151 -116
- package/apps/www/settings/filters/[uid].tsx +3 -1
- package/apps/www/settings/filters/new/index.tsx +3 -1
- package/apps/www/settings/privacy/index.tsx +3 -8
- package/apps/www/settings/read-receipts/index.tsx +3 -7
- package/apps/www/settings/sharing/index.tsx +44 -65
- package/apps/www/settings/signatures/[uid].tsx +3 -1
- package/apps/www/settings/signatures/new/index.tsx +3 -2
- package/apps/www/tasks/index.tsx +11 -16
- package/dist/apps/admin/_layout.d.ts +5 -1
- package/dist/apps/admin/_layout.js +3 -2
- package/dist/apps/admin/index.js +3 -2
- package/dist/apps/admin/ingest-queue/index.js +2 -1
- package/dist/apps/admin/mailboxes/[uid].js +9 -6
- package/dist/apps/admin/quarantine/index.js +2 -1
- package/dist/apps/admin/signing-certificates/index.d.ts +3 -0
- package/dist/apps/admin/signing-certificates/index.js +161 -0
- package/dist/apps/escrow/_layout.d.ts +5 -1
- package/dist/apps/escrow/_layout.js +3 -2
- package/dist/apps/shared/appearance/AppearanceForm.d.ts +7 -0
- package/dist/apps/shared/appearance/AppearanceForm.js +131 -0
- package/dist/apps/shared/appearance/AppearanceHead.d.ts +15 -0
- package/dist/apps/shared/appearance/AppearanceHead.js +31 -0
- package/dist/apps/shared/appearance/AppearanceProvider.d.ts +32 -0
- package/dist/apps/shared/appearance/AppearanceProvider.js +390 -0
- package/dist/apps/shared/appearance/ColorField.d.ts +22 -0
- package/dist/apps/shared/appearance/ColorField.js +40 -0
- package/dist/apps/shared/appearance/appearanceCache.d.ts +45 -0
- package/dist/apps/shared/appearance/appearanceCache.js +80 -0
- package/dist/apps/shared/appearance/appearanceContext.d.ts +45 -0
- package/dist/apps/shared/appearance/appearanceContext.js +29 -0
- package/dist/apps/shared/appearance/bootScript.d.ts +16 -0
- package/dist/apps/shared/appearance/bootScript.js +33 -0
- package/dist/apps/shared/appearance/color.d.ts +65 -0
- package/dist/apps/shared/appearance/color.js +132 -0
- package/dist/apps/shared/appearance/photo.d.ts +17 -0
- package/dist/apps/shared/appearance/photo.js +79 -0
- package/dist/apps/shared/appearance/resolvedTheme.d.ts +21 -0
- package/dist/apps/shared/appearance/resolvedTheme.js +55 -0
- package/dist/apps/shared/appearance/theme.d.ts +111 -0
- package/dist/apps/shared/appearance/theme.js +251 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +1 -1
- package/dist/apps/shared/components/admin/layout/AdminShell.js +16 -6
- package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.d.ts +10 -5
- package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.js +49 -34
- package/dist/apps/shared/components/admin/settings/BrandingForm.d.ts +2 -0
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +7 -1
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +106 -20
- package/dist/apps/shared/components/admin/setup/SetupWizard.js +2 -1
- package/dist/apps/shared/components/calendar/CalendarListSidebar.js +8 -8
- package/dist/apps/shared/components/contacts/ContactForm.js +1 -1
- package/dist/apps/shared/components/contacts/ContactsSidebar.js +4 -2
- package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +3 -1
- package/dist/apps/shared/components/contacts/ContactsToolbar.js +24 -9
- package/dist/apps/shared/components/contacts/layout/ContactsShell.js +4 -1
- package/dist/apps/shared/components/escrow/layout/EscrowShell.js +7 -4
- package/dist/apps/shared/components/layout/AppShell.d.ts +6 -1
- package/dist/apps/shared/components/layout/AppShell.js +59 -13
- package/dist/apps/shared/components/layout/BrandingChrome.d.ts +69 -10
- package/dist/apps/shared/components/layout/BrandingChrome.js +140 -12
- package/dist/apps/shared/components/layout/RailIcon.d.ts +21 -0
- package/dist/apps/shared/components/layout/RailIcon.js +85 -0
- package/dist/apps/shared/components/layout/ResponsiveToolbar.d.ts +55 -0
- package/dist/apps/shared/components/layout/ResponsiveToolbar.js +199 -0
- package/dist/apps/shared/components/layout/ThemeSwitch.d.ts +9 -0
- package/dist/apps/shared/components/layout/ThemeSwitch.js +54 -0
- package/dist/apps/shared/components/layout/UserMenu.d.ts +7 -1
- package/dist/apps/shared/components/layout/UserMenu.js +41 -7
- package/dist/apps/shared/components/mail/ConversationList.js +3 -2
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +2 -1
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +42 -20
- package/dist/apps/shared/components/mail/LazyReadingPane.js +9 -8
- package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +3 -4
- package/dist/apps/shared/components/mail/MailSelectionBar.js +2 -3
- package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +18 -7
- package/dist/apps/shared/components/mail/MessageDetailPane.js +86 -41
- package/dist/apps/shared/components/mail/OutboxBadge.d.ts +17 -0
- package/dist/apps/shared/components/mail/OutboxBadge.js +18 -0
- package/dist/apps/shared/components/mail/OutboxRowStatus.d.ts +10 -0
- package/dist/apps/shared/components/mail/OutboxRowStatus.js +19 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +8 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +28 -3
- package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +2 -1
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +229 -328
- package/dist/apps/shared/components/mail/compose/encryptionRequirement.d.ts +49 -0
- package/dist/apps/shared/components/mail/compose/encryptionRequirement.js +35 -0
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +2 -0
- package/dist/apps/shared/components/mail/layout/MailShell.js +20 -14
- package/dist/apps/shared/components/mail/reading/EncryptedBody.d.ts +21 -0
- package/dist/apps/shared/components/mail/reading/EncryptedBody.js +22 -0
- package/dist/apps/shared/components/mail/reading/EncryptedPreview.d.ts +18 -0
- package/dist/apps/shared/components/mail/reading/EncryptedPreview.js +22 -0
- package/dist/apps/shared/components/mail/reading/MessageBody.d.ts +32 -0
- package/dist/apps/shared/components/mail/reading/MessageBody.js +136 -0
- package/dist/apps/shared/components/mail/reading/MessageCard.d.ts +62 -0
- package/dist/apps/shared/components/mail/reading/MessageCard.js +58 -0
- package/dist/apps/shared/components/mail/reading/bodyContent.d.ts +38 -0
- package/dist/apps/shared/components/mail/reading/bodyContent.js +84 -0
- package/dist/apps/shared/components/mail/reading/bodyHtml.d.ts +47 -0
- package/dist/apps/shared/components/mail/reading/bodyHtml.js +267 -0
- package/dist/apps/shared/components/mail/reading/color.d.ts +63 -0
- package/dist/apps/shared/components/mail/reading/color.js +201 -0
- package/dist/apps/shared/components/mail/reading/frameControl.d.ts +33 -0
- package/dist/apps/shared/components/mail/reading/frameControl.js +120 -0
- package/dist/apps/shared/components/mail/reading/frameDocument.d.ts +52 -0
- package/dist/apps/shared/components/mail/reading/frameDocument.js +98 -0
- package/dist/apps/shared/components/mail/reading/safeDocument.d.ts +3 -0
- package/dist/apps/shared/components/mail/reading/safeDocument.js +12 -0
- package/dist/apps/shared/components/mail/reading/themeAdaptation.d.ts +56 -0
- package/dist/apps/shared/components/mail/reading/themeAdaptation.js +144 -0
- package/dist/apps/shared/components/mail/reading/themeSurface.d.ts +17 -0
- package/dist/apps/shared/components/mail/reading/themeSurface.js +83 -0
- package/dist/apps/shared/components/mail/reading/viewOriginal.d.ts +9 -0
- package/dist/apps/shared/components/mail/reading/viewOriginal.js +32 -0
- package/dist/apps/shared/components/settings/SigningCertificateCard.d.ts +32 -0
- package/dist/apps/shared/components/settings/SigningCertificateCard.js +98 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +1 -0
- package/dist/apps/shared/components/sharing/PrincipalPicker.d.ts +26 -0
- package/dist/apps/shared/components/sharing/PrincipalPicker.js +77 -0
- package/dist/apps/shared/components/tasks/TasksSidebar.js +4 -2
- package/dist/apps/shared/components/tasks/layout/TasksShell.js +3 -1
- package/dist/apps/shared/mail/folderCounts.d.ts +1 -1
- package/dist/apps/shared/mail/folderCounts.js +9 -3
- package/dist/apps/shared/mail/folderTree.d.ts +55 -0
- package/dist/apps/shared/mail/folderTree.js +116 -0
- package/dist/apps/shared/mail/outbox/UnlockBridge.d.ts +5 -0
- package/dist/apps/shared/mail/outbox/UnlockBridge.js +18 -0
- package/dist/apps/shared/mail/outbox/composeBridge.d.ts +34 -0
- package/dist/apps/shared/mail/outbox/composeBridge.js +32 -0
- package/dist/apps/shared/mail/outbox/outboxState.d.ts +41 -0
- package/dist/apps/shared/mail/outbox/outboxState.js +42 -0
- package/dist/apps/shared/mail/outbox/pendingSends.d.ts +39 -0
- package/dist/apps/shared/mail/outbox/pendingSends.js +109 -0
- package/dist/apps/shared/mail/outbox/sendDecision.d.ts +80 -0
- package/dist/apps/shared/mail/outbox/sendDecision.js +94 -0
- package/dist/apps/shared/mail/outbox/sendJob.d.ts +68 -0
- package/dist/apps/shared/mail/outbox/sendJob.js +319 -0
- package/dist/apps/shared/mail/outbox/sendOutcomes.d.ts +3 -0
- package/dist/apps/shared/mail/outbox/sendOutcomes.js +141 -0
- package/dist/apps/shared/mail/outbox/sendState.d.ts +25 -0
- package/dist/apps/shared/mail/outbox/sendState.js +8 -0
- package/dist/apps/shared/mail/outbox/useOutboxStatus.d.ts +11 -0
- package/dist/apps/shared/mail/outbox/useOutboxStatus.js +49 -0
- package/dist/apps/shared/mail/useMailConnection.d.ts +9 -8
- package/dist/apps/shared/mail/useMailConnection.js +64 -22
- package/dist/apps/shared/mail/useMailLiveUpdates.d.ts +17 -4
- package/dist/apps/shared/mail/useMailLiveUpdates.js +36 -10
- package/dist/apps/shared/mail/useNewMailNotifications.d.ts +4 -10
- package/dist/apps/shared/mail/useNewMailNotifications.js +43 -23
- package/dist/apps/shared/navigation/AppRouter.js +2 -2
- package/dist/apps/shared/notifications/NotificationCenter.d.ts +19 -0
- package/dist/apps/shared/notifications/NotificationCenter.js +90 -0
- package/dist/apps/shared/notifications/NotificationHistoryDialog.d.ts +10 -0
- package/dist/apps/shared/notifications/NotificationHistoryDialog.js +36 -0
- package/dist/apps/shared/notifications/apiErrors.d.ts +19 -0
- package/dist/apps/shared/notifications/apiErrors.js +86 -0
- package/dist/apps/shared/notifications/headerOffset.d.ts +8 -0
- package/dist/apps/shared/notifications/headerOffset.js +33 -0
- package/dist/apps/shared/notifications/pushStatus.d.ts +9 -0
- package/dist/apps/shared/notifications/pushStatus.js +54 -0
- package/dist/apps/shared/notifications/store.d.ts +136 -0
- package/dist/apps/shared/notifications/store.js +416 -0
- package/dist/apps/shared/notifications/systemErrors.d.ts +9 -0
- package/dist/apps/shared/notifications/systemErrors.js +58 -0
- package/dist/apps/shared/notifications/useNotifications.d.ts +17 -0
- package/dist/apps/shared/notifications/useNotifications.js +18 -0
- package/dist/apps/shared/signing/enrollmentStorage.d.ts +10 -0
- package/dist/apps/shared/signing/enrollmentStorage.js +33 -0
- package/dist/apps/shared/signing/enrollmentTracker.d.ts +73 -0
- package/dist/apps/shared/signing/enrollmentTracker.js +307 -0
- package/dist/apps/shared/signing/enrollmentView.d.ts +57 -0
- package/dist/apps/shared/signing/enrollmentView.js +214 -0
- package/dist/apps/shared/signing/signingInfo.d.ts +11 -0
- package/dist/apps/shared/signing/signingInfo.js +48 -0
- package/dist/apps/shared/signing/useNow.d.ts +2 -0
- package/dist/apps/shared/signing/useNow.js +18 -0
- package/dist/apps/shared/signing/useSigningEnrollmentWatcher.d.ts +16 -0
- package/dist/apps/shared/signing/useSigningEnrollmentWatcher.js +87 -0
- package/dist/apps/shared/styles/app.css +80 -0
- package/dist/apps/www/_layout.d.ts +5 -1
- package/dist/apps/www/_layout.js +3 -2
- package/dist/apps/www/_routes.js +1 -0
- package/dist/apps/www/calendar/index.js +3 -4
- package/dist/apps/www/contacts/[uid].js +5 -7
- package/dist/apps/www/contacts/index.js +14 -21
- package/dist/apps/www/index.js +37 -19
- package/dist/apps/www/messages/[uid].js +3 -1
- package/dist/apps/www/settings/appearance/index.d.ts +4 -0
- package/dist/apps/www/settings/appearance/index.js +13 -0
- package/dist/apps/www/settings/auto-reply/index.js +3 -6
- package/dist/apps/www/settings/encryption/index.js +103 -95
- package/dist/apps/www/settings/filters/[uid].js +3 -1
- package/dist/apps/www/settings/filters/new/index.js +3 -1
- package/dist/apps/www/settings/privacy/index.js +5 -8
- package/dist/apps/www/settings/read-receipts/index.js +3 -6
- package/dist/apps/www/settings/sharing/index.js +19 -33
- package/dist/apps/www/settings/signatures/[uid].js +3 -1
- package/dist/apps/www/settings/signatures/new/index.js +3 -2
- package/dist/apps/www/tasks/index.js +8 -14
- package/package.json +2 -2
- package/apps/shared/components/mail/NewMailToasts.tsx +0 -141
- package/apps/shared/components/mail/compose/SendFailureAlert.tsx +0 -48
- package/dist/apps/shared/components/mail/NewMailToasts.d.ts +0 -19
- package/dist/apps/shared/components/mail/NewMailToasts.js +0 -55
- package/dist/apps/shared/components/mail/compose/SendFailureAlert.d.ts +0 -14
- package/dist/apps/shared/components/mail/compose/SendFailureAlert.js +0 -11
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { useCallback, useState } from "react";
|
|
6
|
+
/** Messages the reader chose to see exactly as authored rather than adapted to the theme, for the life of the tab. */
|
|
7
|
+
const original = new Set();
|
|
8
|
+
/** Whether the reader asked to see `uid` as authored. */
|
|
9
|
+
export function isViewedOriginal(uid) {
|
|
10
|
+
return original.has(uid);
|
|
11
|
+
}
|
|
12
|
+
/** Forgets every choice (the tests). */
|
|
13
|
+
export function clearViewedOriginal() {
|
|
14
|
+
original.clear();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The per-message "View original" choice: `false` (follow the theme) until the reader flips it, then remembered for the session so
|
|
18
|
+
* collapsing and expanding a message, or coming back to it, keeps the choice.
|
|
19
|
+
*/
|
|
20
|
+
export function useViewOriginal(uid) {
|
|
21
|
+
const [value, setValue] = useState(() => isViewedOriginal(uid));
|
|
22
|
+
const update = useCallback((next) => {
|
|
23
|
+
if (next) {
|
|
24
|
+
original.add(uid);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
original.delete(uid);
|
|
28
|
+
}
|
|
29
|
+
setValue(next);
|
|
30
|
+
}, [uid]);
|
|
31
|
+
return [value, update];
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { EnrollmentResult } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
3
|
+
import type { EnrollmentSnapshot } from "../../signing/enrollmentTracker.js";
|
|
4
|
+
import type { SigningEnrollmentInfo } from "../../signing/signingInfo.js";
|
|
5
|
+
export type SigningCertificateMode = "pending" | "issued" | "failed" | "expired";
|
|
6
|
+
export interface SigningCertificateCardProps {
|
|
7
|
+
mode: SigningCertificateMode;
|
|
8
|
+
/** What the server last said about the enrollment (the extended fields are all optional - an older server sends only `status`). */
|
|
9
|
+
enrollment: EnrollmentResult | null;
|
|
10
|
+
/** The tracker's view of it: busy flags, the check cooldown, the last check. Absent when nothing is being followed. */
|
|
11
|
+
snapshot?: EnrollmentSnapshot;
|
|
12
|
+
/** For an issued certificate when the enrollment carries no details (one installed long ago): the active key's own expiry (epoch ms). */
|
|
13
|
+
keyNotAfter?: number;
|
|
14
|
+
/** How this deployment issues certificates (`GET /system/signing-enrollment`): what a pending request says follows it. `null` / absent when it is not known. */
|
|
15
|
+
info?: SigningEnrollmentInfo | null;
|
|
16
|
+
/** The mailbox's address - the one the CA's verification e-mail goes to. */
|
|
17
|
+
address?: string;
|
|
18
|
+
/** Only the mailbox's owner can request a certificate. */
|
|
19
|
+
canRequest: boolean;
|
|
20
|
+
/** "Try again" / "Renew" / "Request a new certificate" is under way. */
|
|
21
|
+
requesting: boolean;
|
|
22
|
+
onCheck?: () => void;
|
|
23
|
+
onRequest?: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Settings > Encryption's "Digital signature certificate" card: where a signing-certificate enrollment is, in the words of the person waiting for
|
|
27
|
+
* it. A progress bar (determinate from the server's `progress`), the steps with a state icon and time each, a status line, when it was requested
|
|
28
|
+
* and last checked (kept current), and a "Check status" button with a busy state and a cooldown. An issued certificate shows its subject, issuer,
|
|
29
|
+
* serial (copyable) and expiry with a warning (and "Renew") inside 30 days; a failed one shows the reason and "Try again"; an expired one offers a
|
|
30
|
+
* new request. Everything but `mode` is optional so a server that only says `pending`/`issued`/`failed` still gets a useful card.
|
|
31
|
+
*/
|
|
32
|
+
export default function SigningCertificateCard({ mode, enrollment, snapshot, keyNotAfter, info, address, canRequest, requesting, onCheck, onRequest }: SigningCertificateCardProps): React.JSX.Element;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { HiOutlineCheckCircle, HiOutlineExclamationTriangle, HiOutlineXCircle } from "react-icons/hi2";
|
|
3
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
4
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
5
|
+
import CopyButton from "@rapidmx/react-shared/components/buttons/CopyButton.js";
|
|
6
|
+
import { CA_UNREACHABLE_TEXT, MANUAL_ISSUE_TEXT, PENDING_FALLBACK_TEXT, expiryOf, formatDate, formatDateTime, healthWarning, isInstalling, isOverdue, issueModeOf, progressOf, requestedFromText, relativeTime, statusLineOf, stepsOf, timeOf, truncateSerial, } from "../../signing/enrollmentView.js";
|
|
7
|
+
import { useNow } from "../../signing/useNow.js";
|
|
8
|
+
const BADGE = {
|
|
9
|
+
pending: { text: "Pending", className: "bg-primary/15 text-primary-dark" },
|
|
10
|
+
issued: { text: "Active", className: "bg-success/15 text-success" },
|
|
11
|
+
failed: { text: "Failed", className: "bg-danger/15 text-danger" },
|
|
12
|
+
expired: { text: "Expired", className: "bg-danger/15 text-danger" },
|
|
13
|
+
};
|
|
14
|
+
const STEP_TEXT = {
|
|
15
|
+
done: "done",
|
|
16
|
+
active: "in progress",
|
|
17
|
+
pending: "waiting",
|
|
18
|
+
failed: "failed",
|
|
19
|
+
};
|
|
20
|
+
function StepIcon({ state }) {
|
|
21
|
+
if (state === "done") {
|
|
22
|
+
return _jsx(HiOutlineCheckCircle, { size: 18, "aria-hidden": "true", className: "shrink-0 text-success" });
|
|
23
|
+
}
|
|
24
|
+
if (state === "failed") {
|
|
25
|
+
return _jsx(HiOutlineXCircle, { size: 18, "aria-hidden": "true", className: "shrink-0 text-danger" });
|
|
26
|
+
}
|
|
27
|
+
if (state === "active") {
|
|
28
|
+
return (_jsx("span", { "aria-hidden": "true", className: "flex h-[18px] w-[18px] shrink-0 items-center justify-center", children: _jsx("span", { className: "h-3.5 w-3.5 rounded-full border-2 border-primary/30 border-t-primary motion-safe:animate-spin motion-reduce:border-primary" }) }));
|
|
29
|
+
}
|
|
30
|
+
return (_jsx("span", { "aria-hidden": "true", className: "flex h-[18px] w-[18px] shrink-0 items-center justify-center", children: _jsx("span", { className: "h-3 w-3 rounded-full border-2 border-border" }) }));
|
|
31
|
+
}
|
|
32
|
+
function Stepper({ steps }) {
|
|
33
|
+
return (_jsx("ol", { "aria-label": "Certificate steps", className: "flex flex-col gap-2", children: steps.map((step) => (_jsxs("li", { className: "flex items-start gap-2 text-sm", "aria-current": step.state === "active" ? "step" : undefined, children: [_jsx(StepIcon, { state: step.state }), _jsxs("span", { className: step.state === "pending" ? "text-text-muted" : "text-text", children: [step.label, _jsxs("span", { className: "sr-only", children: [" - ", STEP_TEXT[step.state]] })] }), step.at && _jsx("span", { className: "ml-auto shrink-0 text-xs text-text-muted", children: formatDateTime(step.at) })] }, step.id))) }));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The progress bar: determinate when the server says how far along it is, an endless shimmer while a step is active and no number is known.
|
|
37
|
+
* `role="progressbar"` with `aria-valuenow` (left off when unknown, as ARIA says for an indeterminate bar) and a `aria-valuetext` in words.
|
|
38
|
+
*/
|
|
39
|
+
function ProgressBar({ value, text }) {
|
|
40
|
+
return (_jsx("div", { role: "progressbar", "aria-label": "Certificate progress", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": value, "aria-valuetext": text, className: "h-2 w-full overflow-hidden rounded-pill bg-border/60", children: value === undefined ? (_jsx("div", { className: "rr-progress-indeterminate h-full w-1/3 rounded-pill bg-primary motion-reduce:w-full motion-reduce:opacity-40" })) : (_jsx("div", { className: "rr-progress-shimmer h-full rounded-pill bg-primary transition-[width] duration-500", style: { width: `${Math.max(value, value > 0 ? 3 : 0)}%` } })) }));
|
|
41
|
+
}
|
|
42
|
+
function Detail({ label, children }) {
|
|
43
|
+
return (_jsxs("div", { className: "grid grid-cols-[6.5rem_1fr] gap-2 text-sm sm:grid-cols-[8rem_1fr]", children: [_jsx("dt", { className: "text-text-muted", children: label }), _jsx("dd", { className: "min-w-0 break-words", children: children })] }));
|
|
44
|
+
}
|
|
45
|
+
/** The sentence under the button: what the last manual check found, or why it cannot be pressed again yet. */
|
|
46
|
+
function checkMessage(snapshot, statusLine, now) {
|
|
47
|
+
if (snapshot?.offline) {
|
|
48
|
+
return "Could not reach the server - showing what was last known.";
|
|
49
|
+
}
|
|
50
|
+
const last = snapshot?.lastCheck;
|
|
51
|
+
if (!last) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (last.outcome === "failed") {
|
|
55
|
+
return "Could not check just now - try again in a moment.";
|
|
56
|
+
}
|
|
57
|
+
if (last.outcome === "limited") {
|
|
58
|
+
return "Checked a moment ago - please wait a few seconds before checking again.";
|
|
59
|
+
}
|
|
60
|
+
if (last.outcome === "changed") {
|
|
61
|
+
return `Updated - ${statusLine ?? "the status changed"}`;
|
|
62
|
+
}
|
|
63
|
+
return `Still waiting - checked ${relativeTime(last.at, now)}`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Settings > Encryption's "Digital signature certificate" card: where a signing-certificate enrollment is, in the words of the person waiting for
|
|
67
|
+
* it. A progress bar (determinate from the server's `progress`), the steps with a state icon and time each, a status line, when it was requested
|
|
68
|
+
* and last checked (kept current), and a "Check status" button with a busy state and a cooldown. An issued certificate shows its subject, issuer,
|
|
69
|
+
* serial (copyable) and expiry with a warning (and "Renew") inside 30 days; a failed one shows the reason and "Try again"; an expired one offers a
|
|
70
|
+
* new request. Everything but `mode` is optional so a server that only says `pending`/`issued`/`failed` still gets a useful card.
|
|
71
|
+
*/
|
|
72
|
+
export default function SigningCertificateCard({ mode, enrollment, snapshot, keyNotAfter, info, address, canRequest, requesting, onCheck, onRequest }) {
|
|
73
|
+
const busy = mode === "pending" || (snapshot?.retryAt ?? 0) > Date.now();
|
|
74
|
+
const now = useNow(busy ? 1000 : 30000);
|
|
75
|
+
const steps = stepsOf(enrollment);
|
|
76
|
+
const progress = progressOf(enrollment);
|
|
77
|
+
const statusLine = statusLineOf(enrollment);
|
|
78
|
+
// Any of the newer fields gives a percentage (the server's, or the share of steps done), so this is "the server told us more than pending".
|
|
79
|
+
const detailed = progress !== undefined;
|
|
80
|
+
const badge = BADGE[mode];
|
|
81
|
+
// What the words say depends on how this deployment issues certificates: a public CA does it by itself, an administrator uploads it, or nobody has said.
|
|
82
|
+
const issueMode = issueModeOf(enrollment, info);
|
|
83
|
+
const problem = healthWarning(info);
|
|
84
|
+
const notAfter = enrollment?.notAfter ?? keyNotAfter;
|
|
85
|
+
const expiry = expiryOf(notAfter, now);
|
|
86
|
+
const requestedAgo = relativeTime(enrollment?.requestedAt, now);
|
|
87
|
+
const checkedAt = timeOf(enrollment?.lastCheckedAt) ?? snapshot?.answeredAt ?? undefined;
|
|
88
|
+
const checkedAgo = relativeTime(checkedAt, now);
|
|
89
|
+
const waitSeconds = Math.max(0, Math.ceil(((snapshot?.retryAt ?? 0) - now) / 1000));
|
|
90
|
+
const checkingNow = snapshot?.checkingNow ?? false;
|
|
91
|
+
const message = checkMessage(snapshot, statusLine, now);
|
|
92
|
+
const overdue = isOverdue(enrollment, now);
|
|
93
|
+
return (_jsxs("section", { "aria-label": "Digital signature certificate", className: "flex flex-col gap-3 rounded-md border border-border bg-surface p-4", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("h3", { className: "text-sm font-semibold", children: "Digital signature certificate" }), _jsx("span", { className: ["rounded-pill px-2 py-0.5 text-xs font-bold", badge.className].join(" "), children: badge.text })] }), mode === "pending" && (_jsxs(_Fragment, { children: [issueMode === "manual" ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-sm", children: MANUAL_ISSUE_TEXT }), info?.contactEmail && _jsxs("p", { className: "text-xs text-text-muted", children: ["Administrator: ", info.contactEmail] })] })) : (_jsxs(_Fragment, { children: [issueMode === "automatic" && _jsx("p", { className: "text-sm text-text-muted", children: requestedFromText(info, address) }), detailed ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-sm", children: statusLine ?? "In progress" }), _jsx(ProgressBar, { value: progress, text: `${progress} percent - ${statusLine ?? "in progress"}` })] })) : (_jsxs(_Fragment, { children: [_jsx(ProgressBar, { value: undefined, text: "In progress" }), issueMode === "unknown" && _jsx("p", { className: "text-sm text-text-muted", children: PENDING_FALLBACK_TEXT })] }))] })), problem && (_jsxs("div", { role: "alert", className: "flex items-start gap-2 rounded-sm border border-danger/40 bg-danger/10 px-3 py-2 text-sm", children: [_jsx(HiOutlineExclamationTriangle, { size: 18, "aria-hidden": "true", className: "mt-0.5 shrink-0 text-danger" }), _jsx("span", { children: problem })] })), overdue && (_jsxs("p", { className: "text-sm", children: ["This is taking longer than expected", checkedAgo ? ` - last checked ${checkedAgo}` : "", ". Use Check status to ask again."] })), enrollment?.errorCode === "ca-unreachable" && _jsx("p", { className: "text-sm text-text-muted", children: CA_UNREACHABLE_TEXT }), enrollment?.note && _jsx("p", { className: "text-xs text-text-muted", children: enrollment.note }), steps.length > 0 && _jsx(Stepper, { steps: steps }), issueMode === "automatic" && (_jsx("p", { className: "text-xs text-text-muted", children: "You can leave this page - you will be told when the certificate is issued or the request fails." })), (requestedAgo || checkedAgo) && (_jsxs("p", { className: "text-xs text-text-muted", children: [requestedAgo ? `Requested ${issueMode === "manual" ? formatDateTime(enrollment?.requestedAt) : requestedAgo}` : "", requestedAgo && checkedAgo ? " - " : "", checkedAgo ? `last checked ${checkedAgo}` : ""] })), onCheck && (_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1", children: [_jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", loading: checkingNow, disabled: checkingNow || waitSeconds > 0, "aria-busy": checkingNow, onClick: onCheck, children: checkingNow ? "Checking..." : waitSeconds > 0 ? `Check again in ${waitSeconds} s` : "Check status" }), _jsx("span", { role: "status", "aria-live": "polite", className: "text-xs text-text-muted", children: message })] }))] })), mode === "issued" && (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-sm", children: isInstalling(enrollment)
|
|
94
|
+
? statusLineOf(enrollment)
|
|
95
|
+
: notAfter !== undefined
|
|
96
|
+
? `Issued - valid until ${formatDate(notAfter)}`
|
|
97
|
+
: "Issued" }), enrollment?.note && _jsx("p", { className: "text-xs text-text-muted", children: enrollment.note }), expiry.state === "soon" && (_jsxs("div", { role: "alert", className: "flex items-start gap-2 rounded-sm border border-danger/40 bg-danger/10 px-3 py-2 text-sm", children: [_jsx(HiOutlineExclamationTriangle, { size: 18, "aria-hidden": "true", className: "mt-0.5 shrink-0 text-danger" }), _jsxs("span", { children: ["This certificate expires ", expiry.daysLeft === 1 ? "tomorrow" : `in ${expiry.daysLeft} days`, ". Renew it so your mail stays signed."] })] })), (enrollment?.subject || enrollment?.issuer || enrollment?.serialNumber || enrollment?.issuedAt) && (_jsxs("dl", { className: "flex flex-col gap-1.5", children: [enrollment.subject && _jsx(Detail, { label: "Subject", children: enrollment.subject }), enrollment.issuer && _jsx(Detail, { label: "Issuer", children: enrollment.issuer }), enrollment.serialNumber && (_jsx(Detail, { label: "Serial number", children: _jsxs("span", { className: "inline-flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "font-mono text-xs", title: enrollment.serialNumber, children: truncateSerial(enrollment.serialNumber) }), _jsx(CopyButton, { value: enrollment.serialNumber, label: "Copy the certificate's serial number" })] }) })), enrollment.issuedAt && _jsx(Detail, { label: "Issued", children: formatDate(enrollment.issuedAt) }), notAfter !== undefined && _jsx(Detail, { label: "Valid until", children: formatDate(notAfter) })] })), canRequest && onRequest && expiry.state === "soon" && (_jsx("div", { children: _jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", loading: requesting, disabled: requesting, onClick: onRequest, children: "Renew" }) }))] })), mode === "failed" && (_jsxs(_Fragment, { children: [_jsx(Alert, { children: statusLine ?? "Failed: the certificate could not be issued." }), steps.length > 0 && _jsx(Stepper, { steps: steps }), canRequest && onRequest && enrollment?.retryable !== false && (_jsx("div", { children: _jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", loading: requesting, disabled: requesting, onClick: onRequest, children: "Try again" }) }))] })), mode === "expired" && (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-sm", children: notAfter !== undefined ? `Expired on ${formatDate(notAfter)}. Mail from this mailbox is no longer signed.` : "This certificate has expired. Mail from this mailbox is no longer signed." }), canRequest && onRequest && (_jsx("div", { children: _jsx(Button, { type: "button", variant: "secondary", className: "!w-auto", loading: requesting, disabled: requesting, onClick: onRequest, children: "Request a new certificate" }) }))] }))] }));
|
|
98
|
+
}
|
|
@@ -16,6 +16,7 @@ import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
|
|
|
16
16
|
import { mergePluginNavItems } from "../../../plugins/pluginNav.js";
|
|
17
17
|
/** Every settings section with its own sidebar entry. */
|
|
18
18
|
export const SETTINGS_SECTIONS = [
|
|
19
|
+
{ id: "appearance", href: "/settings/appearance", label: "Appearance" },
|
|
19
20
|
{ id: "auto-reply", href: "/settings/auto-reply", label: "Automatic Replies" },
|
|
20
21
|
{ id: "filters", href: "/settings/filters", label: "Mail Filters" },
|
|
21
22
|
{ id: "signatures", href: "/settings/signatures", label: "Signatures" },
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MailboxAccessRole, ResolvedPrincipal } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
|
|
3
|
+
export interface PrincipalPickerProps {
|
|
4
|
+
mailboxUid: string;
|
|
5
|
+
/** What each access level is called on this page. */
|
|
6
|
+
roleLabels: Record<MailboxAccessRole, string>;
|
|
7
|
+
/** Text put in the box to start with - a stored entry being replaced, say. */
|
|
8
|
+
initialPrincipal?: string;
|
|
9
|
+
/** The access level pre-selected. */
|
|
10
|
+
defaultRole?: MailboxAccessRole;
|
|
11
|
+
/** What the box asks for. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Called once the grant is saved, with the person it went to. */
|
|
14
|
+
onGranted: (person: ResolvedPrincipal, role: MailboxAccessRole) => void | Promise<void>;
|
|
15
|
+
/** Shown as a Cancel button next to the box when set (replacing an entry). */
|
|
16
|
+
onCancel?: () => void;
|
|
17
|
+
}
|
|
18
|
+
/** Who a resolved person is, for a person to check before saving: their name and address, else their uid. */
|
|
19
|
+
export declare function describePerson(person: ResolvedPrincipal): string;
|
|
20
|
+
/**
|
|
21
|
+
* "Who?" for a sharing screen. What is typed - a mailbox address, an auth-server username or e-mail alias, or a user id -
|
|
22
|
+
* is RESOLVED by the server (`resolveMailboxPrincipal()`) to the person it names before anything is saved, and the person
|
|
23
|
+
* is shown (name and address) for the caller to confirm; only then is the grant made, against that person's uid. Free text
|
|
24
|
+
* is never stored: an ACL record matches a user uid and nothing else, so a grant to a typed username applies to nobody.
|
|
25
|
+
*/
|
|
26
|
+
export default function PrincipalPicker({ mailboxUid, roleLabels, initialPrincipal, defaultRole, placeholder, onGranted, onCancel }: PrincipalPickerProps): React.JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
3
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
4
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
5
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
8
|
+
import { resolveMailboxPrincipal, setMailboxAccess, } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
|
|
9
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
10
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
11
|
+
/** Who a resolved person is, for a person to check before saving: their name and address, else their uid. */
|
|
12
|
+
export function describePerson(person) {
|
|
13
|
+
if (person.displayName && person.address)
|
|
14
|
+
return `${person.displayName} <${person.address}>`;
|
|
15
|
+
return person.displayName ?? person.address ?? `user ${person.userUid}`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* "Who?" for a sharing screen. What is typed - a mailbox address, an auth-server username or e-mail alias, or a user id -
|
|
19
|
+
* is RESOLVED by the server (`resolveMailboxPrincipal()`) to the person it names before anything is saved, and the person
|
|
20
|
+
* is shown (name and address) for the caller to confirm; only then is the grant made, against that person's uid. Free text
|
|
21
|
+
* is never stored: an ACL record matches a user uid and nothing else, so a grant to a typed username applies to nobody.
|
|
22
|
+
*/
|
|
23
|
+
export default function PrincipalPicker({ mailboxUid, roleLabels, initialPrincipal, defaultRole = "viewer", placeholder, onGranted, onCancel }) {
|
|
24
|
+
const [typed, setTyped] = useState(initialPrincipal ?? "");
|
|
25
|
+
const [role, setRole] = useState(defaultRole);
|
|
26
|
+
const [person, setPerson] = useState(null);
|
|
27
|
+
const [busy, setBusy] = useState(false);
|
|
28
|
+
const [error, setError] = useState(null);
|
|
29
|
+
// A stored entry being replaced is looked up straight away, so its person is shown without a click.
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (initialPrincipal) {
|
|
32
|
+
void find(initialPrincipal);
|
|
33
|
+
}
|
|
34
|
+
}, [initialPrincipal]);
|
|
35
|
+
async function find(principal) {
|
|
36
|
+
setBusy(true);
|
|
37
|
+
setError(null);
|
|
38
|
+
setPerson(null);
|
|
39
|
+
try {
|
|
40
|
+
setPerson(await resolveMailboxPrincipal(mailboxUid, principal));
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not look that person up.");
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
setBusy(false);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function handleFind(e) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
const principal = typed.trim();
|
|
52
|
+
if (principal) {
|
|
53
|
+
void find(principal);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Only reachable from the confirm button, which only renders once `person` is set.
|
|
57
|
+
async function handleGrant() {
|
|
58
|
+
setBusy(true);
|
|
59
|
+
setError(null);
|
|
60
|
+
try {
|
|
61
|
+
await setMailboxAccess(mailboxUid, person.userUid, role);
|
|
62
|
+
await onGranted(person, role);
|
|
63
|
+
setTyped("");
|
|
64
|
+
setPerson(null);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not grant access.");
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
setBusy(false);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [error && _jsx(Alert, { children: error }), _jsxs("form", { onSubmit: handleFind, className: "flex gap-2", children: [_jsx("input", { type: "text", "aria-label": "Who to share with", placeholder: placeholder ?? "Email address, username or user id", className: "flex-1 text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text", value: typed, onChange: (e) => {
|
|
74
|
+
setTyped(e.target.value);
|
|
75
|
+
setPerson(null);
|
|
76
|
+
}, disabled: busy }), _jsx("select", { "aria-label": "Access level", className: "text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text", value: role, onChange: (e) => setRole(e.target.value), disabled: busy, children: Object.keys(roleLabels).map((value) => (_jsx("option", { value: value, children: roleLabels[value] }, value))) }), _jsx(Button, { type: "submit", variant: "secondary", loading: busy && !person, disabled: busy, className: "!w-auto", children: "Find" }), onCancel && (_jsx(Button, { type: "button", variant: "text", className: "!w-auto", onClick: onCancel, children: "Cancel" }))] }), person && (_jsxs("div", { className: "flex items-center justify-between gap-3 text-sm py-2 px-3 border border-border rounded-sm", children: [_jsxs("span", { children: ["Share with ", _jsx("strong", { className: "break-all", children: describePerson(person) }), " as ", _jsx("em", { children: roleLabels[role] }), "?"] }), _jsx(Button, { type: "button", loading: busy, disabled: busy, className: "!w-auto", onClick: () => void handleGrant(), children: "Grant" })] }))] }));
|
|
77
|
+
}
|
|
@@ -8,6 +8,7 @@ import { HiOutlineBars3 } from "react-icons/hi2";
|
|
|
8
8
|
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
9
9
|
import { createTaskList, listTaskLists } from "@rapidmx/react-shared/tasks/tasksApi.js";
|
|
10
10
|
import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
|
|
11
|
+
import { notifyApiError } from "../../notifications/apiErrors.js";
|
|
11
12
|
export function tasksViewKey(view) {
|
|
12
13
|
return view.type === "list" ? `list:${view.uid}` : view.type;
|
|
13
14
|
}
|
|
@@ -66,7 +67,8 @@ export default function TasksSidebar({ mailboxUid, tasks, userUid, active, onSel
|
|
|
66
67
|
setAddingList(false);
|
|
67
68
|
}
|
|
68
69
|
catch (err) {
|
|
69
|
-
|
|
70
|
+
// A pop-up: `listsError` is only the lists' own load failure.
|
|
71
|
+
notifyApiError(err, "Couldn't create the list");
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
function handleSelect(view) {
|
|
@@ -77,5 +79,5 @@ export default function TasksSidebar({ mailboxUid, tasks, userUid, active, onSel
|
|
|
77
79
|
// `Drawer` (see `ContactsSidebar` for the identical pattern and the duplicate-id reasoning behind
|
|
78
80
|
// the `idPrefix`).
|
|
79
81
|
const navContent = (idPrefix) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex flex-col gap-0.5", children: [_jsx(NavItem, { label: "My Day", count: myDayCount, active: active.type === "myDay", onClick: () => handleSelect({ type: "myDay" }) }), _jsx(NavItem, { label: "Important", count: importantCount, active: active.type === "important", onClick: () => handleSelect({ type: "important" }) }), _jsx(NavItem, { label: "Planned", count: plannedCount, active: active.type === "planned", onClick: () => handleSelect({ type: "planned" }) }), _jsx(NavItem, { label: "Assigned to me", count: assignedToMeCount, active: active.type === "assignedToMe", onClick: () => handleSelect({ type: "assignedToMe" }) }), _jsx(NavItem, { label: "Flagged email", active: active.type === "flagged", onClick: () => handleSelect({ type: "flagged" }) })] }), _jsx(NavItem, { label: "Tasks", count: tasks.length, active: active.type === "all", onClick: () => handleSelect({ type: "all" }) }), _jsxs("div", { children: [_jsxs("div", { className: "flex items-center justify-between px-2.5 mb-1", children: [_jsx("h2", { className: "text-xs font-bold uppercase tracking-wide text-text-muted", children: "Lists" }), _jsx("button", { type: "button", onClick: () => setAddingList(true), "aria-label": "New list", className: "text-xs font-bold text-primary-dark hover:underline", children: "+" })] }), listsError && _jsx("p", { className: "px-2.5 text-xs text-danger", children: listsError }), _jsx("div", { className: "flex flex-col gap-0.5", children: lists.map((list) => (_jsx(NavItem, { label: list.name, count: listCounts.get(list.uid) ?? 0, active: active.type === "list" && active.uid === list.uid, onClick: () => handleSelect({ type: "list", uid: list.uid, name: list.name }) }, list.uid))) }), addingList && (_jsxs("form", { onSubmit: handleAddList, className: "flex items-center gap-1 px-2.5 mt-1", children: [_jsx("input", { type: "text", autoFocus: true, "aria-label": "New list name", id: `${idPrefix}-new-list-name`, value: newListName, onChange: (e) => setNewListName(e.target.value), className: "flex-1 text-xs py-1 px-1.5 border border-border rounded-sm bg-surface" }), _jsx("button", { type: "submit", className: "text-xs font-semibold text-primary-dark", children: "Add" })] }))] })] }));
|
|
80
|
-
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "
|
|
82
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "lg:hidden m-3 mb-0 w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text", "aria-label": "Open tasks menu", onClick: () => setDrawerOpen(true), children: _jsx(HiOutlineBars3, { size: 20, "aria-hidden": "true" }) }), _jsx("nav", { "aria-label": "Tasks", className: "hidden lg:flex w-56 shrink-0 border-r border-border flex-col gap-4 p-3 overflow-y-auto", children: navContent("desktop") }), _jsx(Drawer, { open: drawerOpen, onClose: () => setDrawerOpen(false), title: "Tasks", children: _jsx("div", { className: "flex flex-col gap-4", children: navContent("mobile") }) })] }));
|
|
81
83
|
}
|
|
@@ -96,7 +96,9 @@ export default function TasksShell({ userUid, authServerUrl, impersonating, impe
|
|
|
96
96
|
const sidebarContent = (idPrefix) => (_jsxs(_Fragment, { children: [mailboxes.length > 1 && (_jsxs("div", { children: [_jsx("label", { className: "block text-xs font-bold uppercase tracking-wide text-text-muted mb-1", htmlFor: `${idPrefix}-tasks-mailbox-switcher`, children: "Mailbox" }), _jsx("select", { id: `${idPrefix}-tasks-mailbox-switcher`, className: "w-full text-sm border border-border rounded-sm py-1.5 px-2 bg-surface", value: mailboxUid, onChange: (e) => {
|
|
97
97
|
navigate(`/tasks?mailboxUid=${encodeURIComponent(e.target.value)}`);
|
|
98
98
|
}, children: mailboxes.map((mb) => (_jsxs("option", { value: mb.uid, children: [mb.displayName, mb.ownerUserUid ? "" : " (shared)"] }, mb.uid))) })] })), folderError && _jsx(Alert, { children: folderError })] }));
|
|
99
|
-
|
|
99
|
+
// With a single mailbox and no error this column would be empty: no 224 px of nothing beside the tasks' own menu.
|
|
100
|
+
const hasSidebar = mailboxes.length > 1 || !!folderError;
|
|
101
|
+
inner = (_jsxs(_Fragment, { children: [hasSidebar && (_jsx("aside", { className: "hidden lg:flex w-56 shrink-0 bg-surface border-r border-border flex-col p-3 gap-3", children: sidebarContent("desktop") })), _jsx(Drawer, { open: drawerOpen, onClose: () => setDrawerOpen(false), title: "Mailbox", children: _jsx("div", { className: "flex flex-col gap-3", children: sidebarContent("mobile") }) }), _jsxs("main", { className: "flex-1 min-w-0 flex flex-col", children: [hasSidebar && (_jsx("button", { type: "button", className: "lg:hidden m-3 w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text", "aria-label": "Open mailbox switcher", onClick: () => setDrawerOpen(true), children: _jsx(HiOutlineBars3, { size: 20, "aria-hidden": "true" }) })), _jsx(TasksShellContext.Provider, { value: contextValue, children: children })] })] }));
|
|
100
102
|
}
|
|
101
103
|
return (_jsx(AppShell, { active: "tasks", userUid: userUid, authServerUrl: authServerUrl, impersonating: impersonating, impersonationBaseUrl: impersonationBaseUrl, trusted: trusted, trustedRoles: trustedRoles, pluginNav: pluginNav, children: inner }));
|
|
102
104
|
}
|
|
@@ -75,4 +75,4 @@ export interface FolderCounts {
|
|
|
75
75
|
* Holds the folder counts overlay for `MailShell`. `folders` is every folder the sidebar lists (the overlay starts from what
|
|
76
76
|
* each was loaded with); `mailboxes` is whose folders to read back. The overlay starts again whenever `mailboxes` does.
|
|
77
77
|
*/
|
|
78
|
-
export declare function useFolderCounts(mailboxes: Mailbox[], folders: Folder[]): FolderCounts;
|
|
78
|
+
export declare function useFolderCounts(mailboxes: Mailbox[], folders: Folder[], onFoldersListed?: (folders: Folder[]) => void): FolderCounts;
|
|
@@ -62,10 +62,10 @@ const SEEN_LIMIT = 500;
|
|
|
62
62
|
* Holds the folder counts overlay for `MailShell`. `folders` is every folder the sidebar lists (the overlay starts from what
|
|
63
63
|
* each was loaded with); `mailboxes` is whose folders to read back. The overlay starts again whenever `mailboxes` does.
|
|
64
64
|
*/
|
|
65
|
-
export function useFolderCounts(mailboxes, folders) {
|
|
65
|
+
export function useFolderCounts(mailboxes, folders, onFoldersListed) {
|
|
66
66
|
const [counts, setCounts] = useState({});
|
|
67
|
-
const latestRef = useRef({ mailboxes, folders });
|
|
68
|
-
latestRef.current = { mailboxes, folders };
|
|
67
|
+
const latestRef = useRef({ mailboxes, folders, onFoldersListed });
|
|
68
|
+
latestRef.current = { mailboxes, folders, onFoldersListed };
|
|
69
69
|
// Bumped by every change of the overlay this page makes, so a read that started before one can tell it is out of date.
|
|
70
70
|
const changesRef = useRef(0);
|
|
71
71
|
const inFlightRef = useRef(0);
|
|
@@ -116,6 +116,12 @@ export function useFolderCounts(mailboxes, folders) {
|
|
|
116
116
|
if (stoppedRef.current || run !== runRef.current) {
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
+
// Whatever the counts' fate below, these are the mailboxes' folders as they are: a folder the sidebar does not have yet is filed now.
|
|
120
|
+
for (const list of results) {
|
|
121
|
+
if (list) {
|
|
122
|
+
latestRef.current.onFoldersListed?.(list);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
119
125
|
if (inFlightRef.current > 0 || changesRef.current !== startedAt) {
|
|
120
126
|
// A change of this page's own began or ended while that was being read, so it may predate it: read again.
|
|
121
127
|
refresh();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Folder } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
2
|
+
import type { MailboxFolders } from "../components/mail/layout/MailShell.js";
|
|
3
|
+
/**
|
|
4
|
+
* The sidebar's order of a mailbox's well-known folders; anything else (`user`) follows, alphabetically. Also the order push channels are asked
|
|
5
|
+
* for (`pushChannelsFor()`), so when the server's channel cap bites it is the folders lowest in this list that go without live updates.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FOLDER_ORDER: string[];
|
|
8
|
+
/**
|
|
9
|
+
* A mailbox's `calendar`/`contacts`/`tasks`/`notes` folders back their own dedicated apps (see `CalendarShell`/`ContactsShell`/`TasksShell`), not
|
|
10
|
+
* Mail - `listFolders()` returns every well-known folder for the mailbox regardless of which app owns it, so Mail's own folder tree filters down
|
|
11
|
+
* to just the mail ones itself, or those other apps' folders leak into its sidebar.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAIL_FOLDER_TYPES: Set<string>;
|
|
14
|
+
/** The well-known folders the server creates lazily around a first send: what the sidebar shows a placeholder for while a message is on its way. */
|
|
15
|
+
export declare const SEND_FOLDER_TYPES: readonly ["outbox", "sent_items"];
|
|
16
|
+
export declare function isMailFolder(folder: {
|
|
17
|
+
type: string;
|
|
18
|
+
}): boolean;
|
|
19
|
+
/** Well-known folders in `FOLDER_ORDER`, then the rest by name. A new array; the input is left alone. */
|
|
20
|
+
export declare function sortFolders(folders: Folder[]): Folder[];
|
|
21
|
+
/** What a sidebar row is: a folder that exists, or (`placeholder`) one that is expected to but has not arrived yet. */
|
|
22
|
+
export type FolderRow = {
|
|
23
|
+
kind: "folder";
|
|
24
|
+
folder: Folder;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "placeholder";
|
|
27
|
+
type: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The rows of one mailbox's sidebar section, in order: every folder that exists, and - while `sending` messages are on their way and the
|
|
31
|
+
* server has not made the folder yet - a placeholder for each of the Outbox and Sent Items that is missing. The one place a folder that has not
|
|
32
|
+
* arrived is drawn, so it can never appear twice: the moment the real folder is in `folders` its placeholder is not built.
|
|
33
|
+
*/
|
|
34
|
+
export declare function folderRows(folders: Folder[], sending: number): FolderRow[];
|
|
35
|
+
/** What a folder can be changed to by an event or a refetch: everything about it except the counts, which the counts overlay owns. */
|
|
36
|
+
export type FolderChange = Partial<Pick<Folder, "name" | "type" | "parentFolderUid" | "color">> & {
|
|
37
|
+
uid: string;
|
|
38
|
+
mailboxUid?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Files `folder` in the tree: added under its mailbox when unknown (a type Mail does not list is ignored), else its name, type, parent and
|
|
42
|
+
* colour brought up to date (a folder that became a type Mail does not list leaves the tree). Returns `entries` itself - the same array - when
|
|
43
|
+
* nothing changed, because everything on screen that depends on the tree starts over when it is a new one.
|
|
44
|
+
*/
|
|
45
|
+
export declare function upsertFolder(entries: MailboxFolders[], folder: Folder | FolderChange): MailboxFolders[];
|
|
46
|
+
/** Takes a deleted folder out of the tree. The same array when it was not in it. */
|
|
47
|
+
export declare function removeFolder(entries: MailboxFolders[], folderUid: string): MailboxFolders[];
|
|
48
|
+
/**
|
|
49
|
+
* Brings one mailbox's part of the tree up to date with a listing the server just gave (`listFolders()`): folders it has that the tree lacks
|
|
50
|
+
* are added, changed names and types are taken. Nothing is removed - a listing that began before a folder was created here would take it out
|
|
51
|
+
* again, and deletions arrive as events - and the counts are not touched (see `useFolderCounts()`). The same array when there is nothing to do.
|
|
52
|
+
*/
|
|
53
|
+
export declare function reconcileFolders(entries: MailboxFolders[], listed: Folder[]): MailboxFolders[];
|
|
54
|
+
/** Every folder uid in the tree. */
|
|
55
|
+
export declare function knownFolderUids(entries: MailboxFolders[]): Set<string>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sidebar's order of a mailbox's well-known folders; anything else (`user`) follows, alphabetically. Also the order push channels are asked
|
|
3
|
+
* for (`pushChannelsFor()`), so when the server's channel cap bites it is the folders lowest in this list that go without live updates.
|
|
4
|
+
*/
|
|
5
|
+
export const FOLDER_ORDER = ["inbox", "drafts", "outbox", "sent_items", "deleted_items", "junk", "archive"];
|
|
6
|
+
/**
|
|
7
|
+
* A mailbox's `calendar`/`contacts`/`tasks`/`notes` folders back their own dedicated apps (see `CalendarShell`/`ContactsShell`/`TasksShell`), not
|
|
8
|
+
* Mail - `listFolders()` returns every well-known folder for the mailbox regardless of which app owns it, so Mail's own folder tree filters down
|
|
9
|
+
* to just the mail ones itself, or those other apps' folders leak into its sidebar.
|
|
10
|
+
*/
|
|
11
|
+
export const MAIL_FOLDER_TYPES = new Set([...FOLDER_ORDER, "user"]);
|
|
12
|
+
/** The well-known folders the server creates lazily around a first send: what the sidebar shows a placeholder for while a message is on its way. */
|
|
13
|
+
export const SEND_FOLDER_TYPES = ["outbox", "sent_items"];
|
|
14
|
+
export function isMailFolder(folder) {
|
|
15
|
+
return MAIL_FOLDER_TYPES.has(folder.type);
|
|
16
|
+
}
|
|
17
|
+
function sortKey(type) {
|
|
18
|
+
const index = FOLDER_ORDER.indexOf(type);
|
|
19
|
+
return index === -1 ? FOLDER_ORDER.length : index;
|
|
20
|
+
}
|
|
21
|
+
/** Well-known folders in `FOLDER_ORDER`, then the rest by name. A new array; the input is left alone. */
|
|
22
|
+
export function sortFolders(folders) {
|
|
23
|
+
return [...folders].sort((a, b) => sortKey(a.type) - sortKey(b.type) || a.name.localeCompare(b.name));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The rows of one mailbox's sidebar section, in order: every folder that exists, and - while `sending` messages are on their way and the
|
|
27
|
+
* server has not made the folder yet - a placeholder for each of the Outbox and Sent Items that is missing. The one place a folder that has not
|
|
28
|
+
* arrived is drawn, so it can never appear twice: the moment the real folder is in `folders` its placeholder is not built.
|
|
29
|
+
*/
|
|
30
|
+
export function folderRows(folders, sending) {
|
|
31
|
+
const rows = sortFolders(folders).map((folder) => ({ kind: "folder", folder }));
|
|
32
|
+
if (sending > 0) {
|
|
33
|
+
for (const type of SEND_FOLDER_TYPES) {
|
|
34
|
+
if (!folders.some((folder) => folder.type === type)) {
|
|
35
|
+
rows.push({ kind: "placeholder", type });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
rows.sort((a, b) => sortKey(rowType(a)) - sortKey(rowType(b)));
|
|
39
|
+
}
|
|
40
|
+
return rows;
|
|
41
|
+
}
|
|
42
|
+
function rowType(row) {
|
|
43
|
+
return row.kind === "folder" ? row.folder.type : row.type;
|
|
44
|
+
}
|
|
45
|
+
const CHANGEABLE = ["name", "type", "parentFolderUid", "color"];
|
|
46
|
+
/**
|
|
47
|
+
* Files `folder` in the tree: added under its mailbox when unknown (a type Mail does not list is ignored), else its name, type, parent and
|
|
48
|
+
* colour brought up to date (a folder that became a type Mail does not list leaves the tree). Returns `entries` itself - the same array - when
|
|
49
|
+
* nothing changed, because everything on screen that depends on the tree starts over when it is a new one.
|
|
50
|
+
*/
|
|
51
|
+
export function upsertFolder(entries, folder) {
|
|
52
|
+
let changed = false;
|
|
53
|
+
const next = entries.map((entry) => {
|
|
54
|
+
const existing = entry.folders.find((f) => f.uid === folder.uid);
|
|
55
|
+
if (!existing) {
|
|
56
|
+
// Only a whole folder can be added: an update for one that is not known has nothing to add it with (the refetch it causes will).
|
|
57
|
+
if (entry.mailbox.uid !== folder.mailboxUid || !isFullFolder(folder) || !isMailFolder(folder)) {
|
|
58
|
+
return entry;
|
|
59
|
+
}
|
|
60
|
+
// A well-known folder is one per mailbox - the server treats the oldest as the real one - so a second of the same type (made by a client that did
|
|
61
|
+
// not know it existed) is not a second row: the older of the two is the one shown.
|
|
62
|
+
const sameType = folder.type === "user" ? undefined : entry.folders.find((f) => f.type === folder.type);
|
|
63
|
+
if (sameType) {
|
|
64
|
+
if (!isOlder(folder, sameType)) {
|
|
65
|
+
return entry;
|
|
66
|
+
}
|
|
67
|
+
changed = true;
|
|
68
|
+
return { ...entry, folders: entry.folders.map((f) => (f === sameType ? folder : f)) };
|
|
69
|
+
}
|
|
70
|
+
changed = true;
|
|
71
|
+
return { ...entry, folders: [...entry.folders, folder] };
|
|
72
|
+
}
|
|
73
|
+
const patch = {};
|
|
74
|
+
for (const key of CHANGEABLE) {
|
|
75
|
+
if (key in folder && folder[key] !== undefined && folder[key] !== existing[key]) {
|
|
76
|
+
patch[key] = folder[key];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (Object.keys(patch).length === 0) {
|
|
80
|
+
return entry;
|
|
81
|
+
}
|
|
82
|
+
changed = true;
|
|
83
|
+
const updated = { ...existing, ...patch };
|
|
84
|
+
return { ...entry, folders: isMailFolder(updated) ? entry.folders.map((f) => (f === existing ? updated : f)) : entry.folders.filter((f) => f !== existing) };
|
|
85
|
+
});
|
|
86
|
+
return changed ? next : entries;
|
|
87
|
+
}
|
|
88
|
+
function isFullFolder(folder) {
|
|
89
|
+
return typeof folder.name === "string" && typeof folder.type === "string";
|
|
90
|
+
}
|
|
91
|
+
/** Whether `a` was created before `b`: only when both say when. */
|
|
92
|
+
function isOlder(a, b) {
|
|
93
|
+
// (A folder from the network may lack the date: `Date.parse(undefined)` is NaN, which is "cannot tell".)
|
|
94
|
+
const first = Date.parse(a.dateCreated);
|
|
95
|
+
const second = Date.parse(b.dateCreated);
|
|
96
|
+
return Number.isFinite(first) && Number.isFinite(second) && first < second;
|
|
97
|
+
}
|
|
98
|
+
/** Takes a deleted folder out of the tree. The same array when it was not in it. */
|
|
99
|
+
export function removeFolder(entries, folderUid) {
|
|
100
|
+
if (!entries.some((entry) => entry.folders.some((folder) => folder.uid === folderUid))) {
|
|
101
|
+
return entries;
|
|
102
|
+
}
|
|
103
|
+
return entries.map((entry) => (entry.folders.some((folder) => folder.uid === folderUid) ? { ...entry, folders: entry.folders.filter((folder) => folder.uid !== folderUid) } : entry));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Brings one mailbox's part of the tree up to date with a listing the server just gave (`listFolders()`): folders it has that the tree lacks
|
|
107
|
+
* are added, changed names and types are taken. Nothing is removed - a listing that began before a folder was created here would take it out
|
|
108
|
+
* again, and deletions arrive as events - and the counts are not touched (see `useFolderCounts()`). The same array when there is nothing to do.
|
|
109
|
+
*/
|
|
110
|
+
export function reconcileFolders(entries, listed) {
|
|
111
|
+
return listed.reduce((tree, folder) => upsertFolder(tree, folder), entries);
|
|
112
|
+
}
|
|
113
|
+
/** Every folder uid in the tree. */
|
|
114
|
+
export function knownFolderUids(entries) {
|
|
115
|
+
return new Set(entries.flatMap((entry) => entry.folders.map((folder) => folder.uid)));
|
|
116
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { useUnlockPrompt } from "../../components/layout/UnlockPromptProvider.js";
|
|
7
|
+
import { registerUnlockOpener } from "./composeBridge.js";
|
|
8
|
+
/**
|
|
9
|
+
* Lets code with no React context - a pop-up's "Unlock" action - open the app's one unlock prompt (`UnlockPromptProvider`). Renders nothing;
|
|
10
|
+
* mounted once, inside the provider it reaches.
|
|
11
|
+
*/
|
|
12
|
+
export default function UnlockBridge() {
|
|
13
|
+
const { requestUnlock } = useUnlockPrompt();
|
|
14
|
+
useEffect(() => registerUnlockOpener(async (mailboxUid, keys) => {
|
|
15
|
+
await requestUnlock(mailboxUid, keys);
|
|
16
|
+
}), [requestUnlock]);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Attachment, Message } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
2
|
+
import type { PublicKey } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
3
|
+
/**
|
|
4
|
+
* A compose window to re-open around a message that was already composed: a failed send's "Open draft". The message keeps its uid - the
|
|
5
|
+
* server draft it was assembled into - and everything the sender had typed comes back exactly as it was, including what could not have
|
|
6
|
+
* been read back from the server (the plain text of a message that was encrypted before it was stored).
|
|
7
|
+
*/
|
|
8
|
+
export interface ResumeCompose {
|
|
9
|
+
/** The server draft the window continues - it must be in Drafts (a message that is in Outbox is moved back first). */
|
|
10
|
+
draft: Message;
|
|
11
|
+
mailboxUid: string;
|
|
12
|
+
to: string;
|
|
13
|
+
cc: string;
|
|
14
|
+
bcc: string;
|
|
15
|
+
subject: string;
|
|
16
|
+
html: string;
|
|
17
|
+
attachments: Attachment[];
|
|
18
|
+
requestReceipt: boolean;
|
|
19
|
+
signEnabled: boolean;
|
|
20
|
+
encryptRequested: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** What the app frame's compose provider offers to code that has no React context (a pop-up's action, a push-event handler). */
|
|
23
|
+
export interface ComposeOpenerInput {
|
|
24
|
+
mailboxUid?: string;
|
|
25
|
+
resume?: ResumeCompose;
|
|
26
|
+
}
|
|
27
|
+
/** Registered by `ComposeProvider`; returns the function that unregisters it. */
|
|
28
|
+
export declare function registerComposeOpener(open: (input: ComposeOpenerInput) => void): () => void;
|
|
29
|
+
/** Opens a compose window from outside React. `false` when no compose provider is mounted (nothing was opened). */
|
|
30
|
+
export declare function openComposeFromOutside(input: ComposeOpenerInput): boolean;
|
|
31
|
+
/** Registered by the unlock prompt's owner; returns the function that unregisters it. */
|
|
32
|
+
export declare function registerUnlockOpener(unlock: (mailboxUid: string, keys: PublicKey[]) => Promise<void>): () => void;
|
|
33
|
+
/** Opens the existing unlock prompt from outside React. Resolves once the keys are unlocked; rejects when the user dismissed it (or there is no prompt). */
|
|
34
|
+
export declare function requestUnlockFromOutside(mailboxUid: string, keys: PublicKey[]): Promise<void>;
|