@rapidmx/web-client 0.4.0 → 0.6.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 +88 -0
- package/apps/admin/audit-log/index.tsx +35 -8
- package/apps/admin/data-requests/index.tsx +480 -485
- package/apps/admin/distribution-lists/[uid].tsx +19 -1
- package/apps/admin/escrow-scopes/[uid].tsx +348 -237
- package/apps/admin/escrow-scopes/new/index.tsx +8 -2
- package/apps/admin/index.tsx +19 -1
- package/apps/admin/ingest-queue/index.tsx +44 -5
- package/apps/admin/mailboxes/[uid].tsx +211 -184
- package/apps/admin/quarantine/index.tsx +46 -14
- package/apps/admin/transport-rules/[uid].tsx +30 -1
- package/apps/admin/transport-rules/_transportRuleConfig.tsx +38 -2
- package/apps/admin/transport-rules/index.tsx +24 -6
- package/apps/admin/transport-rules/new/index.tsx +30 -1
- package/apps/escrow/_layout.tsx +2 -3
- package/apps/escrow/audit-log/index.tsx +196 -168
- package/apps/escrow/matters/[uid].tsx +621 -521
- package/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.tsx +22 -1
- package/apps/shared/components/admin/layout/AdminShell.tsx +28 -9
- package/apps/shared/components/admin/mailboxes/EscrowScopeCard.tsx +152 -0
- package/apps/shared/components/admin/mailboxes/ResourceSettingsCard.tsx +3 -3
- package/apps/shared/components/admin/mailboxes/ShareAccessCard.tsx +55 -11
- package/apps/shared/components/admin/settings/BrandingForm.tsx +15 -4
- package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +18 -7
- package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +10 -2
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +6 -0
- package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +45 -12
- package/apps/shared/components/admin/settings/PluginsManager.tsx +1235 -595
- package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +174 -98
- package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +49 -13
- package/apps/shared/components/admin/setup/SetupWizard.tsx +150 -34
- package/apps/shared/components/admin/signOut.ts +79 -0
- package/apps/shared/components/admin/usePagedList.tsx +129 -0
- package/apps/shared/components/calendar/EventModal.tsx +717 -549
- package/apps/shared/components/calendar/MonthView.tsx +173 -139
- package/apps/shared/components/calendar/RecurrenceEditor.tsx +222 -180
- package/apps/shared/components/calendar/SplitDayView.tsx +143 -137
- package/apps/shared/components/calendar/TimeGridView.tsx +244 -198
- package/apps/shared/components/calendar/allDay.ts +124 -0
- package/apps/shared/components/calendar/layout/CalendarShell.tsx +194 -192
- package/apps/shared/components/contacts/ContactDetailPane.tsx +100 -21
- package/apps/shared/components/contacts/ContactForm.tsx +377 -348
- package/apps/shared/components/contacts/ContactsSidebar.tsx +6 -2
- package/apps/shared/components/contacts/KeyChangeReview.tsx +192 -0
- package/apps/shared/components/contacts/contactKeys.ts +78 -0
- package/apps/shared/components/contacts/layout/ContactsShell.tsx +199 -197
- package/apps/shared/components/escrow/layout/EscrowShell.tsx +148 -134
- package/apps/shared/components/layout/AppShell.tsx +123 -33
- package/apps/shared/components/layout/BrandingChrome.tsx +48 -10
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +389 -298
- package/apps/shared/components/layout/MailboxProvisioning.tsx +19 -3
- package/apps/shared/components/layout/RecoveryCodeUnlock.tsx +350 -0
- package/apps/shared/components/layout/UnlockPromptProvider.tsx +257 -128
- package/apps/shared/components/mail/ConversationThreadPane.tsx +216 -181
- package/apps/shared/components/mail/MessageDetailPane.tsx +1318 -630
- package/apps/shared/components/mail/compose/ComposeContext.tsx +20 -15
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +854 -132
- package/apps/shared/components/mail/compose/composeFlushRegistry.ts +60 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +420 -408
- package/apps/shared/components/mail/pinnedSigners.ts +124 -0
- package/apps/shared/components/mail/verificationSeals.ts +125 -0
- package/apps/shared/components/mail/writableMailboxes.ts +101 -0
- package/apps/shared/components/rules/RuleBuilder.tsx +311 -276
- package/apps/shared/components/settings/layout/SettingsShell.tsx +23 -9
- package/apps/shared/components/tasks/layout/TasksShell.tsx +201 -199
- package/apps/shared/mail/listAllPages.ts +39 -0
- package/apps/shared/plugins/pluginNav.ts +73 -0
- package/apps/shared/search/LocalIndexLifecycle.tsx +64 -55
- package/apps/shared/search/localIndexBuilder.ts +481 -179
- package/apps/shared/search/localIndexRpcClient.ts +231 -29
- package/apps/shared/search/localIndexSchema.ts +15 -6
- package/apps/shared/search/localIndexStorage.ts +98 -0
- package/apps/shared/search/localIndexVFS.ts +32 -1
- package/apps/shared/search/localIndexWorker.ts +648 -186
- package/apps/www/calendar/index.tsx +438 -417
- package/apps/www/contacts/[uid].tsx +21 -2
- package/apps/www/contacts/index.tsx +116 -12
- package/apps/www/index.tsx +1314 -1041
- package/apps/www/messages/[uid].tsx +18 -6
- package/apps/www/settings/auto-reply/index.tsx +134 -129
- package/apps/www/settings/encryption/index.tsx +739 -216
- package/apps/www/settings/filters/[uid].tsx +171 -155
- package/apps/www/settings/filters/new/index.tsx +8 -1
- package/apps/www/settings/focused-inbox/index.tsx +150 -148
- package/apps/www/settings/privacy/index.tsx +494 -436
- package/apps/www/settings/read-receipts/index.tsx +148 -125
- package/apps/www/settings/sharing/index.tsx +17 -14
- package/apps/www/tasks/index.tsx +638 -579
- package/dist/apps/admin/_404.d.ts +2 -0
- package/dist/apps/admin/_500.d.ts +2 -0
- package/dist/apps/admin/_layout.d.ts +8 -0
- package/dist/apps/admin/audit-log/index.d.ts +11 -0
- package/dist/apps/admin/audit-log/index.js +38 -8
- package/dist/apps/admin/branding/index.d.ts +3 -0
- package/dist/apps/admin/data-requests/index.d.ts +3 -0
- package/dist/apps/admin/data-requests/index.js +52 -72
- package/dist/apps/admin/distribution-lists/[uid].d.ts +7 -0
- package/dist/apps/admin/distribution-lists/[uid].js +1 -1
- package/dist/apps/admin/distribution-lists/index.d.ts +3 -0
- package/dist/apps/admin/distribution-lists/new/index.d.ts +3 -0
- package/dist/apps/admin/domains/[uid].d.ts +7 -0
- package/dist/apps/admin/domains/index.d.ts +3 -0
- package/dist/apps/admin/domains/new/index.d.ts +3 -0
- package/dist/apps/admin/encryption-policy/index.d.ts +3 -0
- package/dist/apps/admin/escrow-scopes/[uid].d.ts +21 -0
- package/dist/apps/admin/escrow-scopes/[uid].js +91 -12
- package/dist/apps/admin/escrow-scopes/index.d.ts +3 -0
- package/dist/apps/admin/escrow-scopes/new/index.d.ts +3 -0
- package/dist/apps/admin/escrow-scopes/new/index.js +8 -3
- package/dist/apps/admin/index.d.ts +3 -0
- package/dist/apps/admin/index.js +4 -1
- package/dist/apps/admin/ingest-queue/index.d.ts +4 -0
- package/dist/apps/admin/ingest-queue/index.js +24 -6
- package/dist/apps/admin/mailbox-policy/index.d.ts +3 -0
- package/dist/apps/admin/mailboxes/[uid].d.ts +7 -0
- package/dist/apps/admin/mailboxes/[uid].js +20 -4
- package/dist/apps/admin/mailboxes/new/index.d.ts +3 -0
- package/dist/apps/admin/plugins/index.d.ts +3 -0
- package/dist/apps/admin/quarantine/index.d.ts +6 -0
- package/dist/apps/admin/quarantine/index.js +20 -11
- package/dist/apps/admin/retention-policy/index.d.ts +3 -0
- package/dist/apps/admin/setup/index.d.ts +3 -0
- package/dist/apps/admin/transport-rules/[uid].d.ts +7 -0
- package/dist/apps/admin/transport-rules/[uid].js +18 -2
- package/dist/apps/admin/transport-rules/_transportRuleConfig.d.ts +21 -0
- package/dist/apps/admin/transport-rules/_transportRuleConfig.js +19 -0
- package/dist/apps/admin/transport-rules/index.d.ts +3 -0
- package/dist/apps/admin/transport-rules/index.js +22 -6
- package/dist/apps/admin/transport-rules/new/index.d.ts +3 -0
- package/dist/apps/admin/transport-rules/new/index.js +18 -2
- package/dist/apps/escrow/_layout.d.ts +10 -0
- package/dist/apps/escrow/_layout.js +3 -3
- package/dist/apps/escrow/audit-log/index.d.ts +9 -0
- package/dist/apps/escrow/audit-log/index.js +26 -1
- package/dist/apps/escrow/index.d.ts +3 -0
- package/dist/apps/escrow/matters/[uid].d.ts +7 -0
- package/dist/apps/escrow/matters/[uid].js +77 -42
- package/dist/apps/escrow/matters/new/index.d.ts +3 -0
- package/dist/apps/shared/components/admin/distributionLists/MemberListCard.d.ts +17 -0
- package/dist/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.d.ts +32 -0
- package/dist/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.js +11 -2
- package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +32 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.js +15 -6
- package/dist/apps/shared/components/admin/mailboxes/EscrowScopeCard.d.ts +12 -0
- package/dist/apps/shared/components/admin/mailboxes/EscrowScopeCard.js +72 -0
- package/dist/apps/shared/components/admin/mailboxes/MailboxTable.d.ts +6 -0
- package/dist/apps/shared/components/admin/mailboxes/ResourceSettingsCard.d.ts +19 -0
- package/dist/apps/shared/components/admin/mailboxes/ResourceSettingsCard.js +3 -3
- package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.d.ts +12 -0
- package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.js +22 -4
- package/dist/apps/shared/components/admin/settings/BrandingForm.d.ts +9 -0
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +15 -4
- package/dist/apps/shared/components/admin/settings/DomainDnsSetup.d.ts +12 -0
- package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +13 -7
- package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.d.ts +12 -0
- package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.js +7 -2
- package/dist/apps/shared/components/admin/settings/LoadedSettingsForm.d.ts +9 -0
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.d.ts +19 -0
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +6 -0
- package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.d.ts +10 -0
- package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.js +34 -12
- package/dist/apps/shared/components/admin/settings/PluginsManager.d.ts +4 -0
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +390 -78
- package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.d.ts +9 -0
- package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.js +40 -11
- package/dist/apps/shared/components/admin/setup/EscrowSetupStep.d.ts +14 -0
- package/dist/apps/shared/components/admin/setup/EscrowSetupStep.js +29 -13
- package/dist/apps/shared/components/admin/setup/SetupWizard.d.ts +36 -0
- package/dist/apps/shared/components/admin/setup/SetupWizard.js +87 -21
- package/dist/apps/shared/components/admin/signOut.d.ts +23 -0
- package/dist/apps/shared/components/admin/signOut.js +75 -0
- package/dist/apps/shared/components/admin/usePagedList.d.ts +39 -0
- package/dist/apps/shared/components/admin/usePagedList.js +99 -0
- package/dist/apps/shared/components/calendar/CalendarListSidebar.d.ts +26 -0
- package/dist/apps/shared/components/calendar/EventModal.d.ts +46 -0
- package/dist/apps/shared/components/calendar/EventModal.js +142 -21
- package/dist/apps/shared/components/calendar/MonthView.d.ts +15 -0
- package/dist/apps/shared/components/calendar/MonthView.js +12 -5
- package/dist/apps/shared/components/calendar/RecurrenceEditor.d.ts +20 -0
- package/dist/apps/shared/components/calendar/RecurrenceEditor.js +40 -5
- package/dist/apps/shared/components/calendar/ResourcePicker.d.ts +19 -0
- package/dist/apps/shared/components/calendar/SplitDayView.d.ts +28 -0
- package/dist/apps/shared/components/calendar/SplitDayView.js +10 -4
- package/dist/apps/shared/components/calendar/TimeGridView.d.ts +17 -0
- package/dist/apps/shared/components/calendar/TimeGridView.js +23 -7
- package/dist/apps/shared/components/calendar/allDay.d.ts +51 -0
- package/dist/apps/shared/components/calendar/allDay.js +111 -0
- package/dist/apps/shared/components/calendar/layout/CalendarShell.d.ts +40 -0
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +3 -3
- package/dist/apps/shared/components/contacts/ContactDetailPane.d.ts +23 -0
- package/dist/apps/shared/components/contacts/ContactDetailPane.js +43 -5
- package/dist/apps/shared/components/contacts/ContactForm.d.ts +20 -0
- package/dist/apps/shared/components/contacts/ContactForm.js +32 -10
- package/dist/apps/shared/components/contacts/ContactsSidebar.d.ts +40 -0
- package/dist/apps/shared/components/contacts/ContactsSidebar.js +2 -2
- package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +25 -0
- package/dist/apps/shared/components/contacts/KeyChangeReview.d.ts +40 -0
- package/dist/apps/shared/components/contacts/KeyChangeReview.js +63 -0
- package/dist/apps/shared/components/contacts/contactKeys.d.ts +29 -0
- package/dist/apps/shared/components/contacts/contactKeys.js +64 -0
- package/dist/apps/shared/components/contacts/layout/ContactsShell.d.ts +21 -0
- package/dist/apps/shared/components/contacts/layout/ContactsShell.js +2 -2
- package/dist/apps/shared/components/escrow/layout/EscrowShell.d.ts +25 -0
- package/dist/apps/shared/components/escrow/layout/EscrowShell.js +24 -5
- package/dist/apps/shared/components/forms/StringListField.d.ts +22 -0
- package/dist/apps/shared/components/layout/AppShell.d.ts +49 -0
- package/dist/apps/shared/components/layout/AppShell.js +97 -26
- package/dist/apps/shared/components/layout/BrandingChrome.d.ts +18 -0
- package/dist/apps/shared/components/layout/BrandingChrome.js +45 -10
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.d.ts +51 -0
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +49 -12
- package/dist/apps/shared/components/layout/MailboxProvisioning.d.ts +13 -0
- package/dist/apps/shared/components/layout/MailboxProvisioning.js +10 -2
- package/dist/apps/shared/components/layout/RecoveryCodeUnlock.d.ts +66 -0
- package/dist/apps/shared/components/layout/RecoveryCodeUnlock.js +174 -0
- package/dist/apps/shared/components/layout/UnlockPromptProvider.d.ts +45 -0
- package/dist/apps/shared/components/layout/UnlockPromptProvider.js +73 -14
- package/dist/apps/shared/components/layout/UserMenu.d.ts +23 -0
- package/dist/apps/shared/components/mail/ConversationList.d.ts +11 -0
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +23 -0
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +50 -12
- package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +93 -0
- package/dist/apps/shared/components/mail/MessageDetailPane.js +441 -36
- package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +58 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +9 -6
- package/dist/apps/shared/components/mail/compose/ComposeToolbar.d.ts +15 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +37 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +699 -128
- package/dist/apps/shared/components/mail/compose/EmojiPicker.d.ts +14 -0
- package/dist/apps/shared/components/mail/compose/GifPicker.d.ts +13 -0
- package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +34 -0
- package/dist/apps/shared/components/mail/compose/ScheduleSendPicker.d.ts +16 -0
- package/dist/apps/shared/components/mail/compose/composeFlushRegistry.d.ts +27 -0
- package/dist/apps/shared/components/mail/compose/composeFlushRegistry.js +50 -0
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +57 -0
- package/dist/apps/shared/components/mail/layout/MailShell.js +13 -4
- package/dist/apps/shared/components/mail/pinnedSigners.d.ts +33 -0
- package/dist/apps/shared/components/mail/pinnedSigners.js +98 -0
- package/dist/apps/shared/components/mail/verificationSeals.d.ts +22 -0
- package/dist/apps/shared/components/mail/verificationSeals.js +112 -0
- package/dist/apps/shared/components/mail/writableMailboxes.d.ts +15 -0
- package/dist/apps/shared/components/mail/writableMailboxes.js +87 -0
- package/dist/apps/shared/components/rules/RuleBuilder.d.ts +70 -0
- package/dist/apps/shared/components/rules/RuleBuilder.js +34 -6
- package/dist/apps/shared/components/settings/layout/SettingsShell.d.ts +41 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +19 -9
- package/dist/apps/shared/components/tasks/TasksSidebar.d.ts +41 -0
- package/dist/apps/shared/components/tasks/TasksToolbar.d.ts +14 -0
- package/dist/apps/shared/components/tasks/layout/TasksShell.d.ts +24 -0
- package/dist/apps/shared/components/tasks/layout/TasksShell.js +2 -2
- package/dist/apps/shared/mail/findWellKnownFolderUid.d.ts +5 -0
- package/dist/apps/shared/mail/listAllPages.d.ts +17 -0
- package/dist/apps/shared/mail/listAllPages.js +25 -0
- package/dist/apps/shared/plugins/pluginNav.d.ts +39 -0
- package/dist/apps/shared/plugins/pluginNav.js +33 -0
- package/dist/apps/shared/search/LocalIndexLifecycle.d.ts +13 -0
- package/dist/apps/shared/search/LocalIndexLifecycle.js +58 -54
- package/dist/apps/shared/search/localIndexBlockCipher.d.ts +36 -0
- package/dist/apps/shared/search/localIndexBuilder.d.ts +85 -0
- package/dist/apps/shared/search/localIndexBuilder.js +292 -37
- package/dist/apps/shared/search/localIndexKey.d.ts +4 -0
- package/dist/apps/shared/search/localIndexRpcClient.d.ts +71 -0
- package/dist/apps/shared/search/localIndexRpcClient.js +191 -26
- package/dist/apps/shared/search/localIndexSchema.d.ts +111 -0
- package/dist/apps/shared/search/localIndexSchema.js +12 -6
- package/dist/apps/shared/search/localIndexSizePreference.d.ts +27 -0
- package/dist/apps/shared/search/localIndexStorage.d.ts +28 -0
- package/dist/apps/shared/search/localIndexStorage.js +86 -0
- package/dist/apps/shared/search/localIndexVFS.d.ts +101 -0
- package/dist/apps/shared/search/localIndexVFS.js +68 -40
- package/dist/apps/shared/search/localIndexWorker.d.ts +145 -0
- package/dist/apps/shared/search/localIndexWorker.js +519 -173
- package/dist/apps/shared/search/searchTier2.d.ts +30 -0
- package/dist/apps/www/_404.d.ts +2 -0
- package/dist/apps/www/_500.d.ts +2 -0
- package/dist/apps/www/_layout.d.ts +14 -0
- package/dist/apps/www/calendar/index.d.ts +3 -0
- package/dist/apps/www/calendar/index.js +28 -10
- package/dist/apps/www/contacts/[uid].d.ts +13 -0
- package/dist/apps/www/contacts/[uid].js +13 -2
- package/dist/apps/www/contacts/index.d.ts +3 -0
- package/dist/apps/www/contacts/index.js +80 -10
- package/dist/apps/www/index.d.ts +3 -0
- package/dist/apps/www/index.js +339 -108
- package/dist/apps/www/messages/[uid].d.ts +11 -0
- package/dist/apps/www/messages/[uid].js +18 -6
- package/dist/apps/www/settings/auto-reply/index.d.ts +4 -0
- package/dist/apps/www/settings/auto-reply/index.js +9 -4
- package/dist/apps/www/settings/encryption/index.d.ts +7 -0
- package/dist/apps/www/settings/encryption/index.js +514 -97
- package/dist/apps/www/settings/filters/[uid].d.ts +8 -0
- package/dist/apps/www/settings/filters/[uid].js +22 -7
- package/dist/apps/www/settings/filters/_mailFilterRuleConfig.d.ts +11 -0
- package/dist/apps/www/settings/filters/index.d.ts +4 -0
- package/dist/apps/www/settings/filters/new/index.d.ts +4 -0
- package/dist/apps/www/settings/filters/new/index.js +8 -2
- package/dist/apps/www/settings/focused-inbox/index.d.ts +4 -0
- package/dist/apps/www/settings/focused-inbox/index.js +3 -1
- package/dist/apps/www/settings/labels/index.d.ts +4 -0
- package/dist/apps/www/settings/privacy/index.d.ts +4 -0
- package/dist/apps/www/settings/privacy/index.js +57 -22
- package/dist/apps/www/settings/read-receipts/index.d.ts +4 -0
- package/dist/apps/www/settings/read-receipts/index.js +10 -3
- package/dist/apps/www/settings/sharing/index.d.ts +4 -0
- package/dist/apps/www/settings/sharing/index.js +7 -11
- package/dist/apps/www/settings/signatures/[uid].d.ts +8 -0
- package/dist/apps/www/settings/signatures/index.d.ts +4 -0
- package/dist/apps/www/settings/signatures/new/index.d.ts +4 -0
- package/dist/apps/www/settings/signatures/signatureDefaults.d.ts +10 -0
- package/dist/apps/www/tasks/index.d.ts +3 -0
- package/dist/apps/www/tasks/index.js +50 -10
- package/package.json +3 -3
- package/apps/shared/components/booking/AvailabilityEditor.tsx +0 -118
- package/apps/www/settings/booking-types/[uid].tsx +0 -300
- package/apps/www/settings/booking-types/index.tsx +0 -98
- package/apps/www/settings/booking-types/new/index.tsx +0 -212
- package/dist/apps/shared/components/booking/AvailabilityEditor.js +0 -45
- package/dist/apps/www/settings/booking-types/[uid].js +0 -129
- package/dist/apps/www/settings/booking-types/index.js +0 -29
- package/dist/apps/www/settings/booking-types/new/index.js +0 -86
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
3
|
// SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import React, { FormEvent, useEffect, useState } from "react";
|
|
5
|
+
import React, { FormEvent, useEffect, useRef, useState } from "react";
|
|
6
6
|
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
7
|
import { getRetentionPolicy } from "@rapidmx/react-shared/admin/retentionPolicyApi.js";
|
|
8
8
|
import { getMailboxPolicy } from "@rapidmx/react-shared/admin/mailboxPolicyApi.js";
|
|
9
9
|
import { createDomain, Domain, listDomains } from "@rapidmx/react-shared/admin/domainsApi.js";
|
|
10
|
-
import { completeSetup, getSetupStatus, saveSetupStep } from "@rapidmx/react-shared/admin/setupApi.js";
|
|
10
|
+
import { completeSetup, getSetupStatus, saveSetupStep, SetupStatus } from "@rapidmx/react-shared/admin/setupApi.js";
|
|
11
11
|
import { getBranding } from "@rapidmx/react-shared/branding/brandingApi.js";
|
|
12
12
|
import { EncryptionPolicy, getEncryptionPolicy } from "@rapidmx/react-shared/crypto/keyvaultApi.js";
|
|
13
13
|
import { listMailboxes, Mailbox } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
14
14
|
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
15
15
|
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
16
16
|
import FormField from "@rapidmx/react-shared/components/forms/FormField.js";
|
|
17
|
+
import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
|
|
17
18
|
import BrandingForm from "../settings/BrandingForm.js";
|
|
18
19
|
import DomainDnsSetup from "../settings/DomainDnsSetup.js";
|
|
19
20
|
import EncryptionPolicyForm, { isEncryptionEnabled } from "../settings/EncryptionPolicyForm.js";
|
|
@@ -42,6 +43,10 @@ function isStepId(value: string | undefined): value is SetupStepId {
|
|
|
42
43
|
return SETUP_STEPS.some((step) => step.id === value);
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
function errorMessage(err: unknown, fallback: string): string {
|
|
47
|
+
return err instanceof ApiRequestError ? err.message : fallback;
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
export interface SetupWizardProps {
|
|
46
51
|
userUid: string;
|
|
47
52
|
}
|
|
@@ -53,15 +58,33 @@ export interface SetupWizardProps {
|
|
|
53
58
|
*/
|
|
54
59
|
export default function SetupWizard({ userUid }: SetupWizardProps) {
|
|
55
60
|
const [step, setStep] = useState<SetupStepId | null>(null);
|
|
61
|
+
const [status, setStatus] = useState<SetupStatus | undefined>();
|
|
56
62
|
const [domains, setDomains] = useState<Domain[]>([]);
|
|
63
|
+
const [domainsError, setDomainsError] = useState<string | null>(null);
|
|
57
64
|
const [encryption, setEncryption] = useState<EncryptionPolicy | null>(null);
|
|
58
65
|
const [finishing, setFinishing] = useState(false);
|
|
59
66
|
const [error, setError] = useState<string | null>(null);
|
|
67
|
+
/** Which of the settings step's forms have edits that haven't been saved. */
|
|
68
|
+
const [unsaved, setUnsaved] = useState<Record<string, boolean>>({});
|
|
69
|
+
/** The step the administrator asked to go to while the settings step had unsaved edits. */
|
|
70
|
+
const [leavingTo, setLeavingTo] = useState<SetupStepId | null>(null);
|
|
71
|
+
const [progressFailed, setProgressFailed] = useState(false);
|
|
72
|
+
/** Step saves run one at a time, and only the latest step still waiting is saved. */
|
|
73
|
+
const progress = useRef<{ running: Promise<void> | null; next: SetupStepId | null }>({ running: null, next: null });
|
|
74
|
+
|
|
75
|
+
function loadDomains(): Promise<void> {
|
|
76
|
+
return listDomains({ limit: 25 })
|
|
77
|
+
.then((list) => {
|
|
78
|
+
setDomains(list);
|
|
79
|
+
setDomainsError(null);
|
|
80
|
+
})
|
|
81
|
+
.catch((err) => setDomainsError(errorMessage(err, "Could not load your domains.")));
|
|
82
|
+
}
|
|
60
83
|
|
|
61
84
|
useEffect(() => {
|
|
62
|
-
void Promise.all([getSetupStatus().catch(() => undefined),
|
|
63
|
-
|
|
64
|
-
setStep(isStepId(
|
|
85
|
+
void Promise.all([getSetupStatus().catch(() => undefined), loadDomains()]).then(([loaded]) => {
|
|
86
|
+
setStatus(loaded);
|
|
87
|
+
setStep(isStepId(loaded?.currentStep) ? loaded.currentStep : "plugins");
|
|
65
88
|
});
|
|
66
89
|
}, []);
|
|
67
90
|
|
|
@@ -81,35 +104,95 @@ export default function SetupWizard({ userUid }: SetupWizardProps) {
|
|
|
81
104
|
const current = SETUP_STEPS[index];
|
|
82
105
|
const last = index === SETUP_STEPS.length - 1;
|
|
83
106
|
|
|
107
|
+
/** Records the step the administrator is on. Progress is a convenience for resuming, so a failure is only noted. */
|
|
108
|
+
function saveProgress(next: SetupStepId) {
|
|
109
|
+
const queue = progress.current;
|
|
110
|
+
queue.next = next;
|
|
111
|
+
if (queue.running) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
queue.running = (async () => {
|
|
115
|
+
while (queue.next) {
|
|
116
|
+
const target: SetupStepId = queue.next;
|
|
117
|
+
queue.next = null;
|
|
118
|
+
try {
|
|
119
|
+
await saveSetupStep(target);
|
|
120
|
+
setProgressFailed(false);
|
|
121
|
+
} catch (err) {
|
|
122
|
+
console.warn("Could not save setup progress", err);
|
|
123
|
+
setProgressFailed(true);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
queue.running = null;
|
|
127
|
+
})();
|
|
128
|
+
}
|
|
129
|
+
|
|
84
130
|
function goTo(next: SetupStepId) {
|
|
85
131
|
setError(null);
|
|
132
|
+
setLeavingTo(null);
|
|
133
|
+
setUnsaved({});
|
|
86
134
|
setStep(next);
|
|
87
|
-
|
|
88
|
-
void saveSetupStep(next).catch(() => undefined);
|
|
135
|
+
saveProgress(next);
|
|
89
136
|
window.scrollTo?.(0, 0);
|
|
90
137
|
}
|
|
91
138
|
|
|
139
|
+
/** Goes to `next`, first asking whether to discard any unsaved server settings. */
|
|
140
|
+
function requestGoTo(next: SetupStepId) {
|
|
141
|
+
// Going to the step already shown would clear the unsaved-edit tracking while the forms keep their edits.
|
|
142
|
+
if (next === step) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (step === "settings" && Object.values(unsaved).some(Boolean)) {
|
|
146
|
+
setLeavingTo(next);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
goTo(next);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const trackUnsaved = (form: string) => (dirty: boolean) => setUnsaved((prev) => ({ ...prev, [form]: dirty }));
|
|
153
|
+
|
|
92
154
|
async function finish() {
|
|
93
155
|
setFinishing(true);
|
|
94
156
|
setError(null);
|
|
95
157
|
try {
|
|
158
|
+
// Let a step still being recorded land first, so it can't arrive after setup is marked finished.
|
|
159
|
+
await progress.current.running;
|
|
96
160
|
await completeSetup();
|
|
97
161
|
window.location.href = "/admin";
|
|
98
162
|
} catch (err) {
|
|
99
|
-
setError(err
|
|
163
|
+
setError(errorMessage(err, "Could not finish setup."));
|
|
100
164
|
setFinishing(false);
|
|
101
165
|
}
|
|
102
166
|
}
|
|
103
167
|
|
|
104
|
-
const
|
|
168
|
+
const noDomain: boolean = domains.length === 0;
|
|
169
|
+
const blocked = (step === "domain" || last) && noDomain;
|
|
105
170
|
|
|
106
171
|
return (
|
|
107
172
|
<div className="flex flex-col gap-6">
|
|
108
|
-
<div>
|
|
109
|
-
<
|
|
110
|
-
|
|
173
|
+
<div className="flex items-start justify-between gap-4">
|
|
174
|
+
<div>
|
|
175
|
+
<h1 className="text-xl font-bold uppercase tracking-wide mb-1">Set up your server</h1>
|
|
176
|
+
<p className="text-sm text-text-muted">You can change any of these settings later from the admin console.</p>
|
|
177
|
+
</div>
|
|
178
|
+
{status && !status.required && (
|
|
179
|
+
<a href="/admin" className="text-sm text-primary-dark underline whitespace-nowrap">
|
|
180
|
+
Exit setup
|
|
181
|
+
</a>
|
|
182
|
+
)}
|
|
111
183
|
</div>
|
|
112
184
|
|
|
185
|
+
{domainsError && (
|
|
186
|
+
<Alert>
|
|
187
|
+
<span className="flex flex-wrap items-center gap-2">
|
|
188
|
+
{domainsError}
|
|
189
|
+
<Button type="button" variant="secondary" className="!w-auto !py-1 !px-2 !text-xs" onClick={() => void loadDomains()}>
|
|
190
|
+
Retry
|
|
191
|
+
</Button>
|
|
192
|
+
</span>
|
|
193
|
+
</Alert>
|
|
194
|
+
)}
|
|
195
|
+
|
|
113
196
|
<ol aria-label="Setup steps" className="flex flex-wrap gap-2">
|
|
114
197
|
{SETUP_STEPS.map((s, i) => (
|
|
115
198
|
<li key={s.id}>
|
|
@@ -117,8 +200,8 @@ export default function SetupWizard({ userUid }: SetupWizardProps) {
|
|
|
117
200
|
type="button"
|
|
118
201
|
aria-current={s.id === step ? "step" : undefined}
|
|
119
202
|
// Steps after the domain need somewhere to put mail first.
|
|
120
|
-
disabled={i > 1 &&
|
|
121
|
-
onClick={() =>
|
|
203
|
+
disabled={i > 1 && noDomain}
|
|
204
|
+
onClick={() => requestGoTo(s.id)}
|
|
122
205
|
className={[
|
|
123
206
|
"text-sm py-1.5 px-3 rounded-pill border disabled:opacity-50",
|
|
124
207
|
s.id === step
|
|
@@ -151,6 +234,7 @@ export default function SetupWizard({ userUid }: SetupWizardProps) {
|
|
|
151
234
|
{(policy, onChange) => (
|
|
152
235
|
<EncryptionPolicyForm
|
|
153
236
|
policy={policy}
|
|
237
|
+
onDirtyChange={trackUnsaved("encryption")}
|
|
154
238
|
onChange={(updated) => {
|
|
155
239
|
onChange(updated);
|
|
156
240
|
setEncryption(updated);
|
|
@@ -159,10 +243,10 @@ export default function SetupWizard({ userUid }: SetupWizardProps) {
|
|
|
159
243
|
)}
|
|
160
244
|
</LoadedSettingsForm>
|
|
161
245
|
<LoadedSettingsForm load={getRetentionPolicy} loadErrorMessage="Could not load the retention policy.">
|
|
162
|
-
{(policy, onChange) => <RetentionPolicyForm policy={policy} onChange={onChange} />}
|
|
246
|
+
{(policy, onChange) => <RetentionPolicyForm policy={policy} onChange={onChange} onDirtyChange={trackUnsaved("retention")} />}
|
|
163
247
|
</LoadedSettingsForm>
|
|
164
248
|
<LoadedSettingsForm load={getMailboxPolicy} loadErrorMessage="Could not load the mailbox policy.">
|
|
165
|
-
{(policy, onChange) => <MailboxPolicyForm policy={policy} onChange={onChange} />}
|
|
249
|
+
{(policy, onChange) => <MailboxPolicyForm policy={policy} onChange={onChange} onDirtyChange={trackUnsaved("mailbox")} />}
|
|
166
250
|
</LoadedSettingsForm>
|
|
167
251
|
</div>
|
|
168
252
|
)}
|
|
@@ -173,7 +257,7 @@ export default function SetupWizard({ userUid }: SetupWizardProps) {
|
|
|
173
257
|
turn encryption on.
|
|
174
258
|
</p>
|
|
175
259
|
) : (
|
|
176
|
-
<EscrowSetupStep />
|
|
260
|
+
<EscrowSetupStep adminUid={userUid} />
|
|
177
261
|
))}
|
|
178
262
|
{step === "branding" && (
|
|
179
263
|
<LoadedSettingsForm load={getBranding} loadErrorMessage="Could not load branding.">
|
|
@@ -187,22 +271,37 @@ export default function SetupWizard({ userUid }: SetupWizardProps) {
|
|
|
187
271
|
|
|
188
272
|
<div className="flex items-center gap-3 border-t border-border pt-5">
|
|
189
273
|
{index > 0 && (
|
|
190
|
-
<Button type="button" variant="secondary" className="!w-auto" onClick={() =>
|
|
274
|
+
<Button type="button" variant="secondary" className="!w-auto" onClick={() => requestGoTo(SETUP_STEPS[index - 1].id)}>
|
|
191
275
|
Back
|
|
192
276
|
</Button>
|
|
193
277
|
)}
|
|
194
278
|
<div className="flex-1" />
|
|
195
|
-
{
|
|
279
|
+
{progressFailed && <span className="text-xs text-text-muted">Your place in setup couldn’t be saved.</span>}
|
|
280
|
+
{blocked && <span className="text-sm text-text-muted">{last ? "Add a domain before finishing setup." : "Add a domain to continue."}</span>}
|
|
196
281
|
{last ? (
|
|
197
|
-
<Button type="button" className="!w-auto" loading={finishing} disabled={finishing} onClick={() => void finish()}>
|
|
282
|
+
<Button type="button" className="!w-auto" loading={finishing} disabled={finishing || blocked} onClick={() => void finish()}>
|
|
198
283
|
Finish setup
|
|
199
284
|
</Button>
|
|
200
285
|
) : (
|
|
201
|
-
<Button type="button" className="!w-auto" disabled={blocked} onClick={() =>
|
|
286
|
+
<Button type="button" className="!w-auto" disabled={blocked} onClick={() => requestGoTo(SETUP_STEPS[index + 1].id)}>
|
|
202
287
|
Continue
|
|
203
288
|
</Button>
|
|
204
289
|
)}
|
|
205
290
|
</div>
|
|
291
|
+
|
|
292
|
+
{leavingTo && (
|
|
293
|
+
<Modal open onClose={() => setLeavingTo(null)} title="Discard unsaved changes?">
|
|
294
|
+
<p className="text-sm mb-4">Some server settings on this step have changes that haven’t been saved.</p>
|
|
295
|
+
<div className="flex gap-2 justify-end">
|
|
296
|
+
<Button type="button" variant="secondary" className="!w-auto" onClick={() => setLeavingTo(null)}>
|
|
297
|
+
Keep editing
|
|
298
|
+
</Button>
|
|
299
|
+
<Button type="button" className="!w-auto" onClick={() => goTo(leavingTo)}>
|
|
300
|
+
Discard changes
|
|
301
|
+
</Button>
|
|
302
|
+
</div>
|
|
303
|
+
</Modal>
|
|
304
|
+
)}
|
|
206
305
|
</div>
|
|
207
306
|
);
|
|
208
307
|
}
|
|
@@ -224,7 +323,7 @@ function DomainStep({ domains, onCreated }: { domains: Domain[]; onCreated: (dom
|
|
|
224
323
|
onCreated(await createDomain({ name: name.trim() }));
|
|
225
324
|
setName("");
|
|
226
325
|
} catch (err) {
|
|
227
|
-
setError(err
|
|
326
|
+
setError(errorMessage(err, "Could not add the domain."));
|
|
228
327
|
} finally {
|
|
229
328
|
setSaving(false);
|
|
230
329
|
}
|
|
@@ -260,18 +359,29 @@ function DomainStep({ domains, onCreated }: { domains: Domain[]; onCreated: (dom
|
|
|
260
359
|
|
|
261
360
|
function MailboxesStep({ userUid, domain }: { userUid: string; domain?: string }) {
|
|
262
361
|
const [mailboxes, setMailboxes] = useState<Mailbox[]>([]);
|
|
362
|
+
const [loaded, setLoaded] = useState(false);
|
|
363
|
+
const [error, setError] = useState<string | null>(null);
|
|
263
364
|
const [formKey, setFormKey] = useState(0);
|
|
264
365
|
|
|
265
366
|
useEffect(() => {
|
|
266
367
|
listMailboxes({ limit: 100 })
|
|
267
|
-
.then(
|
|
268
|
-
|
|
368
|
+
.then((list) =>
|
|
369
|
+
// Keep any mailbox created here while the list was loading.
|
|
370
|
+
setMailboxes((prev) => [...list, ...prev.filter((mine) => !list.some((mailbox) => mailbox.uid === mine.uid))]),
|
|
371
|
+
)
|
|
372
|
+
.catch((err) =>
|
|
373
|
+
setError(
|
|
374
|
+
`${errorMessage(err, "Could not load the existing mailboxes.")} Check the Mailboxes page before creating your own, so you don't create it twice.`,
|
|
375
|
+
),
|
|
376
|
+
)
|
|
377
|
+
.finally(() => setLoaded(true));
|
|
269
378
|
}, []);
|
|
270
379
|
|
|
271
380
|
const hasOwn = mailboxes.some((mailbox) => mailbox.ownerUserUid === userUid);
|
|
272
381
|
|
|
273
382
|
return (
|
|
274
383
|
<div className="flex flex-col gap-5 max-w-xl">
|
|
384
|
+
{error && <Alert>{error}</Alert>}
|
|
275
385
|
{mailboxes.length > 0 && (
|
|
276
386
|
<div>
|
|
277
387
|
<h3 className="text-sm font-bold uppercase tracking-wide mb-2">Mailboxes created</h3>
|
|
@@ -285,16 +395,22 @@ function MailboxesStep({ userUid, domain }: { userUid: string; domain?: string }
|
|
|
285
395
|
</ul>
|
|
286
396
|
</div>
|
|
287
397
|
)}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
398
|
+
{!loaded ? (
|
|
399
|
+
<p className="text-sm text-text-muted">Loading…</p>
|
|
400
|
+
) : (
|
|
401
|
+
<>
|
|
402
|
+
<h3 className="text-base font-bold">{hasOwn ? "Add another mailbox" : "Your mailbox"}</h3>
|
|
403
|
+
<MailboxCreateForm
|
|
404
|
+
key={formKey}
|
|
405
|
+
submitLabel="Create mailbox"
|
|
406
|
+
defaults={hasOwn ? { domain } : { localPart: "admin", domain, displayName: "Administrator", ownerUserUid: userUid }}
|
|
407
|
+
onCreated={(mailbox) => {
|
|
408
|
+
setMailboxes((prev) => [...prev, mailbox]);
|
|
409
|
+
setFormKey((k) => k + 1);
|
|
410
|
+
}}
|
|
411
|
+
/>
|
|
412
|
+
</>
|
|
413
|
+
)}
|
|
298
414
|
</div>
|
|
299
415
|
);
|
|
300
416
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import { authApiFetch } from "@rapidmx/react-shared/util/api.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The cross-tab sign-out channel - must stay identical to `SIGN_OUT_CHANNEL` in
|
|
9
|
+
* `apps/shared/search/localIndexRpcClient.ts` (the channel `AppShell` listens on and `destroyAllLocalIndexes()`
|
|
10
|
+
* announces on). Duplicated rather than imported so the admin/escrow consoles don't pull the local-search Worker
|
|
11
|
+
* client into their bundles; `test/apps/admin/_components/signOut.test.ts` fails if the two ever drift apart.
|
|
12
|
+
*/
|
|
13
|
+
export const CONSOLE_SIGN_OUT_CHANNEL = "rapidmx-localsearch";
|
|
14
|
+
|
|
15
|
+
/** How long sign-out waits for auth-server's logout before navigating anyway (same bound as `AppShell`). */
|
|
16
|
+
export const CONSOLE_LOGOUT_TIMEOUT_MS = 3_000;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The local search index's pending-deletions `localStorage` key - must stay identical to `PENDING_DELETIONS_KEY`
|
|
20
|
+
* in `apps/shared/search/localIndexRpcClient.ts`, duplicated for the same bundle reason as the channel above
|
|
21
|
+
* (the test checks it). `"*"` is that module's "every index on this device" entry.
|
|
22
|
+
*/
|
|
23
|
+
export const CONSOLE_PENDING_DELETIONS_KEY = "rapidmx-localsearch-pending-deletions";
|
|
24
|
+
const ALL_LOCAL_INDEXES = "*";
|
|
25
|
+
|
|
26
|
+
/** Records that every local search index on this device must be deleted. The consoles can't delete them
|
|
27
|
+
* themselves (no local-index client here); the next mail page load retries recorded deletions before opening
|
|
28
|
+
* any index. With storage blocked nothing is recorded, and only an open mail tab hearing the broadcast deletes
|
|
29
|
+
* them. */
|
|
30
|
+
function markLocalIndexesForDeletion(): void {
|
|
31
|
+
try {
|
|
32
|
+
localStorage.setItem(CONSOLE_PENDING_DELETIONS_KEY, JSON.stringify([ALL_LOCAL_INDEXES]));
|
|
33
|
+
} catch {
|
|
34
|
+
// See the doc comment.
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Tells every other tab of this origin that the session ended (`{ type: "sign-out" }`, `AppShell`'s message).
|
|
39
|
+
* An open mail tab then destroys its unlocked keys and every local search index on the device, and leaves too.
|
|
40
|
+
* A no-op where BroadcastChannel is unavailable. */
|
|
41
|
+
function broadcastSignOut(): void {
|
|
42
|
+
if (typeof BroadcastChannel === "undefined") {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const channel = new BroadcastChannel(CONSOLE_SIGN_OUT_CHANNEL);
|
|
46
|
+
channel.postMessage({ type: "sign-out" });
|
|
47
|
+
channel.close();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Calls auth-server's logout (`POST ${authServerUrl}/api/auth/logout`, credentials included), bounded by
|
|
51
|
+
* `CONSOLE_LOGOUT_TIMEOUT_MS`. Never rejects - a failure must not keep the user from leaving. */
|
|
52
|
+
async function logOutOfAuthServer(authServerUrl: string | undefined): Promise<void> {
|
|
53
|
+
if (!authServerUrl) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const controller = new AbortController();
|
|
57
|
+
const timer = setTimeout(() => controller.abort(), CONSOLE_LOGOUT_TIMEOUT_MS);
|
|
58
|
+
try {
|
|
59
|
+
await authApiFetch(authServerUrl, "/auth/logout", { method: "POST", signal: controller.signal });
|
|
60
|
+
} catch {
|
|
61
|
+
// Navigate anyway.
|
|
62
|
+
} finally {
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Sign-out for `AdminShell`/`EscrowShell`: announces the sign-out to other tabs, ends the auth-server session
|
|
69
|
+
* (clears the auth cookie and invalidates the refresh token - navigating alone would leave the session valid),
|
|
70
|
+
* then navigates to auth-server (or `/`). Mirrors `AppShell.handleSignOut`, except that the consoles hold no
|
|
71
|
+
* unlocked keys and can't delete local search indexes in their own tab: they record every index for deletion
|
|
72
|
+
* (finished by the next mail page load) and rely on an open mail tab hearing the broadcast to delete them now.
|
|
73
|
+
*/
|
|
74
|
+
export async function signOutOfConsole(authServerUrl: string | undefined): Promise<void> {
|
|
75
|
+
markLocalIndexesForDeletion();
|
|
76
|
+
broadcastSignOut();
|
|
77
|
+
await logOutOfAuthServer(authServerUrl);
|
|
78
|
+
window.location.href = authServerUrl ?? "/";
|
|
79
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { useRef, useState } from "react";
|
|
6
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
8
|
+
|
|
9
|
+
/** Page size for the async-request lists (the server returns them newest first and caps `limit` at 500). */
|
|
10
|
+
export const REQUEST_LIST_PAGE_SIZE = 50;
|
|
11
|
+
|
|
12
|
+
export interface PagedList<T> {
|
|
13
|
+
items: T[];
|
|
14
|
+
/** `true` until the first page has loaded (or failed). */
|
|
15
|
+
loading: boolean;
|
|
16
|
+
loadError: string | null;
|
|
17
|
+
/** Whether the last page fetched was full, so another may follow. */
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
loadingMore: boolean;
|
|
20
|
+
/** Re-fetches from the first page, dropping anything loaded beyond it. */
|
|
21
|
+
reload: () => Promise<void>;
|
|
22
|
+
/** Fetches the next page and appends what's new in it. */
|
|
23
|
+
loadMore: () => Promise<void>;
|
|
24
|
+
/** Replaces one already-loaded item in place (e.g. with an action's response). */
|
|
25
|
+
replaceItem: (item: T) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A newest-first list fetched a page at a time with "Load more". Only the most recently started `reload()`'s
|
|
30
|
+
* responses are applied, so a slow earlier fetch (e.g. the mount fetch racing a reload after a create) can't
|
|
31
|
+
* overwrite a newer list, and a "Load more" that was in flight during a reload is dropped.
|
|
32
|
+
*
|
|
33
|
+
* Paging is by offset, so "Load more" re-reads the previous page alongside the next one and continues after the last
|
|
34
|
+
* row already shown: rows created since shift older rows onto later pages (repeats are skipped), and rows deleted
|
|
35
|
+
* since shift them onto earlier pages (which a plain next-page fetch would silently skip). If that row can't be found
|
|
36
|
+
* in the two pages at all (it was deleted, or more than a page of rows came or went), the list reloads from the start.
|
|
37
|
+
*/
|
|
38
|
+
export function usePagedList<T extends { uid: string }>(
|
|
39
|
+
fetchPage: (params: { limit: number; page: number }) => Promise<T[]>,
|
|
40
|
+
errorMessage: string,
|
|
41
|
+
): PagedList<T> {
|
|
42
|
+
const pageSize = REQUEST_LIST_PAGE_SIZE;
|
|
43
|
+
const [items, setItems] = useState<T[]>([]);
|
|
44
|
+
const [loading, setLoading] = useState(true);
|
|
45
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
46
|
+
const [hasMore, setHasMore] = useState(false);
|
|
47
|
+
const [loadingMore, setLoadingMore] = useState(false);
|
|
48
|
+
const generation = useRef(0);
|
|
49
|
+
const nextPage = useRef(0);
|
|
50
|
+
const loaded = useRef<T[]>(items);
|
|
51
|
+
loaded.current = items;
|
|
52
|
+
|
|
53
|
+
function describe(err: unknown): string {
|
|
54
|
+
return err instanceof ApiRequestError ? err.message : errorMessage;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function reload() {
|
|
58
|
+
const current = ++generation.current;
|
|
59
|
+
try {
|
|
60
|
+
const data = await fetchPage({ limit: pageSize, page: 0 });
|
|
61
|
+
if (current !== generation.current) return;
|
|
62
|
+
setItems(data);
|
|
63
|
+
setHasMore(data.length === pageSize);
|
|
64
|
+
setLoadError(null);
|
|
65
|
+
nextPage.current = 1;
|
|
66
|
+
} catch (err) {
|
|
67
|
+
if (current === generation.current) setLoadError(describe(err));
|
|
68
|
+
} finally {
|
|
69
|
+
if (current === generation.current) setLoading(false);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function loadMore() {
|
|
74
|
+
const current = generation.current;
|
|
75
|
+
const page = nextPage.current;
|
|
76
|
+
setLoadingMore(true);
|
|
77
|
+
try {
|
|
78
|
+
const [previous, data] = await Promise.all([
|
|
79
|
+
fetchPage({ limit: pageSize, page: page - 1 }),
|
|
80
|
+
fetchPage({ limit: pageSize, page }),
|
|
81
|
+
]);
|
|
82
|
+
if (current !== generation.current) return;
|
|
83
|
+
const window: T[] = [...previous, ...data];
|
|
84
|
+
// "Load more" is only offered after a full page, so at least one row is shown.
|
|
85
|
+
const lastShown: string = loaded.current[loaded.current.length - 1].uid;
|
|
86
|
+
const boundary: number = window.map((item) => item.uid).lastIndexOf(lastShown);
|
|
87
|
+
if (boundary === -1) {
|
|
88
|
+
await reload();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const after: T[] = window.slice(boundary + 1);
|
|
92
|
+
setItems((prev) => [...prev, ...after.filter((item) => !prev.some((existing) => existing.uid === item.uid))]);
|
|
93
|
+
setHasMore(data.length === pageSize);
|
|
94
|
+
setLoadError(null);
|
|
95
|
+
nextPage.current = page + 1;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
if (current === generation.current) setLoadError(describe(err));
|
|
98
|
+
} finally {
|
|
99
|
+
setLoadingMore(false);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function replaceItem(item: T) {
|
|
104
|
+
setItems((prev) => prev.map((existing) => (existing.uid === item.uid ? item : existing)));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return { items, loading, loadError, hasMore, loadingMore, reload, loadMore, replaceItem };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The "Load more" button for a `usePagedList()` list - renders nothing once there's nothing more to load. */
|
|
111
|
+
export function LoadMoreButton({ list, label }: { list: Pick<PagedList<unknown>, "hasMore" | "loadingMore" | "loadMore">; label: string }) {
|
|
112
|
+
if (!list.hasMore) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return (
|
|
116
|
+
<div className="mt-3">
|
|
117
|
+
<Button
|
|
118
|
+
type="button"
|
|
119
|
+
variant="secondary"
|
|
120
|
+
className="!w-auto"
|
|
121
|
+
loading={list.loadingMore}
|
|
122
|
+
disabled={list.loadingMore}
|
|
123
|
+
onClick={() => void list.loadMore()}
|
|
124
|
+
>
|
|
125
|
+
{label}
|
|
126
|
+
</Button>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|