@rapidmx/web-client 0.10.0 → 0.12.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/mailboxes/new/index.tsx +3 -3
- 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/escrowScopes/EscrowScopeKeyAndHoldersFields.tsx +4 -4
- 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/DomainDnsSetup.tsx +60 -14
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +65 -16
- 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/PrincipalListField.tsx +82 -0
- package/apps/shared/components/sharing/PrincipalPicker.tsx +76 -0
- package/apps/shared/components/sharing/PrincipalResolver.tsx +164 -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/mailboxes/new/index.js +1 -1
- 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/escrowScopes/EscrowScopeKeyAndHoldersFields.js +3 -2
- 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/DomainDnsSetup.js +25 -5
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +18 -7
- 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/PrincipalListField.d.ts +24 -0
- package/dist/apps/shared/components/sharing/PrincipalListField.js +23 -0
- package/dist/apps/shared/components/sharing/PrincipalPicker.d.ts +28 -0
- package/dist/apps/shared/components/sharing/PrincipalPicker.js +24 -0
- package/dist/apps/shared/components/sharing/PrincipalResolver.d.ts +44 -0
- package/dist/apps/shared/components/sharing/PrincipalResolver.js +92 -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,164 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { KeyboardEvent, ReactNode, useEffect, useState } from "react";
|
|
6
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
+
import { ResolvedPrincipal } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
|
|
8
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
9
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
10
|
+
|
|
11
|
+
export interface PrincipalResolverProps {
|
|
12
|
+
/** Resolves what was typed - a mailbox address, an auth-server username or e-mail alias, or a user uid - to
|
|
13
|
+
* the one person it names, exact match only. Rejects (typically with an `ApiRequestError`) for nobody. */
|
|
14
|
+
resolve: (principal: string) => Promise<ResolvedPrincipal>;
|
|
15
|
+
/** Called once the caller confirms the resolved person is the right one. The box is cleared once this
|
|
16
|
+
* resolves - throw (or reject) to keep the person on screen and show an error instead. */
|
|
17
|
+
onResolved: (person: ResolvedPrincipal) => void | Promise<void>;
|
|
18
|
+
/** Text put in the box to start with - a stored entry being replaced, say - looked up automatically on mount. */
|
|
19
|
+
initialPrincipal?: string;
|
|
20
|
+
/** What the box asks for. */
|
|
21
|
+
placeholder: string;
|
|
22
|
+
/** The box's accessible name. */
|
|
23
|
+
ariaLabel: string;
|
|
24
|
+
/** Extra controls rendered between the text box and the Find button (e.g. a role selector). */
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
/** The confirm button's label (e.g. "Grant", "Use this owner"). */
|
|
27
|
+
confirmLabel: string;
|
|
28
|
+
/** What the confirmation row says once a person is found - e.g. "Share with X as Y?". */
|
|
29
|
+
describeConfirm: (person: ResolvedPrincipal) => ReactNode;
|
|
30
|
+
/** Shown if `onResolved` rejects, unless it was an `ApiRequestError` (then its own message is shown). */
|
|
31
|
+
confirmErrorMessage: string;
|
|
32
|
+
/** Shown as a Cancel button next to the box when set (replacing an entry). */
|
|
33
|
+
onCancel?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Who a resolved person is, for a person to check before confirming: their name and address, else their uid. */
|
|
37
|
+
export function describePerson(person: ResolvedPrincipal): string {
|
|
38
|
+
if (person.displayName && person.address) return `${person.displayName} <${person.address}>`;
|
|
39
|
+
return person.displayName ?? person.address ?? `user ${person.userUid}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* "Who?" - anywhere a person is assigned by typed identifier rather than picked from an already-loaded list. What
|
|
44
|
+
* is typed is RESOLVED by the server (`resolve`) to the person it names before anything is saved, and the person is
|
|
45
|
+
* shown (name and address) for the caller to confirm; only `onResolved` ever sees the resolved, verified person -
|
|
46
|
+
* never the free text. This is deliberately exact-match, type-then-confirm - never a live/fuzzy search-as-you-type
|
|
47
|
+
* autocomplete, which would let anyone with access to the field enumerate the user directory by partial name.
|
|
48
|
+
*
|
|
49
|
+
* Parameterized entirely by `resolve`/`onResolved` (and the wording props) so every caller - mailbox sharing
|
|
50
|
+
* (`PrincipalPicker`, a thin wrapper around this component), mailbox ownership, escrow-scope holders, ... - reuses
|
|
51
|
+
* the same resolve-then-confirm UX and privacy posture rather than each reimplementing it.
|
|
52
|
+
*
|
|
53
|
+
* Deliberately renders no `<form>` of its own (Enter-to-find is wired up by hand instead, see `handleKeyDown()`) -
|
|
54
|
+
* some callers (`MailboxCreateForm`) use this as one field of their own, larger `<form>`, and a nested `<form>` is
|
|
55
|
+
* invalid HTML that real browsers mis-handle (an inner Enter keypress can submit the wrong one).
|
|
56
|
+
*/
|
|
57
|
+
export default function PrincipalResolver({
|
|
58
|
+
resolve,
|
|
59
|
+
onResolved,
|
|
60
|
+
initialPrincipal,
|
|
61
|
+
placeholder,
|
|
62
|
+
ariaLabel,
|
|
63
|
+
children,
|
|
64
|
+
confirmLabel,
|
|
65
|
+
describeConfirm,
|
|
66
|
+
confirmErrorMessage,
|
|
67
|
+
onCancel,
|
|
68
|
+
}: PrincipalResolverProps) {
|
|
69
|
+
const [typed, setTyped] = useState(initialPrincipal ?? "");
|
|
70
|
+
const [person, setPerson] = useState<ResolvedPrincipal | null>(null);
|
|
71
|
+
const [busy, setBusy] = useState(false);
|
|
72
|
+
const [error, setError] = useState<string | null>(null);
|
|
73
|
+
|
|
74
|
+
// A stored entry being replaced is looked up straight away, so its person is shown without a click.
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (initialPrincipal) {
|
|
77
|
+
void find(initialPrincipal);
|
|
78
|
+
}
|
|
79
|
+
}, [initialPrincipal]);
|
|
80
|
+
|
|
81
|
+
async function find(principal: string) {
|
|
82
|
+
setBusy(true);
|
|
83
|
+
setError(null);
|
|
84
|
+
setPerson(null);
|
|
85
|
+
try {
|
|
86
|
+
setPerson(await resolve(principal));
|
|
87
|
+
} catch (err) {
|
|
88
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not look that person up.");
|
|
89
|
+
} finally {
|
|
90
|
+
setBusy(false);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function submitFind() {
|
|
95
|
+
const principal = typed.trim();
|
|
96
|
+
if (principal) {
|
|
97
|
+
void find(principal);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Enter in the text box finds, same as clicking the button - handled here (not a native `<form>` submit,
|
|
102
|
+
* see this component's own doc comment on why) so it works whether or not a caller nests this inside one of
|
|
103
|
+
* their own forms (`MailboxCreateForm` does). */
|
|
104
|
+
function handleKeyDown(e: KeyboardEvent<HTMLInputElement>) {
|
|
105
|
+
if (e.key === "Enter") {
|
|
106
|
+
// Stops the keystroke from also submitting an ANCESTOR `<form>` this component happens to be nested in.
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
submitFind();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Only reachable from the confirm button, which only renders once `person` is set.
|
|
113
|
+
async function handleConfirm() {
|
|
114
|
+
setBusy(true);
|
|
115
|
+
setError(null);
|
|
116
|
+
try {
|
|
117
|
+
await onResolved(person!);
|
|
118
|
+
setTyped("");
|
|
119
|
+
setPerson(null);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
setError(err instanceof ApiRequestError ? err.message : confirmErrorMessage);
|
|
122
|
+
} finally {
|
|
123
|
+
setBusy(false);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<div className="flex flex-col gap-2">
|
|
129
|
+
{error && <Alert>{error}</Alert>}
|
|
130
|
+
<div className="flex gap-2">
|
|
131
|
+
<input
|
|
132
|
+
type="text"
|
|
133
|
+
aria-label={ariaLabel}
|
|
134
|
+
placeholder={placeholder}
|
|
135
|
+
className="flex-1 text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text"
|
|
136
|
+
value={typed}
|
|
137
|
+
onChange={(e) => {
|
|
138
|
+
setTyped(e.target.value);
|
|
139
|
+
setPerson(null);
|
|
140
|
+
}}
|
|
141
|
+
onKeyDown={handleKeyDown}
|
|
142
|
+
disabled={busy}
|
|
143
|
+
/>
|
|
144
|
+
{children}
|
|
145
|
+
<Button type="button" variant="secondary" loading={busy && !person} disabled={busy} className="!w-auto" onClick={submitFind}>
|
|
146
|
+
Find
|
|
147
|
+
</Button>
|
|
148
|
+
{onCancel && (
|
|
149
|
+
<Button type="button" variant="text" className="!w-auto" onClick={onCancel}>
|
|
150
|
+
Cancel
|
|
151
|
+
</Button>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
{person && (
|
|
155
|
+
<div className="flex items-center justify-between gap-3 text-sm py-2 px-3 border border-border rounded-sm">
|
|
156
|
+
<span>{describeConfirm(person)}</span>
|
|
157
|
+
<Button type="button" loading={busy} disabled={busy} className="!w-auto" onClick={() => void handleConfirm()}>
|
|
158
|
+
{confirmLabel}
|
|
159
|
+
</Button>
|
|
160
|
+
</div>
|
|
161
|
+
)}
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
@@ -7,6 +7,7 @@ import { HiOutlineBars3 } from "react-icons/hi2";
|
|
|
7
7
|
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
8
8
|
import { Task, TaskList, createTaskList, listTaskLists } from "@rapidmx/react-shared/tasks/tasksApi.js";
|
|
9
9
|
import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
|
|
10
|
+
import { notifyApiError } from "../../notifications/apiErrors.js";
|
|
10
11
|
|
|
11
12
|
export type TasksView =
|
|
12
13
|
| { type: "myDay" }
|
|
@@ -102,7 +103,8 @@ export default function TasksSidebar({ mailboxUid, tasks, userUid, active, onSel
|
|
|
102
103
|
setNewListName("");
|
|
103
104
|
setAddingList(false);
|
|
104
105
|
} catch (err) {
|
|
105
|
-
|
|
106
|
+
// A pop-up: `listsError` is only the lists' own load failure.
|
|
107
|
+
notifyApiError(err, "Couldn't create the list");
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
|
|
@@ -184,13 +186,13 @@ export default function TasksSidebar({ mailboxUid, tasks, userUid, active, onSel
|
|
|
184
186
|
<>
|
|
185
187
|
<button
|
|
186
188
|
type="button"
|
|
187
|
-
className="
|
|
189
|
+
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"
|
|
188
190
|
aria-label="Open tasks menu"
|
|
189
191
|
onClick={() => setDrawerOpen(true)}
|
|
190
192
|
>
|
|
191
193
|
<HiOutlineBars3 size={20} aria-hidden="true" />
|
|
192
194
|
</button>
|
|
193
|
-
<nav aria-label="Tasks" className="hidden
|
|
195
|
+
<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">
|
|
194
196
|
{navContent("desktop")}
|
|
195
197
|
</nav>
|
|
196
198
|
<Drawer open={drawerOpen} onClose={() => setDrawerOpen(false)} title="Tasks">
|
|
@@ -171,19 +171,23 @@ export default function TasksShell({
|
|
|
171
171
|
</>
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
+
// With a single mailbox and no error this column would be empty: no 224 px of nothing beside the tasks' own menu.
|
|
175
|
+
const hasSidebar = mailboxes.length > 1 || !!folderError;
|
|
174
176
|
inner = (
|
|
175
177
|
<>
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
{hasSidebar && (
|
|
179
|
+
<aside className="hidden lg:flex w-56 shrink-0 bg-surface border-r border-border flex-col p-3 gap-3">
|
|
180
|
+
{sidebarContent("desktop")}
|
|
181
|
+
</aside>
|
|
182
|
+
)}
|
|
179
183
|
<Drawer open={drawerOpen} onClose={() => setDrawerOpen(false)} title="Mailbox">
|
|
180
184
|
<div className="flex flex-col gap-3">{sidebarContent("mobile")}</div>
|
|
181
185
|
</Drawer>
|
|
182
186
|
<main className="flex-1 min-w-0 flex flex-col">
|
|
183
|
-
{
|
|
187
|
+
{hasSidebar && (
|
|
184
188
|
<button
|
|
185
189
|
type="button"
|
|
186
|
-
className="
|
|
190
|
+
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"
|
|
187
191
|
aria-label="Open mailbox switcher"
|
|
188
192
|
onClick={() => setDrawerOpen(true)}
|
|
189
193
|
>
|
|
@@ -132,10 +132,10 @@ export interface FolderCounts {
|
|
|
132
132
|
* Holds the folder counts overlay for `MailShell`. `folders` is every folder the sidebar lists (the overlay starts from what
|
|
133
133
|
* each was loaded with); `mailboxes` is whose folders to read back. The overlay starts again whenever `mailboxes` does.
|
|
134
134
|
*/
|
|
135
|
-
export function useFolderCounts(mailboxes: Mailbox[], folders: Folder[]): FolderCounts {
|
|
135
|
+
export function useFolderCounts(mailboxes: Mailbox[], folders: Folder[], onFoldersListed?: (folders: Folder[]) => void): FolderCounts {
|
|
136
136
|
const [counts, setCounts] = useState<Record<string, FolderCount>>({});
|
|
137
|
-
const latestRef = useRef({ mailboxes, folders });
|
|
138
|
-
latestRef.current = { mailboxes, folders };
|
|
137
|
+
const latestRef = useRef({ mailboxes, folders, onFoldersListed });
|
|
138
|
+
latestRef.current = { mailboxes, folders, onFoldersListed };
|
|
139
139
|
// Bumped by every change of the overlay this page makes, so a read that started before one can tell it is out of date.
|
|
140
140
|
const changesRef = useRef(0);
|
|
141
141
|
const inFlightRef = useRef(0);
|
|
@@ -189,6 +189,12 @@ export function useFolderCounts(mailboxes: Mailbox[], folders: Folder[]): Folder
|
|
|
189
189
|
if (stoppedRef.current || run !== runRef.current) {
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
|
+
// Whatever the counts' fate below, these are the mailboxes' folders as they are: a folder the sidebar does not have yet is filed now.
|
|
193
|
+
for (const list of results) {
|
|
194
|
+
if (list) {
|
|
195
|
+
latestRef.current.onFoldersListed?.(list);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
192
198
|
if (inFlightRef.current > 0 || changesRef.current !== startedAt) {
|
|
193
199
|
// A change of this page's own began or ended while that was being read, so it may predate it: read again.
|
|
194
200
|
refresh();
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import type { Folder } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
6
|
+
import type { MailboxFolders } from "../components/mail/layout/MailShell.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The sidebar's order of a mailbox's well-known folders; anything else (`user`) follows, alphabetically. Also the order push channels are asked
|
|
10
|
+
* for (`pushChannelsFor()`), so when the server's channel cap bites it is the folders lowest in this list that go without live updates.
|
|
11
|
+
*/
|
|
12
|
+
export const FOLDER_ORDER = ["inbox", "drafts", "outbox", "sent_items", "deleted_items", "junk", "archive"];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A mailbox's `calendar`/`contacts`/`tasks`/`notes` folders back their own dedicated apps (see `CalendarShell`/`ContactsShell`/`TasksShell`), not
|
|
16
|
+
* Mail - `listFolders()` returns every well-known folder for the mailbox regardless of which app owns it, so Mail's own folder tree filters down
|
|
17
|
+
* to just the mail ones itself, or those other apps' folders leak into its sidebar.
|
|
18
|
+
*/
|
|
19
|
+
export const MAIL_FOLDER_TYPES = new Set([...FOLDER_ORDER, "user"]);
|
|
20
|
+
|
|
21
|
+
/** 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. */
|
|
22
|
+
export const SEND_FOLDER_TYPES = ["outbox", "sent_items"] as const;
|
|
23
|
+
|
|
24
|
+
export function isMailFolder(folder: { type: string }): boolean {
|
|
25
|
+
return MAIL_FOLDER_TYPES.has(folder.type);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function sortKey(type: string): number {
|
|
29
|
+
const index = FOLDER_ORDER.indexOf(type);
|
|
30
|
+
return index === -1 ? FOLDER_ORDER.length : index;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Well-known folders in `FOLDER_ORDER`, then the rest by name. A new array; the input is left alone. */
|
|
34
|
+
export function sortFolders(folders: Folder[]): Folder[] {
|
|
35
|
+
return [...folders].sort((a, b) => sortKey(a.type) - sortKey(b.type) || a.name.localeCompare(b.name));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** What a sidebar row is: a folder that exists, or (`placeholder`) one that is expected to but has not arrived yet. */
|
|
39
|
+
export type FolderRow = { kind: "folder"; folder: Folder } | { kind: "placeholder"; type: string };
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The rows of one mailbox's sidebar section, in order: every folder that exists, and - while `sending` messages are on their way and the
|
|
43
|
+
* 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
|
|
44
|
+
* arrived is drawn, so it can never appear twice: the moment the real folder is in `folders` its placeholder is not built.
|
|
45
|
+
*/
|
|
46
|
+
export function folderRows(folders: Folder[], sending: number): FolderRow[] {
|
|
47
|
+
const rows: FolderRow[] = sortFolders(folders).map((folder) => ({ kind: "folder", folder }));
|
|
48
|
+
if (sending > 0) {
|
|
49
|
+
for (const type of SEND_FOLDER_TYPES) {
|
|
50
|
+
if (!folders.some((folder) => folder.type === type)) {
|
|
51
|
+
rows.push({ kind: "placeholder", type });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
rows.sort((a, b) => sortKey(rowType(a)) - sortKey(rowType(b)));
|
|
55
|
+
}
|
|
56
|
+
return rows;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function rowType(row: FolderRow): string {
|
|
60
|
+
return row.kind === "folder" ? row.folder.type : row.type;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** What a folder can be changed to by an event or a refetch: everything about it except the counts, which the counts overlay owns. */
|
|
64
|
+
export type FolderChange = Partial<Pick<Folder, "name" | "type" | "parentFolderUid" | "color">> & { uid: string; mailboxUid?: string };
|
|
65
|
+
|
|
66
|
+
const CHANGEABLE = ["name", "type", "parentFolderUid", "color"] as const;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 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
|
|
70
|
+
* 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
|
|
71
|
+
* nothing changed, because everything on screen that depends on the tree starts over when it is a new one.
|
|
72
|
+
*/
|
|
73
|
+
export function upsertFolder(entries: MailboxFolders[], folder: Folder | FolderChange): MailboxFolders[] {
|
|
74
|
+
let changed = false;
|
|
75
|
+
const next = entries.map((entry) => {
|
|
76
|
+
const existing = entry.folders.find((f) => f.uid === folder.uid);
|
|
77
|
+
if (!existing) {
|
|
78
|
+
// 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).
|
|
79
|
+
if (entry.mailbox.uid !== folder.mailboxUid || !isFullFolder(folder) || !isMailFolder(folder)) {
|
|
80
|
+
return entry;
|
|
81
|
+
}
|
|
82
|
+
// 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
|
|
83
|
+
// not know it existed) is not a second row: the older of the two is the one shown.
|
|
84
|
+
const sameType = folder.type === "user" ? undefined : entry.folders.find((f) => f.type === folder.type);
|
|
85
|
+
if (sameType) {
|
|
86
|
+
if (!isOlder(folder, sameType)) {
|
|
87
|
+
return entry;
|
|
88
|
+
}
|
|
89
|
+
changed = true;
|
|
90
|
+
return { ...entry, folders: entry.folders.map((f) => (f === sameType ? folder : f)) };
|
|
91
|
+
}
|
|
92
|
+
changed = true;
|
|
93
|
+
return { ...entry, folders: [...entry.folders, folder] };
|
|
94
|
+
}
|
|
95
|
+
const patch: Partial<Folder> = {};
|
|
96
|
+
for (const key of CHANGEABLE) {
|
|
97
|
+
if (key in folder && folder[key] !== undefined && folder[key] !== existing[key]) {
|
|
98
|
+
(patch as Record<string, unknown>)[key] = folder[key];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (Object.keys(patch).length === 0) {
|
|
102
|
+
return entry;
|
|
103
|
+
}
|
|
104
|
+
changed = true;
|
|
105
|
+
const updated = { ...existing, ...patch };
|
|
106
|
+
return { ...entry, folders: isMailFolder(updated) ? entry.folders.map((f) => (f === existing ? updated : f)) : entry.folders.filter((f) => f !== existing) };
|
|
107
|
+
});
|
|
108
|
+
return changed ? next : entries;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isFullFolder(folder: Folder | FolderChange): folder is Folder {
|
|
112
|
+
return typeof folder.name === "string" && typeof folder.type === "string";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Whether `a` was created before `b`: only when both say when. */
|
|
116
|
+
function isOlder(a: Folder, b: Folder): boolean {
|
|
117
|
+
// (A folder from the network may lack the date: `Date.parse(undefined)` is NaN, which is "cannot tell".)
|
|
118
|
+
const first = Date.parse(a.dateCreated);
|
|
119
|
+
const second = Date.parse(b.dateCreated);
|
|
120
|
+
return Number.isFinite(first) && Number.isFinite(second) && first < second;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Takes a deleted folder out of the tree. The same array when it was not in it. */
|
|
124
|
+
export function removeFolder(entries: MailboxFolders[], folderUid: string): MailboxFolders[] {
|
|
125
|
+
if (!entries.some((entry) => entry.folders.some((folder) => folder.uid === folderUid))) {
|
|
126
|
+
return entries;
|
|
127
|
+
}
|
|
128
|
+
return entries.map((entry) => (entry.folders.some((folder) => folder.uid === folderUid) ? { ...entry, folders: entry.folders.filter((folder) => folder.uid !== folderUid) } : entry));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 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
|
|
133
|
+
* 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
|
|
134
|
+
* again, and deletions arrive as events - and the counts are not touched (see `useFolderCounts()`). The same array when there is nothing to do.
|
|
135
|
+
*/
|
|
136
|
+
export function reconcileFolders(entries: MailboxFolders[], listed: Folder[]): MailboxFolders[] {
|
|
137
|
+
return listed.reduce((tree, folder) => upsertFolder(tree, folder), entries);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Every folder uid in the tree. */
|
|
141
|
+
export function knownFolderUids(entries: MailboxFolders[]): Set<string> {
|
|
142
|
+
return new Set(entries.flatMap((entry) => entry.folders.map((folder) => folder.uid)));
|
|
143
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* Lets code with no React context - a pop-up's "Unlock" action - open the app's one unlock prompt (`UnlockPromptProvider`). Renders nothing;
|
|
11
|
+
* mounted once, inside the provider it reaches.
|
|
12
|
+
*/
|
|
13
|
+
export default function UnlockBridge(): null {
|
|
14
|
+
const { requestUnlock } = useUnlockPrompt();
|
|
15
|
+
useEffect(
|
|
16
|
+
() =>
|
|
17
|
+
registerUnlockOpener(async (mailboxUid, keys) => {
|
|
18
|
+
await requestUnlock(mailboxUid, keys);
|
|
19
|
+
}),
|
|
20
|
+
[requestUnlock],
|
|
21
|
+
);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import type { Attachment, Message } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
6
|
+
import type { PublicKey } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 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
|
|
10
|
+
* server draft it was assembled into - and everything the sender had typed comes back exactly as it was, including what could not have
|
|
11
|
+
* been read back from the server (the plain text of a message that was encrypted before it was stored).
|
|
12
|
+
*/
|
|
13
|
+
export interface ResumeCompose {
|
|
14
|
+
/** The server draft the window continues - it must be in Drafts (a message that is in Outbox is moved back first). */
|
|
15
|
+
draft: Message;
|
|
16
|
+
mailboxUid: string;
|
|
17
|
+
to: string;
|
|
18
|
+
cc: string;
|
|
19
|
+
bcc: string;
|
|
20
|
+
subject: string;
|
|
21
|
+
html: string;
|
|
22
|
+
attachments: Attachment[];
|
|
23
|
+
requestReceipt: boolean;
|
|
24
|
+
signEnabled: boolean;
|
|
25
|
+
encryptRequested: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** What the app frame's compose provider offers to code that has no React context (a pop-up's action, a push-event handler). */
|
|
29
|
+
export interface ComposeOpenerInput {
|
|
30
|
+
mailboxUid?: string;
|
|
31
|
+
resume?: ResumeCompose;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let opener: ((input: ComposeOpenerInput) => void) | undefined;
|
|
35
|
+
let unlocker: ((mailboxUid: string, keys: PublicKey[]) => Promise<void>) | undefined;
|
|
36
|
+
|
|
37
|
+
/** Registered by `ComposeProvider`; returns the function that unregisters it. */
|
|
38
|
+
export function registerComposeOpener(open: (input: ComposeOpenerInput) => void): () => void {
|
|
39
|
+
opener = open;
|
|
40
|
+
return () => {
|
|
41
|
+
if (opener === open) {
|
|
42
|
+
opener = undefined;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Opens a compose window from outside React. `false` when no compose provider is mounted (nothing was opened). */
|
|
48
|
+
export function openComposeFromOutside(input: ComposeOpenerInput): boolean {
|
|
49
|
+
if (!opener) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
opener(input);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Registered by the unlock prompt's owner; returns the function that unregisters it. */
|
|
57
|
+
export function registerUnlockOpener(unlock: (mailboxUid: string, keys: PublicKey[]) => Promise<void>): () => void {
|
|
58
|
+
unlocker = unlock;
|
|
59
|
+
return () => {
|
|
60
|
+
if (unlocker === unlock) {
|
|
61
|
+
unlocker = undefined;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 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). */
|
|
67
|
+
export function requestUnlockFromOutside(mailboxUid: string, keys: PublicKey[]): Promise<void> {
|
|
68
|
+
return unlocker ? unlocker(mailboxUid, keys) : Promise.reject(new Error("No unlock prompt is available."));
|
|
69
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import type { Message } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* What a message in Outbox is doing, read from the fields the server keeps on it (`scheduledSend*`):
|
|
9
|
+
*
|
|
10
|
+
* These are the server's own definitions (`@rapidmx/restapi`'s background send):
|
|
11
|
+
*
|
|
12
|
+
* - `sending`: a lease (`scheduledSendLeaseExpiresAt`) is running, or a *due* `scheduledSendTime` with no failed attempts yet - a message
|
|
13
|
+
* queued for the server's worker (a background send is queued as an ordinary due message, `scheduledSendTime` = when it was queued);
|
|
14
|
+
* - `retrying`: `scheduledSendAttempts > 0` with a later `scheduledSendTime` (or a lease on one): a delivery attempt failed and the server
|
|
15
|
+
* will try again;
|
|
16
|
+
* - `failed`: `scheduledSendError` set and no `scheduledSendTime` - the server gave up; it stays in Outbox, waiting for the user to retry
|
|
17
|
+
* (the same send call again) or to open it (back to Drafts is allowed, it is not in flight);
|
|
18
|
+
* - `scheduled`: a send-later message whose time has not come.
|
|
19
|
+
*
|
|
20
|
+
* "Due" is judged against the message's own `dateModified` as well as the clock: a background send's `scheduledSendTime` is set by the server
|
|
21
|
+
* at the moment it queued the message, so a browser whose clock runs behind must not read it as a send scheduled for the future.
|
|
22
|
+
*/
|
|
23
|
+
export type OutboxItemState = "sending" | "retrying" | "failed" | "scheduled";
|
|
24
|
+
|
|
25
|
+
export interface OutboxItemStatus {
|
|
26
|
+
state: OutboxItemState;
|
|
27
|
+
/** Failed delivery attempts so far (`retrying`). */
|
|
28
|
+
attempts: number;
|
|
29
|
+
/** Why it failed (`failed`). */
|
|
30
|
+
error?: string;
|
|
31
|
+
/** When it will be sent or tried again (`scheduled`, `retrying`), epoch ms. */
|
|
32
|
+
at?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A `scheduledSendTime` this close to the message's last modification was set by the server as "now": a due message, not a scheduled one. */
|
|
36
|
+
export const DUE_SLACK_MS = 2_000;
|
|
37
|
+
|
|
38
|
+
export function outboxItemStatus(message: Message, now: number = Date.now()): OutboxItemStatus {
|
|
39
|
+
const attempts = message.scheduledSendAttempts ?? 0;
|
|
40
|
+
const lease = message.scheduledSendLeaseExpiresAt ? Date.parse(message.scheduledSendLeaseExpiresAt) : NaN;
|
|
41
|
+
const at = message.scheduledSendTime ? Date.parse(message.scheduledSendTime) : NaN;
|
|
42
|
+
if (message.scheduledSendError && !message.scheduledSendTime && !(lease > now)) {
|
|
43
|
+
return { state: "failed", attempts, error: message.scheduledSendError };
|
|
44
|
+
}
|
|
45
|
+
if (lease > now) {
|
|
46
|
+
return { state: attempts > 0 ? "retrying" : "sending", attempts };
|
|
47
|
+
}
|
|
48
|
+
if (attempts > 0) {
|
|
49
|
+
return { state: "retrying", attempts, at: Number.isNaN(at) ? undefined : at };
|
|
50
|
+
}
|
|
51
|
+
const modified = message.dateModified ? Date.parse(message.dateModified) : NaN;
|
|
52
|
+
const dueWhenModified = at - modified <= DUE_SLACK_MS;
|
|
53
|
+
if (at > now && !dueWhenModified) {
|
|
54
|
+
return { state: "scheduled", attempts, at };
|
|
55
|
+
}
|
|
56
|
+
return { state: "sending", attempts };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** How many messages of each kind an Outbox folder holds. */
|
|
60
|
+
export interface OutboxFolderStatus {
|
|
61
|
+
sending: number;
|
|
62
|
+
retrying: number;
|
|
63
|
+
failed: number;
|
|
64
|
+
scheduled: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const EMPTY_OUTBOX_STATUS: OutboxFolderStatus = { sending: 0, retrying: 0, failed: 0, scheduled: 0 };
|
|
68
|
+
|
|
69
|
+
export function summarizeOutbox(messages: Message[], now: number = Date.now()): OutboxFolderStatus {
|
|
70
|
+
const status = { ...EMPTY_OUTBOX_STATUS };
|
|
71
|
+
for (const message of messages) {
|
|
72
|
+
status[outboxItemStatus(message, now).state] += 1;
|
|
73
|
+
}
|
|
74
|
+
return status;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The text a screen reader gets for an Outbox count, and the tooltip: "2 messages sending", "3 messages, 1 failed". */
|
|
78
|
+
export function outboxLabel(total: number, status: OutboxFolderStatus | undefined, pendingHere: number): string {
|
|
79
|
+
const noun = `${total} ${total === 1 ? "message" : "messages"}`;
|
|
80
|
+
if (status && status.failed > 0) {
|
|
81
|
+
return `${noun}, ${status.failed} failed`;
|
|
82
|
+
}
|
|
83
|
+
const inFlight = (status ? status.sending + status.retrying : 0) + pendingHere;
|
|
84
|
+
if (inFlight > 0) {
|
|
85
|
+
return `${noun} sending`;
|
|
86
|
+
}
|
|
87
|
+
return status && status.scheduled > 0 && status.scheduled === total ? `${noun} scheduled` : noun;
|
|
88
|
+
}
|