@peers-app/peers-ui 0.27.3 → 0.27.4
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/network-viewer-ipc.d.ts +3 -1
- 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,365 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Devices,
|
|
3
|
-
DISPLAY_NAME_MAX_LENGTH,
|
|
4
|
-
getUserContext,
|
|
5
|
-
type IDevice,
|
|
6
|
-
type INetworkConnectionInfo,
|
|
7
|
-
TrustLevel,
|
|
8
|
-
thisDeviceId,
|
|
9
|
-
} from "@peers-app/peers-sdk";
|
|
10
|
-
import { useEffect, useState } from "react";
|
|
11
|
-
import { RemoteAppUpdatePanel } from "../../app-updates/remote-app-update-panel";
|
|
12
|
-
import { Input } from "../../components/input";
|
|
13
|
-
import { LoadingIndicator } from "../../components/loading-indicator";
|
|
14
|
-
import { mainContentPath } from "../../globals";
|
|
15
|
-
import { useObservable, useObservableState, usePromise } from "../../hooks";
|
|
16
|
-
import { SourceDevicePairing } from "../device-pairing";
|
|
17
|
-
import { IDENTITY_DEVICES_PATH, IDENTITY_PAIR_PATH } from "../identity/identity-routes";
|
|
18
|
-
import { PendingWorkLink } from "../invites/activity-view";
|
|
19
|
-
import {
|
|
20
|
-
getNetworkControlConsumer,
|
|
21
|
-
getNetworkDiagnosticsConsumer,
|
|
22
|
-
} from "../network-viewer/network-viewer-ipc";
|
|
23
|
-
|
|
24
|
-
function trustLabel(level: TrustLevel): string {
|
|
25
|
-
return TrustLevel[level] ?? String(level);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function connectionLabel(connection: INetworkConnectionInfo | undefined): string {
|
|
29
|
-
if (!connection) {
|
|
30
|
-
return "Offline";
|
|
31
|
-
}
|
|
32
|
-
const path =
|
|
33
|
-
connection.pathType === "direct"
|
|
34
|
-
? "direct"
|
|
35
|
-
: connection.pathType === "indirect"
|
|
36
|
-
? "indirect"
|
|
37
|
-
: "unknown path";
|
|
38
|
-
return `${connection.connectionState} · ${path}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Compact, fully clickable row for one of the signed-in user's devices. */
|
|
42
|
-
export function DeviceRow(props: {
|
|
43
|
-
device: IDevice;
|
|
44
|
-
connection?: INetworkConnectionInfo;
|
|
45
|
-
isThisDevice: boolean;
|
|
46
|
-
}) {
|
|
47
|
-
const connected = props.connection !== undefined;
|
|
48
|
-
return (
|
|
49
|
-
<a
|
|
50
|
-
href={`#${IDENTITY_DEVICES_PATH}/${props.device.deviceId}`}
|
|
51
|
-
className="list-group-item list-group-item-action d-flex align-items-center gap-3 py-3"
|
|
52
|
-
>
|
|
53
|
-
<span
|
|
54
|
-
className="rounded-3 bg-body-secondary d-inline-flex align-items-center justify-content-center flex-shrink-0"
|
|
55
|
-
style={{ width: 44, height: 44 }}
|
|
56
|
-
aria-hidden="true"
|
|
57
|
-
>
|
|
58
|
-
<i className={`bi ${props.isThisDevice ? "bi-laptop-fill" : "bi-laptop"}`} />
|
|
59
|
-
</span>
|
|
60
|
-
<span className="flex-grow-1 overflow-hidden">
|
|
61
|
-
<span className="d-flex align-items-center gap-2 flex-wrap">
|
|
62
|
-
<span className="fw-semibold text-truncate">
|
|
63
|
-
{props.device.name || props.device.reportedName || "Unnamed device"}
|
|
64
|
-
</span>
|
|
65
|
-
{props.isThisDevice ? <span className="badge text-bg-primary">This device</span> : null}
|
|
66
|
-
</span>
|
|
67
|
-
<span className="small text-muted d-block">
|
|
68
|
-
{props.device.lastSeen ? `Seen ${relativeTime(props.device.lastSeen)}` : "Never seen"}
|
|
69
|
-
</span>
|
|
70
|
-
</span>
|
|
71
|
-
<span className={`badge ${connected ? "text-bg-success" : "text-bg-secondary"}`}>
|
|
72
|
-
{connected ? "Online" : "Offline"}
|
|
73
|
-
</span>
|
|
74
|
-
{connected && props.connection?.pathType ? (
|
|
75
|
-
<span className="badge text-bg-light border text-capitalize">
|
|
76
|
-
{props.connection.pathType}
|
|
77
|
-
</span>
|
|
78
|
-
) : null}
|
|
79
|
-
<i className="bi bi-chevron-right text-muted" aria-hidden="true" />
|
|
80
|
-
</a>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function ThisDeviceCard(props: { device: IDevice }) {
|
|
85
|
-
const name = useObservableState(props.device.name ?? "");
|
|
86
|
-
const [nameValue] = useObservable(name);
|
|
87
|
-
const [saving, setSaving] = useState(false);
|
|
88
|
-
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
name(props.device.name ?? "");
|
|
91
|
-
}, [name, props.device.deviceId, props.device.name]);
|
|
92
|
-
|
|
93
|
-
const save = async () => {
|
|
94
|
-
setSaving(true);
|
|
95
|
-
try {
|
|
96
|
-
const userContext = await getUserContext();
|
|
97
|
-
const table = Devices(userContext.userDataContext);
|
|
98
|
-
const next = { ...props.device, name: nameValue.trim() || undefined };
|
|
99
|
-
await table.save(next);
|
|
100
|
-
} catch (err) {
|
|
101
|
-
alert(`Could not save this device: ${(err as Error).message}`);
|
|
102
|
-
} finally {
|
|
103
|
-
setSaving(false);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const dirty = (nameValue ?? "") !== (props.device.name ?? "");
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<div className="card mb-3">
|
|
111
|
-
<div className="card-body">
|
|
112
|
-
<h6 className="card-title">This device</h6>
|
|
113
|
-
<label className="form-label small" htmlFor="this-device-name">
|
|
114
|
-
Name
|
|
115
|
-
</label>
|
|
116
|
-
<div className="input-group">
|
|
117
|
-
<Input
|
|
118
|
-
id="this-device-name"
|
|
119
|
-
value={name}
|
|
120
|
-
className="form-control"
|
|
121
|
-
maxLength={DISPLAY_NAME_MAX_LENGTH}
|
|
122
|
-
placeholder="e.g. My laptop"
|
|
123
|
-
/>
|
|
124
|
-
<button
|
|
125
|
-
type="button"
|
|
126
|
-
className="btn btn-primary"
|
|
127
|
-
disabled={!dirty || saving}
|
|
128
|
-
onClick={() => void save()}
|
|
129
|
-
>
|
|
130
|
-
Save
|
|
131
|
-
</button>
|
|
132
|
-
</div>
|
|
133
|
-
<div className="small text-muted mt-2">
|
|
134
|
-
{trustLabel(props.device.trustLevel)} · {props.device.deviceId}
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** Which devices surface the Identity shell is showing. */
|
|
142
|
-
export type DevicesSectionMode = "list" | "pair" | "detail";
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Devices section of Identity: the account's devices, pairing, or one device.
|
|
146
|
-
*/
|
|
147
|
-
export function DevicesSection(props: { mode?: DevicesSectionMode; deviceId?: string }) {
|
|
148
|
-
const mode = props.mode ?? "list";
|
|
149
|
-
const userContext = usePromise(getUserContext);
|
|
150
|
-
const [thisId] = useObservable(thisDeviceId);
|
|
151
|
-
const [devices, setDevices] = useState<IDevice[] | undefined>();
|
|
152
|
-
const [connections, setConnections] = useState<INetworkConnectionInfo[]>([]);
|
|
153
|
-
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
if (!userContext) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
let disposed = false;
|
|
159
|
-
const table = Devices(userContext.userDataContext);
|
|
160
|
-
const load = async () => {
|
|
161
|
-
const rows = await table.list();
|
|
162
|
-
if (!disposed) {
|
|
163
|
-
setDevices(rows);
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
void load();
|
|
167
|
-
const subscription = table.dataChanged.subscribe(() => {
|
|
168
|
-
void load();
|
|
169
|
-
});
|
|
170
|
-
return () => {
|
|
171
|
-
disposed = true;
|
|
172
|
-
subscription.unsubscribe();
|
|
173
|
-
};
|
|
174
|
-
}, [userContext]);
|
|
175
|
-
|
|
176
|
-
useEffect(() => {
|
|
177
|
-
let disposed = false;
|
|
178
|
-
const load = async () => {
|
|
179
|
-
try {
|
|
180
|
-
const diagnostics = await getNetworkDiagnosticsConsumer();
|
|
181
|
-
const result = await diagnostics.tools.getConnections();
|
|
182
|
-
if (!disposed) {
|
|
183
|
-
setConnections(result.connections);
|
|
184
|
-
}
|
|
185
|
-
} catch {
|
|
186
|
-
if (!disposed) {
|
|
187
|
-
setConnections([]);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
void load();
|
|
192
|
-
const timer = window.setInterval(() => void load(), 5000);
|
|
193
|
-
return () => {
|
|
194
|
-
disposed = true;
|
|
195
|
-
window.clearInterval(timer);
|
|
196
|
-
};
|
|
197
|
-
}, []);
|
|
198
|
-
|
|
199
|
-
if (!userContext || !devices) {
|
|
200
|
-
return <LoadingIndicator />;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const byId = new Map(connections.map((connection) => [connection.deviceId, connection]));
|
|
204
|
-
const accountDevices = devicesForUser(devices, userContext.userId);
|
|
205
|
-
const mine = accountDevices.find((device) => device.deviceId === thisId);
|
|
206
|
-
const others = accountDevices
|
|
207
|
-
.filter((device) => device.deviceId !== thisId)
|
|
208
|
-
.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
209
|
-
|
|
210
|
-
if (mode === "pair") {
|
|
211
|
-
return (
|
|
212
|
-
<div className="container-fluid p-3" style={{ maxWidth: 720 }}>
|
|
213
|
-
<a href={`#${IDENTITY_DEVICES_PATH}`} className="btn btn-link btn-sm px-0 mb-2">
|
|
214
|
-
Back to devices
|
|
215
|
-
</a>
|
|
216
|
-
<SourceDevicePairing onClose={() => mainContentPath(IDENTITY_DEVICES_PATH)} />
|
|
217
|
-
</div>
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (mode === "detail") {
|
|
222
|
-
const device = accountDevices.find((entry) => entry.deviceId === props.deviceId);
|
|
223
|
-
if (!device) {
|
|
224
|
-
return (
|
|
225
|
-
<div className="container-fluid p-3">
|
|
226
|
-
<a href={`#${IDENTITY_DEVICES_PATH}`}>Back to devices</a>
|
|
227
|
-
<p className="mt-3 text-muted">That device is not on this account.</p>
|
|
228
|
-
</div>
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
return (
|
|
232
|
-
<DeviceDetail
|
|
233
|
-
device={device}
|
|
234
|
-
connection={byId.get(device.deviceId)}
|
|
235
|
-
isThisDevice={device.deviceId === thisId}
|
|
236
|
-
/>
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return (
|
|
241
|
-
<div className="container-xxl p-3">
|
|
242
|
-
<div className="mb-3">
|
|
243
|
-
<h4 className="mb-1">
|
|
244
|
-
<i className="bi bi-laptop me-2" />
|
|
245
|
-
My devices
|
|
246
|
-
</h4>
|
|
247
|
-
<div className="small text-muted">
|
|
248
|
-
Installations signed in to this account. Connection diagnostics stay in{" "}
|
|
249
|
-
<a href="#network-viewer">Network Viewer</a>.
|
|
250
|
-
</div>
|
|
251
|
-
</div>
|
|
252
|
-
<PendingWorkLink type="device" />
|
|
253
|
-
<div className="list-group">
|
|
254
|
-
{mine ? (
|
|
255
|
-
<DeviceRow device={mine} connection={byId.get(mine.deviceId)} isThisDevice />
|
|
256
|
-
) : null}
|
|
257
|
-
{others.map((device) => (
|
|
258
|
-
<DeviceRow
|
|
259
|
-
key={device.deviceId}
|
|
260
|
-
device={device}
|
|
261
|
-
connection={byId.get(device.deviceId)}
|
|
262
|
-
isThisDevice={false}
|
|
263
|
-
/>
|
|
264
|
-
))}
|
|
265
|
-
</div>
|
|
266
|
-
{!mine && others.length === 0 ? (
|
|
267
|
-
<div className="border rounded p-4 text-center">
|
|
268
|
-
<i className="bi bi-laptop fs-2 text-muted" />
|
|
269
|
-
<h6 className="mt-2">No devices are registered yet</h6>
|
|
270
|
-
<a href={`#${IDENTITY_PAIR_PATH}`} className="btn btn-primary btn-sm">
|
|
271
|
-
Add a device
|
|
272
|
-
</a>
|
|
273
|
-
</div>
|
|
274
|
-
) : null}
|
|
275
|
-
{mine && others.length === 0 ? (
|
|
276
|
-
<p className="small text-muted mt-3">
|
|
277
|
-
This is your only device. Use <a href={`#${IDENTITY_PAIR_PATH}`}>Add device</a> to sign in
|
|
278
|
-
somewhere else.
|
|
279
|
-
</p>
|
|
280
|
-
) : null}
|
|
281
|
-
</div>
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function DeviceDetail(props: {
|
|
286
|
-
device: IDevice;
|
|
287
|
-
connection?: INetworkConnectionInfo;
|
|
288
|
-
isThisDevice: boolean;
|
|
289
|
-
}) {
|
|
290
|
-
return (
|
|
291
|
-
<div className="container-xxl p-3">
|
|
292
|
-
<a href={`#${IDENTITY_DEVICES_PATH}`} className="btn btn-link btn-sm px-0 mb-2">
|
|
293
|
-
Back to devices
|
|
294
|
-
</a>
|
|
295
|
-
<h4 className="mb-3">{props.device.name || "Unnamed device"}</h4>
|
|
296
|
-
{props.isThisDevice ? <ThisDeviceCard device={props.device} /> : null}
|
|
297
|
-
<dl className="row small mb-3">
|
|
298
|
-
<dt className="col-sm-4">Trust</dt>
|
|
299
|
-
<dd className="col-sm-8">{trustLabel(props.device.trustLevel)}</dd>
|
|
300
|
-
<dt className="col-sm-4">Connection</dt>
|
|
301
|
-
<dd className="col-sm-8">{connectionLabel(props.connection)}</dd>
|
|
302
|
-
<dt className="col-sm-4">Last seen</dt>
|
|
303
|
-
<dd className="col-sm-8">
|
|
304
|
-
{props.device.lastSeen ? new Date(props.device.lastSeen).toLocaleString() : "Unknown"}
|
|
305
|
-
</dd>
|
|
306
|
-
<dt className="col-sm-4">Device ID</dt>
|
|
307
|
-
<dd className="col-sm-8 text-break">{props.device.deviceId}</dd>
|
|
308
|
-
</dl>
|
|
309
|
-
<a href="#network-viewer" className="btn btn-outline-secondary btn-sm me-2">
|
|
310
|
-
Open Network Viewer
|
|
311
|
-
</a>
|
|
312
|
-
{props.isThisDevice ? null : (
|
|
313
|
-
<button
|
|
314
|
-
type="button"
|
|
315
|
-
className="btn btn-outline-danger btn-sm"
|
|
316
|
-
onClick={() => void forgetDevice(props.device)}
|
|
317
|
-
>
|
|
318
|
-
Forget
|
|
319
|
-
</button>
|
|
320
|
-
)}
|
|
321
|
-
{props.isThisDevice ? null : (
|
|
322
|
-
<RemoteAppUpdatePanel deviceId={props.device.deviceId} deviceName={props.device.name} />
|
|
323
|
-
)}
|
|
324
|
-
</div>
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
async function forgetDevice(device: IDevice) {
|
|
329
|
-
const confirmed = confirm(`Forget ${device.name || device.deviceId}?`);
|
|
330
|
-
if (!confirmed) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const control = await getNetworkControlConsumer();
|
|
334
|
-
const result = await control.tools.deleteDevice({ deviceId: device.deviceId });
|
|
335
|
-
if (!result.success) {
|
|
336
|
-
alert(result.message);
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
mainContentPath(IDENTITY_DEVICES_PATH);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/** Keep only devices whose signed-in owner is the requested user. */
|
|
343
|
-
export function devicesForUser(devices: IDevice[], userId: string): IDevice[] {
|
|
344
|
-
return devices.filter((device) => device.userId === userId);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
function relativeTime(value: Date): string {
|
|
348
|
-
const elapsedMs = Math.max(0, Date.now() - new Date(value).getTime());
|
|
349
|
-
const minutes = Math.floor(elapsedMs / 60_000);
|
|
350
|
-
if (minutes < 1) {
|
|
351
|
-
return "just now";
|
|
352
|
-
}
|
|
353
|
-
if (minutes < 60) {
|
|
354
|
-
return `${minutes}m ago`;
|
|
355
|
-
}
|
|
356
|
-
const hours = Math.floor(minutes / 60);
|
|
357
|
-
if (hours < 24) {
|
|
358
|
-
return `${hours}h ago`;
|
|
359
|
-
}
|
|
360
|
-
const days = Math.floor(hours / 24);
|
|
361
|
-
if (days < 30) {
|
|
362
|
-
return `${days}d ago`;
|
|
363
|
-
}
|
|
364
|
-
return new Date(value).toLocaleDateString();
|
|
365
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DevicesSection } from "./devices-list";
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Groups,
|
|
3
|
-
getIconClassName,
|
|
4
|
-
getUserContext,
|
|
5
|
-
type IDoc,
|
|
6
|
-
type IGroup,
|
|
7
|
-
type Observable,
|
|
8
|
-
rpcServerCalls,
|
|
9
|
-
sleep,
|
|
10
|
-
} from "@peers-app/peers-sdk";
|
|
11
|
-
import { Checkbox } from "../../components/checkbox";
|
|
12
|
-
import { Input } from "../../components/input";
|
|
13
|
-
import { LoadingIndicator } from "../../components/loading-indicator";
|
|
14
|
-
import { MarkdownEditorInline } from "../../components/markdown-editor/editor-inline";
|
|
15
|
-
import { SaveButton } from "../../components/save-button";
|
|
16
|
-
import { Tabs } from "../../components/tabs";
|
|
17
|
-
import { usePromise } from "../../hooks";
|
|
18
|
-
import { GroupMembersUI } from "./group-members";
|
|
19
|
-
|
|
20
|
-
interface IProps {
|
|
21
|
-
groupId: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Edit group metadata and manage members and invitations inside Identity. */
|
|
25
|
-
export const GroupDetails = (props: IProps) => {
|
|
26
|
-
const group = usePromise(
|
|
27
|
-
async () => {
|
|
28
|
-
const userContext = await getUserContext();
|
|
29
|
-
const userGroupTable = Groups(userContext.userDataContext);
|
|
30
|
-
const group = await userGroupTable.get(props.groupId);
|
|
31
|
-
if (!group) {
|
|
32
|
-
throw new Error("Group not found");
|
|
33
|
-
}
|
|
34
|
-
const groupDoc = userGroupTable.initDoc(group);
|
|
35
|
-
// saves go to both the group and user db
|
|
36
|
-
groupDoc.save = async () => {
|
|
37
|
-
const groupDataContext = userContext.getDataContext(group.groupId);
|
|
38
|
-
const groupGroupTable = Groups(groupDataContext);
|
|
39
|
-
const groupData = groupDoc.toJS();
|
|
40
|
-
await groupGroupTable.signAndSave(groupData);
|
|
41
|
-
await userGroupTable.signAndSave(groupData);
|
|
42
|
-
return groupDoc.load();
|
|
43
|
-
};
|
|
44
|
-
const originalDelete = groupDoc.delete;
|
|
45
|
-
groupDoc.delete = async () => {
|
|
46
|
-
const deleteResult = await originalDelete();
|
|
47
|
-
userContext.defaultDataContext(userContext.userDataContext);
|
|
48
|
-
await sleep(100);
|
|
49
|
-
await rpcServerCalls.flushDatabases();
|
|
50
|
-
window.location.reload();
|
|
51
|
-
return deleteResult;
|
|
52
|
-
};
|
|
53
|
-
return groupDoc;
|
|
54
|
-
},
|
|
55
|
-
undefined,
|
|
56
|
-
[props.groupId],
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
if (!group) {
|
|
60
|
-
return <LoadingIndicator />;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<div className="container-xxl p-3">
|
|
65
|
-
<div className="d-flex">
|
|
66
|
-
<div>
|
|
67
|
-
<h4>
|
|
68
|
-
<i className={`${getIconClassName(Groups())} me-2`}></i>
|
|
69
|
-
</h4>
|
|
70
|
-
</div>
|
|
71
|
-
<div className="flex-grow-1">
|
|
72
|
-
<h4>
|
|
73
|
-
<Input
|
|
74
|
-
key={group.groupId}
|
|
75
|
-
className="border border-0"
|
|
76
|
-
style={{ width: "100%", outline: "none", backgroundColor: "transparent" }}
|
|
77
|
-
value={group.qs.name}
|
|
78
|
-
/>
|
|
79
|
-
</h4>
|
|
80
|
-
</div>
|
|
81
|
-
<SaveButton key={group.groupId} doc={group} />
|
|
82
|
-
</div>
|
|
83
|
-
|
|
84
|
-
<Tabs
|
|
85
|
-
key={group.groupId}
|
|
86
|
-
tabs={[
|
|
87
|
-
{
|
|
88
|
-
name: "Info",
|
|
89
|
-
content: (
|
|
90
|
-
<div>
|
|
91
|
-
<GroupInfo group={group} />
|
|
92
|
-
</div>
|
|
93
|
-
),
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: "Members",
|
|
97
|
-
content: (
|
|
98
|
-
<div>
|
|
99
|
-
<GroupMembersWrapper groupId={props.groupId} />
|
|
100
|
-
</div>
|
|
101
|
-
),
|
|
102
|
-
},
|
|
103
|
-
]}
|
|
104
|
-
/>
|
|
105
|
-
</div>
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const GroupInfo = (props: { group: IDoc<IGroup> }) => {
|
|
110
|
-
const { group } = props;
|
|
111
|
-
|
|
112
|
-
group.description = group.description || "";
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<div>
|
|
116
|
-
<small>Name:</small>
|
|
117
|
-
<Input
|
|
118
|
-
value={group.qs.name}
|
|
119
|
-
className="form-control mb-3 p-0 ps-2"
|
|
120
|
-
placeholder="Group name"
|
|
121
|
-
title="Group name"
|
|
122
|
-
/>
|
|
123
|
-
|
|
124
|
-
<small>Icon Class Name:</small>
|
|
125
|
-
<Input
|
|
126
|
-
value={group.qs.iconClassName}
|
|
127
|
-
className="form-control mb-3 p-0 ps-2"
|
|
128
|
-
placeholder="bi-people-fill"
|
|
129
|
-
title="Icon class name (e.g., bi-people-fill, bi-house-fill, bi-star-fill)"
|
|
130
|
-
/>
|
|
131
|
-
|
|
132
|
-
<small>Group ID:</small>
|
|
133
|
-
<div
|
|
134
|
-
className="form-control mb-3 p-2 bg-body-secondary text-body-secondary"
|
|
135
|
-
style={{ fontFamily: "monospace", fontSize: "0.9em" }}
|
|
136
|
-
>
|
|
137
|
-
{group.groupId}
|
|
138
|
-
</div>
|
|
139
|
-
|
|
140
|
-
<div className="d-flex flex-row">
|
|
141
|
-
<div className="ms-2">
|
|
142
|
-
<label className="form-label small mt-2 me-2">Disabled:</label>
|
|
143
|
-
<Checkbox className="form-check-input mt-2" checked={group.qs.disabled} />
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
|
|
147
|
-
<br />
|
|
148
|
-
|
|
149
|
-
<small className="mt-2">Description:</small>
|
|
150
|
-
<MarkdownEditorInline value={group.qs.description as Observable<string>} />
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const GroupMembersWrapper = (props: { groupId: string }) => {
|
|
156
|
-
const userContext = usePromise(() => getUserContext());
|
|
157
|
-
if (!userContext) return null;
|
|
158
|
-
|
|
159
|
-
return <GroupMembersUI groupId={props.groupId} userContext={userContext} />;
|
|
160
|
-
};
|