@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,50 +0,0 @@
|
|
|
1
|
-
import { observable } from "@peers-app/peers-sdk";
|
|
2
|
-
import type React from "react";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A globally-mounted overlay component contributed by a package (or peers-ui itself).
|
|
6
|
-
*
|
|
7
|
-
* Overlays are rendered by {@link RootLayoutHost} above every root layout (alongside the
|
|
8
|
-
* command palette), so they remain visible regardless of which tab/app is active. Each
|
|
9
|
-
* overlay is responsible for deciding its own visibility (e.g. returning `null` when it
|
|
10
|
-
* should be hidden); the registry only controls whether the component is mounted.
|
|
11
|
-
*/
|
|
12
|
-
export interface GlobalOverlay {
|
|
13
|
-
/** Stable id. Re-registering with the same id replaces the prior entry. */
|
|
14
|
-
id: string;
|
|
15
|
-
/** The component rendered by the host. It owns its own visibility and positioning. */
|
|
16
|
-
Component: React.ComponentType;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Reactive registry of global overlays rendered by {@link RootLayoutHost}.
|
|
21
|
-
*
|
|
22
|
-
* This mirrors the command-palette registry pattern: a package's UI bundle calls
|
|
23
|
-
* {@link registerGlobalOverlay} when it loads, and the host re-renders because this is an
|
|
24
|
-
* observable. Because peers-core (and other packages) externalize `@peers-app/peers-ui`
|
|
25
|
-
* to the shared `window.PeersUI` singleton, they register into this exact instance.
|
|
26
|
-
*/
|
|
27
|
-
export const globalOverlays = observable<GlobalOverlay[]>([]);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Register a global overlay component, replacing any existing overlay with the same id.
|
|
31
|
-
*
|
|
32
|
-
* @param id Stable identifier for the overlay (used for replacement/removal).
|
|
33
|
-
* @param Component The React component to mount globally.
|
|
34
|
-
*/
|
|
35
|
-
export function registerGlobalOverlay(id: string, Component: React.ComponentType): void {
|
|
36
|
-
const next = globalOverlays().filter((o) => o.id !== id);
|
|
37
|
-
next.push({ id, Component });
|
|
38
|
-
globalOverlays(next);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Remove a previously-registered global overlay by id. No-op if the id is not registered.
|
|
43
|
-
*
|
|
44
|
-
* @param id The id passed to {@link registerGlobalOverlay}.
|
|
45
|
-
*/
|
|
46
|
-
export function unregisterGlobalOverlay(id: string): void {
|
|
47
|
-
const current = globalOverlays();
|
|
48
|
-
const next = current.filter((o) => o.id !== id);
|
|
49
|
-
if (next.length !== current.length) globalOverlays(next);
|
|
50
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout picker — Settings entry point for choosing the root layout.
|
|
3
|
-
*
|
|
4
|
-
* Lists every registered {@link RootLayout} and writes the selection to
|
|
5
|
-
* `selectedRootLayoutId` (per-device). `RootLayoutHost` subscribes to that pvar, so the
|
|
6
|
-
* layout swaps live on select. Mirrors the `ColorModeDropdown` pattern.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useObservable } from "../hooks";
|
|
10
|
-
import { getRootLayouts } from "./root-layout-registry";
|
|
11
|
-
import { selectedRootLayoutId, setRootLayout } from "./root-layout-state";
|
|
12
|
-
|
|
13
|
-
/** Dropdown that selects the active root layout. */
|
|
14
|
-
export const LayoutPicker = () => {
|
|
15
|
-
const [selectedId] = useObservable(selectedRootLayoutId);
|
|
16
|
-
const layouts = getRootLayouts();
|
|
17
|
-
const active = layouts.find((layout) => layout.id === selectedId);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<div className="dropdown">
|
|
21
|
-
<button
|
|
22
|
-
className="btn btn-secondary dropdown-toggle"
|
|
23
|
-
type="button"
|
|
24
|
-
id="layoutPickerDropdown"
|
|
25
|
-
data-bs-toggle="dropdown"
|
|
26
|
-
aria-expanded="false"
|
|
27
|
-
>
|
|
28
|
-
Layout: {active?.name ?? selectedId}
|
|
29
|
-
</button>
|
|
30
|
-
<ul className="dropdown-menu" aria-labelledby="layoutPickerDropdown">
|
|
31
|
-
{layouts.map((layout) => (
|
|
32
|
-
<li key={layout.id}>
|
|
33
|
-
<button
|
|
34
|
-
type="button"
|
|
35
|
-
className="dropdown-item"
|
|
36
|
-
onClick={() => setRootLayout(layout.id)}
|
|
37
|
-
>
|
|
38
|
-
<i className={`${layout.iconClassName} me-2`} />
|
|
39
|
-
{layout.name} {layout.id === selectedId && "✓"}
|
|
40
|
-
<div className="small text-muted ms-4">{layout.description}</div>
|
|
41
|
-
</button>
|
|
42
|
-
</li>
|
|
43
|
-
))}
|
|
44
|
-
</ul>
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Full-screen root layout — one screen at a time, no tab strip.
|
|
3
|
-
*
|
|
4
|
-
* Renders only the active tab's content under a minimal header. All navigation flows
|
|
5
|
-
* through the command palette (Cmd/Ctrl+K), which {@link RootLayoutHost} always mounts,
|
|
6
|
-
* plus a Home button back to the app launcher. While mounted, this layout enables
|
|
7
|
-
* single-tab mode (see `setSingleTabMode`) so opening an app replaces the current screen
|
|
8
|
-
* instead of accumulating tabs. This is non-destructive: any tabs opened under a multi-tab
|
|
9
|
-
* layout are left untouched and reappear if the user switches back.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { type ReactNode, useEffect } from "react";
|
|
13
|
-
import { openCommandPalette } from "../../command-palette/command-palette";
|
|
14
|
-
import { GroupSwitcher } from "../../components/group-switcher";
|
|
15
|
-
import { isDesktop } from "../../globals";
|
|
16
|
-
import { useObservable } from "../../hooks";
|
|
17
|
-
import { colorMode } from "../../screens/settings/color-mode-dropdown";
|
|
18
|
-
import { TabContent, TabErrorBoundary } from "../../tabs-layout/tabs-layout";
|
|
19
|
-
import {
|
|
20
|
-
activeTabId,
|
|
21
|
-
activeTabs,
|
|
22
|
-
launcherApp,
|
|
23
|
-
setSingleTabMode,
|
|
24
|
-
} from "../../tabs-layout/tabs-state";
|
|
25
|
-
|
|
26
|
-
const isMac =
|
|
27
|
-
typeof navigator !== "undefined" ? /Mac|iPod|iPhone|iPad/.test(navigator.userAgent) : false;
|
|
28
|
-
const paletteHint = isMac ? "⌘K" : "Ctrl+K";
|
|
29
|
-
|
|
30
|
-
/** The full-screen layout body: minimal header + the single active screen. */
|
|
31
|
-
export function FullScreenLayout() {
|
|
32
|
-
const [mode] = useObservable(colorMode);
|
|
33
|
-
const [tabs] = useObservable(activeTabs);
|
|
34
|
-
const [activeId] = useObservable(activeTabId);
|
|
35
|
-
useObservable(isDesktop);
|
|
36
|
-
const isMobile = !isDesktop();
|
|
37
|
-
|
|
38
|
-
// Single-tab navigation while this layout is active; restore on unmount/layout swap.
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
setSingleTabMode(true);
|
|
41
|
-
return () => setSingleTabMode(false);
|
|
42
|
-
}, []);
|
|
43
|
-
|
|
44
|
-
const activeTab = tabs.find((t) => t.tabId === activeId) ?? launcherApp;
|
|
45
|
-
const isLauncher = activeTab.packageId === "launcher" || activeTab.tabId === "launcher";
|
|
46
|
-
const isLight = mode === "light";
|
|
47
|
-
|
|
48
|
-
const title = isLauncher ? "Apps" : activeTab.title;
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<div
|
|
52
|
-
className="d-flex flex-column"
|
|
53
|
-
style={{ height: "calc(100vh - 25px)", overflow: "hidden" }}
|
|
54
|
-
>
|
|
55
|
-
{/* Minimal header */}
|
|
56
|
-
<div
|
|
57
|
-
className={`border-bottom d-flex align-items-center px-1 ${isLight ? "bg-light" : "bg-dark"}`}
|
|
58
|
-
style={{ height: "36px", borderBottomColor: isLight ? "#dee2e6" : "#495057" }}
|
|
59
|
-
>
|
|
60
|
-
<GroupSwitcher colorMode={mode} isMobile={isMobile} />
|
|
61
|
-
|
|
62
|
-
<HeaderButton
|
|
63
|
-
isLight={isLight}
|
|
64
|
-
active={isLauncher}
|
|
65
|
-
icon="bi-grid-3x3-gap"
|
|
66
|
-
label="Apps"
|
|
67
|
-
onClick={() => activeTabId("launcher")}
|
|
68
|
-
/>
|
|
69
|
-
|
|
70
|
-
{/* Current screen title */}
|
|
71
|
-
<div className="d-flex align-items-center flex-grow-1 overflow-hidden px-2">
|
|
72
|
-
{!isLauncher && activeTab.iconClassName && (
|
|
73
|
-
<i className={`${activeTab.iconClassName} me-2`} />
|
|
74
|
-
)}
|
|
75
|
-
<span className="text-truncate fw-medium" style={{ fontSize: "13px" }}>
|
|
76
|
-
{title}
|
|
77
|
-
</span>
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
|
-
{/* Command palette (navigation) */}
|
|
81
|
-
<HeaderButton
|
|
82
|
-
isLight={isLight}
|
|
83
|
-
icon="bi-search"
|
|
84
|
-
label={`Search and navigate (${paletteHint})`}
|
|
85
|
-
onClick={openCommandPalette}
|
|
86
|
-
>
|
|
87
|
-
<span className="d-none d-md-inline ms-1" style={{ fontSize: "11px" }}>
|
|
88
|
-
{paletteHint}
|
|
89
|
-
</span>
|
|
90
|
-
</HeaderButton>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
{/* The single active screen. Key on tabId so each screen mounts fresh (and the error
|
|
94
|
-
boundary resets) when navigating. */}
|
|
95
|
-
<div className="flex-grow-1 overflow-hidden">
|
|
96
|
-
<TabErrorBoundary key={activeTab.tabId} tabTitle={activeTab.title} tabId={activeTab.tabId}>
|
|
97
|
-
<TabContent tab={activeTab} isMobile={isMobile} isActive />
|
|
98
|
-
</TabErrorBoundary>
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
interface HeaderButtonProps {
|
|
105
|
-
isLight: boolean;
|
|
106
|
-
icon: string;
|
|
107
|
-
label: string;
|
|
108
|
-
onClick: () => void;
|
|
109
|
-
active?: boolean;
|
|
110
|
-
children?: ReactNode;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** A small, transparent header button matching the tabs layout's toolbar styling. */
|
|
114
|
-
function HeaderButton({ isLight, icon, label, onClick, active, children }: HeaderButtonProps) {
|
|
115
|
-
const baseColor = active ? (isLight ? "#0d6efd" : "#ffffff") : isLight ? "#6c757d" : "#adb5bd";
|
|
116
|
-
return (
|
|
117
|
-
<button
|
|
118
|
-
type="button"
|
|
119
|
-
className="btn btn-sm d-flex align-items-center"
|
|
120
|
-
onClick={onClick}
|
|
121
|
-
title={label}
|
|
122
|
-
aria-label={label}
|
|
123
|
-
style={{
|
|
124
|
-
padding: "4px 8px",
|
|
125
|
-
fontSize: "12px",
|
|
126
|
-
borderRadius: "6px",
|
|
127
|
-
border: "none",
|
|
128
|
-
background: "transparent",
|
|
129
|
-
color: baseColor,
|
|
130
|
-
}}
|
|
131
|
-
onMouseEnter={(e) => {
|
|
132
|
-
e.currentTarget.style.backgroundColor = isLight ? "#f8f9fa" : "#495057";
|
|
133
|
-
e.currentTarget.style.color = isLight ? "#0d6efd" : "#ffffff";
|
|
134
|
-
}}
|
|
135
|
-
onMouseLeave={(e) => {
|
|
136
|
-
e.currentTarget.style.backgroundColor = "transparent";
|
|
137
|
-
e.currentTarget.style.color = baseColor;
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
<i className={icon} style={{ fontSize: "14px" }} />
|
|
141
|
-
{children}
|
|
142
|
-
</button>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tabs + Console root layout.
|
|
3
|
-
*
|
|
4
|
-
* Renders the standard tab UI and the Operator Console as two real, side-by-side panels
|
|
5
|
-
* in a flex split — not an overlay. Neither panel covers the other; each scrolls
|
|
6
|
-
* independently and the tab UI is sized to the space the console does not occupy.
|
|
7
|
-
*
|
|
8
|
-
* This layout owns everything the old overlay used to self-manage: the split sizing, the
|
|
9
|
-
* drag-to-resize divider, the collapsed edge strip, and the docked edge. The console's
|
|
10
|
-
* own chrome is the presentational {@link OperatorConsolePanel}. Panel state (expanded,
|
|
11
|
-
* dock edge, sizes, maximized) is read reactively from `operatorConsolePanel`, the same
|
|
12
|
-
* per-device state the `Ctrl+`` `` shortcut and the "Toggle Console" command drive.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import type React from "react";
|
|
16
|
-
import { useEffect, useRef, useState } from "react";
|
|
17
|
-
import { useObservable } from "../../hooks";
|
|
18
|
-
import { getConsoleTheme, OperatorConsolePanel } from "../../operator-console/operator-console";
|
|
19
|
-
import {
|
|
20
|
-
type ConsoleDock,
|
|
21
|
-
openConsole,
|
|
22
|
-
operatorConsolePanel,
|
|
23
|
-
setConsoleSize,
|
|
24
|
-
} from "../../operator-console/operator-console-state";
|
|
25
|
-
import { colorMode } from "../../screens/settings/color-mode-dropdown";
|
|
26
|
-
import { TabsLayoutInternal } from "../../tabs-layout/tabs-layout";
|
|
27
|
-
|
|
28
|
-
const STRIP_THICKNESS = 26;
|
|
29
|
-
const HANDLE_THICKNESS = 6;
|
|
30
|
-
const MIN_SIZE = 120;
|
|
31
|
-
|
|
32
|
-
function clamp(value: number, min: number, max: number): number {
|
|
33
|
-
return Math.max(min, Math.min(max, value));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Pixels occupied by the fixed titlebar (macOS = 25, hidden elsewhere). */
|
|
37
|
-
function getTopOffset(): number {
|
|
38
|
-
if (typeof document === "undefined") return 0;
|
|
39
|
-
return Number.parseInt(getComputedStyle(document.body).paddingTop, 10) || 0;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The `tabs-with-console` layout body. Splits its area between the tab UI and the
|
|
44
|
-
* Operator Console along the docked edge, with a drag-to-resize divider. Collapses the
|
|
45
|
-
* console to a thin clickable strip and supports maximizing it to fill the layout body.
|
|
46
|
-
*/
|
|
47
|
-
export function TabsWithConsoleLayout() {
|
|
48
|
-
const [state] = useObservable(operatorConsolePanel);
|
|
49
|
-
const [mode] = useObservable(colorMode);
|
|
50
|
-
const [topOffset] = useState(getTopOffset);
|
|
51
|
-
|
|
52
|
-
const [dragSize, setDragSize] = useState<number | null>(null);
|
|
53
|
-
const [isResizing, setIsResizing] = useState(false);
|
|
54
|
-
const dragStartRef = useRef<{ startX: number; startY: number; startSize: number } | null>(null);
|
|
55
|
-
const latestSizeRef = useRef<number | null>(null);
|
|
56
|
-
|
|
57
|
-
const { expanded, dock, bottomHeight, sideWidth, maximized } = state;
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (!isResizing) return;
|
|
61
|
-
|
|
62
|
-
const onMove = (e: MouseEvent) => {
|
|
63
|
-
const start = dragStartRef.current;
|
|
64
|
-
if (!start) return;
|
|
65
|
-
let next: number;
|
|
66
|
-
if (dock === "bottom") {
|
|
67
|
-
next = clamp(
|
|
68
|
-
start.startSize + (start.startY - e.clientY),
|
|
69
|
-
MIN_SIZE,
|
|
70
|
-
window.innerHeight - topOffset - MIN_SIZE,
|
|
71
|
-
);
|
|
72
|
-
} else if (dock === "left") {
|
|
73
|
-
next = clamp(
|
|
74
|
-
start.startSize + (e.clientX - start.startX),
|
|
75
|
-
MIN_SIZE,
|
|
76
|
-
window.innerWidth - MIN_SIZE,
|
|
77
|
-
);
|
|
78
|
-
} else {
|
|
79
|
-
next = clamp(
|
|
80
|
-
start.startSize + (start.startX - e.clientX),
|
|
81
|
-
MIN_SIZE,
|
|
82
|
-
window.innerWidth - MIN_SIZE,
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
latestSizeRef.current = next;
|
|
86
|
-
setDragSize(next);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const onUp = () => {
|
|
90
|
-
setIsResizing(false);
|
|
91
|
-
const finalSize = latestSizeRef.current;
|
|
92
|
-
if (finalSize != null) {
|
|
93
|
-
setConsoleSize(dock === "bottom" ? { bottomHeight: finalSize } : { sideWidth: finalSize });
|
|
94
|
-
}
|
|
95
|
-
setDragSize(null);
|
|
96
|
-
latestSizeRef.current = null;
|
|
97
|
-
dragStartRef.current = null;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
document.addEventListener("mousemove", onMove);
|
|
101
|
-
document.addEventListener("mouseup", onUp);
|
|
102
|
-
return () => {
|
|
103
|
-
document.removeEventListener("mousemove", onMove);
|
|
104
|
-
document.removeEventListener("mouseup", onUp);
|
|
105
|
-
};
|
|
106
|
-
}, [isResizing, dock, topOffset]);
|
|
107
|
-
|
|
108
|
-
const theme = getConsoleTheme(mode === "dark");
|
|
109
|
-
const isVertical = dock !== "bottom";
|
|
110
|
-
const consoleSize = dragSize ?? (dock === "bottom" ? bottomHeight : sideWidth);
|
|
111
|
-
|
|
112
|
-
const onResizeStart = (e: React.MouseEvent) => {
|
|
113
|
-
e.preventDefault();
|
|
114
|
-
const startSize = dock === "bottom" ? bottomHeight : sideWidth;
|
|
115
|
-
dragStartRef.current = { startX: e.clientX, startY: e.clientY, startSize };
|
|
116
|
-
latestSizeRef.current = startSize;
|
|
117
|
-
setIsResizing(true);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// Tabs panel stays mounted across maximize so the tab subtree keeps its state; it is
|
|
121
|
-
// hidden (not unmounted) when the console is maximized.
|
|
122
|
-
const tabsHidden = expanded && maximized;
|
|
123
|
-
const tabsPanel = (
|
|
124
|
-
<div
|
|
125
|
-
key="tabs"
|
|
126
|
-
style={{
|
|
127
|
-
flex: 1,
|
|
128
|
-
minWidth: 0,
|
|
129
|
-
minHeight: 0,
|
|
130
|
-
overflow: "hidden",
|
|
131
|
-
display: tabsHidden ? "none" : "block",
|
|
132
|
-
}}
|
|
133
|
-
>
|
|
134
|
-
<TabsLayoutInternal fillContainer />
|
|
135
|
-
</div>
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
let consoleRegion: React.ReactNode;
|
|
139
|
-
if (!expanded) {
|
|
140
|
-
consoleRegion = <CollapsedStrip key="console" dock={dock} theme={theme} />;
|
|
141
|
-
} else if (maximized) {
|
|
142
|
-
consoleRegion = (
|
|
143
|
-
<div key="console" style={{ flex: 1, minWidth: 0, minHeight: 0 }}>
|
|
144
|
-
<OperatorConsolePanel />
|
|
145
|
-
</div>
|
|
146
|
-
);
|
|
147
|
-
} else {
|
|
148
|
-
consoleRegion = (
|
|
149
|
-
<div
|
|
150
|
-
key="console"
|
|
151
|
-
style={{
|
|
152
|
-
flex: "0 0 auto",
|
|
153
|
-
minWidth: 0,
|
|
154
|
-
minHeight: 0,
|
|
155
|
-
...(dock === "bottom" ? { height: `${consoleSize}px` } : { width: `${consoleSize}px` }),
|
|
156
|
-
}}
|
|
157
|
-
>
|
|
158
|
-
<OperatorConsolePanel />
|
|
159
|
-
</div>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const divider =
|
|
164
|
-
expanded && !maximized ? (
|
|
165
|
-
<ResizeDivider
|
|
166
|
-
key="divider"
|
|
167
|
-
isVertical={isVertical}
|
|
168
|
-
isResizing={isResizing}
|
|
169
|
-
theme={theme}
|
|
170
|
-
onMouseDown={onResizeStart}
|
|
171
|
-
/>
|
|
172
|
-
) : null;
|
|
173
|
-
|
|
174
|
-
const children =
|
|
175
|
-
dock === "left" ? [consoleRegion, divider, tabsPanel] : [tabsPanel, divider, consoleRegion];
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<div
|
|
179
|
-
style={{
|
|
180
|
-
height: "calc(100vh - 25px)",
|
|
181
|
-
display: "flex",
|
|
182
|
-
flexDirection: isVertical ? "row" : "column",
|
|
183
|
-
overflow: "hidden",
|
|
184
|
-
userSelect: isResizing ? "none" : undefined,
|
|
185
|
-
}}
|
|
186
|
-
>
|
|
187
|
-
{children}
|
|
188
|
-
</div>
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
interface CollapsedStripProps {
|
|
193
|
-
dock: ConsoleDock;
|
|
194
|
-
theme: ReturnType<typeof getConsoleTheme>;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/** Thin clickable edge strip shown when the console is collapsed; opens it on click. */
|
|
198
|
-
function CollapsedStrip({ dock, theme }: CollapsedStripProps) {
|
|
199
|
-
const isVertical = dock !== "bottom";
|
|
200
|
-
return (
|
|
201
|
-
<button
|
|
202
|
-
type="button"
|
|
203
|
-
onClick={openConsole}
|
|
204
|
-
title="Open Console (Ctrl+`)"
|
|
205
|
-
style={{
|
|
206
|
-
flex: `0 0 ${STRIP_THICKNESS}px`,
|
|
207
|
-
display: "flex",
|
|
208
|
-
alignItems: "center",
|
|
209
|
-
justifyContent: "center",
|
|
210
|
-
gap: "6px",
|
|
211
|
-
border: "none",
|
|
212
|
-
padding: 0,
|
|
213
|
-
backgroundColor: theme.headerBg,
|
|
214
|
-
color: theme.muted,
|
|
215
|
-
cursor: "pointer",
|
|
216
|
-
userSelect: "none",
|
|
217
|
-
fontSize: "12px",
|
|
218
|
-
...(dock === "bottom"
|
|
219
|
-
? { width: "100%", borderTop: `1px solid ${theme.border}` }
|
|
220
|
-
: dock === "left"
|
|
221
|
-
? { height: "100%", borderRight: `1px solid ${theme.border}` }
|
|
222
|
-
: { height: "100%", borderLeft: `1px solid ${theme.border}` }),
|
|
223
|
-
}}
|
|
224
|
-
>
|
|
225
|
-
<i className="bi-terminal" style={{ fontSize: "14px" }} />
|
|
226
|
-
{!isVertical && <span>Console</span>}
|
|
227
|
-
<i className={isVertical ? "bi-chevron-left" : "bi-chevron-up"} />
|
|
228
|
-
</button>
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
interface ResizeDividerProps {
|
|
233
|
-
isVertical: boolean;
|
|
234
|
-
isResizing: boolean;
|
|
235
|
-
theme: ReturnType<typeof getConsoleTheme>;
|
|
236
|
-
onMouseDown: (e: React.MouseEvent) => void;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/** Drag handle between the tabs and console panels; resizes the console along the dock edge. */
|
|
240
|
-
function ResizeDivider({ isVertical, isResizing, theme, onMouseDown }: ResizeDividerProps) {
|
|
241
|
-
return (
|
|
242
|
-
// biome-ignore lint/a11y/noStaticElementInteractions: pointer-only resize gutter; size is also adjustable via persisted state
|
|
243
|
-
<div
|
|
244
|
-
onMouseDown={onMouseDown}
|
|
245
|
-
onMouseEnter={(e) => {
|
|
246
|
-
if (!isResizing) e.currentTarget.style.backgroundColor = theme.accent;
|
|
247
|
-
}}
|
|
248
|
-
onMouseLeave={(e) => {
|
|
249
|
-
if (!isResizing) e.currentTarget.style.backgroundColor = "transparent";
|
|
250
|
-
}}
|
|
251
|
-
style={{
|
|
252
|
-
flex: `0 0 ${HANDLE_THICKNESS}px`,
|
|
253
|
-
backgroundColor: isResizing ? theme.accent : "transparent",
|
|
254
|
-
cursor: isVertical ? "ew-resize" : "ns-resize",
|
|
255
|
-
}}
|
|
256
|
-
/>
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export default TabsWithConsoleLayout;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { fireEvent, render } from "@testing-library/react";
|
|
2
|
-
import { mainContentPath } from "../globals";
|
|
3
|
-
import { IDENTITY_ACCEPT_PATH } from "../screens/identity/identity-routes";
|
|
4
|
-
import { peekPendingInvite } from "../screens/invites/invite-capture";
|
|
5
|
-
import { RootLayoutHost } from "./root-layout-host";
|
|
6
|
-
|
|
7
|
-
const TOKEN = "eyJhbGciOiJub25lIn0-_abcdefghijklmnopqrstuvwxyz0123456789";
|
|
8
|
-
|
|
9
|
-
jest.mock("@peers-app/peers-sdk", () => {
|
|
10
|
-
const actual = jest.requireActual<typeof import("@peers-app/peers-sdk")>("@peers-app/peers-sdk");
|
|
11
|
-
return {
|
|
12
|
-
...actual,
|
|
13
|
-
hasShownWelcomeModal: Object.assign(
|
|
14
|
-
jest.fn(() => true),
|
|
15
|
-
{
|
|
16
|
-
loadingPromise: Promise.resolve(),
|
|
17
|
-
},
|
|
18
|
-
),
|
|
19
|
-
setDefaultClientUserContext: jest.fn(),
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
jest.mock("../command-palette/command-palette-ui", () => ({
|
|
24
|
-
CommandPaletteOverlay: () => null,
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
jest.mock("../globals", () => ({
|
|
28
|
-
loadGlobals: jest.fn(async () => true),
|
|
29
|
-
mainContentPath: jest.fn(),
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
jest.mock("../hooks", () => ({
|
|
33
|
-
useObservable: (observable: () => unknown) => [observable(), observable],
|
|
34
|
-
usePromise: (promiseOrFactory: unknown) => {
|
|
35
|
-
if (
|
|
36
|
-
typeof promiseOrFactory === "function" &&
|
|
37
|
-
Function.prototype.toString.call(promiseOrFactory).includes("getSession")
|
|
38
|
-
) {
|
|
39
|
-
return "local-user";
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
},
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
jest.mock("../screens/settings/color-mode-dropdown", () => ({
|
|
46
|
-
colorMode: jest.fn(() => "light"),
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
jest.mock("../screens/setup-user", () => ({
|
|
50
|
-
SetupUser: () => null,
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
jest.mock("../screens/welcome-modal", () => ({
|
|
54
|
-
WelcomeModal: () => null,
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
jest.mock("../tabs-layout/tabs-state", () => ({
|
|
58
|
-
activeTabId: { loadingPromise: Promise.resolve() },
|
|
59
|
-
activeTabs: { loadingPromise: Promise.resolve() },
|
|
60
|
-
recentlyUsedApps: { loadingPromise: Promise.resolve() },
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
jest.mock("../ui-router/routes-loader", () => ({
|
|
64
|
-
loadAllRoutes: jest.fn(async () => undefined),
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
jest.mock("./global-overlays", () => ({
|
|
68
|
-
globalOverlays: jest.fn(() => []),
|
|
69
|
-
}));
|
|
70
|
-
|
|
71
|
-
jest.mock("./root-layout-registry", () => ({
|
|
72
|
-
DEFAULT_ROOT_LAYOUT_ID: "default",
|
|
73
|
-
getRootLayout: jest.fn(() => ({ Component: () => null })),
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
jest.mock("./root-layout-state", () => ({
|
|
77
|
-
selectedRootLayoutId: jest.fn(() => undefined),
|
|
78
|
-
}));
|
|
79
|
-
|
|
80
|
-
describe("RootLayoutHost", () => {
|
|
81
|
-
beforeEach(() => {
|
|
82
|
-
sessionStorage.clear();
|
|
83
|
-
window.history.replaceState(null, "", "/");
|
|
84
|
-
jest.clearAllMocks();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("captures and sanitizes invite links opened after startup", () => {
|
|
88
|
-
render(<RootLayoutHost />);
|
|
89
|
-
window.history.replaceState(null, "", `/?app#invite=${TOKEN}`);
|
|
90
|
-
|
|
91
|
-
fireEvent(window, new HashChangeEvent("hashchange"));
|
|
92
|
-
|
|
93
|
-
expect(window.location.hash).toBe("");
|
|
94
|
-
expect(peekPendingInvite()).toBe(TOKEN);
|
|
95
|
-
expect(mainContentPath).toHaveBeenCalledWith(IDENTITY_ACCEPT_PATH);
|
|
96
|
-
expect(mainContentPath).not.toHaveBeenCalledWith(expect.stringContaining(TOKEN));
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("ignores ordinary hash routes", () => {
|
|
100
|
-
render(<RootLayoutHost />);
|
|
101
|
-
window.history.replaceState(null, "", "/?app#groups");
|
|
102
|
-
|
|
103
|
-
fireEvent(window, new HashChangeEvent("hashchange"));
|
|
104
|
-
|
|
105
|
-
expect(window.location.hash).toBe("#groups");
|
|
106
|
-
expect(peekPendingInvite()).toBeUndefined();
|
|
107
|
-
});
|
|
108
|
-
});
|