@rapidmx/web-client 0.14.1 → 0.16.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 +373 -373
- package/apps/admin/branding/index.tsx +39 -39
- package/apps/admin/data-requests/index.tsx +482 -480
- package/apps/admin/domains/[uid].tsx +164 -163
- package/apps/admin/escrow-scopes/[uid].tsx +348 -348
- package/apps/admin/index.tsx +127 -124
- package/apps/admin/mailboxes/[uid].tsx +269 -224
- package/apps/admin/mailboxes/new/index.tsx +28 -28
- package/apps/admin/plugins/index.tsx +15 -15
- package/apps/admin/retention-policy/index.tsx +39 -39
- package/apps/admin/signing-certificates/index.tsx +343 -343
- package/apps/escrow/audit-log/index.tsx +196 -196
- package/apps/escrow/matters/[uid].tsx +621 -621
- package/apps/shared/appearance/AppearanceForm.tsx +9 -1
- package/apps/shared/auth/adminAccess.ts +99 -99
- package/apps/shared/calendar/bookingPlugin.ts +100 -0
- package/apps/shared/calendar/calendarLiveUpdates.ts +27 -0
- package/apps/shared/components/admin/layout/AdminShell.tsx +378 -346
- package/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.tsx +238 -0
- package/apps/shared/components/admin/mailboxes/EscrowScopeCard.tsx +152 -152
- package/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.tsx +194 -0
- package/apps/shared/components/admin/settings/BrandingForm.tsx +423 -423
- package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +119 -119
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +53 -4
- package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +198 -198
- package/apps/shared/components/admin/settings/PluginsManager.tsx +64 -10
- package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +182 -182
- package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +288 -288
- package/apps/shared/components/admin/setup/SetupWizard.tsx +444 -444
- package/apps/shared/components/admin/usePagedList.tsx +129 -129
- package/apps/shared/components/calendar/AppointmentQuickForm.tsx +327 -0
- package/apps/shared/components/calendar/DescriptionEditor.tsx +274 -0
- package/apps/shared/components/calendar/EventDescriptionView.tsx +70 -0
- package/apps/shared/components/calendar/EventDetails.tsx +401 -0
- package/apps/shared/components/calendar/EventEditor.tsx +635 -0
- package/apps/shared/components/calendar/EventExpandedForm.tsx +210 -0
- package/apps/shared/components/calendar/EventFormParts.tsx +591 -0
- package/apps/shared/components/calendar/EventModal.tsx +206 -946
- package/apps/shared/components/calendar/EventQuickForm.tsx +116 -0
- package/apps/shared/components/calendar/EventShell.tsx +202 -0
- package/apps/shared/components/calendar/FindATime.tsx +379 -0
- package/apps/shared/components/calendar/GuestInput.tsx +100 -0
- package/apps/shared/components/calendar/LazyDescriptionEditor.tsx +70 -0
- package/apps/shared/components/calendar/MonthView.tsx +185 -173
- package/apps/shared/components/calendar/QuickCreateFaces.tsx +87 -0
- package/apps/shared/components/calendar/QuickCreateTabs.tsx +81 -0
- package/apps/shared/components/calendar/QuickFaceFrame.tsx +81 -0
- package/apps/shared/components/calendar/RecurrenceEditor.tsx +227 -222
- package/apps/shared/components/calendar/RequestChangeForm.tsx +240 -0
- package/apps/shared/components/calendar/SplitDayView.tsx +144 -143
- package/apps/shared/components/calendar/TaskQuickForm.tsx +289 -0
- package/apps/shared/components/calendar/TimeGridView.tsx +246 -244
- package/apps/shared/components/calendar/allDay.ts +124 -124
- package/apps/shared/components/calendar/eventDialogFields.ts +86 -0
- package/apps/shared/components/calendar/eventForm.ts +108 -0
- package/apps/shared/components/calendar/eventFormat.ts +210 -0
- package/apps/shared/components/calendar/findTimeGrid.ts +90 -0
- package/apps/shared/components/calendar/layout/CalendarShell.tsx +201 -200
- package/apps/shared/components/calendar/swipeNavigation.ts +14 -0
- package/apps/shared/components/contacts/ContactForm.tsx +383 -383
- package/apps/shared/components/contacts/ContactsSidebar.tsx +1 -1
- package/apps/shared/components/contacts/ContactsToolbar.tsx +103 -98
- package/apps/shared/components/contacts/layout/ContactsShell.tsx +217 -216
- package/apps/shared/components/escrow/layout/EscrowShell.tsx +155 -155
- package/apps/shared/components/layout/AppShell.tsx +480 -480
- package/apps/shared/components/layout/FloatingActionButton.tsx +31 -0
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -398
- package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -168
- package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -315
- package/apps/shared/components/layout/ThemeSwitch.tsx +84 -84
- package/apps/shared/components/layout/UserMenu.tsx +439 -372
- package/apps/shared/components/mail/ConversationList.tsx +323 -271
- package/apps/shared/components/mail/ConversationThreadPane.tsx +130 -5
- package/apps/shared/components/mail/InviteCard.tsx +387 -0
- package/apps/shared/components/mail/MailSelectionBar.tsx +236 -227
- package/apps/shared/components/mail/MessageDetailPane.tsx +1559 -1537
- package/apps/shared/components/mail/SwipeRow.tsx +120 -0
- package/apps/shared/components/mail/compose/ComposeContext.tsx +312 -312
- package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -422
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +1681 -1673
- package/apps/shared/components/mail/compose/RecipientInput.tsx +54 -11
- package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -147
- package/apps/shared/components/mail/compose/composeFlushRegistry.ts +60 -60
- package/apps/shared/components/mail/compose/quotedBody.ts +161 -161
- package/apps/shared/components/mail/invite/InviteRowChip.tsx +104 -0
- package/apps/shared/components/mail/invite/InviteRsvpPopover.tsx +271 -0
- package/apps/shared/components/mail/invite/InviteTimeline.tsx +200 -0
- package/apps/shared/components/mail/invite/ProposeTimeForm.tsx +109 -0
- package/apps/shared/components/mail/invite/inviteFormat.ts +110 -0
- package/apps/shared/components/mail/invite/inviteStore.ts +114 -0
- package/apps/shared/components/mail/layout/FolderBadgeChip.tsx +21 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +546 -490
- package/apps/shared/components/mail/layout/SidebarSection.tsx +66 -0
- package/apps/shared/components/mail/reading/PendingMessageCard.tsx +68 -0
- package/apps/shared/components/mail/verificationSeals.ts +125 -125
- package/apps/shared/components/rules/RuleBuilder.tsx +311 -311
- package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -344
- package/apps/shared/components/settings/layout/SettingsShell.tsx +255 -253
- package/apps/shared/components/tasks/TasksSidebar.tsx +1 -1
- package/apps/shared/components/tasks/layout/TasksShell.tsx +218 -217
- package/apps/shared/gestures/useEnterSlide.ts +54 -0
- package/apps/shared/gestures/useSwipe.ts +114 -0
- package/apps/shared/gestures/useSwipeSlide.ts +113 -0
- package/apps/shared/gestures/useWheelPaging.ts +107 -0
- package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -51
- package/apps/shared/keyboard/ShortcutProvider.tsx +62 -62
- package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -84
- package/apps/shared/keyboard/dispatch.ts +124 -124
- package/apps/shared/keyboard/format.ts +89 -89
- package/apps/shared/keyboard/keymap.ts +114 -114
- package/apps/shared/keyboard/registry.ts +65 -65
- package/apps/shared/keyboard/targets.ts +79 -79
- package/apps/shared/mail/folderCounts.ts +17 -0
- package/apps/shared/mail/folderTree.ts +143 -143
- package/apps/shared/mail/listAllPages.ts +39 -39
- package/apps/shared/mail/newMailNotifications.ts +3 -15
- package/apps/shared/mail/outbox/outgoingReplies.ts +192 -0
- package/apps/shared/mail/outbox/sendJob.ts +19 -1
- package/apps/shared/mail/outbox/sendOutcomes.ts +13 -4
- package/apps/shared/mail/primaryMailbox.ts +71 -0
- package/apps/shared/mail/useCollapsedSections.ts +146 -0
- package/apps/shared/mail/useMailConnection.ts +205 -203
- package/apps/shared/mail/useMailLiveUpdates.ts +277 -277
- package/apps/shared/mail/useMarkMessageRead.ts +47 -47
- package/apps/shared/mail/useNewMailNotifications.ts +2 -2
- package/apps/shared/navigation/AppRouter.tsx +300 -300
- package/apps/shared/navigation/routerContext.tsx +83 -83
- package/apps/shared/notifications/preferences.ts +36 -0
- package/apps/shared/notifications/store.ts +9 -0
- package/apps/shared/search/LocalIndexLifecycle.tsx +114 -114
- package/apps/shared/search/crossMailboxSearch.ts +169 -0
- package/apps/shared/search/localIndexBuilder.ts +481 -481
- package/apps/shared/signing/enrollmentStorage.ts +33 -33
- package/apps/shared/signing/enrollmentTracker.ts +385 -385
- package/apps/shared/signing/enrollmentView.ts +251 -251
- package/apps/shared/signing/useNow.ts +19 -19
- package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -90
- package/apps/shared/styles/app.css +396 -386
- package/apps/www/_routes.ts +1 -0
- package/apps/www/calendar/index.tsx +578 -469
- package/apps/www/contacts/[uid].tsx +109 -109
- package/apps/www/contacts/index.tsx +6 -0
- package/apps/www/index.tsx +2847 -2332
- package/apps/www/messages/[uid].tsx +135 -108
- package/apps/www/settings/auto-reply/index.tsx +133 -133
- package/apps/www/settings/encryption/index.tsx +1287 -1287
- package/apps/www/settings/filters/[uid].tsx +176 -176
- package/apps/www/settings/filters/index.tsx +102 -102
- package/apps/www/settings/filters/new/index.tsx +140 -140
- package/apps/www/settings/labels/index.tsx +204 -204
- package/apps/www/settings/privacy/index.tsx +492 -492
- package/apps/www/settings/profile/index.tsx +248 -0
- package/apps/www/settings/read-receipts/index.tsx +147 -147
- package/apps/www/settings/sharing/index.tsx +256 -256
- package/apps/www/settings/signatures/[uid].tsx +172 -172
- package/apps/www/settings/signatures/index.tsx +88 -88
- package/apps/www/settings/signatures/new/index.tsx +135 -135
- package/apps/www/tasks/index.tsx +649 -649
- package/dist/apps/admin/data-requests/index.js +1 -1
- package/dist/apps/admin/domains/[uid].js +4 -2
- package/dist/apps/admin/index.js +2 -1
- package/dist/apps/admin/mailboxes/[uid].js +12 -2
- package/dist/apps/shared/appearance/AppearanceForm.js +9 -1
- package/dist/apps/shared/calendar/bookingPlugin.d.ts +50 -0
- package/dist/apps/shared/calendar/bookingPlugin.js +57 -0
- package/dist/apps/shared/calendar/calendarLiveUpdates.d.ts +11 -0
- package/dist/apps/shared/calendar/calendarLiveUpdates.js +23 -0
- package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +1 -1
- package/dist/apps/shared/components/admin/layout/AdminShell.js +7 -3
- package/dist/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.d.ts +35 -0
- package/dist/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.js +115 -0
- package/dist/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.d.ts +16 -0
- package/dist/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.js +92 -0
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +3 -3
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +28 -4
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +40 -6
- package/dist/apps/shared/components/calendar/AppointmentQuickForm.d.ts +47 -0
- package/dist/apps/shared/components/calendar/AppointmentQuickForm.js +135 -0
- package/dist/apps/shared/components/calendar/DescriptionEditor.d.ts +26 -0
- package/dist/apps/shared/components/calendar/DescriptionEditor.js +192 -0
- package/dist/apps/shared/components/calendar/EventDescriptionView.d.ts +14 -0
- package/dist/apps/shared/components/calendar/EventDescriptionView.js +39 -0
- package/dist/apps/shared/components/calendar/EventDetails.d.ts +33 -0
- package/dist/apps/shared/components/calendar/EventDetails.js +137 -0
- package/dist/apps/shared/components/calendar/EventEditor.d.ts +59 -0
- package/dist/apps/shared/components/calendar/EventEditor.js +544 -0
- package/dist/apps/shared/components/calendar/EventExpandedForm.d.ts +14 -0
- package/dist/apps/shared/components/calendar/EventExpandedForm.js +44 -0
- package/dist/apps/shared/components/calendar/EventFormParts.d.ts +70 -0
- package/dist/apps/shared/components/calendar/EventFormParts.js +191 -0
- package/dist/apps/shared/components/calendar/EventModal.d.ts +26 -13
- package/dist/apps/shared/components/calendar/EventModal.js +57 -459
- package/dist/apps/shared/components/calendar/EventQuickForm.d.ts +18 -0
- package/dist/apps/shared/components/calendar/EventQuickForm.js +25 -0
- package/dist/apps/shared/components/calendar/EventShell.d.ts +64 -0
- package/dist/apps/shared/components/calendar/EventShell.js +134 -0
- package/dist/apps/shared/components/calendar/FindATime.d.ts +18 -0
- package/dist/apps/shared/components/calendar/FindATime.js +190 -0
- package/dist/apps/shared/components/calendar/GuestInput.d.ts +45 -0
- package/dist/apps/shared/components/calendar/GuestInput.js +30 -0
- package/dist/apps/shared/components/calendar/LazyDescriptionEditor.d.ts +8 -0
- package/dist/apps/shared/components/calendar/LazyDescriptionEditor.js +44 -0
- package/dist/apps/shared/components/calendar/MonthView.d.ts +5 -1
- package/dist/apps/shared/components/calendar/MonthView.js +11 -5
- package/dist/apps/shared/components/calendar/QuickCreateFaces.d.ts +30 -0
- package/dist/apps/shared/components/calendar/QuickCreateFaces.js +44 -0
- package/dist/apps/shared/components/calendar/QuickCreateTabs.d.ts +24 -0
- package/dist/apps/shared/components/calendar/QuickCreateTabs.js +46 -0
- package/dist/apps/shared/components/calendar/QuickFaceFrame.d.ts +25 -0
- package/dist/apps/shared/components/calendar/QuickFaceFrame.js +19 -0
- package/dist/apps/shared/components/calendar/RecurrenceEditor.d.ts +4 -1
- package/dist/apps/shared/components/calendar/RecurrenceEditor.js +2 -2
- package/dist/apps/shared/components/calendar/RequestChangeForm.d.ts +36 -0
- package/dist/apps/shared/components/calendar/RequestChangeForm.js +127 -0
- package/dist/apps/shared/components/calendar/SplitDayView.d.ts +3 -2
- package/dist/apps/shared/components/calendar/SplitDayView.js +3 -2
- package/dist/apps/shared/components/calendar/TaskQuickForm.d.ts +40 -0
- package/dist/apps/shared/components/calendar/TaskQuickForm.js +101 -0
- package/dist/apps/shared/components/calendar/TimeGridView.d.ts +4 -2
- package/dist/apps/shared/components/calendar/TimeGridView.js +3 -2
- package/dist/apps/shared/components/calendar/eventDialogFields.d.ts +28 -0
- package/dist/apps/shared/components/calendar/eventDialogFields.js +59 -0
- package/dist/apps/shared/components/calendar/eventForm.d.ts +98 -0
- package/dist/apps/shared/components/calendar/eventForm.js +1 -0
- package/dist/apps/shared/components/calendar/eventFormat.d.ts +80 -0
- package/dist/apps/shared/components/calendar/eventFormat.js +190 -0
- package/dist/apps/shared/components/calendar/findTimeGrid.d.ts +30 -0
- package/dist/apps/shared/components/calendar/findTimeGrid.js +83 -0
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +3 -2
- package/dist/apps/shared/components/calendar/swipeNavigation.d.ts +9 -0
- package/dist/apps/shared/components/calendar/swipeNavigation.js +8 -0
- package/dist/apps/shared/components/contacts/ContactsSidebar.js +1 -1
- package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +3 -1
- package/dist/apps/shared/components/contacts/ContactsToolbar.js +4 -2
- package/dist/apps/shared/components/contacts/layout/ContactsShell.js +4 -3
- package/dist/apps/shared/components/layout/FloatingActionButton.d.ts +13 -0
- package/dist/apps/shared/components/layout/FloatingActionButton.js +9 -0
- package/dist/apps/shared/components/layout/UserMenu.d.ts +14 -9
- package/dist/apps/shared/components/layout/UserMenu.js +74 -26
- package/dist/apps/shared/components/mail/ConversationList.d.ts +12 -1
- package/dist/apps/shared/components/mail/ConversationList.js +21 -4
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +4 -1
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +127 -22
- package/dist/apps/shared/components/mail/InviteCard.d.ts +20 -0
- package/dist/apps/shared/components/mail/InviteCard.js +150 -0
- package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +6 -1
- package/dist/apps/shared/components/mail/MailSelectionBar.js +3 -3
- package/dist/apps/shared/components/mail/MessageDetailPane.js +13 -2
- package/dist/apps/shared/components/mail/SwipeRow.d.ts +22 -0
- package/dist/apps/shared/components/mail/SwipeRow.js +71 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +16 -7
- package/dist/apps/shared/components/mail/compose/RecipientInput.d.ts +21 -1
- package/dist/apps/shared/components/mail/compose/RecipientInput.js +18 -10
- package/dist/apps/shared/components/mail/invite/InviteRowChip.d.ts +23 -0
- package/dist/apps/shared/components/mail/invite/InviteRowChip.js +46 -0
- package/dist/apps/shared/components/mail/invite/InviteRsvpPopover.d.ts +20 -0
- package/dist/apps/shared/components/mail/invite/InviteRsvpPopover.js +141 -0
- package/dist/apps/shared/components/mail/invite/InviteTimeline.d.ts +27 -0
- package/dist/apps/shared/components/mail/invite/InviteTimeline.js +120 -0
- package/dist/apps/shared/components/mail/invite/ProposeTimeForm.d.ts +17 -0
- package/dist/apps/shared/components/mail/invite/ProposeTimeForm.js +45 -0
- package/dist/apps/shared/components/mail/invite/inviteFormat.d.ts +28 -0
- package/dist/apps/shared/components/mail/invite/inviteFormat.js +94 -0
- package/dist/apps/shared/components/mail/invite/inviteStore.d.ts +28 -0
- package/dist/apps/shared/components/mail/invite/inviteStore.js +95 -0
- package/dist/apps/shared/components/mail/layout/FolderBadgeChip.d.ts +6 -0
- package/dist/apps/shared/components/mail/layout/FolderBadgeChip.js +9 -0
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +10 -0
- package/dist/apps/shared/components/mail/layout/MailShell.js +76 -46
- package/dist/apps/shared/components/mail/layout/SidebarSection.d.ts +23 -0
- package/dist/apps/shared/components/mail/layout/SidebarSection.js +16 -0
- package/dist/apps/shared/components/mail/reading/PendingMessageCard.d.ts +14 -0
- package/dist/apps/shared/components/mail/reading/PendingMessageCard.js +16 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +7 -5
- package/dist/apps/shared/components/tasks/TasksSidebar.js +1 -1
- package/dist/apps/shared/components/tasks/layout/TasksShell.js +4 -3
- package/dist/apps/shared/gestures/useEnterSlide.d.ts +14 -0
- package/dist/apps/shared/gestures/useEnterSlide.js +47 -0
- package/dist/apps/shared/gestures/useSwipe.d.ts +45 -0
- package/dist/apps/shared/gestures/useSwipe.js +90 -0
- package/dist/apps/shared/gestures/useSwipeSlide.d.ts +40 -0
- package/dist/apps/shared/gestures/useSwipeSlide.js +95 -0
- package/dist/apps/shared/gestures/useWheelPaging.d.ts +32 -0
- package/dist/apps/shared/gestures/useWheelPaging.js +85 -0
- package/dist/apps/shared/mail/folderCounts.d.ts +10 -0
- package/dist/apps/shared/mail/folderCounts.js +12 -0
- package/dist/apps/shared/mail/newMailNotifications.d.ts +3 -8
- package/dist/apps/shared/mail/newMailNotifications.js +3 -12
- package/dist/apps/shared/mail/outbox/outgoingReplies.d.ts +80 -0
- package/dist/apps/shared/mail/outbox/outgoingReplies.js +131 -0
- package/dist/apps/shared/mail/outbox/sendJob.d.ts +5 -1
- package/dist/apps/shared/mail/outbox/sendJob.js +14 -1
- package/dist/apps/shared/mail/outbox/sendOutcomes.js +13 -4
- package/dist/apps/shared/mail/primaryMailbox.d.ts +29 -0
- package/dist/apps/shared/mail/primaryMailbox.js +61 -0
- package/dist/apps/shared/mail/useCollapsedSections.d.ts +32 -0
- package/dist/apps/shared/mail/useCollapsedSections.js +110 -0
- package/dist/apps/shared/mail/useMailConnection.js +3 -1
- package/dist/apps/shared/mail/useNewMailNotifications.js +3 -2
- package/dist/apps/shared/notifications/preferences.d.ts +13 -0
- package/dist/apps/shared/notifications/preferences.js +36 -0
- package/dist/apps/shared/notifications/store.d.ts +1 -0
- package/dist/apps/shared/notifications/store.js +7 -23
- package/dist/apps/shared/search/crossMailboxSearch.d.ts +72 -0
- package/dist/apps/shared/search/crossMailboxSearch.js +136 -0
- package/dist/apps/shared/styles/app.css +396 -386
- package/dist/apps/www/_routes.js +1 -0
- package/dist/apps/www/calendar/index.js +78 -7
- package/dist/apps/www/contacts/index.js +3 -1
- package/dist/apps/www/index.js +548 -210
- package/dist/apps/www/messages/[uid].js +13 -5
- package/dist/apps/www/settings/profile/index.d.ts +4 -0
- package/dist/apps/www/settings/profile/index.js +124 -0
- package/package.json +2 -2
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import React, { FormEvent, useEffect, useState } from "react";
|
|
6
|
-
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
-
import { MailboxPolicy, updateMailboxPolicy } from "@rapidmx/react-shared/admin/mailboxPolicyApi.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
|
-
const INPUT_CLASS =
|
|
12
|
-
"w-full text-sm py-2 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
|
|
13
|
-
|
|
14
|
-
const GB = 1_000_000_000;
|
|
15
|
-
|
|
16
|
-
/** Unrounded, so a quota that isn't a whole number of hundredths of a GB (say 4 MB) is shown as it is. */
|
|
17
|
-
function toGb(bytes: number): string {
|
|
18
|
-
return String(bytes / GB);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Whether a quota field's text is not the given number of bytes. */
|
|
22
|
-
function differsFromBytes(text: string, bytes: number): boolean {
|
|
23
|
-
return Math.round(Number(text) * GB) !== bytes;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Puts a field back to the server's config value; nothing is saved until the form is. */
|
|
27
|
-
function ResetToDefault({ label, shown, onClick }: { label: string; shown: boolean; onClick: () => void }) {
|
|
28
|
-
if (!shown) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
return (
|
|
32
|
-
<Button type="button" variant="text" className="!w-auto self-start text-xs -mt-2" onClick={onClick}>
|
|
33
|
-
Reset to server default ({label})
|
|
34
|
-
</Button>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** The form's values as they were loaded or last saved. */
|
|
39
|
-
interface Baseline {
|
|
40
|
-
defaultQuotaGb: string;
|
|
41
|
-
autoProvisionEnabled: boolean;
|
|
42
|
-
autoProvisionQuotaGb: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface MailboxPolicyFormProps {
|
|
46
|
-
policy: MailboxPolicy;
|
|
47
|
-
onChange: (policy: MailboxPolicy) => void;
|
|
48
|
-
/** Told whether the form has edits that haven't been saved. */
|
|
49
|
-
onDirtyChange?: (dirty: boolean) => void;
|
|
50
|
-
/** Set when shown as one section of a page with its own heading (the setup wizard), so the title is a smaller,
|
|
51
|
-
* lower-level heading. */
|
|
52
|
-
embedded?: boolean;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* The mailbox defaults editor, shared by the Mailbox Policy page and the setup wizard. Each field can be reset to what
|
|
57
|
-
* the server's config currently says (`policy.defaults`), which lets an administrator take a newly deployed value
|
|
58
|
-
* without typing it in; the reset fills the field in and is saved with the rest of the form.
|
|
59
|
-
*/
|
|
60
|
-
export default function MailboxPolicyForm({ policy, onChange, onDirtyChange, embedded = false }: MailboxPolicyFormProps) {
|
|
61
|
-
const defaults = policy.defaults;
|
|
62
|
-
const [defaultQuotaGb, setDefaultQuotaGb] = useState(toGb(policy.defaultQuotaBytes));
|
|
63
|
-
const [autoProvisionEnabled, setAutoProvisionEnabled] = useState(policy.autoProvisionEnabled);
|
|
64
|
-
const [autoProvisionQuotaGb, setAutoProvisionQuotaGb] = useState(toGb(policy.autoProvisionQuotaBytes));
|
|
65
|
-
const [error, setError] = useState<string | null>(null);
|
|
66
|
-
const [saving, setSaving] = useState(false);
|
|
67
|
-
const [saved, setSaved] = useState(false);
|
|
68
|
-
|
|
69
|
-
// Edits are unsaved until they match what was loaded or last saved.
|
|
70
|
-
const [baseline, setBaseline] = useState<Baseline>({ defaultQuotaGb, autoProvisionEnabled, autoProvisionQuotaGb });
|
|
71
|
-
const dirty: boolean =
|
|
72
|
-
defaultQuotaGb !== baseline.defaultQuotaGb ||
|
|
73
|
-
autoProvisionEnabled !== baseline.autoProvisionEnabled ||
|
|
74
|
-
autoProvisionQuotaGb !== baseline.autoProvisionQuotaGb;
|
|
75
|
-
useEffect(() => onDirtyChange?.(dirty), [dirty]);
|
|
76
|
-
|
|
77
|
-
async function handleSubmit(e: FormEvent) {
|
|
78
|
-
e.preventDefault();
|
|
79
|
-
setError(null);
|
|
80
|
-
setSaved(false);
|
|
81
|
-
// Only fields the administrator changed are sent, so a quota left alone keeps its exact stored bytes.
|
|
82
|
-
const patch: Partial<MailboxPolicy> = {};
|
|
83
|
-
for (const [field, text, base] of [
|
|
84
|
-
["defaultQuotaBytes", defaultQuotaGb, baseline.defaultQuotaGb],
|
|
85
|
-
["autoProvisionQuotaBytes", autoProvisionQuotaGb, baseline.autoProvisionQuotaGb],
|
|
86
|
-
] as const) {
|
|
87
|
-
if (text === base) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
const bytes: number = Math.round(Number(text) * GB);
|
|
91
|
-
if (!(bytes >= 1)) {
|
|
92
|
-
setError("Quotas must be more than 0 GB.");
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
patch[field] = bytes;
|
|
96
|
-
}
|
|
97
|
-
if (autoProvisionEnabled !== baseline.autoProvisionEnabled) {
|
|
98
|
-
patch.autoProvisionEnabled = autoProvisionEnabled;
|
|
99
|
-
}
|
|
100
|
-
const current: Baseline = { defaultQuotaGb, autoProvisionEnabled, autoProvisionQuotaGb };
|
|
101
|
-
if (Object.keys(patch).length === 0) {
|
|
102
|
-
setSaved(true);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
setSaving(true);
|
|
106
|
-
try {
|
|
107
|
-
const updated = await updateMailboxPolicy(patch);
|
|
108
|
-
onChange(updated);
|
|
109
|
-
setBaseline(current);
|
|
110
|
-
setSaved(true);
|
|
111
|
-
} catch (err) {
|
|
112
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not save the mailbox policy.");
|
|
113
|
-
} finally {
|
|
114
|
-
setSaving(false);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<div className="max-w-xl">
|
|
120
|
-
{embedded ? (
|
|
121
|
-
<h3 className="text-base font-bold uppercase tracking-wide mb-1">Mailboxes</h3>
|
|
122
|
-
) : (
|
|
123
|
-
<h2 className="text-lg font-bold uppercase tracking-wide mb-1">Mailboxes</h2>
|
|
124
|
-
)}
|
|
125
|
-
<p className="text-sm text-text-muted mb-5">Defaults for new mailboxes on this server.</p>
|
|
126
|
-
|
|
127
|
-
{error && <Alert>{error}</Alert>}
|
|
128
|
-
{saved && !error && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
|
|
129
|
-
|
|
130
|
-
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
131
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
132
|
-
<span className="font-semibold">Default quota (GB)</span>
|
|
133
|
-
<input
|
|
134
|
-
aria-label="Default quota (GB)"
|
|
135
|
-
type="number"
|
|
136
|
-
min={0}
|
|
137
|
-
step="any"
|
|
138
|
-
className={INPUT_CLASS}
|
|
139
|
-
value={defaultQuotaGb}
|
|
140
|
-
onChange={(e) => setDefaultQuotaGb(e.target.value)}
|
|
141
|
-
/>
|
|
142
|
-
<span className="text-xs text-text-muted">The storage a mailbox starts with when an administrator creates it.</span>
|
|
143
|
-
</label>
|
|
144
|
-
<ResetToDefault
|
|
145
|
-
label={defaults ? `${toGb(defaults.defaultQuotaBytes)} GB` : ""}
|
|
146
|
-
shown={!!defaults && differsFromBytes(defaultQuotaGb, defaults.defaultQuotaBytes)}
|
|
147
|
-
onClick={() => setDefaultQuotaGb(toGb(defaults!.defaultQuotaBytes))}
|
|
148
|
-
/>
|
|
149
|
-
<label className="flex items-start gap-2 text-sm">
|
|
150
|
-
<input
|
|
151
|
-
type="checkbox"
|
|
152
|
-
className="mt-1"
|
|
153
|
-
checked={autoProvisionEnabled}
|
|
154
|
-
onChange={(e) => setAutoProvisionEnabled(e.target.checked)}
|
|
155
|
-
/>
|
|
156
|
-
<span>
|
|
157
|
-
<span className="font-semibold block">Let people create their own mailbox</span>
|
|
158
|
-
<span className="text-xs text-text-muted">
|
|
159
|
-
Someone who signs in without a mailbox can create one, using their username on one of this
|
|
160
|
-
server’s verified domains.
|
|
161
|
-
</span>
|
|
162
|
-
</span>
|
|
163
|
-
</label>
|
|
164
|
-
<ResetToDefault
|
|
165
|
-
label={defaults?.autoProvisionEnabled ? "on" : "off"}
|
|
166
|
-
shown={!!defaults && autoProvisionEnabled !== defaults.autoProvisionEnabled}
|
|
167
|
-
onClick={() => setAutoProvisionEnabled(defaults!.autoProvisionEnabled)}
|
|
168
|
-
/>
|
|
169
|
-
{autoProvisionEnabled && (
|
|
170
|
-
<>
|
|
171
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
172
|
-
<span className="font-semibold">Quota for self-created mailboxes (GB)</span>
|
|
173
|
-
<input
|
|
174
|
-
aria-label="Quota for self-created mailboxes (GB)"
|
|
175
|
-
type="number"
|
|
176
|
-
min={0}
|
|
177
|
-
step="any"
|
|
178
|
-
className={INPUT_CLASS}
|
|
179
|
-
value={autoProvisionQuotaGb}
|
|
180
|
-
onChange={(e) => setAutoProvisionQuotaGb(e.target.value)}
|
|
181
|
-
/>
|
|
182
|
-
</label>
|
|
183
|
-
<ResetToDefault
|
|
184
|
-
label={defaults ? `${toGb(defaults.autoProvisionQuotaBytes)} GB` : ""}
|
|
185
|
-
shown={!!defaults && differsFromBytes(autoProvisionQuotaGb, defaults.autoProvisionQuotaBytes)}
|
|
186
|
-
onClick={() => setAutoProvisionQuotaGb(toGb(defaults!.autoProvisionQuotaBytes))}
|
|
187
|
-
/>
|
|
188
|
-
</>
|
|
189
|
-
)}
|
|
190
|
-
<div>
|
|
191
|
-
<Button type="submit" loading={saving} disabled={saving} className="!w-auto">
|
|
192
|
-
Save
|
|
193
|
-
</Button>
|
|
194
|
-
</div>
|
|
195
|
-
</form>
|
|
196
|
-
</div>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { FormEvent, useEffect, useState } from "react";
|
|
6
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
7
|
+
import { MailboxPolicy, updateMailboxPolicy } from "@rapidmx/react-shared/admin/mailboxPolicyApi.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
|
+
const INPUT_CLASS =
|
|
12
|
+
"w-full text-sm py-2 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
|
|
13
|
+
|
|
14
|
+
const GB = 1_000_000_000;
|
|
15
|
+
|
|
16
|
+
/** Unrounded, so a quota that isn't a whole number of hundredths of a GB (say 4 MB) is shown as it is. */
|
|
17
|
+
function toGb(bytes: number): string {
|
|
18
|
+
return String(bytes / GB);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Whether a quota field's text is not the given number of bytes. */
|
|
22
|
+
function differsFromBytes(text: string, bytes: number): boolean {
|
|
23
|
+
return Math.round(Number(text) * GB) !== bytes;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Puts a field back to the server's config value; nothing is saved until the form is. */
|
|
27
|
+
function ResetToDefault({ label, shown, onClick }: { label: string; shown: boolean; onClick: () => void }) {
|
|
28
|
+
if (!shown) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return (
|
|
32
|
+
<Button type="button" variant="text" className="!w-auto self-start text-xs -mt-2" onClick={onClick}>
|
|
33
|
+
Reset to server default ({label})
|
|
34
|
+
</Button>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The form's values as they were loaded or last saved. */
|
|
39
|
+
interface Baseline {
|
|
40
|
+
defaultQuotaGb: string;
|
|
41
|
+
autoProvisionEnabled: boolean;
|
|
42
|
+
autoProvisionQuotaGb: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface MailboxPolicyFormProps {
|
|
46
|
+
policy: MailboxPolicy;
|
|
47
|
+
onChange: (policy: MailboxPolicy) => void;
|
|
48
|
+
/** Told whether the form has edits that haven't been saved. */
|
|
49
|
+
onDirtyChange?: (dirty: boolean) => void;
|
|
50
|
+
/** Set when shown as one section of a page with its own heading (the setup wizard), so the title is a smaller,
|
|
51
|
+
* lower-level heading. */
|
|
52
|
+
embedded?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The mailbox defaults editor, shared by the Mailbox Policy page and the setup wizard. Each field can be reset to what
|
|
57
|
+
* the server's config currently says (`policy.defaults`), which lets an administrator take a newly deployed value
|
|
58
|
+
* without typing it in; the reset fills the field in and is saved with the rest of the form.
|
|
59
|
+
*/
|
|
60
|
+
export default function MailboxPolicyForm({ policy, onChange, onDirtyChange, embedded = false }: MailboxPolicyFormProps) {
|
|
61
|
+
const defaults = policy.defaults;
|
|
62
|
+
const [defaultQuotaGb, setDefaultQuotaGb] = useState(toGb(policy.defaultQuotaBytes));
|
|
63
|
+
const [autoProvisionEnabled, setAutoProvisionEnabled] = useState(policy.autoProvisionEnabled);
|
|
64
|
+
const [autoProvisionQuotaGb, setAutoProvisionQuotaGb] = useState(toGb(policy.autoProvisionQuotaBytes));
|
|
65
|
+
const [error, setError] = useState<string | null>(null);
|
|
66
|
+
const [saving, setSaving] = useState(false);
|
|
67
|
+
const [saved, setSaved] = useState(false);
|
|
68
|
+
|
|
69
|
+
// Edits are unsaved until they match what was loaded or last saved.
|
|
70
|
+
const [baseline, setBaseline] = useState<Baseline>({ defaultQuotaGb, autoProvisionEnabled, autoProvisionQuotaGb });
|
|
71
|
+
const dirty: boolean =
|
|
72
|
+
defaultQuotaGb !== baseline.defaultQuotaGb ||
|
|
73
|
+
autoProvisionEnabled !== baseline.autoProvisionEnabled ||
|
|
74
|
+
autoProvisionQuotaGb !== baseline.autoProvisionQuotaGb;
|
|
75
|
+
useEffect(() => onDirtyChange?.(dirty), [dirty]);
|
|
76
|
+
|
|
77
|
+
async function handleSubmit(e: FormEvent) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
setError(null);
|
|
80
|
+
setSaved(false);
|
|
81
|
+
// Only fields the administrator changed are sent, so a quota left alone keeps its exact stored bytes.
|
|
82
|
+
const patch: Partial<MailboxPolicy> = {};
|
|
83
|
+
for (const [field, text, base] of [
|
|
84
|
+
["defaultQuotaBytes", defaultQuotaGb, baseline.defaultQuotaGb],
|
|
85
|
+
["autoProvisionQuotaBytes", autoProvisionQuotaGb, baseline.autoProvisionQuotaGb],
|
|
86
|
+
] as const) {
|
|
87
|
+
if (text === base) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const bytes: number = Math.round(Number(text) * GB);
|
|
91
|
+
if (!(bytes >= 1)) {
|
|
92
|
+
setError("Quotas must be more than 0 GB.");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
patch[field] = bytes;
|
|
96
|
+
}
|
|
97
|
+
if (autoProvisionEnabled !== baseline.autoProvisionEnabled) {
|
|
98
|
+
patch.autoProvisionEnabled = autoProvisionEnabled;
|
|
99
|
+
}
|
|
100
|
+
const current: Baseline = { defaultQuotaGb, autoProvisionEnabled, autoProvisionQuotaGb };
|
|
101
|
+
if (Object.keys(patch).length === 0) {
|
|
102
|
+
setSaved(true);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
setSaving(true);
|
|
106
|
+
try {
|
|
107
|
+
const updated = await updateMailboxPolicy(patch);
|
|
108
|
+
onChange(updated);
|
|
109
|
+
setBaseline(current);
|
|
110
|
+
setSaved(true);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not save the mailbox policy.");
|
|
113
|
+
} finally {
|
|
114
|
+
setSaving(false);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className="max-w-xl">
|
|
120
|
+
{embedded ? (
|
|
121
|
+
<h3 className="text-base font-bold uppercase tracking-wide mb-1">Mailboxes</h3>
|
|
122
|
+
) : (
|
|
123
|
+
<h2 className="text-lg font-bold uppercase tracking-wide mb-1">Mailboxes</h2>
|
|
124
|
+
)}
|
|
125
|
+
<p className="text-sm text-text-muted mb-5">Defaults for new mailboxes on this server.</p>
|
|
126
|
+
|
|
127
|
+
{error && <Alert>{error}</Alert>}
|
|
128
|
+
{saved && !error && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
|
|
129
|
+
|
|
130
|
+
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
131
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
132
|
+
<span className="font-semibold">Default quota (GB)</span>
|
|
133
|
+
<input
|
|
134
|
+
aria-label="Default quota (GB)"
|
|
135
|
+
type="number"
|
|
136
|
+
min={0}
|
|
137
|
+
step="any"
|
|
138
|
+
className={INPUT_CLASS}
|
|
139
|
+
value={defaultQuotaGb}
|
|
140
|
+
onChange={(e) => setDefaultQuotaGb(e.target.value)}
|
|
141
|
+
/>
|
|
142
|
+
<span className="text-xs text-text-muted">The storage a mailbox starts with when an administrator creates it.</span>
|
|
143
|
+
</label>
|
|
144
|
+
<ResetToDefault
|
|
145
|
+
label={defaults ? `${toGb(defaults.defaultQuotaBytes)} GB` : ""}
|
|
146
|
+
shown={!!defaults && differsFromBytes(defaultQuotaGb, defaults.defaultQuotaBytes)}
|
|
147
|
+
onClick={() => setDefaultQuotaGb(toGb(defaults!.defaultQuotaBytes))}
|
|
148
|
+
/>
|
|
149
|
+
<label className="flex items-start gap-2 text-sm">
|
|
150
|
+
<input
|
|
151
|
+
type="checkbox"
|
|
152
|
+
className="mt-1"
|
|
153
|
+
checked={autoProvisionEnabled}
|
|
154
|
+
onChange={(e) => setAutoProvisionEnabled(e.target.checked)}
|
|
155
|
+
/>
|
|
156
|
+
<span>
|
|
157
|
+
<span className="font-semibold block">Let people create their own mailbox</span>
|
|
158
|
+
<span className="text-xs text-text-muted">
|
|
159
|
+
Someone who signs in without a mailbox can create one, using their username on one of this
|
|
160
|
+
server’s verified domains.
|
|
161
|
+
</span>
|
|
162
|
+
</span>
|
|
163
|
+
</label>
|
|
164
|
+
<ResetToDefault
|
|
165
|
+
label={defaults?.autoProvisionEnabled ? "on" : "off"}
|
|
166
|
+
shown={!!defaults && autoProvisionEnabled !== defaults.autoProvisionEnabled}
|
|
167
|
+
onClick={() => setAutoProvisionEnabled(defaults!.autoProvisionEnabled)}
|
|
168
|
+
/>
|
|
169
|
+
{autoProvisionEnabled && (
|
|
170
|
+
<>
|
|
171
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
172
|
+
<span className="font-semibold">Quota for self-created mailboxes (GB)</span>
|
|
173
|
+
<input
|
|
174
|
+
aria-label="Quota for self-created mailboxes (GB)"
|
|
175
|
+
type="number"
|
|
176
|
+
min={0}
|
|
177
|
+
step="any"
|
|
178
|
+
className={INPUT_CLASS}
|
|
179
|
+
value={autoProvisionQuotaGb}
|
|
180
|
+
onChange={(e) => setAutoProvisionQuotaGb(e.target.value)}
|
|
181
|
+
/>
|
|
182
|
+
</label>
|
|
183
|
+
<ResetToDefault
|
|
184
|
+
label={defaults ? `${toGb(defaults.autoProvisionQuotaBytes)} GB` : ""}
|
|
185
|
+
shown={!!defaults && differsFromBytes(autoProvisionQuotaGb, defaults.autoProvisionQuotaBytes)}
|
|
186
|
+
onClick={() => setAutoProvisionQuotaGb(toGb(defaults!.autoProvisionQuotaBytes))}
|
|
187
|
+
/>
|
|
188
|
+
</>
|
|
189
|
+
)}
|
|
190
|
+
<div>
|
|
191
|
+
<Button type="submit" loading={saving} disabled={saving} className="!w-auto">
|
|
192
|
+
Save
|
|
193
|
+
</Button>
|
|
194
|
+
</div>
|
|
195
|
+
</form>
|
|
196
|
+
</div>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
@@ -268,8 +268,9 @@ export default function PluginsManager({ embedded = false }: PluginsManagerProps
|
|
|
268
268
|
void refreshUpdates();
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
/** Runs an action on an installed plugin's
|
|
272
|
-
|
|
271
|
+
/** Runs an action on a plugin's row (an installed plugin's, or an uninstalled one's), which is busy meanwhile, and
|
|
272
|
+
* shows why it failed. */
|
|
273
|
+
async function onRow(plugin: { uid: string }, action: () => Promise<string | null>) {
|
|
273
274
|
setBusy(plugin.uid, true);
|
|
274
275
|
setError(null);
|
|
275
276
|
setRetryEnableUid(null);
|
|
@@ -383,6 +384,20 @@ export default function PluginsManager({ embedded = false }: PluginsManagerProps
|
|
|
383
384
|
return onRow(plugin, () => changeVersion(plugin, packageVersion));
|
|
384
385
|
}
|
|
385
386
|
|
|
387
|
+
/** Installs an uninstalled plugin again, at its latest version - as adding it by name would. */
|
|
388
|
+
function reinstall(purge: PluginPurgeInfo) {
|
|
389
|
+
const displayName: string = purgeName(purge);
|
|
390
|
+
return onRow(purge, async () => {
|
|
391
|
+
let latest: string;
|
|
392
|
+
try {
|
|
393
|
+
latest = (await planPluginChange(purge.name)).plugin.version;
|
|
394
|
+
} catch (err) {
|
|
395
|
+
return errorMessage(err, `Could not install ${displayName}.`);
|
|
396
|
+
}
|
|
397
|
+
return install(purge.name, latest, displayName);
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
|
|
386
401
|
/** Runs the steps of a failed data deletion that failed, again. */
|
|
387
402
|
async function retryPurge(purge: PluginPurgeInfo) {
|
|
388
403
|
setBusy(purge.uid, true);
|
|
@@ -564,7 +579,13 @@ export default function PluginsManager({ embedded = false }: PluginsManagerProps
|
|
|
564
579
|
);
|
|
565
580
|
})}
|
|
566
581
|
{purges.map((purge) => (
|
|
567
|
-
<UninstalledPluginRow
|
|
582
|
+
<UninstalledPluginRow
|
|
583
|
+
key={purge.uid}
|
|
584
|
+
purge={purge}
|
|
585
|
+
busy={busyUids.has(purge.uid)}
|
|
586
|
+
onRetry={() => void retryPurge(purge)}
|
|
587
|
+
onInstall={() => void reinstall(purge)}
|
|
588
|
+
/>
|
|
568
589
|
))}
|
|
569
590
|
</tbody>
|
|
570
591
|
</table>
|
|
@@ -899,7 +920,7 @@ function PluginServers({ plugin, status }: { plugin: Plugin; status: PluginStatu
|
|
|
899
920
|
}
|
|
900
921
|
|
|
901
922
|
/** The row of a plugin that was uninstalled but whose data deletion is still listed: what became of its data. */
|
|
902
|
-
function UninstalledPluginRow({ purge, busy, onRetry }: { purge: PluginPurgeInfo; busy: boolean; onRetry: () => void }) {
|
|
923
|
+
function UninstalledPluginRow({ purge, busy, onRetry, onInstall }: { purge: PluginPurgeInfo; busy: boolean; onRetry: () => void; onInstall: () => void }) {
|
|
903
924
|
const failedSteps = purge.steps.filter((step) => !step.ok);
|
|
904
925
|
return (
|
|
905
926
|
<tr role="row" className={INSTALLED_ROW_CLASS}>
|
|
@@ -940,8 +961,8 @@ function UninstalledPluginRow({ purge, busy, onRetry }: { purge: PluginPurgeInfo
|
|
|
940
961
|
</div>
|
|
941
962
|
</td>
|
|
942
963
|
<td role="cell" className={`${INSTALLED_TD_CLASS} basis-full pt-1 pb-3`}>
|
|
943
|
-
|
|
944
|
-
|
|
964
|
+
<div className="flex gap-2 lg:justify-end">
|
|
965
|
+
{purge.state === "failed" && (
|
|
945
966
|
<Button
|
|
946
967
|
type="button"
|
|
947
968
|
variant="secondary"
|
|
@@ -953,8 +974,20 @@ function UninstalledPluginRow({ purge, busy, onRetry }: { purge: PluginPurgeInfo
|
|
|
953
974
|
>
|
|
954
975
|
Retry
|
|
955
976
|
</Button>
|
|
956
|
-
|
|
957
|
-
|
|
977
|
+
)}
|
|
978
|
+
{/* A plugin can always be installed again. Adding it before its data is deleted cancels the deletion;
|
|
979
|
+
while the deletion is running the server asks to wait until it has finished. */}
|
|
980
|
+
<Button
|
|
981
|
+
type="button"
|
|
982
|
+
variant="secondary"
|
|
983
|
+
className="!w-auto"
|
|
984
|
+
aria-label={`Install ${purgeName(purge)}`}
|
|
985
|
+
disabled={busy || purge.state === "running"}
|
|
986
|
+
onClick={onInstall}
|
|
987
|
+
>
|
|
988
|
+
Install
|
|
989
|
+
</Button>
|
|
990
|
+
</div>
|
|
958
991
|
</td>
|
|
959
992
|
</tr>
|
|
960
993
|
);
|
|
@@ -1266,12 +1299,32 @@ function needsSelection(definition: PluginSettingDefinition, saved: PluginSettin
|
|
|
1266
1299
|
);
|
|
1267
1300
|
}
|
|
1268
1301
|
|
|
1302
|
+
/** What a plugin's setting default writes for the host this console was reached at, like `https://<host>/meet`. */
|
|
1303
|
+
const HOST_PLACEHOLDER = "<host>";
|
|
1304
|
+
|
|
1305
|
+
/**
|
|
1306
|
+
* The value offered for a text setting whose default names the host (`https://<host>/meet`) and that has no real value
|
|
1307
|
+
* saved yet - nothing, an empty value, or the placeholder itself, which an older server stores when it installs the
|
|
1308
|
+
* plugin. It's the default with this console's host filled in, and is only stored once the form is saved.
|
|
1309
|
+
*/
|
|
1310
|
+
function suggestedHost(definition: PluginSettingDefinition, saved: PluginSettingValue | undefined): string | undefined {
|
|
1311
|
+
if (typeof definition.default !== "string" || !definition.default.includes(HOST_PLACEHOLDER) || typeof window === "undefined") {
|
|
1312
|
+
return undefined;
|
|
1313
|
+
}
|
|
1314
|
+
const unset: boolean = saved === undefined || saved === "" || (typeof saved === "string" && saved.includes(HOST_PLACEHOLDER));
|
|
1315
|
+
return unset ? definition.default.split(HOST_PLACEHOLDER).join(window.location.host) : undefined;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1269
1318
|
/** A setting's current form value: its saved value, else its default - or, for a required select with neither, its
|
|
1270
1319
|
* first option. Kept as a string for text inputs. */
|
|
1271
1320
|
function initialValue(definition: PluginSettingDefinition, saved: PluginSettingValue | undefined): PluginSettingValue | "" {
|
|
1272
1321
|
if (needsSelection(definition, saved)) {
|
|
1273
1322
|
return definition.options![0].value;
|
|
1274
1323
|
}
|
|
1324
|
+
const suggestion = suggestedHost(definition, saved);
|
|
1325
|
+
if (suggestion !== undefined) {
|
|
1326
|
+
return suggestion;
|
|
1327
|
+
}
|
|
1275
1328
|
const value = saved ?? definition.default;
|
|
1276
1329
|
if (definition.type === "boolean") {
|
|
1277
1330
|
return value === true;
|
|
@@ -1291,13 +1344,14 @@ function SettingsModal({ plugin, onClose, onSaved }: { plugin: Plugin; onClose:
|
|
|
1291
1344
|
e.preventDefault();
|
|
1292
1345
|
// The server replaces the whole settings object, so every setting is sent. One left alone is sent as it's saved
|
|
1293
1346
|
// - `null` when nothing is, so it keeps following the plugin's default rather than pinning the default shown.
|
|
1294
|
-
// A required select with nothing to fall back on
|
|
1347
|
+
// A required select with nothing to fall back on, and a setting offering this console's host, are sent as the
|
|
1348
|
+
// form shows them.
|
|
1295
1349
|
const settings: Record<string, PluginSettingValue | null> = {};
|
|
1296
1350
|
let changed = false;
|
|
1297
1351
|
for (const definition of definitions) {
|
|
1298
1352
|
const key: string = definition.key;
|
|
1299
1353
|
const value = values[key];
|
|
1300
|
-
if (value === initial.current[key] && !needsSelection(definition, plugin.settings[key])) {
|
|
1354
|
+
if (value === initial.current[key] && !needsSelection(definition, plugin.settings[key]) && suggestedHost(definition, plugin.settings[key]) === undefined) {
|
|
1301
1355
|
settings[key] = plugin.settings[key] ?? null;
|
|
1302
1356
|
continue;
|
|
1303
1357
|
}
|