@rapidmx/web-client 0.3.1 → 0.5.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/apps/admin/audit-log/index.tsx +35 -8
- package/apps/admin/branding/index.tsx +39 -404
- package/apps/admin/data-requests/index.tsx +480 -485
- package/apps/admin/distribution-lists/[uid].tsx +19 -1
- package/apps/admin/domains/[uid].tsx +92 -259
- package/apps/admin/encryption-policy/index.tsx +19 -0
- package/apps/admin/escrow-scopes/[uid].tsx +348 -237
- package/apps/admin/escrow-scopes/new/index.tsx +8 -2
- package/apps/admin/index.tsx +118 -82
- package/apps/admin/ingest-queue/index.tsx +44 -5
- package/apps/admin/mailbox-policy/index.tsx +19 -0
- package/apps/admin/mailboxes/[uid].tsx +211 -184
- package/apps/admin/mailboxes/new/index.tsx +28 -291
- package/apps/admin/plugins/index.tsx +15 -0
- package/apps/admin/quarantine/index.tsx +46 -14
- package/apps/admin/retention-policy/index.tsx +39 -132
- package/apps/admin/setup/index.tsx +15 -0
- 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 +251 -210
- 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 +385 -0
- package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +187 -0
- package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +112 -0
- package/apps/shared/components/admin/settings/LoadedSettingsForm.tsx +34 -0
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +308 -0
- package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +152 -0
- package/apps/shared/components/admin/settings/PluginsManager.tsx +1235 -0
- package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +174 -0
- package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +290 -0
- package/apps/shared/components/admin/setup/SetupWizard.tsx +416 -0
- package/apps/shared/components/admin/signOut.ts +79 -0
- package/apps/shared/components/admin/usePagedList.tsx +129 -0
- package/apps/shared/components/calendar/CalendarListSidebar.tsx +120 -76
- package/apps/shared/components/calendar/EventModal.tsx +717 -513
- 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 +80 -99
- package/apps/shared/components/contacts/ContactDetailPane.tsx +100 -21
- package/apps/shared/components/contacts/ContactForm.tsx +377 -314
- 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/escrow/layout/EscrowShell.tsx +148 -134
- package/apps/shared/components/layout/AppShell.tsx +270 -169
- package/apps/shared/components/layout/BrandingChrome.tsx +48 -10
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +150 -26
- 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 -0
- package/apps/shared/components/mail/ConversationThreadPane.tsx +216 -181
- package/apps/shared/components/mail/MessageDetailPane.tsx +799 -76
- package/apps/shared/components/mail/compose/ComposeContext.tsx +26 -16
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +1652 -765
- package/apps/shared/components/mail/compose/composeFlushRegistry.ts +60 -0
- package/apps/shared/components/mail/layout/MailShell.tsx +418 -302
- 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 +1 -0
- package/apps/shared/mail/findWellKnownFolderUid.ts +13 -0
- package/apps/shared/mail/listAllPages.ts +39 -0
- package/apps/shared/search/LocalIndexLifecycle.tsx +98 -0
- package/apps/shared/search/localIndexBlockCipher.ts +83 -0
- package/apps/shared/search/localIndexBuilder.ts +481 -0
- package/apps/shared/search/localIndexKey.ts +27 -0
- package/apps/shared/search/localIndexRpcClient.ts +316 -0
- package/apps/shared/search/localIndexSchema.ts +236 -0
- package/apps/shared/search/localIndexSizePreference.ts +88 -0
- package/apps/shared/search/localIndexStorage.ts +98 -0
- package/apps/shared/search/localIndexVFS.ts +266 -0
- package/apps/shared/search/localIndexWorker.ts +926 -0
- package/apps/shared/search/searchTier2.ts +79 -0
- package/apps/shared/search/wa-sqlite-shims.d.ts +44 -0
- package/apps/www/calendar/index.tsx +438 -407
- package/apps/www/contacts/[uid].tsx +21 -2
- package/apps/www/contacts/index.tsx +148 -17
- package/apps/www/index.tsx +1314 -486
- package/apps/www/messages/[uid].tsx +23 -7
- package/apps/www/settings/auto-reply/index.tsx +134 -129
- package/apps/www/settings/booking-types/[uid].tsx +306 -300
- package/apps/www/settings/encryption/index.tsx +800 -215
- 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 +274 -0
- package/apps/www/tasks/index.tsx +638 -530
- package/dist/apps/admin/audit-log/index.js +38 -8
- package/dist/apps/admin/branding/index.js +4 -98
- package/dist/apps/admin/data-requests/index.js +52 -72
- package/dist/apps/admin/distribution-lists/[uid].js +1 -1
- package/dist/apps/admin/domains/[uid].js +5 -68
- package/dist/apps/admin/encryption-policy/index.js +8 -0
- package/dist/apps/admin/escrow-scopes/[uid].js +91 -12
- package/dist/apps/admin/escrow-scopes/new/index.js +8 -3
- package/dist/apps/admin/index.js +17 -1
- package/dist/apps/admin/ingest-queue/index.js +24 -6
- package/dist/apps/admin/mailbox-policy/index.js +8 -0
- package/dist/apps/admin/mailboxes/[uid].js +20 -4
- package/dist/apps/admin/mailboxes/new/index.js +4 -89
- package/dist/apps/admin/plugins/index.js +6 -0
- package/dist/apps/admin/quarantine/index.js +20 -11
- package/dist/apps/admin/retention-policy/index.js +3 -36
- package/dist/apps/admin/setup/index.js +6 -0
- package/dist/apps/admin/transport-rules/[uid].js +18 -2
- package/dist/apps/admin/transport-rules/_transportRuleConfig.js +19 -0
- package/dist/apps/admin/transport-rules/index.js +22 -6
- package/dist/apps/admin/transport-rules/new/index.js +18 -2
- package/dist/apps/escrow/_layout.js +3 -3
- package/dist/apps/escrow/audit-log/index.js +26 -1
- package/dist/apps/escrow/matters/[uid].js +77 -42
- package/dist/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.js +11 -2
- package/dist/apps/shared/components/admin/layout/AdminShell.js +37 -4
- package/dist/apps/shared/components/admin/mailboxes/EscrowScopeCard.js +72 -0
- package/dist/apps/shared/components/admin/mailboxes/ResourceSettingsCard.js +3 -3
- package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.js +22 -4
- package/dist/apps/shared/components/admin/settings/BrandingForm.js +116 -0
- package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +83 -0
- package/dist/apps/shared/components/admin/settings/EncryptionPolicyForm.js +62 -0
- package/dist/apps/shared/components/admin/settings/LoadedSettingsForm.js +25 -0
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +112 -0
- package/dist/apps/shared/components/admin/settings/MailboxPolicyForm.js +74 -0
- package/dist/apps/shared/components/admin/settings/PluginsManager.js +572 -0
- package/dist/apps/shared/components/admin/settings/RetentionPolicyForm.js +73 -0
- package/dist/apps/shared/components/admin/setup/EscrowSetupStep.js +147 -0
- package/dist/apps/shared/components/admin/setup/SetupWizard.js +208 -0
- package/dist/apps/shared/components/admin/signOut.js +75 -0
- package/dist/apps/shared/components/admin/usePagedList.js +99 -0
- package/dist/apps/shared/components/calendar/CalendarListSidebar.js +24 -13
- package/dist/apps/shared/components/calendar/EventModal.js +154 -21
- package/dist/apps/shared/components/calendar/MonthView.js +12 -5
- package/dist/apps/shared/components/calendar/RecurrenceEditor.js +40 -5
- package/dist/apps/shared/components/calendar/SplitDayView.js +10 -4
- package/dist/apps/shared/components/calendar/TimeGridView.js +23 -7
- package/dist/apps/shared/components/calendar/allDay.js +111 -0
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +47 -39
- package/dist/apps/shared/components/contacts/ContactDetailPane.js +43 -5
- package/dist/apps/shared/components/contacts/ContactForm.js +45 -12
- package/dist/apps/shared/components/contacts/ContactsSidebar.js +2 -2
- package/dist/apps/shared/components/contacts/KeyChangeReview.js +63 -0
- package/dist/apps/shared/components/contacts/contactKeys.js +64 -0
- package/dist/apps/shared/components/escrow/layout/EscrowShell.js +24 -5
- package/dist/apps/shared/components/layout/AppShell.js +100 -8
- package/dist/apps/shared/components/layout/BrandingChrome.js +45 -10
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +63 -14
- package/dist/apps/shared/components/layout/MailboxProvisioning.js +10 -2
- package/dist/apps/shared/components/layout/RecoveryCodeUnlock.js +174 -0
- package/dist/apps/shared/components/layout/UnlockPromptProvider.js +136 -0
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +50 -12
- package/dist/apps/shared/components/mail/MessageDetailPane.js +464 -34
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +9 -6
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +807 -116
- package/dist/apps/shared/components/mail/compose/composeFlushRegistry.js +50 -0
- package/dist/apps/shared/components/mail/layout/MailShell.js +116 -41
- package/dist/apps/shared/components/mail/pinnedSigners.js +98 -0
- package/dist/apps/shared/components/mail/verificationSeals.js +112 -0
- package/dist/apps/shared/components/mail/writableMailboxes.js +87 -0
- package/dist/apps/shared/components/rules/RuleBuilder.js +34 -6
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +1 -0
- package/dist/apps/shared/mail/findWellKnownFolderUid.js +12 -0
- package/dist/apps/shared/mail/listAllPages.js +25 -0
- package/dist/apps/shared/search/LocalIndexLifecycle.js +80 -0
- package/dist/apps/shared/search/localIndexBlockCipher.js +63 -0
- package/dist/apps/shared/search/localIndexBuilder.js +408 -0
- package/dist/apps/shared/search/localIndexKey.js +25 -0
- package/dist/apps/shared/search/localIndexRpcClient.js +241 -0
- package/dist/apps/shared/search/localIndexSchema.js +185 -0
- package/dist/apps/shared/search/localIndexSizePreference.js +78 -0
- package/dist/apps/shared/search/localIndexStorage.js +86 -0
- package/dist/apps/shared/search/localIndexVFS.js +258 -0
- package/dist/apps/shared/search/localIndexWorker.js +687 -0
- package/dist/apps/shared/search/searchTier2.js +38 -0
- package/dist/apps/www/calendar/index.js +38 -18
- package/dist/apps/www/contacts/[uid].js +13 -2
- package/dist/apps/www/contacts/index.js +94 -15
- package/dist/apps/www/index.js +770 -137
- package/dist/apps/www/messages/[uid].js +23 -7
- package/dist/apps/www/settings/auto-reply/index.js +9 -4
- package/dist/apps/www/settings/booking-types/[uid].js +17 -12
- package/dist/apps/www/settings/encryption/index.js +541 -96
- package/dist/apps/www/settings/filters/[uid].js +22 -7
- package/dist/apps/www/settings/filters/new/index.js +8 -2
- package/dist/apps/www/settings/focused-inbox/index.js +3 -1
- package/dist/apps/www/settings/privacy/index.js +57 -22
- package/dist/apps/www/settings/read-receipts/index.js +10 -3
- package/dist/apps/www/settings/sharing/index.js +124 -0
- package/dist/apps/www/tasks/index.js +76 -14
- package/package.json +3 -2
|
@@ -0,0 +1,152 @@
|
|
|
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 { EscrowScope, listEscrowScopes } from "@rapidmx/react-shared/admin/escrowScopesApi.js";
|
|
8
|
+
import { Mailbox, updateMailbox } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
9
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
10
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
11
|
+
import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
|
|
12
|
+
|
|
13
|
+
const SELECT_CLASS =
|
|
14
|
+
"text-sm py-2 px-3 border border-border rounded-sm bg-surface text-text focus:outline-none focus:border-primary";
|
|
15
|
+
|
|
16
|
+
/** Enough for any realistic deployment's scopes in one list. */
|
|
17
|
+
const SCOPE_LIST_LIMIT = 200;
|
|
18
|
+
|
|
19
|
+
export interface EscrowScopeCardProps {
|
|
20
|
+
mailbox: Mailbox;
|
|
21
|
+
/** Called with the saved mailbox, same push-up pattern as `ResourceSettingsCard`. */
|
|
22
|
+
onUpdate: (mailbox: Mailbox) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Assigns a mailbox to an escrow scope (or none), which decides whose holders can recover its encrypted mail. Only
|
|
27
|
+
* shown in the admin console, whose trusted-role gate the server enforces again for `escrowScopeId`.
|
|
28
|
+
*/
|
|
29
|
+
export default function EscrowScopeCard({ mailbox, onUpdate }: EscrowScopeCardProps) {
|
|
30
|
+
const [scopes, setScopes] = useState<EscrowScope[] | null>(null);
|
|
31
|
+
const [loadError, setLoadError] = useState<string | null>(null);
|
|
32
|
+
const [escrowScopeId, setEscrowScopeId] = useState(mailbox.escrowScopeId ?? "");
|
|
33
|
+
const [saving, setSaving] = useState(false);
|
|
34
|
+
const [saveError, setSaveError] = useState<string | null>(null);
|
|
35
|
+
const [saved, setSaved] = useState(false);
|
|
36
|
+
const [confirming, setConfirming] = useState(false);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
listEscrowScopes({ limit: SCOPE_LIST_LIMIT })
|
|
40
|
+
.then(setScopes)
|
|
41
|
+
.catch((err) => setLoadError(err instanceof ApiRequestError ? err.message : "Could not load escrow scopes."));
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
// Changing the scope changes who can recover this mailbox's encrypted mail, so it's confirmed first.
|
|
45
|
+
function handleSubmit(e: FormEvent) {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
setConfirming(true);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function save() {
|
|
51
|
+
setConfirming(false);
|
|
52
|
+
setSaveError(null);
|
|
53
|
+
setSaved(false);
|
|
54
|
+
setSaving(true);
|
|
55
|
+
try {
|
|
56
|
+
const updated = await updateMailbox({ uid: mailbox.uid, version: mailbox.version, escrowScopeId: escrowScopeId || null });
|
|
57
|
+
onUpdate(updated);
|
|
58
|
+
setSaved(true);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
setSaveError(err instanceof ApiRequestError ? err.message : "Could not save the escrow scope.");
|
|
61
|
+
} finally {
|
|
62
|
+
setSaving(false);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const current = mailbox.escrowScopeId ?? "";
|
|
67
|
+
const unknownCurrent = !!current && !!scopes && !scopes.some((scope) => scope.uid === current);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div className="bg-surface border border-border rounded-md p-6">
|
|
71
|
+
<h2 className="text-base font-bold uppercase tracking-wide mb-1">Escrow scope</h2>
|
|
72
|
+
<p className="text-sm text-text-muted mb-4">
|
|
73
|
+
The holders of this scope can jointly recover this mailbox’s encrypted mail, for example for legal
|
|
74
|
+
discovery. With no scope, nobody can.
|
|
75
|
+
</p>
|
|
76
|
+
|
|
77
|
+
{loadError && <Alert>{loadError}</Alert>}
|
|
78
|
+
{saveError && <Alert>{saveError}</Alert>}
|
|
79
|
+
{saved && !saveError && <div className="mb-4 text-sm text-success font-medium">Saved.</div>}
|
|
80
|
+
|
|
81
|
+
{scopes && (
|
|
82
|
+
<form onSubmit={handleSubmit} className="flex items-end gap-3 flex-wrap">
|
|
83
|
+
<label className="flex flex-col gap-1.5 text-sm">
|
|
84
|
+
<span className="font-semibold">Scope</span>
|
|
85
|
+
<select
|
|
86
|
+
aria-label="Escrow scope"
|
|
87
|
+
className={SELECT_CLASS}
|
|
88
|
+
value={escrowScopeId}
|
|
89
|
+
onChange={(e) => {
|
|
90
|
+
setEscrowScopeId(e.target.value);
|
|
91
|
+
setSaved(false);
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
<option value="">No escrow</option>
|
|
95
|
+
{unknownCurrent && <option value={current}>Unknown scope ({current})</option>}
|
|
96
|
+
{scopes.map((scope) => (
|
|
97
|
+
<option key={scope.uid} value={scope.uid}>
|
|
98
|
+
{scope.name}
|
|
99
|
+
</option>
|
|
100
|
+
))}
|
|
101
|
+
</select>
|
|
102
|
+
</label>
|
|
103
|
+
<Button type="submit" className="!w-auto" loading={saving} disabled={saving || escrowScopeId === current}>
|
|
104
|
+
Save escrow scope
|
|
105
|
+
</Button>
|
|
106
|
+
</form>
|
|
107
|
+
)}
|
|
108
|
+
|
|
109
|
+
<Modal open={confirming} onClose={() => setConfirming(false)} title="Change escrow scope">
|
|
110
|
+
<p className="text-sm mb-3">
|
|
111
|
+
This changes who can jointly recover <strong className="break-all">{mailbox.primarySmtpAddress}</strong>
|
|
112
|
+
’s encrypted mail.
|
|
113
|
+
</p>
|
|
114
|
+
<dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm mb-4">
|
|
115
|
+
<dt className="text-text-muted">From</dt>
|
|
116
|
+
<dd className="break-all">
|
|
117
|
+
<ScopeSummary uid={current} scopes={scopes ?? []} />
|
|
118
|
+
</dd>
|
|
119
|
+
<dt className="text-text-muted">To</dt>
|
|
120
|
+
<dd className="break-all">
|
|
121
|
+
<ScopeSummary uid={escrowScopeId} scopes={scopes ?? []} />
|
|
122
|
+
</dd>
|
|
123
|
+
</dl>
|
|
124
|
+
<div className="flex gap-3 justify-end">
|
|
125
|
+
<Button type="button" variant="secondary" className="!w-auto" onClick={() => setConfirming(false)}>
|
|
126
|
+
Cancel
|
|
127
|
+
</Button>
|
|
128
|
+
<Button type="button" className="!w-auto" onClick={() => void save()}>
|
|
129
|
+
Confirm and save
|
|
130
|
+
</Button>
|
|
131
|
+
</div>
|
|
132
|
+
</Modal>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** A scope's name, holders and required approvals - or what having no (or an unlisted) scope means. */
|
|
138
|
+
function ScopeSummary({ uid, scopes }: { uid: string; scopes: EscrowScope[] }) {
|
|
139
|
+
if (!uid) {
|
|
140
|
+
return <span>No escrow - nobody can recover this mailbox’s encrypted mail</span>;
|
|
141
|
+
}
|
|
142
|
+
const scope = scopes.find((candidate) => candidate.uid === uid);
|
|
143
|
+
if (!scope) {
|
|
144
|
+
return <span>Unknown scope ({uid})</span>;
|
|
145
|
+
}
|
|
146
|
+
return (
|
|
147
|
+
<span>
|
|
148
|
+
<strong>{scope.name}</strong> - holders {scope.holderUserUids.join(", ")}; {scope.requiredHolders} of{" "}
|
|
149
|
+
{scope.holderUserUids.length} must approve
|
|
150
|
+
</span>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
@@ -51,11 +51,11 @@ export default function ResourceSettingsCard({ mailbox, onUpdate }: ResourceSett
|
|
|
51
51
|
uid: mailbox.uid,
|
|
52
52
|
version: mailbox.version,
|
|
53
53
|
resourceType,
|
|
54
|
-
resourceCapacity: resourceCapacity ? Number(resourceCapacity) :
|
|
54
|
+
resourceCapacity: resourceCapacity ? Number(resourceCapacity) : null,
|
|
55
55
|
autoAcceptBookings,
|
|
56
56
|
allowConflicts,
|
|
57
|
-
bookingWindowDays: bookingWindowDays ? Number(bookingWindowDays) :
|
|
58
|
-
maxDurationMinutes: maxDurationMinutes ? Number(maxDurationMinutes) :
|
|
57
|
+
bookingWindowDays: bookingWindowDays ? Number(bookingWindowDays) : null,
|
|
58
|
+
maxDurationMinutes: maxDurationMinutes ? Number(maxDurationMinutes) : null,
|
|
59
59
|
});
|
|
60
60
|
onUpdate(updated);
|
|
61
61
|
setSaved(true);
|
|
@@ -7,11 +7,14 @@ import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
|
7
7
|
import { AccessControlList, getMailboxAcl, grantMailboxAccess, revokeMailboxAccess } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
8
8
|
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
9
9
|
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
10
|
+
import Modal from "@rapidmx/react-shared/components/overlays/Modal.js";
|
|
10
11
|
|
|
11
12
|
const DEFAULT_DELEGATE_ACTIONS = ["read", "list", "count", "exists"];
|
|
12
13
|
|
|
13
14
|
export interface ShareAccessCardProps {
|
|
14
15
|
mailboxUid: string;
|
|
16
|
+
/** The mailbox's owner - their own grant is shown but can't be revoked from here. */
|
|
17
|
+
ownerUserUid?: string;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
/**
|
|
@@ -19,12 +22,14 @@ export interface ShareAccessCardProps {
|
|
|
19
22
|
* mechanism behind Exchange-style shared mailboxes. `records` on a mailbox's own ACL doubles as both the
|
|
20
23
|
* owner's grant (if any) and every delegate's — see `BaseMailboxRoute`'s doc comment in `@rapidmx/restapi`.
|
|
21
24
|
*/
|
|
22
|
-
export default function ShareAccessCard({ mailboxUid }: ShareAccessCardProps) {
|
|
25
|
+
export default function ShareAccessCard({ mailboxUid, ownerUserUid }: ShareAccessCardProps) {
|
|
23
26
|
const [acl, setAcl] = useState<AccessControlList | null>(null);
|
|
24
27
|
const [loading, setLoading] = useState(true);
|
|
25
28
|
const [error, setError] = useState<string | null>(null);
|
|
29
|
+
const [notice, setNotice] = useState<string | null>(null);
|
|
26
30
|
const [newUserUid, setNewUserUid] = useState("");
|
|
27
31
|
const [saving, setSaving] = useState(false);
|
|
32
|
+
const [revokeTarget, setRevokeTarget] = useState<string | null>(null);
|
|
28
33
|
|
|
29
34
|
function reload() {
|
|
30
35
|
setLoading(true);
|
|
@@ -45,8 +50,19 @@ export default function ShareAccessCard({ mailboxUid }: ShareAccessCardProps) {
|
|
|
45
50
|
}
|
|
46
51
|
setSaving(true);
|
|
47
52
|
setError(null);
|
|
53
|
+
setNotice(null);
|
|
48
54
|
try {
|
|
49
|
-
|
|
55
|
+
// `grantMailboxAccess()` replaces any existing record for this uid, so granting read access to someone
|
|
56
|
+
// who already has more (e.g. the owner) would silently downgrade them. Merge with their current actions.
|
|
57
|
+
const current = await getMailboxAcl(mailboxUid);
|
|
58
|
+
const existing = current.records.find((record) => record.userOrRoleId === userUid)?.actions ?? [];
|
|
59
|
+
const missing = DEFAULT_DELEGATE_ACTIONS.filter((action) => !existing.includes(action));
|
|
60
|
+
if (missing.length === 0) {
|
|
61
|
+
setNotice(`${userUid} already has this access.`);
|
|
62
|
+
setNewUserUid("");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
await grantMailboxAccess(mailboxUid, userUid, [...existing, ...missing]);
|
|
50
66
|
setNewUserUid("");
|
|
51
67
|
reload();
|
|
52
68
|
} catch (err) {
|
|
@@ -56,9 +72,13 @@ export default function ShareAccessCard({ mailboxUid }: ShareAccessCardProps) {
|
|
|
56
72
|
}
|
|
57
73
|
}
|
|
58
74
|
|
|
59
|
-
|
|
75
|
+
// Only ever invoked from the revoke-confirmation modal below, which only renders once `revokeTarget` is set.
|
|
76
|
+
async function handleRevoke() {
|
|
77
|
+
const userOrRoleId = revokeTarget!;
|
|
78
|
+
setRevokeTarget(null);
|
|
60
79
|
setSaving(true);
|
|
61
80
|
setError(null);
|
|
81
|
+
setNotice(null);
|
|
62
82
|
try {
|
|
63
83
|
await revokeMailboxAccess(mailboxUid, userOrRoleId);
|
|
64
84
|
reload();
|
|
@@ -77,6 +97,7 @@ export default function ShareAccessCard({ mailboxUid }: ShareAccessCardProps) {
|
|
|
77
97
|
</p>
|
|
78
98
|
|
|
79
99
|
{error && <Alert>{error}</Alert>}
|
|
100
|
+
{notice && !error && <div className="mb-4 text-sm text-text-muted">{notice}</div>}
|
|
80
101
|
|
|
81
102
|
{loading ? (
|
|
82
103
|
<p className="text-sm text-text-muted">Loading…</p>
|
|
@@ -94,14 +115,18 @@ export default function ShareAccessCard({ mailboxUid }: ShareAccessCardProps) {
|
|
|
94
115
|
<div className="text-sm font-medium">{record.userOrRoleId}</div>
|
|
95
116
|
<div className="text-xs text-text-muted">{record.actions.join(", ")}</div>
|
|
96
117
|
</div>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
{record.userOrRoleId === ownerUserUid ? (
|
|
119
|
+
<span className="text-xs font-bold uppercase tracking-wide text-text-muted">Owner</span>
|
|
120
|
+
) : (
|
|
121
|
+
<button
|
|
122
|
+
type="button"
|
|
123
|
+
onClick={() => setRevokeTarget(record.userOrRoleId)}
|
|
124
|
+
disabled={saving}
|
|
125
|
+
className="text-sm text-danger hover:underline disabled:opacity-55"
|
|
126
|
+
>
|
|
127
|
+
Revoke
|
|
128
|
+
</button>
|
|
129
|
+
)}
|
|
105
130
|
</li>
|
|
106
131
|
))}
|
|
107
132
|
</ul>
|
|
@@ -119,6 +144,25 @@ export default function ShareAccessCard({ mailboxUid }: ShareAccessCardProps) {
|
|
|
119
144
|
Grant
|
|
120
145
|
</Button>
|
|
121
146
|
</form>
|
|
147
|
+
|
|
148
|
+
<Modal open={revokeTarget !== null} onClose={() => setRevokeTarget(null)} title="Revoke access">
|
|
149
|
+
<p className="text-sm mb-5">
|
|
150
|
+
Revoke <strong className="break-all">{revokeTarget}</strong>’s access to this mailbox? They lose it
|
|
151
|
+
immediately.
|
|
152
|
+
</p>
|
|
153
|
+
<div className="flex gap-3 justify-end">
|
|
154
|
+
<Button type="button" variant="secondary" className="!w-auto" onClick={() => setRevokeTarget(null)}>
|
|
155
|
+
Cancel
|
|
156
|
+
</Button>
|
|
157
|
+
<Button
|
|
158
|
+
type="button"
|
|
159
|
+
className="!w-auto !bg-none !bg-danger !border-danger hover:!bg-danger"
|
|
160
|
+
onClick={() => void handleRevoke()}
|
|
161
|
+
>
|
|
162
|
+
Revoke
|
|
163
|
+
</Button>
|
|
164
|
+
</div>
|
|
165
|
+
</Modal>
|
|
122
166
|
</div>
|
|
123
167
|
);
|
|
124
168
|
}
|