@rapidmx/web-client 0.11.0 → 0.13.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/domains/[uid].tsx +73 -2
- package/apps/admin/domains/index.tsx +2 -1
- package/apps/admin/domains/new/index.tsx +28 -3
- package/apps/admin/mailboxes/new/index.tsx +3 -3
- package/apps/shared/calendar/calendarReminders.ts +76 -0
- package/apps/shared/calendar/useCalendarReminders.ts +91 -0
- package/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.tsx +4 -4
- package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +68 -14
- package/apps/shared/components/admin/settings/MailboxCreateForm.tsx +65 -16
- package/apps/shared/components/calendar/EventModal.tsx +203 -11
- package/apps/shared/components/layout/AppShell.tsx +3 -0
- package/apps/shared/components/sharing/PrincipalListField.tsx +82 -0
- package/apps/shared/components/sharing/PrincipalPicker.tsx +40 -109
- package/apps/shared/components/sharing/PrincipalResolver.tsx +164 -0
- package/apps/shared/notifications/NotificationCenter.tsx +2 -0
- package/apps/shared/notifications/NotificationHistoryDialog.tsx +1 -0
- package/apps/shared/notifications/store.ts +3 -1
- package/dist/apps/admin/domains/[uid].js +38 -2
- package/dist/apps/admin/domains/index.js +1 -1
- package/dist/apps/admin/domains/new/index.js +13 -4
- package/dist/apps/admin/mailboxes/new/index.js +1 -1
- package/dist/apps/shared/calendar/calendarReminders.d.ts +28 -0
- package/dist/apps/shared/calendar/calendarReminders.js +55 -0
- package/dist/apps/shared/calendar/useCalendarReminders.d.ts +23 -0
- package/dist/apps/shared/calendar/useCalendarReminders.js +79 -0
- package/dist/apps/shared/components/admin/escrowScopes/EscrowScopeKeyAndHoldersFields.js +3 -2
- package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +26 -6
- package/dist/apps/shared/components/admin/settings/MailboxCreateForm.js +18 -7
- package/dist/apps/shared/components/calendar/EventModal.d.ts +10 -0
- package/dist/apps/shared/components/calendar/EventModal.js +156 -12
- package/dist/apps/shared/components/layout/AppShell.js +3 -0
- package/dist/apps/shared/components/sharing/PrincipalListField.d.ts +24 -0
- package/dist/apps/shared/components/sharing/PrincipalListField.js +23 -0
- package/dist/apps/shared/components/sharing/PrincipalPicker.d.ts +8 -6
- package/dist/apps/shared/components/sharing/PrincipalPicker.js +12 -65
- package/dist/apps/shared/components/sharing/PrincipalResolver.d.ts +44 -0
- package/dist/apps/shared/components/sharing/PrincipalResolver.js +92 -0
- package/dist/apps/shared/notifications/NotificationCenter.js +2 -1
- package/dist/apps/shared/notifications/NotificationHistoryDialog.js +1 -0
- package/dist/apps/shared/notifications/store.d.ts +1 -1
- package/dist/apps/shared/notifications/store.js +2 -0
- package/package.json +2 -2
|
@@ -41,6 +41,7 @@ import NotificationHistoryDialog from "../../notifications/NotificationHistoryDi
|
|
|
41
41
|
import { notifySessionExpired, setSignInUrl } from "../../notifications/apiErrors.js";
|
|
42
42
|
import { useUnseenErrorCount } from "../../notifications/useNotifications.js";
|
|
43
43
|
import { useSigningEnrollmentWatcher } from "../../signing/useSigningEnrollmentWatcher.js";
|
|
44
|
+
import { useCalendarReminders } from "../../calendar/useCalendarReminders.js";
|
|
44
45
|
/** How long sign-out waits for auth-server's logout before navigating anyway. */
|
|
45
46
|
export const LOGOUT_TIMEOUT_MS = 3000;
|
|
46
47
|
/**
|
|
@@ -113,6 +114,8 @@ export function AppChrome({ active, userUid, authServerUrl, impersonating, imper
|
|
|
113
114
|
const mail = useMailConnection({ userUid, enabled: inFrame, open: navigate });
|
|
114
115
|
// A signing certificate the user asked for is announced when it is issued (or fails), on whichever page they are - see the hook.
|
|
115
116
|
useSigningEnrollmentWatcher({ userUid, mailboxes: mail.mailboxes, enabled: inFrame });
|
|
117
|
+
// A meeting reminder pops up on whichever page they are - see the hook.
|
|
118
|
+
useCalendarReminders({ userUid, enabled: inFrame });
|
|
116
119
|
useRedirectIfUnauthenticated(userUid, authServerUrl);
|
|
117
120
|
// Any request this app makes that the server answers with a 401 - the session ended - raises one "Your session expired" pop-up with a
|
|
118
121
|
// Sign in action (see `notifySessionExpired()`), whichever request noticed first, a background refresh included.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ResolvedPrincipal } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
|
|
3
|
+
export interface PrincipalListFieldProps {
|
|
4
|
+
label: string;
|
|
5
|
+
values: string[];
|
|
6
|
+
onChange: (values: string[]) => void;
|
|
7
|
+
/** Exact-match resolve call for what's typed - see `PrincipalResolver`. */
|
|
8
|
+
resolve: (principal: string) => Promise<ResolvedPrincipal>;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
emptyMessage?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A list-of-user-uids editor - the same visual list/per-item-remove shape `StringListField` established, but a
|
|
15
|
+
* uid can only be ADDED by looking it up and confirming who it is first (`PrincipalResolver`), never typed
|
|
16
|
+
* directly. Unlike `StringListField`'s free-text values (a distribution list's member addresses, a legal hold's
|
|
17
|
+
* custodian MAILBOX uids - values nobody needs to be "looked up" as a person for), every value here is a PERSON's
|
|
18
|
+
* user uid, granted a real role purely by what gets typed here - the exact "raw uid text field with no way to see
|
|
19
|
+
* whose it is" gap this app closes everywhere else a person is assigned by identifier.
|
|
20
|
+
*
|
|
21
|
+
* An already-added uid is still shown as plain text (same as `StringListField`, and as `ShareAccessCard`'s own
|
|
22
|
+
* member list) - it was already resolved and confirmed when it was added, so there is nothing left to look up.
|
|
23
|
+
*/
|
|
24
|
+
export default function PrincipalListField({ label, values, onChange, resolve, placeholder, emptyMessage, disabled }: PrincipalListFieldProps): React.JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import PrincipalResolver, { describePerson } from "./PrincipalResolver.js";
|
|
3
|
+
/**
|
|
4
|
+
* A list-of-user-uids editor - the same visual list/per-item-remove shape `StringListField` established, but a
|
|
5
|
+
* uid can only be ADDED by looking it up and confirming who it is first (`PrincipalResolver`), never typed
|
|
6
|
+
* directly. Unlike `StringListField`'s free-text values (a distribution list's member addresses, a legal hold's
|
|
7
|
+
* custodian MAILBOX uids - values nobody needs to be "looked up" as a person for), every value here is a PERSON's
|
|
8
|
+
* user uid, granted a real role purely by what gets typed here - the exact "raw uid text field with no way to see
|
|
9
|
+
* whose it is" gap this app closes everywhere else a person is assigned by identifier.
|
|
10
|
+
*
|
|
11
|
+
* An already-added uid is still shown as plain text (same as `StringListField`, and as `ShareAccessCard`'s own
|
|
12
|
+
* member list) - it was already resolved and confirmed when it was added, so there is nothing left to look up.
|
|
13
|
+
*/
|
|
14
|
+
export default function PrincipalListField({ label, values, onChange, resolve, placeholder, emptyMessage = "None added yet.", disabled }) {
|
|
15
|
+
function handleRemove(uid) {
|
|
16
|
+
onChange(values.filter((v) => v !== uid));
|
|
17
|
+
}
|
|
18
|
+
return (_jsxs("div", { className: "mb-4", children: [_jsx("span", { className: "block text-sm font-semibold mb-1.5 text-text", children: label }), _jsxs("ul", { className: "flex flex-col gap-2 mb-2", children: [values.length === 0 && (_jsx("li", { className: "text-sm text-text-muted", children: emptyMessage }, "empty")), values.map((uid) => (_jsxs("li", { className: "flex items-center justify-between gap-3 py-2 px-3 border border-border rounded-sm", children: [_jsx("span", { className: "text-sm font-medium break-all", children: uid }), _jsx("button", { type: "button", onClick: () => handleRemove(uid), disabled: disabled, className: "text-sm text-danger hover:underline disabled:opacity-55 shrink-0", children: "Remove" })] }, uid)))] }), !disabled && (_jsx(PrincipalResolver, { resolve: resolve, onResolved: (person) => {
|
|
19
|
+
if (!values.includes(person.userUid)) {
|
|
20
|
+
onChange([...values, person.userUid]);
|
|
21
|
+
}
|
|
22
|
+
}, placeholder: placeholder ?? "Email address, username or user id", ariaLabel: label, confirmLabel: "Add", confirmErrorMessage: "Could not add this person.", describeConfirm: (person) => (_jsxs(_Fragment, { children: ["Add ", _jsx("strong", { className: "break-all", children: describePerson(person) }), "?"] })) }))] }));
|
|
23
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MailboxAccessRole, ResolvedPrincipal } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
|
|
3
|
+
import { describePerson } from "./PrincipalResolver.js";
|
|
4
|
+
export { describePerson };
|
|
3
5
|
export interface PrincipalPickerProps {
|
|
4
6
|
mailboxUid: string;
|
|
5
7
|
/** What each access level is called on this page. */
|
|
@@ -15,12 +17,12 @@ export interface PrincipalPickerProps {
|
|
|
15
17
|
/** Shown as a Cancel button next to the box when set (replacing an entry). */
|
|
16
18
|
onCancel?: () => void;
|
|
17
19
|
}
|
|
18
|
-
/** Who a resolved person is, for a person to check before saving: their name and address, else their uid. */
|
|
19
|
-
export declare function describePerson(person: ResolvedPrincipal): string;
|
|
20
20
|
/**
|
|
21
|
-
* "Who?" for a sharing screen
|
|
22
|
-
*
|
|
23
|
-
* is
|
|
24
|
-
*
|
|
21
|
+
* "Who?" for a sharing screen - a thin wrapper around the general `PrincipalResolver`, supplying mailbox sharing's
|
|
22
|
+
* own resolve call (`resolveMailboxPrincipal()`), its role selector, and its grant action (`setMailboxAccess()`).
|
|
23
|
+
* What is typed - a mailbox address, an auth-server username or e-mail alias, or a user id - is RESOLVED by the
|
|
24
|
+
* server before anything is saved, and the person is shown (name and address) for the caller to confirm; only then
|
|
25
|
+
* is the grant made, against that person's uid. Free text is never stored: an ACL record matches a user uid and
|
|
26
|
+
* nothing else, so a grant to a typed username applies to nobody.
|
|
25
27
|
*/
|
|
26
28
|
export default function PrincipalPicker({ mailboxUid, roleLabels, initialPrincipal, defaultRole, placeholder, onGranted, onCancel }: PrincipalPickerProps): React.JSX.Element;
|
|
@@ -1,77 +1,24 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
///////////////////////////////////////////////////////////////////////////////
|
|
3
3
|
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
4
4
|
// SPDX-License-Identifier: MPL-2.0
|
|
5
5
|
///////////////////////////////////////////////////////////////////////////////
|
|
6
|
-
import {
|
|
7
|
-
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
6
|
+
import { useState } from "react";
|
|
8
7
|
import { resolveMailboxPrincipal, setMailboxAccess, } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
/** Who a resolved person is, for a person to check before saving: their name and address, else their uid. */
|
|
12
|
-
export function describePerson(person) {
|
|
13
|
-
if (person.displayName && person.address)
|
|
14
|
-
return `${person.displayName} <${person.address}>`;
|
|
15
|
-
return person.displayName ?? person.address ?? `user ${person.userUid}`;
|
|
16
|
-
}
|
|
8
|
+
import PrincipalResolver, { describePerson } from "./PrincipalResolver.js";
|
|
9
|
+
export { describePerson };
|
|
17
10
|
/**
|
|
18
|
-
* "Who?" for a sharing screen
|
|
19
|
-
*
|
|
20
|
-
* is
|
|
21
|
-
*
|
|
11
|
+
* "Who?" for a sharing screen - a thin wrapper around the general `PrincipalResolver`, supplying mailbox sharing's
|
|
12
|
+
* own resolve call (`resolveMailboxPrincipal()`), its role selector, and its grant action (`setMailboxAccess()`).
|
|
13
|
+
* What is typed - a mailbox address, an auth-server username or e-mail alias, or a user id - is RESOLVED by the
|
|
14
|
+
* server before anything is saved, and the person is shown (name and address) for the caller to confirm; only then
|
|
15
|
+
* is the grant made, against that person's uid. Free text is never stored: an ACL record matches a user uid and
|
|
16
|
+
* nothing else, so a grant to a typed username applies to nobody.
|
|
22
17
|
*/
|
|
23
18
|
export default function PrincipalPicker({ mailboxUid, roleLabels, initialPrincipal, defaultRole = "viewer", placeholder, onGranted, onCancel }) {
|
|
24
|
-
const [typed, setTyped] = useState(initialPrincipal ?? "");
|
|
25
19
|
const [role, setRole] = useState(defaultRole);
|
|
26
|
-
|
|
27
|
-
const [busy, setBusy] = useState(false);
|
|
28
|
-
const [error, setError] = useState(null);
|
|
29
|
-
// A stored entry being replaced is looked up straight away, so its person is shown without a click.
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (initialPrincipal) {
|
|
32
|
-
void find(initialPrincipal);
|
|
33
|
-
}
|
|
34
|
-
}, [initialPrincipal]);
|
|
35
|
-
async function find(principal) {
|
|
36
|
-
setBusy(true);
|
|
37
|
-
setError(null);
|
|
38
|
-
setPerson(null);
|
|
39
|
-
try {
|
|
40
|
-
setPerson(await resolveMailboxPrincipal(mailboxUid, principal));
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not look that person up.");
|
|
44
|
-
}
|
|
45
|
-
finally {
|
|
46
|
-
setBusy(false);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function handleFind(e) {
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
const principal = typed.trim();
|
|
52
|
-
if (principal) {
|
|
53
|
-
void find(principal);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Only reachable from the confirm button, which only renders once `person` is set.
|
|
57
|
-
async function handleGrant() {
|
|
58
|
-
setBusy(true);
|
|
59
|
-
setError(null);
|
|
60
|
-
try {
|
|
20
|
+
return (_jsx(PrincipalResolver, { resolve: (principal) => resolveMailboxPrincipal(mailboxUid, principal), onResolved: async (person) => {
|
|
61
21
|
await setMailboxAccess(mailboxUid, person.userUid, role);
|
|
62
22
|
await onGranted(person, role);
|
|
63
|
-
|
|
64
|
-
setPerson(null);
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
setError(err instanceof ApiRequestError ? err.message : "Could not grant access.");
|
|
68
|
-
}
|
|
69
|
-
finally {
|
|
70
|
-
setBusy(false);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return (_jsxs("div", { className: "flex flex-col gap-2", children: [error && _jsx(Alert, { children: error }), _jsxs("form", { onSubmit: handleFind, className: "flex gap-2", children: [_jsx("input", { type: "text", "aria-label": "Who to share with", placeholder: placeholder ?? "Email address, username or user id", className: "flex-1 text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text", value: typed, onChange: (e) => {
|
|
74
|
-
setTyped(e.target.value);
|
|
75
|
-
setPerson(null);
|
|
76
|
-
}, disabled: busy }), _jsx("select", { "aria-label": "Access level", className: "text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text", value: role, onChange: (e) => setRole(e.target.value), disabled: busy, children: Object.keys(roleLabels).map((value) => (_jsx("option", { value: value, children: roleLabels[value] }, value))) }), _jsx(Button, { type: "submit", variant: "secondary", loading: busy && !person, disabled: busy, className: "!w-auto", children: "Find" }), onCancel && (_jsx(Button, { type: "button", variant: "text", className: "!w-auto", onClick: onCancel, children: "Cancel" }))] }), person && (_jsxs("div", { className: "flex items-center justify-between gap-3 text-sm py-2 px-3 border border-border rounded-sm", children: [_jsxs("span", { children: ["Share with ", _jsx("strong", { className: "break-all", children: describePerson(person) }), " as ", _jsx("em", { children: roleLabels[role] }), "?"] }), _jsx(Button, { type: "button", loading: busy, disabled: busy, className: "!w-auto", onClick: () => void handleGrant(), children: "Grant" })] }))] }));
|
|
23
|
+
}, initialPrincipal: initialPrincipal, placeholder: placeholder ?? "Email address, username or user id", ariaLabel: "Who to share with", confirmLabel: "Grant", confirmErrorMessage: "Could not grant access.", describeConfirm: (person) => (_jsxs(_Fragment, { children: ["Share with ", _jsx("strong", { className: "break-all", children: describePerson(person) }), " as ", _jsx("em", { children: roleLabels[role] }), "?"] })), onCancel: onCancel, children: _jsx("select", { "aria-label": "Access level", className: "text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text", value: role, onChange: (e) => setRole(e.target.value), children: Object.keys(roleLabels).map((value) => (_jsx("option", { value: value, children: roleLabels[value] }, value))) }) }));
|
|
77
24
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { ResolvedPrincipal } from "@rapidmx/react-shared/mail/mailboxAccessApi.js";
|
|
3
|
+
export interface PrincipalResolverProps {
|
|
4
|
+
/** Resolves what was typed - a mailbox address, an auth-server username or e-mail alias, or a user uid - to
|
|
5
|
+
* the one person it names, exact match only. Rejects (typically with an `ApiRequestError`) for nobody. */
|
|
6
|
+
resolve: (principal: string) => Promise<ResolvedPrincipal>;
|
|
7
|
+
/** Called once the caller confirms the resolved person is the right one. The box is cleared once this
|
|
8
|
+
* resolves - throw (or reject) to keep the person on screen and show an error instead. */
|
|
9
|
+
onResolved: (person: ResolvedPrincipal) => void | Promise<void>;
|
|
10
|
+
/** Text put in the box to start with - a stored entry being replaced, say - looked up automatically on mount. */
|
|
11
|
+
initialPrincipal?: string;
|
|
12
|
+
/** What the box asks for. */
|
|
13
|
+
placeholder: string;
|
|
14
|
+
/** The box's accessible name. */
|
|
15
|
+
ariaLabel: string;
|
|
16
|
+
/** Extra controls rendered between the text box and the Find button (e.g. a role selector). */
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
/** The confirm button's label (e.g. "Grant", "Use this owner"). */
|
|
19
|
+
confirmLabel: string;
|
|
20
|
+
/** What the confirmation row says once a person is found - e.g. "Share with X as Y?". */
|
|
21
|
+
describeConfirm: (person: ResolvedPrincipal) => ReactNode;
|
|
22
|
+
/** Shown if `onResolved` rejects, unless it was an `ApiRequestError` (then its own message is shown). */
|
|
23
|
+
confirmErrorMessage: string;
|
|
24
|
+
/** Shown as a Cancel button next to the box when set (replacing an entry). */
|
|
25
|
+
onCancel?: () => void;
|
|
26
|
+
}
|
|
27
|
+
/** Who a resolved person is, for a person to check before confirming: their name and address, else their uid. */
|
|
28
|
+
export declare function describePerson(person: ResolvedPrincipal): string;
|
|
29
|
+
/**
|
|
30
|
+
* "Who?" - anywhere a person is assigned by typed identifier rather than picked from an already-loaded list. What
|
|
31
|
+
* is typed is RESOLVED by the server (`resolve`) to the person it names before anything is saved, and the person is
|
|
32
|
+
* shown (name and address) for the caller to confirm; only `onResolved` ever sees the resolved, verified person -
|
|
33
|
+
* never the free text. This is deliberately exact-match, type-then-confirm - never a live/fuzzy search-as-you-type
|
|
34
|
+
* autocomplete, which would let anyone with access to the field enumerate the user directory by partial name.
|
|
35
|
+
*
|
|
36
|
+
* Parameterized entirely by `resolve`/`onResolved` (and the wording props) so every caller - mailbox sharing
|
|
37
|
+
* (`PrincipalPicker`, a thin wrapper around this component), mailbox ownership, escrow-scope holders, ... - reuses
|
|
38
|
+
* the same resolve-then-confirm UX and privacy posture rather than each reimplementing it.
|
|
39
|
+
*
|
|
40
|
+
* Deliberately renders no `<form>` of its own (Enter-to-find is wired up by hand instead, see `handleKeyDown()`) -
|
|
41
|
+
* some callers (`MailboxCreateForm`) use this as one field of their own, larger `<form>`, and a nested `<form>` is
|
|
42
|
+
* invalid HTML that real browsers mis-handle (an inner Enter keypress can submit the wrong one).
|
|
43
|
+
*/
|
|
44
|
+
export default function PrincipalResolver({ resolve, onResolved, initialPrincipal, placeholder, ariaLabel, children, confirmLabel, describeConfirm, confirmErrorMessage, onCancel, }: PrincipalResolverProps): React.JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
3
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
4
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
5
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { ApiRequestError } from "@rapidmx/react-shared/util/api.js";
|
|
8
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
9
|
+
import Button from "@rapidmx/react-shared/components/buttons/Button.js";
|
|
10
|
+
/** Who a resolved person is, for a person to check before confirming: their name and address, else their uid. */
|
|
11
|
+
export function describePerson(person) {
|
|
12
|
+
if (person.displayName && person.address)
|
|
13
|
+
return `${person.displayName} <${person.address}>`;
|
|
14
|
+
return person.displayName ?? person.address ?? `user ${person.userUid}`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* "Who?" - anywhere a person is assigned by typed identifier rather than picked from an already-loaded list. What
|
|
18
|
+
* is typed is RESOLVED by the server (`resolve`) to the person it names before anything is saved, and the person is
|
|
19
|
+
* shown (name and address) for the caller to confirm; only `onResolved` ever sees the resolved, verified person -
|
|
20
|
+
* never the free text. This is deliberately exact-match, type-then-confirm - never a live/fuzzy search-as-you-type
|
|
21
|
+
* autocomplete, which would let anyone with access to the field enumerate the user directory by partial name.
|
|
22
|
+
*
|
|
23
|
+
* Parameterized entirely by `resolve`/`onResolved` (and the wording props) so every caller - mailbox sharing
|
|
24
|
+
* (`PrincipalPicker`, a thin wrapper around this component), mailbox ownership, escrow-scope holders, ... - reuses
|
|
25
|
+
* the same resolve-then-confirm UX and privacy posture rather than each reimplementing it.
|
|
26
|
+
*
|
|
27
|
+
* Deliberately renders no `<form>` of its own (Enter-to-find is wired up by hand instead, see `handleKeyDown()`) -
|
|
28
|
+
* some callers (`MailboxCreateForm`) use this as one field of their own, larger `<form>`, and a nested `<form>` is
|
|
29
|
+
* invalid HTML that real browsers mis-handle (an inner Enter keypress can submit the wrong one).
|
|
30
|
+
*/
|
|
31
|
+
export default function PrincipalResolver({ resolve, onResolved, initialPrincipal, placeholder, ariaLabel, children, confirmLabel, describeConfirm, confirmErrorMessage, onCancel, }) {
|
|
32
|
+
const [typed, setTyped] = useState(initialPrincipal ?? "");
|
|
33
|
+
const [person, setPerson] = useState(null);
|
|
34
|
+
const [busy, setBusy] = useState(false);
|
|
35
|
+
const [error, setError] = useState(null);
|
|
36
|
+
// A stored entry being replaced is looked up straight away, so its person is shown without a click.
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (initialPrincipal) {
|
|
39
|
+
void find(initialPrincipal);
|
|
40
|
+
}
|
|
41
|
+
}, [initialPrincipal]);
|
|
42
|
+
async function find(principal) {
|
|
43
|
+
setBusy(true);
|
|
44
|
+
setError(null);
|
|
45
|
+
setPerson(null);
|
|
46
|
+
try {
|
|
47
|
+
setPerson(await resolve(principal));
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
setError(err instanceof ApiRequestError ? err.message : "Could not look that person up.");
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
setBusy(false);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function submitFind() {
|
|
57
|
+
const principal = typed.trim();
|
|
58
|
+
if (principal) {
|
|
59
|
+
void find(principal);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Enter in the text box finds, same as clicking the button - handled here (not a native `<form>` submit,
|
|
63
|
+
* see this component's own doc comment on why) so it works whether or not a caller nests this inside one of
|
|
64
|
+
* their own forms (`MailboxCreateForm` does). */
|
|
65
|
+
function handleKeyDown(e) {
|
|
66
|
+
if (e.key === "Enter") {
|
|
67
|
+
// Stops the keystroke from also submitting an ANCESTOR `<form>` this component happens to be nested in.
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
submitFind();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Only reachable from the confirm button, which only renders once `person` is set.
|
|
73
|
+
async function handleConfirm() {
|
|
74
|
+
setBusy(true);
|
|
75
|
+
setError(null);
|
|
76
|
+
try {
|
|
77
|
+
await onResolved(person);
|
|
78
|
+
setTyped("");
|
|
79
|
+
setPerson(null);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
setError(err instanceof ApiRequestError ? err.message : confirmErrorMessage);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
setBusy(false);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [error && _jsx(Alert, { children: error }), _jsxs("div", { className: "flex gap-2", children: [_jsx("input", { type: "text", "aria-label": ariaLabel, placeholder: placeholder, className: "flex-1 text-sm border border-border rounded-sm py-1.5 px-2 bg-surface text-text", value: typed, onChange: (e) => {
|
|
89
|
+
setTyped(e.target.value);
|
|
90
|
+
setPerson(null);
|
|
91
|
+
}, onKeyDown: handleKeyDown, disabled: busy }), children, _jsx(Button, { type: "button", variant: "secondary", loading: busy && !person, disabled: busy, className: "!w-auto", onClick: submitFind, children: "Find" }), onCancel && (_jsx(Button, { type: "button", variant: "text", className: "!w-auto", onClick: onCancel, children: "Cancel" }))] }), person && (_jsxs("div", { className: "flex items-center justify-between gap-3 text-sm py-2 px-3 border border-border rounded-sm", children: [_jsx("span", { children: describeConfirm(person) }), _jsx(Button, { type: "button", loading: busy, disabled: busy, className: "!w-auto", onClick: () => void handleConfirm(), children: confirmLabel })] }))] }));
|
|
92
|
+
}
|
|
@@ -4,13 +4,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
4
4
|
// SPDX-License-Identifier: MPL-2.0
|
|
5
5
|
///////////////////////////////////////////////////////////////////////////////
|
|
6
6
|
import { useEffect } from "react";
|
|
7
|
-
import { HiOutlineCheckCircle, HiOutlineEnvelope, HiOutlineExclamationCircle, HiOutlineExclamationTriangle, HiOutlineInformationCircle, HiOutlineXMark, } from "react-icons/hi2";
|
|
7
|
+
import { HiOutlineBell, HiOutlineCheckCircle, HiOutlineEnvelope, HiOutlineExclamationCircle, HiOutlineExclamationTriangle, HiOutlineInformationCircle, HiOutlineXMark, } from "react-icons/hi2";
|
|
8
8
|
import CopyButton from "@rapidmx/react-shared/components/buttons/CopyButton.js";
|
|
9
9
|
import { dismiss, setAllPaused, setPaused } from "./store.js";
|
|
10
10
|
import { useNotifications } from "./useNotifications.js";
|
|
11
11
|
import { useSystemErrorNotifications } from "./systemErrors.js";
|
|
12
12
|
const KIND_STYLE = {
|
|
13
13
|
mail: { border: "border-l-primary", icon: "text-primary-dark", Icon: HiOutlineEnvelope, label: "New message" },
|
|
14
|
+
calendar: { border: "border-l-primary", icon: "text-primary-dark", Icon: HiOutlineBell, label: "Reminder" },
|
|
14
15
|
info: { border: "border-l-primary", icon: "text-primary-dark", Icon: HiOutlineInformationCircle, label: "Information" },
|
|
15
16
|
success: { border: "border-l-success", icon: "text-success", Icon: HiOutlineCheckCircle, label: "Success" },
|
|
16
17
|
warning: { border: "border-l-warning", icon: "text-warning", Icon: HiOutlineExclamationTriangle, label: "Warning" },
|
|
@@ -9,6 +9,7 @@ import CopyButton from "@rapidmx/react-shared/components/buttons/CopyButton.js";
|
|
|
9
9
|
import { useNotifications } from "./useNotifications.js";
|
|
10
10
|
const KIND_LABEL = {
|
|
11
11
|
mail: "New message",
|
|
12
|
+
calendar: "Reminder",
|
|
12
13
|
info: "Information",
|
|
13
14
|
success: "Done",
|
|
14
15
|
warning: "Warning",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Nothing is stored where there is no `window` (server-side rendering): the module state is shared between requests there, so
|
|
22
22
|
* `notify()` only hands back an id.
|
|
23
23
|
*/
|
|
24
|
-
export type NotificationKind = "mail" | "info" | "success" | "warning" | "error";
|
|
24
|
+
export type NotificationKind = "mail" | "calendar" | "info" | "success" | "warning" | "error";
|
|
25
25
|
export interface NotificationAction {
|
|
26
26
|
label: string;
|
|
27
27
|
/** Runs when the action is used. */
|
|
@@ -36,6 +36,8 @@ export const MAX_DETAIL_LINE_LENGTH = 500;
|
|
|
36
36
|
/** How long a non-sticky notification stays, by kind. Errors are sticky, so theirs is only for an explicit `sticky: false`. */
|
|
37
37
|
export const DEFAULT_TIMEOUT_MS = {
|
|
38
38
|
mail: 8000,
|
|
39
|
+
// Irrelevant in practice - a reminder always carries actions, which makes it sticky (see `applyInput()`) regardless of this value.
|
|
40
|
+
calendar: 8000,
|
|
39
41
|
info: 6000,
|
|
40
42
|
success: 5000,
|
|
41
43
|
warning: 10000,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rapidmx/web-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "RapidMX's webmail and admin console React UI for web-based clients.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/rapidmx/web-client",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@dnd-kit/core": "^6.3.1",
|
|
40
40
|
"@journeyapps/wa-sqlite": "^2.0.4",
|
|
41
41
|
"@peculiar/x509": "^2.1.0",
|
|
42
|
-
"@rapidmx/react-shared": "^0.
|
|
42
|
+
"@rapidmx/react-shared": "^0.13.0",
|
|
43
43
|
"@tiptap/core": "^3.31.3",
|
|
44
44
|
"@tiptap/extension-highlight": "^3.31.3",
|
|
45
45
|
"@tiptap/extension-image": "^3.31.3",
|