@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,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getIconClassName,
|
|
3
|
-
getUserContext,
|
|
4
|
-
type IPersistentVar,
|
|
5
|
-
newid,
|
|
6
|
-
PersistentVars,
|
|
7
|
-
} from "@peers-app/peers-sdk";
|
|
8
|
-
import { ListScreen } from "../../components/list-screen";
|
|
9
|
-
import { MarkdownWithMentions } from "../../components/markdown-with-mentions";
|
|
10
|
-
import { Tabs } from "../../components/tabs";
|
|
11
|
-
import { mainContentPath } from "../../globals";
|
|
12
|
-
import { registerInternalPeersUI } from "../../ui-router/ui-loader";
|
|
13
|
-
|
|
14
|
-
function renderItem(persistentVar: IPersistentVar) {
|
|
15
|
-
return (
|
|
16
|
-
<div key={persistentVar.persistentVarId} className="container-fluid pb-4">
|
|
17
|
-
<i className={getIconClassName(PersistentVars())}></i>
|
|
18
|
-
<a href={`#variables/${persistentVar.persistentVarId}`}>
|
|
19
|
-
{persistentVar.name || "<empty-name>"}
|
|
20
|
-
</a>
|
|
21
|
-
<div style={{ paddingLeft: "20px" }}>
|
|
22
|
-
<MarkdownWithMentions content={persistentVar.description || ""} />
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** List of user-created variables, with search-to-create. */
|
|
29
|
-
function UserVariableList() {
|
|
30
|
-
async function newRecord(name: string) {
|
|
31
|
-
const userContext = await getUserContext();
|
|
32
|
-
const isPersonal = userContext.currentlyActiveGroupId() === userContext.userId;
|
|
33
|
-
const varName = name.replace(/\s+/g, "_");
|
|
34
|
-
const pVar = await PersistentVars().save({
|
|
35
|
-
persistentVarId: newid(),
|
|
36
|
-
name: varName,
|
|
37
|
-
scope: isPersonal ? "user" : "group",
|
|
38
|
-
description: "",
|
|
39
|
-
value: { value: "" },
|
|
40
|
-
userCreated: true,
|
|
41
|
-
});
|
|
42
|
-
mainContentPath(`variables/${pVar.persistentVarId}`);
|
|
43
|
-
return pVar;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getFilter(searchText: string) {
|
|
47
|
-
return {
|
|
48
|
-
$or: [{ name: { $matchWords: searchText } }, { description: { $matchWords: searchText } }],
|
|
49
|
-
userCreated: true,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<ListScreen
|
|
55
|
-
table={PersistentVars()}
|
|
56
|
-
newRecord={newRecord}
|
|
57
|
-
getFilter={getFilter}
|
|
58
|
-
sortBy={["name"]}
|
|
59
|
-
renderItem={renderItem}
|
|
60
|
-
placeholderName="environment variable"
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Browse/search list of non-user-created variables (system and package-owned pvars).
|
|
67
|
-
* These are read-only here (no create); selecting one opens the same detail screen.
|
|
68
|
-
*/
|
|
69
|
-
function SystemVariableList() {
|
|
70
|
-
function getFilter(searchText: string) {
|
|
71
|
-
return {
|
|
72
|
-
$or: [{ name: { $matchWords: searchText } }, { description: { $matchWords: searchText } }],
|
|
73
|
-
// $ne: true matches both `false` and unset (system/package pvars omit userCreated)
|
|
74
|
-
userCreated: { $ne: true },
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<ListScreen
|
|
80
|
-
table={PersistentVars()}
|
|
81
|
-
getFilter={getFilter}
|
|
82
|
-
sortBy={["name"]}
|
|
83
|
-
renderItem={renderItem}
|
|
84
|
-
placeholderName="system variable"
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function VariableList() {
|
|
90
|
-
return (
|
|
91
|
-
<Tabs
|
|
92
|
-
tabs={[
|
|
93
|
-
{ name: "User", content: <UserVariableList /> },
|
|
94
|
-
{ name: "System", content: <SystemVariableList /> },
|
|
95
|
-
]}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
registerInternalPeersUI({
|
|
101
|
-
peersUIId: "00m5fshz2g6ea23v8z6y0a1ci",
|
|
102
|
-
component: VariableList,
|
|
103
|
-
routes: [
|
|
104
|
-
{
|
|
105
|
-
isMatch: (_props, context) => context.path === "variables",
|
|
106
|
-
uiCategory: "screen",
|
|
107
|
-
priority: 2,
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
});
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Devices,
|
|
3
|
-
DISPLAY_NAME_MAX_LENGTH,
|
|
4
|
-
getMe,
|
|
5
|
-
getUserContext,
|
|
6
|
-
hasShownWelcomeModal,
|
|
7
|
-
type IDevice,
|
|
8
|
-
TrustLevel,
|
|
9
|
-
thisDeviceId,
|
|
10
|
-
Users,
|
|
11
|
-
} from "@peers-app/peers-sdk";
|
|
12
|
-
import type React from "react";
|
|
13
|
-
import { useEffect, useState } from "react";
|
|
14
|
-
import { useObservable, usePromise } from "../hooks";
|
|
15
|
-
import { persistPeersServicesRegistration } from "../peers-services-registration";
|
|
16
|
-
import { identityTools } from "./device-pairing/identity-ipc";
|
|
17
|
-
|
|
18
|
-
interface WelcomeModalProps {
|
|
19
|
-
colorMode: string;
|
|
20
|
-
onClose: () => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function tryRegisterPeersServicesAfterWelcome(): Promise<void> {
|
|
24
|
-
try {
|
|
25
|
-
const { token } = await (await identityTools()).registerWithPeersServices();
|
|
26
|
-
await persistPeersServicesRegistration(token);
|
|
27
|
-
} catch (err: unknown) {
|
|
28
|
-
console.warn("Peers services registration after welcome modal:", err);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** First-run profile dialog for naming the user and current device. */
|
|
33
|
-
export function WelcomeModal({ colorMode, onClose }: WelcomeModalProps) {
|
|
34
|
-
const [displayName, setDisplayName] = useState("");
|
|
35
|
-
const [deviceName, setDeviceName] = useState("");
|
|
36
|
-
const [isSaving, setIsSaving] = useState(false);
|
|
37
|
-
const [error, setError] = useState<string | null>(null);
|
|
38
|
-
const [deviceId] = useObservable(thisDeviceId);
|
|
39
|
-
|
|
40
|
-
const isDark = colorMode === "dark";
|
|
41
|
-
|
|
42
|
-
// Load current user data
|
|
43
|
-
const me = usePromise(async () => getMe());
|
|
44
|
-
|
|
45
|
-
// Pre-populate with existing values if any
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (me?.name) {
|
|
48
|
-
setDisplayName(me.name.slice(0, DISPLAY_NAME_MAX_LENGTH));
|
|
49
|
-
}
|
|
50
|
-
}, [me?.name]);
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
const loadDeviceName = async () => {
|
|
54
|
-
if (!deviceId) return;
|
|
55
|
-
try {
|
|
56
|
-
const userContext = await getUserContext();
|
|
57
|
-
const device = await Devices(userContext.userDataContext).get(deviceId);
|
|
58
|
-
if (device?.name) {
|
|
59
|
-
setDeviceName(device.name.slice(0, DISPLAY_NAME_MAX_LENGTH));
|
|
60
|
-
}
|
|
61
|
-
} catch (err) {
|
|
62
|
-
console.error("Error loading device name:", err);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
loadDeviceName();
|
|
66
|
-
}, [deviceId]);
|
|
67
|
-
|
|
68
|
-
const handleSave = async () => {
|
|
69
|
-
setError(null);
|
|
70
|
-
setIsSaving(true);
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
const userContext = await getUserContext();
|
|
74
|
-
|
|
75
|
-
// Save display name
|
|
76
|
-
if (me && displayName.trim()) {
|
|
77
|
-
me.name = displayName.trim();
|
|
78
|
-
await Users(userContext.userDataContext).signAndSave(me, { saveAsSnapshot: true });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Save device name
|
|
82
|
-
if (deviceId && deviceName.trim()) {
|
|
83
|
-
const devicesTable = Devices(userContext.userDataContext);
|
|
84
|
-
const device: IDevice = (await devicesTable.get(deviceId)) || {
|
|
85
|
-
deviceId,
|
|
86
|
-
userId: userContext.userId,
|
|
87
|
-
firstSeen: new Date(),
|
|
88
|
-
lastSeen: new Date(),
|
|
89
|
-
trustLevel: TrustLevel.NewDevice,
|
|
90
|
-
};
|
|
91
|
-
device.name = deviceName.trim();
|
|
92
|
-
await devicesTable.save(device);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
await tryRegisterPeersServicesAfterWelcome();
|
|
96
|
-
|
|
97
|
-
// Mark the welcome modal as shown
|
|
98
|
-
hasShownWelcomeModal(true);
|
|
99
|
-
|
|
100
|
-
onClose();
|
|
101
|
-
} catch (err: unknown) {
|
|
102
|
-
console.error("Error saving profile:", err);
|
|
103
|
-
setError(err instanceof Error ? err.message : "Failed to save. Please try again.");
|
|
104
|
-
setIsSaving(false);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const handleSkip = async () => {
|
|
109
|
-
await tryRegisterPeersServicesAfterWelcome();
|
|
110
|
-
// Mark as shown even if skipped
|
|
111
|
-
hasShownWelcomeModal(true);
|
|
112
|
-
onClose();
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
116
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
117
|
-
e.preventDefault();
|
|
118
|
-
handleSave();
|
|
119
|
-
} else if (e.key === "Escape") {
|
|
120
|
-
handleSkip();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
if (!me) {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<div
|
|
130
|
-
className="position-fixed w-100 h-100 d-flex align-items-start justify-content-center"
|
|
131
|
-
style={{
|
|
132
|
-
top: 0,
|
|
133
|
-
left: 0,
|
|
134
|
-
zIndex: 1050,
|
|
135
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
136
|
-
backdropFilter: "blur(4px)",
|
|
137
|
-
paddingTop: "10vh",
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
<div
|
|
141
|
-
className={`${isDark ? "bg-dark text-light" : "bg-white text-dark"}`}
|
|
142
|
-
style={{
|
|
143
|
-
width: "90%",
|
|
144
|
-
maxWidth: "500px",
|
|
145
|
-
borderRadius: "12px",
|
|
146
|
-
boxShadow: isDark ? "0 20px 40px rgba(0, 0, 0, 0.5)" : "0 20px 40px rgba(0, 0, 0, 0.1)",
|
|
147
|
-
border: isDark ? "1px solid #495057" : "1px solid #dee2e6",
|
|
148
|
-
overflow: "hidden",
|
|
149
|
-
}}
|
|
150
|
-
>
|
|
151
|
-
{/* Header */}
|
|
152
|
-
<div
|
|
153
|
-
className="p-4 text-center"
|
|
154
|
-
style={{
|
|
155
|
-
borderBottom: `1px solid ${isDark ? "#495057" : "#dee2e6"}`,
|
|
156
|
-
}}
|
|
157
|
-
>
|
|
158
|
-
<i className="bi-person-circle text-primary d-block mb-3" style={{ fontSize: "48px" }} />
|
|
159
|
-
<h4 className="mb-2">Welcome to Peers!</h4>
|
|
160
|
-
<p
|
|
161
|
-
className={`mb-0 ${isDark ? "text-light opacity-75" : "text-muted"}`}
|
|
162
|
-
style={{ fontSize: "14px" }}
|
|
163
|
-
>
|
|
164
|
-
Let's personalize your experience. You can change these anytime in Settings.
|
|
165
|
-
</p>
|
|
166
|
-
</div>
|
|
167
|
-
|
|
168
|
-
{/* Body */}
|
|
169
|
-
<div className="p-4">
|
|
170
|
-
{/* Error Alert */}
|
|
171
|
-
{error && (
|
|
172
|
-
<div className="alert alert-danger py-2 px-3 mb-3" style={{ fontSize: "14px" }}>
|
|
173
|
-
<i className="bi-exclamation-triangle me-2" />
|
|
174
|
-
{error}
|
|
175
|
-
</div>
|
|
176
|
-
)}
|
|
177
|
-
|
|
178
|
-
{/* Display Name */}
|
|
179
|
-
<div className="mb-3">
|
|
180
|
-
<label className="form-label fw-semibold mb-1">
|
|
181
|
-
<i className="bi-person me-2" />
|
|
182
|
-
Display Name
|
|
183
|
-
</label>
|
|
184
|
-
<input
|
|
185
|
-
type="text"
|
|
186
|
-
className={`form-control ${isDark ? "bg-dark text-light border-secondary" : ""}`}
|
|
187
|
-
maxLength={DISPLAY_NAME_MAX_LENGTH}
|
|
188
|
-
placeholder="How should others see you?"
|
|
189
|
-
value={displayName}
|
|
190
|
-
onChange={(e) => {
|
|
191
|
-
setDisplayName(e.target.value);
|
|
192
|
-
setError(null);
|
|
193
|
-
}}
|
|
194
|
-
onKeyDown={handleKeyDown}
|
|
195
|
-
disabled={isSaving}
|
|
196
|
-
style={{
|
|
197
|
-
fontSize: "14px",
|
|
198
|
-
backgroundColor: isDark ? "#343a40" : "#ffffff",
|
|
199
|
-
}}
|
|
200
|
-
/>
|
|
201
|
-
<small
|
|
202
|
-
className={isDark ? "text-light opacity-50" : "text-muted"}
|
|
203
|
-
style={{ fontSize: "11px" }}
|
|
204
|
-
>
|
|
205
|
-
This name will be visible to others when you connect
|
|
206
|
-
</small>
|
|
207
|
-
</div>
|
|
208
|
-
|
|
209
|
-
{/* Device Name */}
|
|
210
|
-
<div className="mb-3">
|
|
211
|
-
<label className="form-label fw-semibold mb-1">
|
|
212
|
-
<i className="bi-laptop me-2" />
|
|
213
|
-
Device Name
|
|
214
|
-
</label>
|
|
215
|
-
<input
|
|
216
|
-
type="text"
|
|
217
|
-
className={`form-control ${isDark ? "bg-dark text-light border-secondary" : ""}`}
|
|
218
|
-
maxLength={DISPLAY_NAME_MAX_LENGTH}
|
|
219
|
-
placeholder="e.g., My Laptop, Work Computer"
|
|
220
|
-
value={deviceName}
|
|
221
|
-
onChange={(e) => {
|
|
222
|
-
setDeviceName(e.target.value);
|
|
223
|
-
setError(null);
|
|
224
|
-
}}
|
|
225
|
-
onKeyDown={handleKeyDown}
|
|
226
|
-
disabled={isSaving}
|
|
227
|
-
style={{
|
|
228
|
-
fontSize: "14px",
|
|
229
|
-
backgroundColor: isDark ? "#343a40" : "#ffffff",
|
|
230
|
-
}}
|
|
231
|
-
/>
|
|
232
|
-
<small
|
|
233
|
-
className={isDark ? "text-light opacity-50" : "text-muted"}
|
|
234
|
-
style={{ fontSize: "11px" }}
|
|
235
|
-
>
|
|
236
|
-
Helps you identify this device when syncing across multiple devices
|
|
237
|
-
</small>
|
|
238
|
-
</div>
|
|
239
|
-
</div>
|
|
240
|
-
|
|
241
|
-
{/* Footer */}
|
|
242
|
-
<div
|
|
243
|
-
className="p-3 d-flex justify-content-between align-items-center"
|
|
244
|
-
style={{
|
|
245
|
-
borderTop: `1px solid ${isDark ? "#495057" : "#dee2e6"}`,
|
|
246
|
-
backgroundColor: isDark ? "#2d3238" : "#f8f9fa",
|
|
247
|
-
}}
|
|
248
|
-
>
|
|
249
|
-
<button
|
|
250
|
-
className={`btn btn-sm ${isDark ? "btn-outline-light" : "btn-outline-secondary"}`}
|
|
251
|
-
onClick={handleSkip}
|
|
252
|
-
disabled={isSaving}
|
|
253
|
-
>
|
|
254
|
-
Skip for now
|
|
255
|
-
</button>
|
|
256
|
-
<button
|
|
257
|
-
className="btn btn-sm btn-primary"
|
|
258
|
-
onClick={handleSave}
|
|
259
|
-
disabled={isSaving}
|
|
260
|
-
style={{ minWidth: "100px" }}
|
|
261
|
-
>
|
|
262
|
-
{isSaving ? (
|
|
263
|
-
<>
|
|
264
|
-
<span
|
|
265
|
-
className="spinner-border spinner-border-sm me-1"
|
|
266
|
-
role="status"
|
|
267
|
-
aria-hidden="true"
|
|
268
|
-
/>
|
|
269
|
-
Saving...
|
|
270
|
-
</>
|
|
271
|
-
) : (
|
|
272
|
-
<>
|
|
273
|
-
<i className="bi-check-lg me-1" />
|
|
274
|
-
Get Started
|
|
275
|
-
</>
|
|
276
|
-
)}
|
|
277
|
-
</button>
|
|
278
|
-
</div>
|
|
279
|
-
|
|
280
|
-
{/* Keyboard Shortcuts Helper */}
|
|
281
|
-
<div
|
|
282
|
-
className={`px-3 py-2 small text-center ${isDark ? "text-light opacity-50" : "text-muted"}`}
|
|
283
|
-
style={{
|
|
284
|
-
borderTop: `1px solid ${isDark ? "#495057" : "#dee2e6"}`,
|
|
285
|
-
fontSize: "11px",
|
|
286
|
-
backgroundColor: isDark ? "#212529" : "#ffffff",
|
|
287
|
-
}}
|
|
288
|
-
>
|
|
289
|
-
<kbd className="small">↵</kbd> to save • <kbd className="small">esc</kbd> to skip
|
|
290
|
-
</div>
|
|
291
|
-
</div>
|
|
292
|
-
</div>
|
|
293
|
-
);
|
|
294
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultAssistantId,
|
|
3
|
-
getAllAssistantIdsMentioned,
|
|
4
|
-
type IWorkflow,
|
|
5
|
-
runWorkflow,
|
|
6
|
-
Workflows,
|
|
7
|
-
} from "@peers-app/peers-sdk";
|
|
8
|
-
import { Input } from "../../components/input";
|
|
9
|
-
import { LoadingIndicator } from "../../components/loading-indicator";
|
|
10
|
-
import { SaveButton } from "../../components/save-button";
|
|
11
|
-
import { ScreenTabBody, Tabs } from "../../components/tabs";
|
|
12
|
-
import { openThread } from "../../globals";
|
|
13
|
-
import { usePromise } from "../../hooks";
|
|
14
|
-
import { updateActiveTabTitle } from "../../tabs-layout/tabs-state";
|
|
15
|
-
import { WorkflowInfo } from "./workflow-info";
|
|
16
|
-
import { WorkflowInstructions } from "./workflow-instructions";
|
|
17
|
-
|
|
18
|
-
interface IProps {
|
|
19
|
-
workflowId: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const WorkflowDetails = (props: IProps) => {
|
|
23
|
-
const workflow = usePromise(
|
|
24
|
-
async () => {
|
|
25
|
-
const workflow = await Workflows().get(props.workflowId);
|
|
26
|
-
if (!workflow) {
|
|
27
|
-
throw new Error("Workflow not found");
|
|
28
|
-
}
|
|
29
|
-
updateActiveTabTitle(workflow.name || "Workflow");
|
|
30
|
-
return Workflows().initDoc(workflow);
|
|
31
|
-
},
|
|
32
|
-
undefined,
|
|
33
|
-
[props.workflowId],
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
if (!workflow) {
|
|
37
|
-
return <LoadingIndicator />;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function saveChanges() {
|
|
41
|
-
if (!workflow) return;
|
|
42
|
-
workflow.updatedAt = new Date();
|
|
43
|
-
const assistantsMentioned = await getAllAssistantIdsMentioned(
|
|
44
|
-
workflow.instructions[0].markdown ?? "",
|
|
45
|
-
);
|
|
46
|
-
workflow.defaultAssistantId = assistantsMentioned[0] || defaultAssistantId;
|
|
47
|
-
workflow.save();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<div className="container-fluid p-3">
|
|
52
|
-
<div className="d-flex">
|
|
53
|
-
<div>
|
|
54
|
-
<h4>
|
|
55
|
-
<i className="bi bi-database-fill-gear me-2"></i>
|
|
56
|
-
</h4>
|
|
57
|
-
</div>
|
|
58
|
-
<div className="flex-grow-1">
|
|
59
|
-
<h4>
|
|
60
|
-
<Input
|
|
61
|
-
key={workflow.workflowId}
|
|
62
|
-
className="border border-0"
|
|
63
|
-
style={{ width: "100%", outline: "none", backgroundColor: "transparent" }}
|
|
64
|
-
value={workflow.qs.name}
|
|
65
|
-
/>
|
|
66
|
-
</h4>
|
|
67
|
-
</div>
|
|
68
|
-
<div>
|
|
69
|
-
<button
|
|
70
|
-
className="btn btn-success me-2"
|
|
71
|
-
onClick={() => {
|
|
72
|
-
saveChanges(); // TODO take this out, is just for testing
|
|
73
|
-
_runWorkflow(workflow.toJS());
|
|
74
|
-
}}
|
|
75
|
-
>
|
|
76
|
-
Run All
|
|
77
|
-
</button>
|
|
78
|
-
|
|
79
|
-
<SaveButton key={workflow.workflowId} onClick={saveChanges} doc={workflow} />
|
|
80
|
-
</div>
|
|
81
|
-
</div>
|
|
82
|
-
|
|
83
|
-
<Tabs
|
|
84
|
-
key={workflow.workflowId}
|
|
85
|
-
tabs={[
|
|
86
|
-
{
|
|
87
|
-
name: "Info",
|
|
88
|
-
content: (
|
|
89
|
-
<ScreenTabBody>
|
|
90
|
-
<WorkflowInfo workflow={workflow} />
|
|
91
|
-
</ScreenTabBody>
|
|
92
|
-
),
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "Instructions",
|
|
96
|
-
content: (
|
|
97
|
-
<ScreenTabBody>
|
|
98
|
-
<WorkflowInstructions workflow={workflow} />
|
|
99
|
-
</ScreenTabBody>
|
|
100
|
-
),
|
|
101
|
-
},
|
|
102
|
-
]}
|
|
103
|
-
/>
|
|
104
|
-
</div>
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
async function _runWorkflow(workflow: IWorkflow) {
|
|
109
|
-
// TODO maybe warn if there are pending changes
|
|
110
|
-
const run = await runWorkflow({
|
|
111
|
-
workflowId: workflow.workflowId,
|
|
112
|
-
vars: {},
|
|
113
|
-
});
|
|
114
|
-
openThread(run.parentMessageId);
|
|
115
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { IDoc, IWorkflow } from "@peers-app/peers-sdk";
|
|
2
|
-
import { Input } from "../../components/input";
|
|
3
|
-
import { MarkdownEditorInline } from "../../components/markdown-editor/editor-inline";
|
|
4
|
-
|
|
5
|
-
export const WorkflowInfo = (props: { workflow: IDoc<IWorkflow> }) => {
|
|
6
|
-
const { workflow } = props;
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div>
|
|
10
|
-
<small>Name:</small>
|
|
11
|
-
<Input
|
|
12
|
-
value={workflow.qs.name}
|
|
13
|
-
className="form-control mb-3 p-0 ps-2"
|
|
14
|
-
placeholder="Workflow name"
|
|
15
|
-
title="Workflow name"
|
|
16
|
-
/>
|
|
17
|
-
|
|
18
|
-
<small>Description:</small>
|
|
19
|
-
<MarkdownEditorInline value={workflow.qs.description} />
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IDoc,
|
|
3
|
-
type IWorkflow,
|
|
4
|
-
type IWorkflowInstruction,
|
|
5
|
-
type Observable,
|
|
6
|
-
observable,
|
|
7
|
-
} from "@peers-app/peers-sdk";
|
|
8
|
-
import { useEffect, useState } from "react";
|
|
9
|
-
import type { IEditorEffects } from "../../components/markdown-editor/editor";
|
|
10
|
-
import { MarkdownEditorInline } from "../../components/markdown-editor/editor-inline";
|
|
11
|
-
import { useObservable } from "../../hooks";
|
|
12
|
-
|
|
13
|
-
export const WorkflowInstructions = (props: { workflow: IDoc<IWorkflow> }) => {
|
|
14
|
-
const { workflow } = props;
|
|
15
|
-
|
|
16
|
-
const instructions = workflow.qs.instructions;
|
|
17
|
-
useObservable(instructions);
|
|
18
|
-
const [focusedInstructionIndex] = useState(() => observable(0));
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div>
|
|
22
|
-
{workflow.qs.instructions().map((_instruction, i) => {
|
|
23
|
-
return (
|
|
24
|
-
<div
|
|
25
|
-
key={i}
|
|
26
|
-
className="mb-2"
|
|
27
|
-
style={
|
|
28
|
-
{
|
|
29
|
-
// border: '1px solid #ccc',
|
|
30
|
-
// borderRadius: '5px',
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
>
|
|
34
|
-
<WorkflowInstruction
|
|
35
|
-
workflow={workflow}
|
|
36
|
-
instructions={instructions}
|
|
37
|
-
thisInstructionIndex={i}
|
|
38
|
-
focusedInstructionIndex={focusedInstructionIndex}
|
|
39
|
-
/>
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
})}
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
interface IWorkflowInstructionProps {
|
|
48
|
-
workflow: IDoc<IWorkflow>;
|
|
49
|
-
instructions: Observable<IWorkflowInstruction[]>;
|
|
50
|
-
thisInstructionIndex: number;
|
|
51
|
-
focusedInstructionIndex: Observable<number>;
|
|
52
|
-
insertInstructionBelow?: () => void;
|
|
53
|
-
deleteInstruction?: () => void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const WorkflowInstruction = (props: IWorkflowInstructionProps) => {
|
|
57
|
-
const { instructions, thisInstructionIndex, focusedInstructionIndex } = props;
|
|
58
|
-
|
|
59
|
-
const [mdEffects] = useState<IEditorEffects>(() => ({}));
|
|
60
|
-
|
|
61
|
-
const thisInstruction = instructions()[thisInstructionIndex];
|
|
62
|
-
|
|
63
|
-
const [markdownObs] = useState(() => observable(thisInstruction.markdown ?? ""));
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
const sub = focusedInstructionIndex.subscribe((focusedIndex) => {
|
|
67
|
-
if (focusedIndex === thisInstructionIndex) {
|
|
68
|
-
mdEffects.focus?.();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return () => sub.dispose();
|
|
72
|
-
}, [thisInstructionIndex, focusedInstructionIndex.subscribe, mdEffects.focus]);
|
|
73
|
-
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
markdownObs(thisInstruction.markdown ?? "");
|
|
76
|
-
const sub = markdownObs.subscribe((value) => {
|
|
77
|
-
thisInstruction.markdown = value;
|
|
78
|
-
props.workflow.q(props.workflow.q() + 1);
|
|
79
|
-
});
|
|
80
|
-
return () => sub.dispose();
|
|
81
|
-
}, [thisInstruction, markdownObs, props.workflow.q]);
|
|
82
|
-
|
|
83
|
-
let backspacedOnEmpty = false;
|
|
84
|
-
mdEffects.onKeyDown = (evt) => {
|
|
85
|
-
if (evt.key === "Enter") {
|
|
86
|
-
if (markdownObs().match(/\n\s*\n$/)) {
|
|
87
|
-
// if the markdown ends with a new line, zero or more whitespace and then another newline, insert a new instruction below
|
|
88
|
-
evt.preventDefault();
|
|
89
|
-
const _instructions = instructions();
|
|
90
|
-
_instructions.splice(thisInstructionIndex + 1, 0, { markdown: "" });
|
|
91
|
-
instructions([..._instructions]);
|
|
92
|
-
markdownObs(markdownObs().trim());
|
|
93
|
-
focusedInstructionIndex(thisInstructionIndex + 1);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (evt.key === "Backspace") {
|
|
97
|
-
if (markdownObs().trim() === "") {
|
|
98
|
-
if (backspacedOnEmpty) {
|
|
99
|
-
evt.preventDefault();
|
|
100
|
-
const _instructions = instructions();
|
|
101
|
-
if (_instructions.length > 1) {
|
|
102
|
-
_instructions.splice(thisInstructionIndex, 1);
|
|
103
|
-
instructions([..._instructions]);
|
|
104
|
-
focusedInstructionIndex(thisInstructionIndex - 1);
|
|
105
|
-
}
|
|
106
|
-
backspacedOnEmpty = false;
|
|
107
|
-
} else {
|
|
108
|
-
backspacedOnEmpty = true;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
function runThisInstruction() {
|
|
116
|
-
// runInstructions([thisInstruction]);
|
|
117
|
-
confirm("TODO: run this instruction not implemented yet");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<MarkdownEditorInline
|
|
122
|
-
value={markdownObs}
|
|
123
|
-
effects={mdEffects}
|
|
124
|
-
autoFocus={props.thisInstructionIndex === focusedInstructionIndex()}
|
|
125
|
-
topRightControls={[
|
|
126
|
-
{
|
|
127
|
-
iconClass: "bi bi-play",
|
|
128
|
-
title: `Run this instruction.`,
|
|
129
|
-
onClick: runThisInstruction,
|
|
130
|
-
},
|
|
131
|
-
]}
|
|
132
|
-
/>
|
|
133
|
-
);
|
|
134
|
-
};
|