@peers-app/peers-ui 0.27.3 → 0.27.5
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/screens/network-viewer/group-details-modal.d.ts +4 -0
- package/dist/screens/network-viewer/group-details-modal.js +6 -46
- package/dist/screens/network-viewer/network-viewer-ipc.d.ts +3 -2
- package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
- package/dist/screens/network-viewer/sync-recovery.js +103 -1
- package/dist/screens/variables/variable-details.js +2 -1
- package/dist/tabs-layout/network-status-indicator.js +26 -12
- package/dist/tabs-layout/use-network-status.d.ts +6 -1
- package/dist/tabs-layout/use-network-status.js +27 -4
- package/package.json +9 -3
- package/.claude/settings.local.json +0 -34
- package/.github/README.md +0 -52
- package/.github/workflows/delete-all-artifacts.yml +0 -49
- package/.github/workflows/publish.yml +0 -51
- package/babel.config.js +0 -7
- package/biome.json +0 -198
- package/dist/app-updates/app-updates-consumer.test.d.ts +0 -1
- package/dist/app-updates/app-updates-consumer.test.js +0 -56
- package/dist/app-updates/app-updates-settings.test.d.ts +0 -1
- package/dist/app-updates/app-updates-settings.test.js +0 -93
- package/dist/app-updates/remote-app-update-panel.test.d.ts +0 -1
- package/dist/app-updates/remote-app-update-panel.test.js +0 -165
- package/dist/components/access-level-field.test.d.ts +0 -1
- package/dist/components/access-level-field.test.js +0 -28
- package/dist/components/message-logs/tool-access-approval-card.test.d.ts +0 -1
- package/dist/components/message-logs/tool-access-approval-card.test.js +0 -102
- package/dist/components/responsive-section-nav.test.d.ts +0 -1
- package/dist/components/responsive-section-nav.test.js +0 -45
- package/dist/globals-hash.test.d.ts +0 -1
- package/dist/globals-hash.test.js +0 -16
- package/dist/hooks/use-observable-state.test.d.ts +0 -1
- package/dist/hooks/use-observable-state.test.js +0 -64
- package/dist/hooks/use-observable.test.d.ts +0 -1
- package/dist/hooks/use-observable.test.js +0 -191
- package/dist/hooks/use-rows.test.d.ts +0 -1
- package/dist/hooks/use-rows.test.js +0 -175
- package/dist/hooks/use-tool.test.d.ts +0 -1
- package/dist/hooks/use-tool.test.js +0 -190
- package/dist/host-shell/host-shell-consumer.test.d.ts +0 -1
- package/dist/host-shell/host-shell-consumer.test.js +0 -28
- package/dist/root-layout/root-layout-host.test.d.ts +0 -1
- package/dist/root-layout/root-layout-host.test.js +0 -86
- package/dist/screens/account/account-screen.test.d.ts +0 -1
- package/dist/screens/account/account-screen.test.js +0 -51
- package/dist/screens/assistants/assistant-config.test.d.ts +0 -1
- package/dist/screens/assistants/assistant-config.test.js +0 -57
- package/dist/screens/contacts/contact-list.test.d.ts +0 -1
- package/dist/screens/contacts/contact-list.test.js +0 -48
- package/dist/screens/device-pairing/device-pairing.test.d.ts +0 -1
- package/dist/screens/device-pairing/device-pairing.test.js +0 -119
- package/dist/screens/devices/devices-list.test.d.ts +0 -1
- package/dist/screens/devices/devices-list.test.js +0 -53
- package/dist/screens/groups/group-list.test.d.ts +0 -1
- package/dist/screens/groups/group-list.test.js +0 -38
- package/dist/screens/identity/identity-routes.test.d.ts +0 -1
- package/dist/screens/identity/identity-routes.test.js +0 -51
- package/dist/screens/identity/identity-screen.test.d.ts +0 -1
- package/dist/screens/identity/identity-screen.test.js +0 -103
- package/dist/screens/invites/accept-invite.test.d.ts +0 -1
- package/dist/screens/invites/accept-invite.test.js +0 -103
- package/dist/screens/invites/activity-view.test.d.ts +0 -1
- package/dist/screens/invites/activity-view.test.js +0 -108
- package/dist/screens/invites/invite-classify.test.d.ts +0 -1
- package/dist/screens/invites/invite-classify.test.js +0 -115
- package/dist/screens/network-viewer/network-viewer-ipc.test.d.ts +0 -1
- package/dist/screens/network-viewer/network-viewer-ipc.test.js +0 -61
- package/dist/screens/network-viewer/network-viewer.section.test.d.ts +0 -1
- package/dist/screens/network-viewer/network-viewer.section.test.js +0 -63
- package/dist/screens/network-viewer/sync-recovery.test.d.ts +0 -1
- package/dist/screens/network-viewer/sync-recovery.test.js +0 -104
- package/dist/screens/packages/package-helpers.test.d.ts +0 -1
- package/dist/screens/packages/package-helpers.test.js +0 -53
- package/dist/screens/packages/package-runtime-status.test.d.ts +0 -1
- package/dist/screens/packages/package-runtime-status.test.js +0 -50
- package/dist/screens/packages/packages-ipc.test.d.ts +0 -1
- package/dist/screens/packages/packages-ipc.test.js +0 -43
- package/dist/screens/settings/settings-page.test.d.ts +0 -1
- package/dist/screens/settings/settings-page.test.js +0 -19
- package/dist/screens/tools/tool-access-ipc.test.d.ts +0 -1
- package/dist/screens/tools/tool-access-ipc.test.js +0 -40
- package/dist/screens/tools/tool-catalog-ipc.test.d.ts +0 -1
- package/dist/screens/tools/tool-catalog-ipc.test.js +0 -52
- package/dist/tabs-layout/network-status-indicator.test.d.ts +0 -1
- package/dist/tabs-layout/network-status-indicator.test.js +0 -665
- package/dist/tabs-layout/tabs-state.test.d.ts +0 -1
- package/dist/tabs-layout/tabs-state.test.js +0 -110
- package/dist/tabs-layout/use-network-status.test.d.ts +0 -1
- package/dist/tabs-layout/use-network-status.test.js +0 -45
- package/dist/ui-router/ui-loader.test.d.ts +0 -1
- package/dist/ui-router/ui-loader.test.js +0 -91
- package/jest.config.js +0 -25
- package/release-guard.js +0 -10
- package/src/app-updates/app-update-controls.tsx +0 -73
- package/src/app-updates/app-updates-consumer.test.ts +0 -83
- package/src/app-updates/app-updates-consumer.ts +0 -121
- package/src/app-updates/app-updates-settings.test.tsx +0 -109
- package/src/app-updates/app-updates-settings.tsx +0 -136
- package/src/app-updates/remote-app-update-panel.test.tsx +0 -205
- package/src/app-updates/remote-app-update-panel.tsx +0 -210
- package/src/app-updates/use-app-update-status.ts +0 -16
- package/src/command-palette/command-palette-ui.tsx +0 -564
- package/src/command-palette/command-palette.ts +0 -242
- package/src/components/access-level-field.test.tsx +0 -32
- package/src/components/access-level-field.tsx +0 -68
- package/src/components/checkbox.tsx +0 -25
- package/src/components/group-switcher.tsx +0 -526
- package/src/components/input-date.tsx +0 -29
- package/src/components/input-number.tsx +0 -83
- package/src/components/input.tsx +0 -25
- package/src/components/inverse-lazy-list.tsx +0 -107
- package/src/components/io-schema-values.tsx +0 -103
- package/src/components/io-schema.tsx +0 -259
- package/src/components/lazy-list.tsx +0 -115
- package/src/components/list-screen.tsx +0 -126
- package/src/components/loading-indicator.tsx +0 -7
- package/src/components/markdown-editor/autolink-plugin.tsx +0 -29
- package/src/components/markdown-editor/editor-inline.tsx +0 -9
- package/src/components/markdown-editor/editor.tsx +0 -158
- package/src/components/markdown-editor/markdown-plugin.tsx +0 -202
- package/src/components/markdown-editor/mention-node.ts +0 -204
- package/src/components/markdown-editor/mentions-plugin.tsx +0 -354
- package/src/components/markdown-editor/move-line-plugin.tsx +0 -186
- package/src/components/markdown-editor/select-line-boundary-plugin.tsx +0 -95
- package/src/components/markdown-editor/theme.ts +0 -46
- package/src/components/markdown-editor/toolbar.tsx +0 -269
- package/src/components/markdown-with-mentions.tsx +0 -198
- package/src/components/message-logs/message-logs.tsx +0 -523
- package/src/components/message-logs/tool-access-approval-card.test.tsx +0 -127
- package/src/components/message-logs/tool-access-approval-card.tsx +0 -178
- package/src/components/messages/avatar.tsx +0 -171
- package/src/components/messages/channel-message-list.tsx +0 -189
- package/src/components/messages/channel-view.tsx +0 -92
- package/src/components/messages/message-compose.tsx +0 -192
- package/src/components/messages/message-display.tsx +0 -231
- package/src/components/messages/thread-message-list.tsx +0 -135
- package/src/components/qr-scanner.tsx +0 -180
- package/src/components/responsive-section-nav.test.tsx +0 -88
- package/src/components/responsive-section-nav.tsx +0 -92
- package/src/components/router.tsx +0 -175
- package/src/components/save-button.tsx +0 -134
- package/src/components/sortable-list.tsx +0 -130
- package/src/components/tabs.tsx +0 -76
- package/src/components/tooltip.tsx +0 -43
- package/src/components/trust-level-badge.tsx +0 -44
- package/src/components/trust-level-dropdown.tsx +0 -136
- package/src/components/typeahead.tsx +0 -357
- package/src/globals-hash.test.ts +0 -19
- package/src/globals.tsx +0 -226
- package/src/hooks/index.ts +0 -8
- package/src/hooks/use-host-contract.ts +0 -75
- package/src/hooks/use-observable-state.test.tsx +0 -101
- package/src/hooks/use-observable-state.ts +0 -29
- package/src/hooks/use-observable.test.tsx +0 -258
- package/src/hooks/use-observable.ts +0 -67
- package/src/hooks/use-on-screen.ts +0 -24
- package/src/hooks/use-promise.ts +0 -34
- package/src/hooks/use-rows.test.tsx +0 -196
- package/src/hooks/use-rows.ts +0 -120
- package/src/hooks/use-subscription.ts +0 -24
- package/src/hooks/use-tool.test.tsx +0 -225
- package/src/hooks/use-tool.ts +0 -116
- package/src/host-shell/host-shell-consumer.test.ts +0 -32
- package/src/host-shell/host-shell-consumer.ts +0 -53
- package/src/index.tsx +0 -42
- package/src/mention-configs.ts +0 -185
- package/src/operator-console/operator-console-state.ts +0 -119
- package/src/operator-console/operator-console.tsx +0 -233
- package/src/peers-services-registration.ts +0 -6
- package/src/root-layout/global-overlays.ts +0 -50
- package/src/root-layout/layout-picker.tsx +0 -47
- package/src/root-layout/layouts/full-screen-layout.tsx +0 -144
- package/src/root-layout/layouts/tabs-with-console-layout.tsx +0 -260
- package/src/root-layout/root-layout-host.test.tsx +0 -108
- package/src/root-layout/root-layout-host.tsx +0 -147
- package/src/root-layout/root-layout-registry.ts +0 -51
- package/src/root-layout/root-layout-state.ts +0 -55
- package/src/root-layout/root-layout.ts +0 -32
- package/src/screens/account/account-screen.test.tsx +0 -65
- package/src/screens/account/account-screen.tsx +0 -942
- package/src/screens/assistants/assistant-config.test.tsx +0 -54
- package/src/screens/assistants/assistant-config.tsx +0 -121
- package/src/screens/assistants/assistant-details.tsx +0 -89
- package/src/screens/assistants/assistant-info.tsx +0 -66
- package/src/screens/assistants/assistant-list.tsx +0 -145
- package/src/screens/assistants/assistant-tools.tsx +0 -82
- package/src/screens/console-logs/console-logs-list.tsx +0 -374
- package/src/screens/console-logs/log-display.tsx +0 -137
- package/src/screens/console-logs/log-filters.tsx +0 -64
- package/src/screens/console-logs/mobile-log-card.tsx +0 -161
- package/src/screens/console-logs/resizable-table-header.tsx +0 -110
- package/src/screens/contacts/contact-details.tsx +0 -123
- package/src/screens/contacts/contact-list.test.tsx +0 -59
- package/src/screens/contacts/contact-list.tsx +0 -286
- package/src/screens/contacts/index.ts +0 -2
- package/src/screens/data-explorer/data-explorer.tsx +0 -633
- package/src/screens/data-explorer/index.ts +0 -6
- package/src/screens/data-explorer/query-executor.tsx +0 -520
- package/src/screens/device-pairing/device-pairing.test.tsx +0 -143
- package/src/screens/device-pairing/device-pairing.tsx +0 -461
- package/src/screens/device-pairing/identity-ipc.ts +0 -25
- package/src/screens/device-pairing/index.ts +0 -2
- package/src/screens/device-pairing/use-device-pairing-state.ts +0 -15
- package/src/screens/devices/devices-list.test.tsx +0 -68
- package/src/screens/devices/devices-list.tsx +0 -365
- package/src/screens/devices/index.ts +0 -1
- package/src/screens/groups/group-details.tsx +0 -160
- package/src/screens/groups/group-invite-panel.tsx +0 -311
- package/src/screens/groups/group-list.test.tsx +0 -44
- package/src/screens/groups/group-list.tsx +0 -317
- package/src/screens/groups/group-members.tsx +0 -343
- package/src/screens/groups/index.ts +0 -3
- package/src/screens/identity/identity-routes.test.ts +0 -70
- package/src/screens/identity/identity-routes.ts +0 -301
- package/src/screens/identity/identity-screen.test.tsx +0 -138
- package/src/screens/identity/identity-screen.tsx +0 -282
- package/src/screens/identity/index.ts +0 -2
- package/src/screens/identity/invite-contact-panel.tsx +0 -45
- package/src/screens/identity/profile-invite.tsx +0 -93
- package/src/screens/invites/accept-invite.test.tsx +0 -115
- package/src/screens/invites/accept-invite.tsx +0 -318
- package/src/screens/invites/activity-view.test.tsx +0 -127
- package/src/screens/invites/activity-view.tsx +0 -162
- package/src/screens/invites/index.ts +0 -6
- package/src/screens/invites/invite-capture.ts +0 -104
- package/src/screens/invites/invite-classify.test.ts +0 -129
- package/src/screens/invites/invite-share.tsx +0 -104
- package/src/screens/invites/invites-ipc.ts +0 -25
- package/src/screens/invites/pending-invites-list.tsx +0 -256
- package/src/screens/network-viewer/connection-troubleshooter.tsx +0 -395
- package/src/screens/network-viewer/cpu-usage-graph.tsx +0 -294
- package/src/screens/network-viewer/device-details-modal.tsx +0 -339
- package/src/screens/network-viewer/group-details-modal.tsx +0 -421
- package/src/screens/network-viewer/index.ts +0 -8
- package/src/screens/network-viewer/network-viewer-ipc.test.ts +0 -72
- package/src/screens/network-viewer/network-viewer-ipc.ts +0 -39
- package/src/screens/network-viewer/network-viewer-section.ts +0 -12
- package/src/screens/network-viewer/network-viewer.section.test.tsx +0 -68
- package/src/screens/network-viewer/network-viewer.tsx +0 -708
- package/src/screens/network-viewer/remote-logs-panel.tsx +0 -190
- package/src/screens/network-viewer/sync-recovery.test.tsx +0 -114
- package/src/screens/network-viewer/sync-recovery.tsx +0 -461
- package/src/screens/network-viewer/usage-graph.tsx +0 -455
- package/src/screens/packages/local-folder-grants-panel.tsx +0 -290
- package/src/screens/packages/local-folders-ipc.ts +0 -28
- package/src/screens/packages/package-details.tsx +0 -166
- package/src/screens/packages/package-helpers.test.ts +0 -57
- package/src/screens/packages/package-helpers.ts +0 -137
- package/src/screens/packages/package-info.tsx +0 -354
- package/src/screens/packages/package-list.tsx +0 -519
- package/src/screens/packages/package-network-panel.tsx +0 -82
- package/src/screens/packages/package-new-local.tsx +0 -100
- package/src/screens/packages/package-runtime-status.test.tsx +0 -58
- package/src/screens/packages/package-runtime-status.tsx +0 -68
- package/src/screens/packages/package-versions.tsx +0 -298
- package/src/screens/packages/packages-ipc.test.ts +0 -47
- package/src/screens/packages/packages-ipc.ts +0 -125
- package/src/screens/peer-types/peer-type-details.tsx +0 -172
- package/src/screens/peer-types/peer-type-list.tsx +0 -64
- package/src/screens/search/global-search.tsx +0 -406
- package/src/screens/settings/color-mode-dropdown.tsx +0 -82
- package/src/screens/settings/settings-page.test.tsx +0 -24
- package/src/screens/settings/settings-page.tsx +0 -426
- package/src/screens/setup-user.tsx +0 -355
- package/src/screens/tools/tool-access-ipc.test.ts +0 -55
- package/src/screens/tools/tool-access-ipc.ts +0 -27
- package/src/screens/tools/tool-catalog-ipc.test.ts +0 -52
- package/src/screens/tools/tool-catalog-ipc.ts +0 -51
- package/src/screens/tools/tool-details.tsx +0 -52
- package/src/screens/tools/tool-info.tsx +0 -45
- package/src/screens/tools/tool-list.tsx +0 -106
- package/src/screens/tools/tool-schema.tsx +0 -44
- package/src/screens/tools/tool-test-details.tsx +0 -89
- package/src/screens/tools/tool-test-list.tsx +0 -73
- package/src/screens/variables/variable-details.tsx +0 -289
- package/src/screens/variables/variable-list.tsx +0 -110
- package/src/screens/welcome-modal.tsx +0 -294
- package/src/screens/workflows/workflow-details.tsx +0 -115
- package/src/screens/workflows/workflow-info.tsx +0 -22
- package/src/screens/workflows/workflow-instructions.tsx +0 -134
- package/src/screens/workflows/workflow-list.tsx +0 -117
- package/src/setupTests.ts +0 -38
- package/src/system-apps/assistants.app.ts +0 -7
- package/src/system-apps/console-logs.app.ts +0 -7
- package/src/system-apps/data-explorer.app.ts +0 -8
- package/src/system-apps/identity.app.ts +0 -9
- package/src/system-apps/index.ts +0 -77
- package/src/system-apps/mobile-settings.app.ts +0 -7
- package/src/system-apps/network-viewer.app.ts +0 -8
- package/src/system-apps/packages.app.ts +0 -7
- package/src/system-apps/search.app.ts +0 -8
- package/src/system-apps/settings.app.ts +0 -7
- package/src/system-apps/threads.app.ts +0 -7
- package/src/system-apps/tools.app.ts +0 -7
- package/src/system-apps/types.app.ts +0 -7
- package/src/system-apps/variables.app.ts +0 -7
- package/src/system-apps/workflows.app.ts +0 -7
- package/src/tabs-layout/network-status-indicator.test.tsx +0 -799
- package/src/tabs-layout/network-status-indicator.tsx +0 -756
- package/src/tabs-layout/tabs-layout.tsx +0 -857
- package/src/tabs-layout/tabs-state.test.ts +0 -152
- package/src/tabs-layout/tabs-state.ts +0 -587
- package/src/tabs-layout/use-network-status.test.tsx +0 -58
- package/src/tabs-layout/use-network-status.ts +0 -68
- package/src/ui-defaults/index.ts +0 -2
- package/src/ui-defaults/list-screen.tsx +0 -94
- package/src/ui-defaults/markdown-field.tsx +0 -87
- package/src/ui-router/routes-loader.ts +0 -193
- package/src/ui-router/ui-loader.test.tsx +0 -108
- package/src/ui-router/ui-loader.tsx +0 -606
- package/src/utils.ts +0 -95
- package/tsconfig.json +0 -18
|
@@ -1,756 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IAppUpdateStatus,
|
|
3
|
-
INetworkConnectionInfo,
|
|
4
|
-
INetworkStatusSummary,
|
|
5
|
-
} from "@peers-app/peers-sdk";
|
|
6
|
-
import moment from "moment";
|
|
7
|
-
import { useEffect, useId, useRef, useState } from "react";
|
|
8
|
-
import { APP_UPDATE_ICON_CLASS, AppUpdatePopoverSection } from "../app-updates/app-update-controls";
|
|
9
|
-
import { describeAppUpdateStatus, hasAppUpdate } from "../app-updates/app-updates-consumer";
|
|
10
|
-
import { useAppUpdateStatus } from "../app-updates/use-app-update-status";
|
|
11
|
-
import { IDENTITY_ACCEPT_PATH, IDENTITY_ACCOUNT_PATH } from "../screens/identity/identity-routes";
|
|
12
|
-
import { getNetworkDiagnosticsConsumer } from "../screens/network-viewer/network-viewer-ipc";
|
|
13
|
-
import { networkViewerSection } from "../screens/network-viewer/network-viewer-section";
|
|
14
|
-
import { goToTabPath } from "./tabs-state";
|
|
15
|
-
import { type INetworkStatusViewState, useNetworkStatus } from "./use-network-status";
|
|
16
|
-
|
|
17
|
-
/** How long continuous raw syncing stays a green pulse before the indeterminate circle. */
|
|
18
|
-
export const SYNCING_GREEN_MS = 4_000;
|
|
19
|
-
|
|
20
|
-
/** How long status must stay fully synced before leaving the syncing visual. */
|
|
21
|
-
export const SYNCED_STABLE_MS = 1_000;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Calm opacity pulse (same feel as kube-tools WatchButton) — not Bootstrap
|
|
25
|
-
* spinner-grow, which scales the mark and reads as noisy in the tabs strip.
|
|
26
|
-
*/
|
|
27
|
-
const PULSE_ANIMATION = "peers-network-pulse-dot 2s ease-in-out infinite";
|
|
28
|
-
|
|
29
|
-
const DOT_SIZE = "0.7rem";
|
|
30
|
-
|
|
31
|
-
type NetworkStatusMark = "solid" | "pulse" | "indeterminate";
|
|
32
|
-
|
|
33
|
-
type ConnectionsLoadState =
|
|
34
|
-
| { status: "idle" }
|
|
35
|
-
| { status: "loading" }
|
|
36
|
-
| { status: "ready"; connections: INetworkConnectionInfo[] }
|
|
37
|
-
| { status: "error" };
|
|
38
|
-
|
|
39
|
-
interface INetworkStatusPresentation {
|
|
40
|
-
label: string;
|
|
41
|
-
shortLabel: string;
|
|
42
|
-
colorClass: string;
|
|
43
|
-
/** Bootstrap Icons class when not using a status mark. */
|
|
44
|
-
iconClass?: string;
|
|
45
|
-
spinning?: boolean;
|
|
46
|
-
/** Size the Bootstrap icon to match the status marks. */
|
|
47
|
-
compactIcon?: boolean;
|
|
48
|
-
/** Solid / pulsing / indeterminate mark (syncing / error). */
|
|
49
|
-
mark?: NetworkStatusMark;
|
|
50
|
-
/**
|
|
51
|
-
* Bottom-right count of sync contexts that have known sync peers but no live connection.
|
|
52
|
-
* Warning/yellow when shown; hidden when offline or count is 0.
|
|
53
|
-
*/
|
|
54
|
-
disconnectedGroupsOverlay?: { count: number };
|
|
55
|
-
/**
|
|
56
|
-
* Top-right connected-groups count when the device has active connections.
|
|
57
|
-
* Green when > 0; red zero when connected devices exist but no groups are live.
|
|
58
|
-
*/
|
|
59
|
-
connectedGroupsOverlay?: { count: number; colorClass: "text-success" | "text-danger" };
|
|
60
|
-
/**
|
|
61
|
-
* Yellow upgrade arrow on the lower-left corner of the status mark when this device
|
|
62
|
-
* has an app update available. Kept on the mark so it does not hang below the tab strip.
|
|
63
|
-
*/
|
|
64
|
-
updateAvailableOverlay?: boolean;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function disconnectedLabelSuffix(disconnectedContextCount: number): string {
|
|
68
|
-
return `; ${disconnectedContextCount} ${disconnectedContextCount === 1 ? "group" : "groups"} without a connection`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function connectedLabelSuffix(connectedContextCount: number): string {
|
|
72
|
-
return `; ${connectedContextCount} ${connectedContextCount === 1 ? "group" : "groups"} connected`;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function withStuckAttention(
|
|
76
|
-
presentation: INetworkStatusPresentation,
|
|
77
|
-
stuckRecoveryCount: number,
|
|
78
|
-
): INetworkStatusPresentation {
|
|
79
|
-
if (stuckRecoveryCount <= 0) {
|
|
80
|
-
return presentation;
|
|
81
|
-
}
|
|
82
|
-
const attention =
|
|
83
|
-
stuckRecoveryCount === 1
|
|
84
|
-
? "1 record needs attention"
|
|
85
|
-
: `${stuckRecoveryCount} records need attention`;
|
|
86
|
-
const labeled = { ...presentation, label: `${presentation.label}; ${attention}` };
|
|
87
|
-
if (presentation.colorClass === "text-danger") {
|
|
88
|
-
return labeled;
|
|
89
|
-
}
|
|
90
|
-
return { ...labeled, colorClass: "text-warning" };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function connectedGroupsOverlay(
|
|
94
|
-
connectionCount: number,
|
|
95
|
-
connectedContextCount: number,
|
|
96
|
-
): INetworkStatusPresentation["connectedGroupsOverlay"] {
|
|
97
|
-
if (connectionCount <= 0) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
count: connectedContextCount,
|
|
102
|
-
colorClass: connectedContextCount > 0 ? "text-success" : "text-danger",
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** Convert host availability and network state into accessible indicator text and styling. */
|
|
107
|
-
export function getNetworkStatusPresentation(
|
|
108
|
-
viewState: INetworkStatusViewState,
|
|
109
|
-
opts?: {
|
|
110
|
-
syncingLongerThanGreenMs?: boolean;
|
|
111
|
-
/** Keep the calm green syncing pulse while waiting for stable synced. */
|
|
112
|
-
holdSyncingVisual?: boolean;
|
|
113
|
-
},
|
|
114
|
-
): INetworkStatusPresentation {
|
|
115
|
-
if (viewState.availability === "loading") {
|
|
116
|
-
return {
|
|
117
|
-
label: "Network status loading",
|
|
118
|
-
shortLabel: "Loading",
|
|
119
|
-
iconClass: "bi-arrow-repeat",
|
|
120
|
-
colorClass: "text-secondary",
|
|
121
|
-
spinning: true,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
if (viewState.availability === "unavailable" || !viewState.status) {
|
|
125
|
-
return {
|
|
126
|
-
label: "Network status unavailable",
|
|
127
|
-
shortLabel: "Unavailable",
|
|
128
|
-
iconClass: "bi-question-circle",
|
|
129
|
-
colorClass: "text-secondary",
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
const {
|
|
133
|
-
connectedContextCount,
|
|
134
|
-
connectionCount,
|
|
135
|
-
disconnectedContextCount,
|
|
136
|
-
errorCount,
|
|
137
|
-
state,
|
|
138
|
-
stuckRecoveryCount,
|
|
139
|
-
syncingContextCount,
|
|
140
|
-
} = viewState.status;
|
|
141
|
-
const disconnectedOverlay =
|
|
142
|
-
disconnectedContextCount > 0 && state !== "offline"
|
|
143
|
-
? { count: disconnectedContextCount }
|
|
144
|
-
: undefined;
|
|
145
|
-
const disconnectedSuffix = disconnectedOverlay
|
|
146
|
-
? disconnectedLabelSuffix(disconnectedContextCount)
|
|
147
|
-
: "";
|
|
148
|
-
const groupsOverlay = connectedGroupsOverlay(connectionCount, connectedContextCount);
|
|
149
|
-
const connectedSuffix = groupsOverlay ? connectedLabelSuffix(connectedContextCount) : "";
|
|
150
|
-
if (state === "error") {
|
|
151
|
-
return withStuckAttention(
|
|
152
|
-
{
|
|
153
|
-
label: `Network error; ${errorCount} sync ${errorCount === 1 ? "error" : "errors"}; ${connectionCount} active ${connectionCount === 1 ? "connection" : "connections"}${connectedSuffix}${disconnectedSuffix}`,
|
|
154
|
-
shortLabel: "Error",
|
|
155
|
-
colorClass: "text-danger",
|
|
156
|
-
mark: "solid",
|
|
157
|
-
disconnectedGroupsOverlay: disconnectedOverlay,
|
|
158
|
-
connectedGroupsOverlay: groupsOverlay,
|
|
159
|
-
},
|
|
160
|
-
stuckRecoveryCount,
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
if (state === "syncing" || opts?.holdSyncingVisual) {
|
|
164
|
-
const longSync = state === "syncing" && opts?.syncingLongerThanGreenMs === true;
|
|
165
|
-
const contextsLabel =
|
|
166
|
-
state === "syncing"
|
|
167
|
-
? `${syncingContextCount} ${syncingContextCount === 1 ? "context" : "contexts"}`
|
|
168
|
-
: "recent activity";
|
|
169
|
-
return withStuckAttention(
|
|
170
|
-
{
|
|
171
|
-
label: `Network syncing ${contextsLabel}; ${connectionCount} active ${connectionCount === 1 ? "connection" : "connections"}${connectedSuffix}${disconnectedSuffix}`,
|
|
172
|
-
shortLabel: "Syncing",
|
|
173
|
-
colorClass: longSync ? "text-primary" : "text-success",
|
|
174
|
-
mark: longSync ? "indeterminate" : "pulse",
|
|
175
|
-
disconnectedGroupsOverlay: disconnectedOverlay,
|
|
176
|
-
connectedGroupsOverlay: groupsOverlay,
|
|
177
|
-
},
|
|
178
|
-
stuckRecoveryCount,
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
if (state === "offline") {
|
|
182
|
-
return withStuckAttention(
|
|
183
|
-
{
|
|
184
|
-
label: "Network offline; no active connections",
|
|
185
|
-
shortLabel: "Offline",
|
|
186
|
-
iconClass: "bi-cloud-slash-fill",
|
|
187
|
-
colorClass: "text-secondary",
|
|
188
|
-
},
|
|
189
|
-
stuckRecoveryCount,
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
return withStuckAttention(
|
|
193
|
-
{
|
|
194
|
-
label: `Network synced; ${connectionCount} active ${connectionCount === 1 ? "connection" : "connections"}${connectedSuffix}${disconnectedSuffix}`,
|
|
195
|
-
shortLabel: "Synced",
|
|
196
|
-
iconClass: "bi-check-circle-fill",
|
|
197
|
-
colorClass: "text-success",
|
|
198
|
-
compactIcon: true,
|
|
199
|
-
disconnectedGroupsOverlay: disconnectedOverlay,
|
|
200
|
-
connectedGroupsOverlay: groupsOverlay,
|
|
201
|
-
},
|
|
202
|
-
stuckRecoveryCount,
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Add the app-update badge and label to a network status presentation. Applies in every
|
|
208
|
-
* network state, offline included, because installing does not depend on connectivity.
|
|
209
|
-
*
|
|
210
|
-
* @param presentation - Presentation from {@link getNetworkStatusPresentation}.
|
|
211
|
-
* @param appUpdate - This device's update status, if known.
|
|
212
|
-
* @returns The presentation, with `updateAvailableOverlay` when an update is available.
|
|
213
|
-
*/
|
|
214
|
-
export function withAppUpdate(
|
|
215
|
-
presentation: INetworkStatusPresentation,
|
|
216
|
-
appUpdate: IAppUpdateStatus | undefined,
|
|
217
|
-
): INetworkStatusPresentation {
|
|
218
|
-
if (!appUpdate?.supported || !hasAppUpdate(appUpdate)) {
|
|
219
|
-
return presentation;
|
|
220
|
-
}
|
|
221
|
-
return {
|
|
222
|
-
...presentation,
|
|
223
|
-
label: `${presentation.label}; ${describeAppUpdateStatus(appUpdate)}`,
|
|
224
|
-
updateAvailableOverlay: true,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function statusMarkBgClass(colorClass: string): string {
|
|
229
|
-
if (colorClass === "text-danger") {
|
|
230
|
-
return "bg-danger";
|
|
231
|
-
}
|
|
232
|
-
if (colorClass === "text-primary") {
|
|
233
|
-
return "bg-primary";
|
|
234
|
-
}
|
|
235
|
-
if (colorClass === "text-warning") {
|
|
236
|
-
return "bg-warning";
|
|
237
|
-
}
|
|
238
|
-
return "bg-success";
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function StatusMark({ mode, colorClass }: { mode: NetworkStatusMark; colorClass: string }) {
|
|
242
|
-
if (mode === "indeterminate") {
|
|
243
|
-
return (
|
|
244
|
-
<span
|
|
245
|
-
className={`spinner-border spinner-border-sm ${colorClass}`}
|
|
246
|
-
style={{ width: DOT_SIZE, height: DOT_SIZE, borderWidth: "0.12em" }}
|
|
247
|
-
aria-hidden="true"
|
|
248
|
-
/>
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const bgClass = statusMarkBgClass(colorClass);
|
|
253
|
-
if (mode === "pulse") {
|
|
254
|
-
return (
|
|
255
|
-
<>
|
|
256
|
-
<span
|
|
257
|
-
className={`network-status-pulse-dot rounded-circle ${bgClass}`}
|
|
258
|
-
style={{
|
|
259
|
-
width: DOT_SIZE,
|
|
260
|
-
height: DOT_SIZE,
|
|
261
|
-
display: "inline-block",
|
|
262
|
-
animation: PULSE_ANIMATION,
|
|
263
|
-
}}
|
|
264
|
-
aria-hidden="true"
|
|
265
|
-
/>
|
|
266
|
-
<style>{`
|
|
267
|
-
@keyframes peers-network-pulse-dot {
|
|
268
|
-
0%, 100% { opacity: 1; }
|
|
269
|
-
50% { opacity: 0.4; }
|
|
270
|
-
}
|
|
271
|
-
`}</style>
|
|
272
|
-
</>
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return (
|
|
277
|
-
<span
|
|
278
|
-
className={`rounded-circle ${bgClass}`}
|
|
279
|
-
style={{ width: DOT_SIZE, height: DOT_SIZE, display: "inline-block" }}
|
|
280
|
-
aria-hidden="true"
|
|
281
|
-
/>
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/** Compact relative time for the status popover (always short enough for one line). */
|
|
286
|
-
export function formatRelativeSyncTime(timestampMs: number, nowMs = Date.now()): string {
|
|
287
|
-
const then = moment(timestampMs);
|
|
288
|
-
const now = moment(nowMs);
|
|
289
|
-
if (now.diff(then, "seconds") < 45) {
|
|
290
|
-
return "now";
|
|
291
|
-
}
|
|
292
|
-
if (now.clone().subtract(1, "day").isSame(then, "day")) {
|
|
293
|
-
return "yesterday";
|
|
294
|
-
}
|
|
295
|
-
return then.from(now);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function middleEllipsis(value: string, head = 4, tail = 4): string {
|
|
299
|
-
if (value.length <= head + tail + 1) {
|
|
300
|
-
return value;
|
|
301
|
-
}
|
|
302
|
-
return `${value.slice(0, head)}…${value.slice(-tail)}`;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/** Prefer a friendly name; otherwise a compact middle-ellipsis of the id. */
|
|
306
|
-
export function connectionIdentityLabel(
|
|
307
|
-
name: string | undefined,
|
|
308
|
-
id: string,
|
|
309
|
-
): { text: string; isId: boolean; title: string } {
|
|
310
|
-
const trimmed = name?.trim();
|
|
311
|
-
if (trimmed) {
|
|
312
|
-
return { text: trimmed, isId: false, title: trimmed };
|
|
313
|
-
}
|
|
314
|
-
return { text: middleEllipsis(id), isId: true, title: id };
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function IdentityPart({ label }: { label: { text: string; isId: boolean; title: string } }) {
|
|
318
|
-
return (
|
|
319
|
-
<span
|
|
320
|
-
className={`text-truncate ${label.isId ? "text-muted" : ""}`}
|
|
321
|
-
style={{
|
|
322
|
-
minWidth: 0,
|
|
323
|
-
...(label.isId ? { fontSize: "0.7rem" } : undefined),
|
|
324
|
-
}}
|
|
325
|
-
title={label.title}
|
|
326
|
-
>
|
|
327
|
-
{label.text}
|
|
328
|
-
</span>
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function ConnectedDeviceRow({ connection }: { connection: INetworkConnectionInfo }) {
|
|
333
|
-
const user = connectionIdentityLabel(connection.userName, connection.userId);
|
|
334
|
-
const device = connectionIdentityLabel(connection.deviceName, connection.deviceId);
|
|
335
|
-
const groupCount = connection.sharedGroups.length;
|
|
336
|
-
|
|
337
|
-
return (
|
|
338
|
-
<li
|
|
339
|
-
className="d-flex align-items-baseline gap-1 py-1"
|
|
340
|
-
style={{ listStyle: "none", minWidth: 0 }}
|
|
341
|
-
>
|
|
342
|
-
<IdentityPart label={user} />
|
|
343
|
-
<span className="text-muted flex-shrink-0" aria-hidden="true">
|
|
344
|
-
·
|
|
345
|
-
</span>
|
|
346
|
-
<IdentityPart label={device} />
|
|
347
|
-
{groupCount > 0 && (
|
|
348
|
-
<span
|
|
349
|
-
className="text-muted flex-shrink-0 ms-auto"
|
|
350
|
-
style={{ fontSize: "0.7rem" }}
|
|
351
|
-
title={`${groupCount} ${groupCount === 1 ? "group" : "groups"}`}
|
|
352
|
-
>
|
|
353
|
-
{groupCount}g
|
|
354
|
-
</span>
|
|
355
|
-
)}
|
|
356
|
-
</li>
|
|
357
|
-
);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function ConnectedDevicesList({ loadState }: { loadState: ConnectionsLoadState }) {
|
|
361
|
-
if (loadState.status === "idle" || loadState.status === "loading") {
|
|
362
|
-
return <p className="small text-muted mb-2">Loading…</p>;
|
|
363
|
-
}
|
|
364
|
-
if (loadState.status === "error") {
|
|
365
|
-
return <p className="small text-muted mb-2">Couldn't load devices</p>;
|
|
366
|
-
}
|
|
367
|
-
if (loadState.connections.length === 0) {
|
|
368
|
-
return <p className="small text-muted mb-2">No connected devices</p>;
|
|
369
|
-
}
|
|
370
|
-
return (
|
|
371
|
-
<ul className="small mb-0 ps-0" style={{ maxHeight: "180px", overflowY: "auto" }}>
|
|
372
|
-
{loadState.connections.map((connection) => (
|
|
373
|
-
<ConnectedDeviceRow key={connection.deviceId} connection={connection} />
|
|
374
|
-
))}
|
|
375
|
-
</ul>
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function StatusCountRow({
|
|
380
|
-
label,
|
|
381
|
-
value,
|
|
382
|
-
className,
|
|
383
|
-
}: {
|
|
384
|
-
label: string;
|
|
385
|
-
value: number;
|
|
386
|
-
className?: string;
|
|
387
|
-
}) {
|
|
388
|
-
const tone = className ? ` ${className}` : "";
|
|
389
|
-
return (
|
|
390
|
-
<>
|
|
391
|
-
<dt className={`col-7${tone}`}>{label}</dt>
|
|
392
|
-
<dd className={`col-5 text-end${tone}`}>{value}</dd>
|
|
393
|
-
</>
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function NetworkStatusDetails({
|
|
398
|
-
detailsId,
|
|
399
|
-
status,
|
|
400
|
-
appUpdate,
|
|
401
|
-
unavailable,
|
|
402
|
-
connectionsLoadState,
|
|
403
|
-
onUseInvite,
|
|
404
|
-
onOpenIdentity,
|
|
405
|
-
onOpenViewer,
|
|
406
|
-
onOpenRecovery,
|
|
407
|
-
}: {
|
|
408
|
-
detailsId: string;
|
|
409
|
-
status?: INetworkStatusSummary;
|
|
410
|
-
appUpdate?: IAppUpdateStatus;
|
|
411
|
-
unavailable: boolean;
|
|
412
|
-
connectionsLoadState: ConnectionsLoadState;
|
|
413
|
-
onUseInvite: () => void;
|
|
414
|
-
onOpenIdentity: () => void;
|
|
415
|
-
onOpenViewer: () => void;
|
|
416
|
-
onOpenRecovery: () => void;
|
|
417
|
-
}) {
|
|
418
|
-
return (
|
|
419
|
-
<div
|
|
420
|
-
id={detailsId}
|
|
421
|
-
role="dialog"
|
|
422
|
-
aria-label="Network status details"
|
|
423
|
-
className="card shadow position-absolute end-0 mt-1"
|
|
424
|
-
style={{ top: "100%", width: "320px", zIndex: 1100 }}
|
|
425
|
-
>
|
|
426
|
-
<div className="card-body p-3">
|
|
427
|
-
<div className="d-flex gap-2 mb-3">
|
|
428
|
-
<button
|
|
429
|
-
type="button"
|
|
430
|
-
className="btn btn-sm btn-outline-primary flex-fill"
|
|
431
|
-
onClick={onUseInvite}
|
|
432
|
-
>
|
|
433
|
-
<i className="bi bi-qr-code me-1" aria-hidden="true" />
|
|
434
|
-
Use Invite
|
|
435
|
-
</button>
|
|
436
|
-
<button
|
|
437
|
-
type="button"
|
|
438
|
-
className="btn btn-sm btn-outline-primary flex-fill"
|
|
439
|
-
onClick={onOpenIdentity}
|
|
440
|
-
>
|
|
441
|
-
<i className="bi bi-person-badge me-1" aria-hidden="true" />
|
|
442
|
-
Identity
|
|
443
|
-
</button>
|
|
444
|
-
</div>
|
|
445
|
-
<AppUpdatePopoverSection status={appUpdate} />
|
|
446
|
-
<h6 className="card-title mb-2">Network status</h6>
|
|
447
|
-
{unavailable || !status ? (
|
|
448
|
-
<p className="small text-muted mb-3">
|
|
449
|
-
Network diagnostics are temporarily unavailable. The local host may still be starting or
|
|
450
|
-
reconnecting.
|
|
451
|
-
</p>
|
|
452
|
-
) : (
|
|
453
|
-
<>
|
|
454
|
-
<dl className="row small mb-2">
|
|
455
|
-
<StatusCountRow label="Connections" value={status.connectionCount} />
|
|
456
|
-
<StatusCountRow label="Groups connected" value={status.connectedContextCount} />
|
|
457
|
-
{status.syncingContextCount > 0 && (
|
|
458
|
-
<StatusCountRow label="Syncing contexts" value={status.syncingContextCount} />
|
|
459
|
-
)}
|
|
460
|
-
{status.disconnectedContextCount > 0 && (
|
|
461
|
-
<StatusCountRow
|
|
462
|
-
label="Groups offline"
|
|
463
|
-
value={status.disconnectedContextCount}
|
|
464
|
-
className="text-warning"
|
|
465
|
-
/>
|
|
466
|
-
)}
|
|
467
|
-
{status.errorCount > 0 && (
|
|
468
|
-
<StatusCountRow label="Sync errors" value={status.errorCount} />
|
|
469
|
-
)}
|
|
470
|
-
{status.lastSuccessfulSyncAt != null && (
|
|
471
|
-
<>
|
|
472
|
-
<dt className="col-7">Last sync</dt>
|
|
473
|
-
<dd
|
|
474
|
-
className="col-5 text-end text-truncate"
|
|
475
|
-
title={new Date(status.lastSuccessfulSyncAt).toLocaleString()}
|
|
476
|
-
>
|
|
477
|
-
{formatRelativeSyncTime(status.lastSuccessfulSyncAt)}
|
|
478
|
-
</dd>
|
|
479
|
-
</>
|
|
480
|
-
)}
|
|
481
|
-
</dl>
|
|
482
|
-
{status.errors.length > 0 && (
|
|
483
|
-
<div className="alert alert-danger py-2 px-2 small mb-2">
|
|
484
|
-
{status.errors[0].message}
|
|
485
|
-
{status.errors.length > 1 && ` (+${status.errors.length - 1} more)`}
|
|
486
|
-
</div>
|
|
487
|
-
)}
|
|
488
|
-
{status.stuckRecoveryCount > 0 && (
|
|
489
|
-
<div className="alert alert-warning py-2 px-2 small mb-2">
|
|
490
|
-
{status.stuckRecoveryCount === 1
|
|
491
|
-
? "1 record needs attention"
|
|
492
|
-
: `${status.stuckRecoveryCount} records need attention`}
|
|
493
|
-
</div>
|
|
494
|
-
)}
|
|
495
|
-
<div className="border-top pt-2 mt-1 mb-2">
|
|
496
|
-
<div className="small text-muted mb-1">Connected Devices</div>
|
|
497
|
-
<ConnectedDevicesList loadState={connectionsLoadState} />
|
|
498
|
-
</div>
|
|
499
|
-
</>
|
|
500
|
-
)}
|
|
501
|
-
<button
|
|
502
|
-
type="button"
|
|
503
|
-
className={`btn btn-sm btn-outline-primary w-100${status && status.stuckRecoveryCount > 0 ? " mb-2" : ""}`}
|
|
504
|
-
onClick={onOpenViewer}
|
|
505
|
-
>
|
|
506
|
-
Open Network Viewer
|
|
507
|
-
</button>
|
|
508
|
-
{status && status.stuckRecoveryCount > 0 && (
|
|
509
|
-
<button type="button" className="btn btn-sm btn-warning w-100" onClick={onOpenRecovery}>
|
|
510
|
-
Sync recovery
|
|
511
|
-
</button>
|
|
512
|
-
)}
|
|
513
|
-
</div>
|
|
514
|
-
</div>
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/** Accessible reactive network status button and details popover. */
|
|
519
|
-
export function NetworkStatusIndicator({ compact = false }: { compact?: boolean }) {
|
|
520
|
-
const viewState = useNetworkStatus();
|
|
521
|
-
const appUpdate = useAppUpdateStatus();
|
|
522
|
-
const [displaySyncing, setDisplaySyncing] = useState(false);
|
|
523
|
-
const [syncingLongerThanGreenMs, setSyncingLongerThanGreenMs] = useState(false);
|
|
524
|
-
const [open, setOpen] = useState(false);
|
|
525
|
-
const [connectionsLoadState, setConnectionsLoadState] = useState<ConnectionsLoadState>({
|
|
526
|
-
status: "idle",
|
|
527
|
-
});
|
|
528
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
529
|
-
const detailsId = useId();
|
|
530
|
-
|
|
531
|
-
const rawState = viewState.availability === "ready" ? viewState.status?.state : undefined;
|
|
532
|
-
const rawIsSyncing = rawState === "syncing";
|
|
533
|
-
const rawIsSynced = rawState === "synced";
|
|
534
|
-
const connectionCount = viewState.status?.connectionCount;
|
|
535
|
-
const diagnosticsReady = viewState.availability === "ready";
|
|
536
|
-
|
|
537
|
-
useEffect(() => {
|
|
538
|
-
if (rawIsSyncing) {
|
|
539
|
-
setDisplaySyncing(true);
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
if (rawIsSynced) {
|
|
543
|
-
if (!displaySyncing) {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
const timer = window.setTimeout(() => {
|
|
547
|
-
setDisplaySyncing(false);
|
|
548
|
-
}, SYNCED_STABLE_MS);
|
|
549
|
-
return () => {
|
|
550
|
-
window.clearTimeout(timer);
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
setDisplaySyncing(false);
|
|
554
|
-
}, [rawIsSyncing, rawIsSynced, displaySyncing]);
|
|
555
|
-
|
|
556
|
-
useEffect(() => {
|
|
557
|
-
if (!rawIsSyncing) {
|
|
558
|
-
setSyncingLongerThanGreenMs(false);
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
const timer = window.setTimeout(() => {
|
|
562
|
-
setSyncingLongerThanGreenMs(true);
|
|
563
|
-
}, SYNCING_GREEN_MS);
|
|
564
|
-
return () => {
|
|
565
|
-
window.clearTimeout(timer);
|
|
566
|
-
};
|
|
567
|
-
}, [rawIsSyncing]);
|
|
568
|
-
|
|
569
|
-
useEffect(() => {
|
|
570
|
-
if (!open || !diagnosticsReady) {
|
|
571
|
-
setConnectionsLoadState({ status: "idle" });
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
let active = true;
|
|
575
|
-
setConnectionsLoadState({ status: "loading" });
|
|
576
|
-
void getNetworkDiagnosticsConsumer()
|
|
577
|
-
.then((diagnostics) => diagnostics.tools.getConnections())
|
|
578
|
-
.then((result) => {
|
|
579
|
-
if (active) {
|
|
580
|
-
setConnectionsLoadState({ status: "ready", connections: result.connections });
|
|
581
|
-
}
|
|
582
|
-
})
|
|
583
|
-
.catch(() => {
|
|
584
|
-
if (active) {
|
|
585
|
-
setConnectionsLoadState({ status: "error" });
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
return () => {
|
|
589
|
-
active = false;
|
|
590
|
-
};
|
|
591
|
-
}, [open, diagnosticsReady, connectionCount]);
|
|
592
|
-
|
|
593
|
-
const holdSyncingVisual = displaySyncing && !rawIsSyncing;
|
|
594
|
-
const presentation = withAppUpdate(
|
|
595
|
-
getNetworkStatusPresentation(viewState, {
|
|
596
|
-
syncingLongerThanGreenMs,
|
|
597
|
-
holdSyncingVisual,
|
|
598
|
-
}),
|
|
599
|
-
appUpdate,
|
|
600
|
-
);
|
|
601
|
-
|
|
602
|
-
useEffect(() => {
|
|
603
|
-
if (!open) {
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
const closeOutside = (event: MouseEvent) => {
|
|
607
|
-
if (!containerRef.current?.contains(event.target as Node)) {
|
|
608
|
-
setOpen(false);
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
const closeOnEscape = (event: KeyboardEvent) => {
|
|
612
|
-
if (event.key === "Escape") {
|
|
613
|
-
setOpen(false);
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
|
-
document.addEventListener("mousedown", closeOutside);
|
|
617
|
-
document.addEventListener("keydown", closeOnEscape);
|
|
618
|
-
return () => {
|
|
619
|
-
document.removeEventListener("mousedown", closeOutside);
|
|
620
|
-
document.removeEventListener("keydown", closeOnEscape);
|
|
621
|
-
};
|
|
622
|
-
}, [open]);
|
|
623
|
-
|
|
624
|
-
return (
|
|
625
|
-
<div ref={containerRef} className="position-relative d-flex align-items-center">
|
|
626
|
-
<button
|
|
627
|
-
type="button"
|
|
628
|
-
className={`btn btn-sm d-flex align-items-center gap-1 px-2 ${presentation.colorClass}`}
|
|
629
|
-
style={{
|
|
630
|
-
border: "none",
|
|
631
|
-
background: "transparent",
|
|
632
|
-
minWidth: compact ? "30px" : undefined,
|
|
633
|
-
}}
|
|
634
|
-
aria-label={presentation.label}
|
|
635
|
-
aria-expanded={open}
|
|
636
|
-
aria-controls={detailsId}
|
|
637
|
-
title={presentation.label}
|
|
638
|
-
onClick={() => setOpen((current) => !current)}
|
|
639
|
-
>
|
|
640
|
-
<span className="position-relative d-inline-flex align-items-center justify-content-center">
|
|
641
|
-
{presentation.mark ? (
|
|
642
|
-
<StatusMark mode={presentation.mark} colorClass={presentation.colorClass} />
|
|
643
|
-
) : (
|
|
644
|
-
<i
|
|
645
|
-
className={`bi ${presentation.iconClass} ${presentation.spinning ? "spin" : ""}`}
|
|
646
|
-
style={
|
|
647
|
-
presentation.compactIcon
|
|
648
|
-
? { fontSize: DOT_SIZE, lineHeight: 1, display: "inline-block" }
|
|
649
|
-
: undefined
|
|
650
|
-
}
|
|
651
|
-
aria-hidden="true"
|
|
652
|
-
/>
|
|
653
|
-
)}
|
|
654
|
-
{presentation.connectedGroupsOverlay && (
|
|
655
|
-
<span
|
|
656
|
-
className={`network-status-connected-count position-absolute ${presentation.connectedGroupsOverlay.colorClass}`}
|
|
657
|
-
style={{
|
|
658
|
-
fontSize: "0.45rem",
|
|
659
|
-
lineHeight: 1,
|
|
660
|
-
fontWeight: 700,
|
|
661
|
-
right: "-0.22rem",
|
|
662
|
-
top: "-0.32rem",
|
|
663
|
-
}}
|
|
664
|
-
aria-hidden="true"
|
|
665
|
-
>
|
|
666
|
-
{presentation.connectedGroupsOverlay.count}
|
|
667
|
-
</span>
|
|
668
|
-
)}
|
|
669
|
-
{presentation.disconnectedGroupsOverlay && (
|
|
670
|
-
<span
|
|
671
|
-
className="network-status-disconnected-count text-warning position-absolute"
|
|
672
|
-
style={{
|
|
673
|
-
fontSize: "0.45rem",
|
|
674
|
-
lineHeight: 1,
|
|
675
|
-
fontWeight: 700,
|
|
676
|
-
right: "-0.28rem",
|
|
677
|
-
bottom: "-0.32rem",
|
|
678
|
-
}}
|
|
679
|
-
aria-hidden="true"
|
|
680
|
-
>
|
|
681
|
-
{presentation.disconnectedGroupsOverlay.count}
|
|
682
|
-
</span>
|
|
683
|
-
)}
|
|
684
|
-
{presentation.updateAvailableOverlay && (
|
|
685
|
-
<>
|
|
686
|
-
<i
|
|
687
|
-
className={`network-status-update-badge bi ${APP_UPDATE_ICON_CLASS} text-warning position-absolute`}
|
|
688
|
-
style={{
|
|
689
|
-
fontSize: "0.5rem",
|
|
690
|
-
lineHeight: 1,
|
|
691
|
-
width: "0.5rem",
|
|
692
|
-
height: "0.5rem",
|
|
693
|
-
left: "-0.46rem",
|
|
694
|
-
bottom: "-0.08rem",
|
|
695
|
-
}}
|
|
696
|
-
aria-hidden="true"
|
|
697
|
-
/>
|
|
698
|
-
{/* Bootstrap Icons shift the glyph below the em box; keep it inside this badge. */}
|
|
699
|
-
<style>{`
|
|
700
|
-
.network-status-update-badge.bi::before {
|
|
701
|
-
vertical-align: 0;
|
|
702
|
-
}
|
|
703
|
-
`}</style>
|
|
704
|
-
</>
|
|
705
|
-
)}
|
|
706
|
-
</span>
|
|
707
|
-
{!compact && (
|
|
708
|
-
<span className="small">
|
|
709
|
-
{viewState.status?.connectionCount ?? 0}
|
|
710
|
-
<span className="visually-hidden"> connections</span>
|
|
711
|
-
</span>
|
|
712
|
-
)}
|
|
713
|
-
</button>
|
|
714
|
-
{open && (
|
|
715
|
-
<NetworkStatusDetails
|
|
716
|
-
detailsId={detailsId}
|
|
717
|
-
status={viewState.status}
|
|
718
|
-
appUpdate={appUpdate}
|
|
719
|
-
unavailable={viewState.availability !== "ready"}
|
|
720
|
-
connectionsLoadState={connectionsLoadState}
|
|
721
|
-
onUseInvite={() => {
|
|
722
|
-
setOpen(false);
|
|
723
|
-
goToTabPath(IDENTITY_ACCEPT_PATH);
|
|
724
|
-
}}
|
|
725
|
-
onOpenIdentity={() => {
|
|
726
|
-
setOpen(false);
|
|
727
|
-
goToTabPath(IDENTITY_ACCOUNT_PATH);
|
|
728
|
-
}}
|
|
729
|
-
onOpenViewer={() => {
|
|
730
|
-
setOpen(false);
|
|
731
|
-
networkViewerSection("main");
|
|
732
|
-
goToTabPath("network-viewer");
|
|
733
|
-
}}
|
|
734
|
-
onOpenRecovery={() => {
|
|
735
|
-
setOpen(false);
|
|
736
|
-
networkViewerSection("sync-recovery");
|
|
737
|
-
goToTabPath("network-viewer");
|
|
738
|
-
}}
|
|
739
|
-
/>
|
|
740
|
-
)}
|
|
741
|
-
</div>
|
|
742
|
-
);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
/** Fixed tabs-strip area for built-in shell indicators. */
|
|
746
|
-
export function TabsStripIndicators({ compact = false }: { compact?: boolean }) {
|
|
747
|
-
return (
|
|
748
|
-
<div
|
|
749
|
-
className="d-flex align-items-center flex-shrink-0"
|
|
750
|
-
role="group"
|
|
751
|
-
aria-label="Application status"
|
|
752
|
-
>
|
|
753
|
-
<NetworkStatusIndicator compact={compact} />
|
|
754
|
-
</div>
|
|
755
|
-
);
|
|
756
|
-
}
|