@peers-app/peers-ui 0.32.2 → 0.33.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/dist/command-palette/command-palette-ui.d.ts +1 -1
- package/dist/command-palette/command-palette-ui.js +10 -74
- package/dist/command-palette/command-palette.js +4 -4
- package/dist/components/markdown-editor/mention-node.js +16 -12
- package/dist/components/markdown-editor/mentions-plugin.js +2 -5
- package/dist/components/markdown-with-mentions.js +10 -5
- package/dist/components/router.d.ts +1 -0
- package/dist/components/router.js +2 -41
- package/dist/globals.d.ts +2 -6
- package/dist/globals.js +0 -35
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/mention-configs.d.ts +1 -5
- package/dist/mention-configs.js +4 -54
- package/dist/notifications/host-controls.d.ts +31 -0
- package/dist/notifications/host-controls.js +9 -0
- package/dist/notifications/index.d.ts +4 -0
- package/dist/notifications/index.js +20 -0
- package/dist/notifications/notification-bell.d.ts +6 -0
- package/dist/notifications/notification-bell.js +81 -0
- package/dist/notifications/notification-item.d.ts +7 -0
- package/dist/notifications/notification-item.js +43 -0
- package/dist/notifications/notifications-client.d.ts +47 -0
- package/dist/notifications/notifications-client.js +155 -0
- package/dist/notifications/notifications-screen.d.ts +2 -0
- package/dist/notifications/notifications-screen.js +209 -0
- package/dist/notifications/priority-alert.d.ts +5 -0
- package/dist/notifications/priority-alert.js +82 -0
- package/dist/root-layout/layouts/full-screen-layout.js +2 -1
- package/dist/root-layout/root-layout-host.js +2 -0
- package/dist/screens/account/account-screen.js +1 -1
- package/dist/screens/network-viewer/connection-troubleshooter.js +8 -9
- package/dist/screens/packages/package-details.js +1 -1
- package/dist/screens/search/global-search.js +2 -4
- package/dist/screens/tools/tool-catalog-ipc.d.ts +6 -6
- package/dist/screens/tools/tool-catalog-ipc.js +4 -5
- package/dist/screens/tools/tool-info.js +2 -2
- package/dist/screens/tools/tool-schema.d.ts +1 -1
- package/dist/screens/tools/tool-schema.js +2 -2
- package/dist/system-apps/index.d.ts +3 -3
- package/dist/system-apps/index.js +7 -15
- package/dist/system-apps/notifications.app.d.ts +3 -0
- package/dist/system-apps/notifications.app.js +9 -0
- package/dist/tabs-layout/network-status-indicator.js +2 -1
- package/dist/tabs-layout/tabs-state.d.ts +1 -0
- package/dist/tabs-layout/tabs-state.js +9 -2
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -9
- package/package.json +3 -3
- package/dist/components/access-level-field.d.ts +0 -10
- package/dist/components/access-level-field.js +0 -28
- package/dist/components/message-logs/message-logs.d.ts +0 -6
- package/dist/components/message-logs/message-logs.js +0 -324
- package/dist/components/message-logs/tool-access-approval-card.d.ts +0 -13
- package/dist/components/message-logs/tool-access-approval-card.js +0 -82
- package/dist/components/messages/avatar.d.ts +0 -9
- package/dist/components/messages/avatar.js +0 -101
- package/dist/components/messages/channel-message-list.d.ts +0 -13
- package/dist/components/messages/channel-message-list.js +0 -158
- package/dist/components/messages/channel-view.d.ts +0 -5
- package/dist/components/messages/channel-view.js +0 -62
- package/dist/components/messages/message-compose.d.ts +0 -11
- package/dist/components/messages/message-compose.js +0 -152
- package/dist/components/messages/message-display.d.ts +0 -9
- package/dist/components/messages/message-display.js +0 -99
- package/dist/components/messages/thread-message-list.d.ts +0 -10
- package/dist/components/messages/thread-message-list.js +0 -122
- package/dist/screens/assistants/assistant-config.d.ts +0 -5
- package/dist/screens/assistants/assistant-config.js +0 -56
- package/dist/screens/assistants/assistant-details.d.ts +0 -3
- package/dist/screens/assistants/assistant-details.js +0 -41
- package/dist/screens/assistants/assistant-info.d.ts +0 -11
- package/dist/screens/assistants/assistant-info.js +0 -13
- package/dist/screens/assistants/assistant-list.d.ts +0 -2
- package/dist/screens/assistants/assistant-list.js +0 -80
- package/dist/screens/assistants/assistant-tools.d.ts +0 -4
- package/dist/screens/assistants/assistant-tools.js +0 -24
- package/dist/screens/tools/tool-access-ipc.d.ts +0 -7
- package/dist/screens/tools/tool-access-ipc.js +0 -18
- package/dist/screens/workflows/workflow-details.d.ts +0 -5
- package/dist/screens/workflows/workflow-details.js +0 -57
- package/dist/screens/workflows/workflow-info.d.ts +0 -4
- package/dist/screens/workflows/workflow-info.js +0 -11
- package/dist/screens/workflows/workflow-instructions.d.ts +0 -4
- package/dist/screens/workflows/workflow-instructions.js +0 -86
- package/dist/screens/workflows/workflow-list.d.ts +0 -1
- package/dist/screens/workflows/workflow-list.js +0 -70
- package/dist/system-apps/assistants.app.d.ts +0 -2
- package/dist/system-apps/assistants.app.js +0 -8
- package/dist/system-apps/threads.app.d.ts +0 -2
- package/dist/system-apps/threads.app.js +0 -8
- package/dist/system-apps/workflows.app.d.ts +0 -2
- package/dist/system-apps/workflows.app.js +0 -8
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Group names by id, with "Personal" for the user's own context. */
|
|
2
|
+
export declare function useGroupNames(): Map<string, string>;
|
|
3
|
+
/** Bell with the notification badge, and a popover of active notifications. */
|
|
4
|
+
export declare function NotificationBell({ compact }: {
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGroupNames = useGroupNames;
|
|
4
|
+
exports.NotificationBell = NotificationBell;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const tabs_state_1 = require("../tabs-layout/tabs-state");
|
|
9
|
+
const notification_item_1 = require("./notification-item");
|
|
10
|
+
const notifications_client_1 = require("./notifications-client");
|
|
11
|
+
/** Group names by id, with "Personal" for the user's own context. */
|
|
12
|
+
function useGroupNames() {
|
|
13
|
+
const [names, setNames] = (0, react_1.useState)(new Map());
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
let cancelled = false;
|
|
16
|
+
void (0, peers_sdk_1.getUserContext)().then(async (userContext) => {
|
|
17
|
+
const groups = await (0, peers_sdk_1.Groups)(userContext.userDataContext).list({});
|
|
18
|
+
const next = new Map(groups.map((group) => [group.groupId, group.name]));
|
|
19
|
+
next.set(userContext.userId, "Personal");
|
|
20
|
+
if (!cancelled)
|
|
21
|
+
setNames(next);
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
cancelled = true;
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
return names;
|
|
28
|
+
}
|
|
29
|
+
/** Bell with the notification badge, and a popover of active notifications. */
|
|
30
|
+
function NotificationBell({ compact = false }) {
|
|
31
|
+
const summary = (0, notifications_client_1.useNotificationSummary)();
|
|
32
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
33
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
34
|
+
const popoverId = (0, react_1.useId)();
|
|
35
|
+
const { notifications, error } = (0, notifications_client_1.useNotifications)({ activeOnly: true, limit: 20 }, open);
|
|
36
|
+
const groupNames = useGroupNames();
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
if (!open)
|
|
39
|
+
return;
|
|
40
|
+
const closeOutside = (event) => {
|
|
41
|
+
if (!containerRef.current?.contains(event.target))
|
|
42
|
+
setOpen(false);
|
|
43
|
+
};
|
|
44
|
+
const closeOnEscape = (event) => {
|
|
45
|
+
if (event.key === "Escape")
|
|
46
|
+
setOpen(false);
|
|
47
|
+
};
|
|
48
|
+
document.addEventListener("mousedown", closeOutside);
|
|
49
|
+
document.addEventListener("keydown", closeOnEscape);
|
|
50
|
+
return () => {
|
|
51
|
+
document.removeEventListener("mousedown", closeOutside);
|
|
52
|
+
document.removeEventListener("keydown", closeOnEscape);
|
|
53
|
+
};
|
|
54
|
+
}, [open]);
|
|
55
|
+
// Opening the list counts as seeing what's in it.
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
if (!open || !notifications)
|
|
58
|
+
return;
|
|
59
|
+
const unseen = notifications.filter((n) => !n.seenAt).map((n) => n.notificationId);
|
|
60
|
+
if (unseen.length)
|
|
61
|
+
void (0, notifications_client_1.actOnNotifications)({ action: "seen", notificationIds: unseen });
|
|
62
|
+
}, [open, notifications]);
|
|
63
|
+
const label = summary.count
|
|
64
|
+
? `${summary.count} notification${summary.count === 1 ? "" : "s"}`
|
|
65
|
+
: summary.dot
|
|
66
|
+
? "New notifications"
|
|
67
|
+
: "Notifications";
|
|
68
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: "position-relative d-flex align-items-center", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm d-flex align-items-center px-2 text-body-secondary", style: {
|
|
69
|
+
border: "none",
|
|
70
|
+
background: "transparent",
|
|
71
|
+
minWidth: compact ? "30px" : undefined,
|
|
72
|
+
}, "aria-label": label, title: summary.paused ? `${label} (paused)` : label, "aria-expanded": open, "aria-controls": popoverId, "data-testid": "notification-bell", onClick: () => setOpen((current) => !current), children: (0, jsx_runtime_1.jsxs)("span", { className: "position-relative d-inline-flex", children: [(0, jsx_runtime_1.jsx)("i", { className: `bi ${summary.paused ? "bi-bell-slash" : summary.count || summary.dot ? "bi-bell-fill" : "bi-bell"}`, "aria-hidden": "true" }), summary.count > 0 ? ((0, jsx_runtime_1.jsx)("span", { className: "position-absolute badge rounded-pill bg-danger", style: {
|
|
73
|
+
fontSize: "0.55rem",
|
|
74
|
+
top: "-0.45rem",
|
|
75
|
+
right: "-0.7rem",
|
|
76
|
+
padding: "0.2em 0.4em",
|
|
77
|
+
}, "aria-hidden": "true", "data-testid": "notification-count", children: summary.count > 99 ? "99+" : summary.count })) : (summary.dot && ((0, jsx_runtime_1.jsx)("span", { className: "position-absolute rounded-circle bg-danger", style: { width: "0.45rem", height: "0.45rem", top: "-0.1rem", right: "-0.2rem" }, "aria-hidden": "true", "data-testid": "notification-dot" })))] }) }), open && ((0, jsx_runtime_1.jsxs)("div", { id: popoverId, role: "dialog", "aria-label": "Notifications", className: "position-absolute end-0 top-100 mt-1 bg-body border rounded shadow", style: { width: "min(22rem, calc(100vw - 2rem))", zIndex: 1080 }, children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center justify-content-between px-2 py-1 border-bottom", children: [(0, jsx_runtime_1.jsx)("strong", { className: "small", children: "Notifications" }), notifications && notifications.length > 0 && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link p-0", onClick: () => void (0, notifications_client_1.actOnNotifications)({ action: "dismiss", all: true }), children: "Clear all" }))] }), (0, jsx_runtime_1.jsx)("div", { style: { maxHeight: "24rem", overflowY: "auto" }, children: error ? ((0, jsx_runtime_1.jsx)("output", { className: "small text-danger p-3", children: error })) : notifications === undefined ? ((0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary p-3", children: "Loading\u2026" })) : notifications.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary p-3", children: "You're all caught up." })) : (notifications.map((notification) => ((0, jsx_runtime_1.jsx)(notification_item_1.NotificationItem, { notification: notification, groupName: groupNames.get(notification.groupId), onOpened: () => setOpen(false) }, notification.notificationId)))) }), (0, jsx_runtime_1.jsx)("div", { className: "border-top px-2 py-1 text-end", children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link p-0", onClick: () => {
|
|
78
|
+
setOpen(false);
|
|
79
|
+
(0, tabs_state_1.goToTabPath)(notifications_client_1.NOTIFICATIONS_PATH);
|
|
80
|
+
}, children: "History and settings" }) })] }))] }));
|
|
81
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { INotification } from "@peers-app/peers-sdk";
|
|
2
|
+
/** One notification row: open on click, with dismiss for active ones. */
|
|
3
|
+
export declare function NotificationItem({ notification, groupName, onOpened, }: {
|
|
4
|
+
notification: INotification;
|
|
5
|
+
groupName?: string;
|
|
6
|
+
onOpened?: () => void;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationItem = NotificationItem;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const notifications_client_1 = require("./notifications-client");
|
|
6
|
+
const levelIcons = {
|
|
7
|
+
priority: "bi-alarm-fill text-danger",
|
|
8
|
+
loud: "bi-bell-fill text-primary",
|
|
9
|
+
quiet: "bi-bell text-secondary",
|
|
10
|
+
background: "bi-dot text-secondary",
|
|
11
|
+
};
|
|
12
|
+
function handledLabel(notification) {
|
|
13
|
+
switch (notification.handledAs) {
|
|
14
|
+
case "acknowledged":
|
|
15
|
+
return "Acknowledged";
|
|
16
|
+
case "dismissed":
|
|
17
|
+
return "Dismissed";
|
|
18
|
+
case "opened":
|
|
19
|
+
return "Opened";
|
|
20
|
+
case "retracted":
|
|
21
|
+
return "No longer needed";
|
|
22
|
+
default:
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** One notification row: open on click, with dismiss for active ones. */
|
|
27
|
+
function NotificationItem({ notification, groupName, onOpened, }) {
|
|
28
|
+
const handled = handledLabel(notification);
|
|
29
|
+
const unseen = !notification.seenAt && !notification.handledAt;
|
|
30
|
+
const detail = [notification.fromName, groupName].filter(Boolean).join(" · ");
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `d-flex align-items-start gap-2 px-2 py-2 border-bottom ${handled ? "opacity-75" : ""}`, "data-notification-id": notification.notificationId, children: [(0, jsx_runtime_1.jsx)("i", { className: `bi ${levelIcons[notification.muted ? "background" : notification.level]} mt-1`, "aria-hidden": "true" }), (0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-link text-start text-reset text-decoration-none p-0 flex-grow-1", style: { minWidth: 0 }, onClick: () => {
|
|
32
|
+
onOpened?.();
|
|
33
|
+
void (0, notifications_client_1.openNotification)(notification);
|
|
34
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { className: `text-truncate ${unseen ? "fw-semibold" : ""}`, children: notification.title }), notification.body && ((0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary", style: {
|
|
35
|
+
display: "-webkit-box",
|
|
36
|
+
WebkitLineClamp: 2,
|
|
37
|
+
WebkitBoxOrient: "vertical",
|
|
38
|
+
overflow: "hidden",
|
|
39
|
+
}, children: notification.body })), (0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary", children: [detail, handled, (0, notifications_client_1.timeAgo)(notification.createdAt)].filter(Boolean).join(" · ") })] }), !notification.handledAt && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link text-body-secondary p-0", title: "Dismiss", "aria-label": `Dismiss ${notification.title}`, onClick: () => void (0, notifications_client_1.actOnNotifications)({
|
|
40
|
+
action: "dismiss",
|
|
41
|
+
notificationIds: [notification.notificationId],
|
|
42
|
+
}), children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-x-lg", "aria-hidden": "true" }) }))] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type IActOnNotificationsInput, type IListNotificationsInput, type INotification, type INotificationSummary, type INotificationsConsumer } from "@peers-app/peers-sdk";
|
|
2
|
+
/** Shared handle for System Notifications on the local host; stable for `useHostContract`. */
|
|
3
|
+
export declare const notificationsContract: import("@peers-app/peers-sdk").IHostContractConsumer<INotificationsConsumer>;
|
|
4
|
+
/** Route of the Notifications system app. */
|
|
5
|
+
export declare const NOTIFICATIONS_PATH = "notifications";
|
|
6
|
+
/** Live badge and alert state from this device. */
|
|
7
|
+
export declare function useNotificationSummary(): INotificationSummary;
|
|
8
|
+
/** Notifications from `list`, reloaded whenever any notification changes. */
|
|
9
|
+
export declare function useNotifications(input: IListNotificationsInput, enabled?: boolean): {
|
|
10
|
+
notifications: {
|
|
11
|
+
title: string;
|
|
12
|
+
level: "priority" | "background" | "loud" | "quiet";
|
|
13
|
+
groupId: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
notificationId: string;
|
|
16
|
+
requestedLevel: "priority" | "background" | "loud" | "quiet";
|
|
17
|
+
link?: string | undefined;
|
|
18
|
+
key?: string | undefined;
|
|
19
|
+
body?: string | undefined;
|
|
20
|
+
kind?: string | undefined;
|
|
21
|
+
expiresAt?: Date | undefined;
|
|
22
|
+
sourcePackageId?: string | undefined;
|
|
23
|
+
fromUserId?: string | undefined;
|
|
24
|
+
fromName?: string | undefined;
|
|
25
|
+
seenAt?: Date | undefined;
|
|
26
|
+
handledAt?: Date | undefined;
|
|
27
|
+
handledAs?: "opened" | "acknowledged" | "dismissed" | "retracted" | undefined;
|
|
28
|
+
snoozedUntil?: Date | undefined;
|
|
29
|
+
muted?: boolean | undefined;
|
|
30
|
+
}[] | undefined;
|
|
31
|
+
error: string | undefined;
|
|
32
|
+
summary: INotificationSummary;
|
|
33
|
+
};
|
|
34
|
+
/** List notifications, with dates revived from the transport. */
|
|
35
|
+
export declare function listNotifications(input: IListNotificationsInput): Promise<INotification[]>;
|
|
36
|
+
/** Act on notifications; errors are logged, not thrown. */
|
|
37
|
+
export declare function actOnNotifications(input: IActOnNotificationsInput): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Open what a notification is about: mark it opened, switch to its group, and go to its link.
|
|
40
|
+
*/
|
|
41
|
+
export declare function openNotification(notification: INotification): Promise<void>;
|
|
42
|
+
/** Finish a notification's group switch after the new group's routes and tabs have loaded. */
|
|
43
|
+
export declare function resumeNotificationNavigation(): Promise<void>;
|
|
44
|
+
/** Open a notification by id, as the desktop app does when its OS notification is clicked. */
|
|
45
|
+
export declare function openNotificationById(notificationId: string): Promise<void>;
|
|
46
|
+
/** Short relative time, such as "3m" or "2d". */
|
|
47
|
+
export declare function timeAgo(date: Date, now?: number): string;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NOTIFICATIONS_PATH = exports.notificationsContract = void 0;
|
|
4
|
+
exports.useNotificationSummary = useNotificationSummary;
|
|
5
|
+
exports.useNotifications = useNotifications;
|
|
6
|
+
exports.listNotifications = listNotifications;
|
|
7
|
+
exports.actOnNotifications = actOnNotifications;
|
|
8
|
+
exports.openNotification = openNotification;
|
|
9
|
+
exports.resumeNotificationNavigation = resumeNotificationNavigation;
|
|
10
|
+
exports.openNotificationById = openNotificationById;
|
|
11
|
+
exports.timeAgo = timeAgo;
|
|
12
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const use_host_contract_1 = require("../hooks/use-host-contract");
|
|
15
|
+
const use_observable_1 = require("../hooks/use-observable");
|
|
16
|
+
const tabs_state_1 = require("../tabs-layout/tabs-state");
|
|
17
|
+
/** Shared handle for System Notifications on the local host; stable for `useHostContract`. */
|
|
18
|
+
exports.notificationsContract = (0, peers_sdk_1.hostContractConsumer)((0, peers_sdk_1.getNotificationsContractDefinition)());
|
|
19
|
+
/** Route of the Notifications system app. */
|
|
20
|
+
exports.NOTIFICATIONS_PATH = "notifications";
|
|
21
|
+
const pendingNavigationKey = "peers.notificationNavigation";
|
|
22
|
+
const emptySummary = {
|
|
23
|
+
count: 0,
|
|
24
|
+
dot: false,
|
|
25
|
+
active: 0,
|
|
26
|
+
ringing: [],
|
|
27
|
+
paused: false,
|
|
28
|
+
revision: 0,
|
|
29
|
+
};
|
|
30
|
+
/** Live badge and alert state from this device. */
|
|
31
|
+
function useNotificationSummary() {
|
|
32
|
+
const { consumer } = (0, use_host_contract_1.useHostContract)(exports.notificationsContract);
|
|
33
|
+
const [summary] = (0, use_observable_1.useObservable)(consumer?.observables.summary);
|
|
34
|
+
return summary ?? emptySummary;
|
|
35
|
+
}
|
|
36
|
+
/** Notifications from `list`, reloaded whenever any notification changes. */
|
|
37
|
+
function useNotifications(input, enabled = true) {
|
|
38
|
+
const summary = useNotificationSummary();
|
|
39
|
+
const [notifications, setNotifications] = (0, react_1.useState)();
|
|
40
|
+
const [error, setError] = (0, react_1.useState)();
|
|
41
|
+
const key = JSON.stringify(input);
|
|
42
|
+
// `key` stands for `input`; the revision reloads the list whenever a notification changes.
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
44
|
+
if (!enabled)
|
|
45
|
+
return;
|
|
46
|
+
let cancelled = false;
|
|
47
|
+
void listNotifications(input)
|
|
48
|
+
.then((rows) => {
|
|
49
|
+
if (!cancelled) {
|
|
50
|
+
setNotifications(rows);
|
|
51
|
+
setError(undefined);
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
.catch((err) => {
|
|
55
|
+
if (!cancelled)
|
|
56
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
cancelled = true;
|
|
60
|
+
};
|
|
61
|
+
}, [key, summary, enabled]);
|
|
62
|
+
return { notifications, error, summary };
|
|
63
|
+
}
|
|
64
|
+
/** List notifications, with dates revived from the transport. */
|
|
65
|
+
async function listNotifications(input) {
|
|
66
|
+
const consumer = await exports.notificationsContract.get();
|
|
67
|
+
const { notifications } = await consumer.tools.listNotifications(input);
|
|
68
|
+
return notifications.map(reviveDates);
|
|
69
|
+
}
|
|
70
|
+
/** Act on notifications; errors are logged, not thrown. */
|
|
71
|
+
async function actOnNotifications(input) {
|
|
72
|
+
try {
|
|
73
|
+
const consumer = await exports.notificationsContract.get();
|
|
74
|
+
await consumer.tools.actOnNotifications(input);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
console.warn("[notifications] action failed", err);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const dateFields = ["createdAt", "expiresAt", "seenAt", "handledAt", "snoozedUntil"];
|
|
81
|
+
function reviveDates(row) {
|
|
82
|
+
const copy = { ...row };
|
|
83
|
+
for (const name of dateFields) {
|
|
84
|
+
const value = copy[name];
|
|
85
|
+
if (value !== undefined && value !== null && !(value instanceof Date)) {
|
|
86
|
+
copy[name] = new Date(value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return copy;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Open what a notification is about: mark it opened, switch to its group, and go to its link.
|
|
93
|
+
*/
|
|
94
|
+
async function openNotification(notification) {
|
|
95
|
+
await actOnNotifications({ action: "open", notificationIds: [notification.notificationId] });
|
|
96
|
+
const userContext = await (0, peers_sdk_1.getUserContext)();
|
|
97
|
+
const target = notification.groupId;
|
|
98
|
+
const path = notification.link || exports.NOTIFICATIONS_PATH;
|
|
99
|
+
if ((userContext.currentlyActiveGroupId() || userContext.userId) !== target) {
|
|
100
|
+
// A group the user has left or disabled, from history: selecting it would create a context
|
|
101
|
+
// for it and keep it as the active group across restarts.
|
|
102
|
+
if (target !== userContext.userId && !userContext.groupIds().includes(target)) {
|
|
103
|
+
(0, tabs_state_1.goToTabPath)(exports.NOTIFICATIONS_PATH);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Group switching reloads the renderer. Carry the destination through startup; navigating
|
|
107
|
+
// after a delay can lose the link or write it into the old group's tabs.
|
|
108
|
+
sessionStorage.setItem(pendingNavigationKey, JSON.stringify({ userId: userContext.userId, groupId: target, path }));
|
|
109
|
+
userContext.currentlyActiveGroupId(target);
|
|
110
|
+
await userContext.waitForActiveGroupPersistence();
|
|
111
|
+
await peers_sdk_1.rpcServerCalls.flushDatabases();
|
|
112
|
+
window.location.reload();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
(0, tabs_state_1.goToTabPath)(path);
|
|
116
|
+
}
|
|
117
|
+
/** Finish a notification's group switch after the new group's routes and tabs have loaded. */
|
|
118
|
+
async function resumeNotificationNavigation() {
|
|
119
|
+
const pending = sessionStorage.getItem(pendingNavigationKey);
|
|
120
|
+
if (!pending)
|
|
121
|
+
return;
|
|
122
|
+
sessionStorage.removeItem(pendingNavigationKey);
|
|
123
|
+
const userContext = await (0, peers_sdk_1.getUserContext)();
|
|
124
|
+
try {
|
|
125
|
+
const target = JSON.parse(pending);
|
|
126
|
+
if (target.userId === userContext.userId &&
|
|
127
|
+
target.groupId === (userContext.currentlyActiveGroupId() || userContext.userId) &&
|
|
128
|
+
typeof target.path === "string")
|
|
129
|
+
(0, tabs_state_1.goToTabPath)(target.path);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// A stale or malformed session value must not prevent the shell from starting.
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Open a notification by id, as the desktop app does when its OS notification is clicked. */
|
|
136
|
+
async function openNotificationById(notificationId) {
|
|
137
|
+
const [notification] = await listNotifications({ notificationIds: [notificationId], limit: 1 });
|
|
138
|
+
if (notification)
|
|
139
|
+
await openNotification(notification);
|
|
140
|
+
else
|
|
141
|
+
(0, tabs_state_1.goToTabPath)(exports.NOTIFICATIONS_PATH);
|
|
142
|
+
}
|
|
143
|
+
/** Short relative time, such as "3m" or "2d". */
|
|
144
|
+
function timeAgo(date, now = Date.now()) {
|
|
145
|
+
const seconds = Math.max(0, Math.round((now - date.getTime()) / 1000));
|
|
146
|
+
if (seconds < 60)
|
|
147
|
+
return "now";
|
|
148
|
+
const minutes = Math.round(seconds / 60);
|
|
149
|
+
if (minutes < 60)
|
|
150
|
+
return `${minutes}m`;
|
|
151
|
+
const hours = Math.round(minutes / 60);
|
|
152
|
+
if (hours < 24)
|
|
153
|
+
return `${hours}h`;
|
|
154
|
+
return `${Math.round(hours / 24)}d`;
|
|
155
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationsScreen = NotificationsScreen;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const use_observable_1 = require("../hooks/use-observable");
|
|
8
|
+
const ui_loader_1 = require("../ui-router/ui-loader");
|
|
9
|
+
const host_controls_1 = require("./host-controls");
|
|
10
|
+
const notification_bell_1 = require("./notification-bell");
|
|
11
|
+
const notification_item_1 = require("./notification-item");
|
|
12
|
+
const notifications_client_1 = require("./notifications-client");
|
|
13
|
+
const levelLabels = {
|
|
14
|
+
priority: "Priority: alarm until dealt with",
|
|
15
|
+
loud: "Loud: sound and popup",
|
|
16
|
+
quiet: "Quiet: no sound",
|
|
17
|
+
background: "Background: only in this list",
|
|
18
|
+
off: "Off",
|
|
19
|
+
};
|
|
20
|
+
/** The Notifications system app: active notifications, history, and settings. */
|
|
21
|
+
function NotificationsScreen() {
|
|
22
|
+
const [section, setSection] = (0, react_1.useState)("inbox");
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid py-3", style: { maxWidth: "48rem" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center justify-content-between mb-3", children: [(0, jsx_runtime_1.jsx)("h4", { className: "m-0", children: "Notifications" }), (0, jsx_runtime_1.jsx)("div", { className: "btn-group btn-group-sm", role: "tablist", children: ["inbox", "history", "settings"].map((name) => ((0, jsx_runtime_1.jsx)("button", { type: "button", role: "tab", "aria-selected": section === name, className: `btn ${section === name ? "btn-primary" : "btn-outline-secondary"}`, onClick: () => setSection(name), children: name === "inbox" ? "Active" : name === "history" ? "History" : "Settings" }, name))) })] }), section === "settings" ? ((0, jsx_runtime_1.jsx)(NotificationSettings, {})) : ((0, jsx_runtime_1.jsx)(NotificationList, { section: section }, section))] }));
|
|
24
|
+
}
|
|
25
|
+
function NotificationList({ section }) {
|
|
26
|
+
const [cursor, setCursor] = (0, react_1.useState)({});
|
|
27
|
+
const { notifications, error } = (0, notifications_client_1.useNotifications)({
|
|
28
|
+
activeOnly: section === "inbox",
|
|
29
|
+
limit: 100,
|
|
30
|
+
...cursor,
|
|
31
|
+
});
|
|
32
|
+
const groupNames = (0, notification_bell_1.useGroupNames)();
|
|
33
|
+
if (error)
|
|
34
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "alert alert-warning", children: error });
|
|
35
|
+
if (!notifications)
|
|
36
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "text-body-secondary", children: "Loading\u2026" });
|
|
37
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "border rounded", children: [section === "inbox" && notifications.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-end gap-3 px-2 py-1 border-bottom", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link p-0", onClick: () => void (0, notifications_client_1.actOnNotifications)({ action: "seen", all: true }), children: "Mark all seen" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link p-0", onClick: () => void (0, notifications_client_1.actOnNotifications)({ action: "dismiss", all: true }), children: "Clear all" })] })), notifications.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "p-3 text-body-secondary", children: section === "inbox" ? "You're all caught up." : "No notifications yet." })) : (notifications.map((notification) => ((0, jsx_runtime_1.jsx)(notification_item_1.NotificationItem, { notification: notification, groupName: groupNames.get(notification.groupId) }, notification.notificationId)))), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-end gap-3 px-2 py-1", children: [cursor.before !== undefined && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link", onClick: () => setCursor({}), children: "Newest notifications" })), notifications.length === 100 && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-link", onClick: () => {
|
|
38
|
+
const last = notifications[notifications.length - 1];
|
|
39
|
+
setCursor({ before: last.createdAt.getTime(), beforeId: last.notificationId });
|
|
40
|
+
}, children: "Older notifications" }))] })] }));
|
|
41
|
+
}
|
|
42
|
+
/** Sources the user has heard from, plus every group, so they can set a level for each. */
|
|
43
|
+
function useSources(history, rules) {
|
|
44
|
+
const groupNames = (0, notification_bell_1.useGroupNames)();
|
|
45
|
+
const [packageNames, setPackageNames] = (0, react_1.useState)(new Map());
|
|
46
|
+
const packageIds = (0, react_1.useMemo)(() => [
|
|
47
|
+
...new Set([
|
|
48
|
+
...(history ?? []).map((n) => n.sourcePackageId),
|
|
49
|
+
...(rules ?? []).map((rule) => rule.packageId),
|
|
50
|
+
].filter((id) => Boolean(id))),
|
|
51
|
+
], [history, rules]);
|
|
52
|
+
(0, react_1.useEffect)(() => {
|
|
53
|
+
let cancelled = false;
|
|
54
|
+
void (0, peers_sdk_1.getUserContext)().then(async (userContext) => {
|
|
55
|
+
const names = new Map();
|
|
56
|
+
// Only contexts this device holds: getDataContext would create one for a left group.
|
|
57
|
+
const groupIds = [userContext.userId, ...userContext.groupIds()];
|
|
58
|
+
for (const packageId of packageIds) {
|
|
59
|
+
for (const groupId of groupIds) {
|
|
60
|
+
const row = await (0, peers_sdk_1.Packages)(userContext.getDataContext(groupId))
|
|
61
|
+
.get(packageId)
|
|
62
|
+
.catch(() => undefined);
|
|
63
|
+
if (row?.name) {
|
|
64
|
+
names.set(packageId, row.name);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!cancelled)
|
|
70
|
+
setPackageNames(names);
|
|
71
|
+
});
|
|
72
|
+
return () => {
|
|
73
|
+
cancelled = true;
|
|
74
|
+
};
|
|
75
|
+
}, [packageIds]);
|
|
76
|
+
return (0, react_1.useMemo)(() => {
|
|
77
|
+
const sources = [];
|
|
78
|
+
for (const [groupId, name] of groupNames) {
|
|
79
|
+
sources.push({ label: `Group: ${name}`, match: { groupId } });
|
|
80
|
+
}
|
|
81
|
+
for (const packageId of packageIds) {
|
|
82
|
+
sources.push({
|
|
83
|
+
label: `App: ${packageNames.get(packageId) ?? packageId}`,
|
|
84
|
+
match: { packageId },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const kinds = new Set();
|
|
88
|
+
for (const n of history ?? []) {
|
|
89
|
+
if (!n.sourcePackageId || !n.kind)
|
|
90
|
+
continue;
|
|
91
|
+
const key = `${n.sourcePackageId}:${n.kind}`;
|
|
92
|
+
if (kinds.has(key))
|
|
93
|
+
continue;
|
|
94
|
+
kinds.add(key);
|
|
95
|
+
sources.push({
|
|
96
|
+
label: `App: ${packageNames.get(n.sourcePackageId) ?? n.sourcePackageId} · ${n.kind}`,
|
|
97
|
+
match: { packageId: n.sourcePackageId, kind: n.kind },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const people = new Map();
|
|
101
|
+
for (const n of history ?? []) {
|
|
102
|
+
if (n.fromUserId && !people.has(n.fromUserId))
|
|
103
|
+
people.set(n.fromUserId, n.fromName ?? n.fromUserId);
|
|
104
|
+
}
|
|
105
|
+
for (const [fromUserId, name] of people) {
|
|
106
|
+
sources.push({ label: `Person: ${name}`, match: { fromUserId } });
|
|
107
|
+
}
|
|
108
|
+
// A saved choice must remain editable after its source leaves the recent history page.
|
|
109
|
+
for (const rule of rules ?? []) {
|
|
110
|
+
if (sources.some((source) => sameMatch(rule, source.match)))
|
|
111
|
+
continue;
|
|
112
|
+
const { packageId, groupId, fromUserId, kind } = rule;
|
|
113
|
+
const label = [
|
|
114
|
+
groupId && `Group: ${groupNames.get(groupId) ?? groupId}`,
|
|
115
|
+
packageId && `App: ${packageNames.get(packageId) ?? packageId}`,
|
|
116
|
+
fromUserId && `Person: ${people.get(fromUserId) ?? fromUserId}`,
|
|
117
|
+
kind,
|
|
118
|
+
]
|
|
119
|
+
.filter(Boolean)
|
|
120
|
+
.join(" · ");
|
|
121
|
+
sources.push({
|
|
122
|
+
label: label || "All notifications",
|
|
123
|
+
match: { packageId, groupId, fromUserId, kind },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return sources;
|
|
127
|
+
}, [groupNames, packageIds, packageNames, history, rules]);
|
|
128
|
+
}
|
|
129
|
+
function sameMatch(rule, match) {
|
|
130
|
+
return (rule.packageId === match.packageId &&
|
|
131
|
+
rule.groupId === match.groupId &&
|
|
132
|
+
rule.fromUserId === match.fromUserId &&
|
|
133
|
+
rule.kind === match.kind);
|
|
134
|
+
}
|
|
135
|
+
function NotificationSettings() {
|
|
136
|
+
const [settings] = (0, use_observable_1.useObservable)(peers_sdk_1.notificationSettingsVar);
|
|
137
|
+
const { notifications: history } = (0, notifications_client_1.useNotifications)({ limit: 300 });
|
|
138
|
+
const sources = useSources(history, settings?.rules);
|
|
139
|
+
const current = settings ?? {};
|
|
140
|
+
const rules = current.rules ?? [];
|
|
141
|
+
const now = Date.now();
|
|
142
|
+
const paused = (current.pausedUntil ?? 0) > now;
|
|
143
|
+
const save = (next) => (0, peers_sdk_1.notificationSettingsVar)(next);
|
|
144
|
+
const setRule = (match, change) => {
|
|
145
|
+
const existing = rules.find((rule) => sameMatch(rule, match));
|
|
146
|
+
const merged = { ...match, ...existing, ...change };
|
|
147
|
+
const others = rules.filter((rule) => rule !== existing);
|
|
148
|
+
const keep = merged.level !== undefined || merged.allowPriority !== undefined;
|
|
149
|
+
save({ ...current, rules: keep ? [...others, merged] : others });
|
|
150
|
+
};
|
|
151
|
+
const pauseFor = (ms) => save({ ...current, pausedUntil: ms === undefined ? undefined : Date.now() + ms });
|
|
152
|
+
const tomorrowMorning = () => {
|
|
153
|
+
const date = new Date();
|
|
154
|
+
// After midnight but before dawn, "tomorrow morning" is this morning.
|
|
155
|
+
if (date.getHours() >= 5)
|
|
156
|
+
date.setDate(date.getDate() + 1);
|
|
157
|
+
date.setHours(8, 0, 0, 0);
|
|
158
|
+
return date.getTime() - Date.now();
|
|
159
|
+
};
|
|
160
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-column gap-4", children: [(0, jsx_runtime_1.jsx)(ThisDeviceSettings, {}), (0, jsx_runtime_1.jsxs)("section", { children: [(0, jsx_runtime_1.jsx)("h6", { children: "Do not disturb" }), (0, jsx_runtime_1.jsx)("p", { className: "small text-body-secondary mb-2", children: "While paused, loud notifications arrive without sound. Priority notifications still come through." }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap gap-2 align-items-center", children: [paused && ((0, jsx_runtime_1.jsxs)("span", { className: "small me-2", children: ["Paused until ", new Date(current.pausedUntil ?? 0).toLocaleString()] })), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-secondary", onClick: () => pauseFor(60 * 60_000), children: "1 hour" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-secondary", onClick: () => pauseFor(tomorrowMorning()), children: "Until tomorrow morning" }), paused && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-primary", onClick: () => pauseFor(undefined), children: "Resume" }))] })] }), (0, jsx_runtime_1.jsxs)("section", { children: [(0, jsx_runtime_1.jsx)("h6", { children: "Levels by source" }), (0, jsx_runtime_1.jsx)("p", { className: "small text-body-secondary mb-2", children: "Each app asks for a level; you decide what you get. More specific choices win, and a person can only use priority if you allow it here." }), (0, jsx_runtime_1.jsxs)("div", { className: "border rounded", children: [sources.length === 0 && ((0, jsx_runtime_1.jsx)("div", { className: "p-3 small text-body-secondary", children: "Sources appear here once you've had a notification from them." })), sources.map((source) => {
|
|
161
|
+
const rule = rules.find((r) => sameMatch(r, source.match));
|
|
162
|
+
const key = `${source.match.groupId ?? ""}:${source.match.packageId ?? ""}:${source.match.fromUserId ?? ""}:${source.match.kind ?? ""}`;
|
|
163
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap align-items-center gap-2 px-2 py-2 border-bottom", children: [(0, jsx_runtime_1.jsx)("span", { className: "flex-grow-1 small", children: source.label }), (0, jsx_runtime_1.jsxs)("select", { className: "form-select form-select-sm", style: { width: "auto" }, "aria-label": `Level for ${source.label}`, value: rule?.level ?? "", onChange: (event) => setRule(source.match, {
|
|
164
|
+
level: (event.target.value || undefined),
|
|
165
|
+
}), children: [(0, jsx_runtime_1.jsx)("option", { value: "", children: "As the app asks" }), ["priority", "loud", "quiet", "background", "off"].map((level) => ((0, jsx_runtime_1.jsx)("option", { value: level, children: levelLabels[level] }, level)))] }), source.match.fromUserId && ((0, jsx_runtime_1.jsxs)("label", { className: "form-check-label small d-flex align-items-center gap-1", children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", className: "form-check-input m-0", checked: rule?.allowPriority === true, onChange: (event) => setRule(source.match, {
|
|
166
|
+
allowPriority: event.target.checked ? true : undefined,
|
|
167
|
+
}) }), "Allow priority"] }))] }, key));
|
|
168
|
+
})] })] })] }));
|
|
169
|
+
}
|
|
170
|
+
/** Per-device controls the host provides, such as the PWA's browser permission. */
|
|
171
|
+
function ThisDeviceSettings() {
|
|
172
|
+
const [controls] = (0, use_observable_1.useObservable)(host_controls_1.notificationHostControls);
|
|
173
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
174
|
+
const [error, setError] = (0, react_1.useState)();
|
|
175
|
+
if (!controls)
|
|
176
|
+
return null;
|
|
177
|
+
const run = async (action) => {
|
|
178
|
+
if (!action)
|
|
179
|
+
return;
|
|
180
|
+
setBusy(true);
|
|
181
|
+
setError(undefined);
|
|
182
|
+
try {
|
|
183
|
+
await action();
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
setBusy(false);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const stateLabel = {
|
|
193
|
+
unsupported: "Not available in this browser",
|
|
194
|
+
blocked: "Blocked by the browser",
|
|
195
|
+
off: "Off",
|
|
196
|
+
on: "On",
|
|
197
|
+
};
|
|
198
|
+
return ((0, jsx_runtime_1.jsxs)("section", { children: [(0, jsx_runtime_1.jsx)("h6", { children: "This device" }), (0, jsx_runtime_1.jsx)("p", { className: "small text-body-secondary mb-2", children: controls.description }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap gap-2 align-items-center", children: [(0, jsx_runtime_1.jsxs)("span", { className: "small me-2", children: ["Notifications on this device: ", (0, jsx_runtime_1.jsx)("strong", { children: stateLabel[controls.state] })] }), controls.state === "off" && controls.enable && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-primary", disabled: busy, onClick: () => void run(controls.enable), children: "Turn on" })), controls.state === "on" && controls.disable && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-secondary", disabled: busy, onClick: () => void run(controls.disable), children: "Turn off" }))] }), (error ?? controls.detail) && ((0, jsx_runtime_1.jsx)("p", { className: `small mb-0 mt-2 ${error ? "text-danger" : "text-body-secondary"}`, children: error ?? controls.detail }))] }));
|
|
199
|
+
}
|
|
200
|
+
(0, ui_loader_1.registerInternalPeersUI)({
|
|
201
|
+
component: NotificationsScreen,
|
|
202
|
+
routes: [
|
|
203
|
+
{
|
|
204
|
+
isMatch: (_props, context) => context.path === notifications_client_1.NOTIFICATIONS_PATH,
|
|
205
|
+
uiCategory: "screen",
|
|
206
|
+
priority: 0,
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
});
|