@peers-app/peers-ui 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +8 -5
- package/babel.config.js +4 -4
- package/biome.json +191 -0
- package/dist/command-palette/command-palette-ui.d.ts +1 -2
- package/dist/command-palette/command-palette-ui.js +175 -244
- package/dist/command-palette/command-palette.js +65 -64
- package/dist/components/chat-overlay.d.ts +2 -2
- package/dist/components/chat-overlay.js +160 -217
- package/dist/components/checkbox.d.ts +5 -4
- package/dist/components/checkbox.js +4 -7
- package/dist/components/group-switcher.d.ts +1 -2
- package/dist/components/group-switcher.js +119 -159
- package/dist/components/input-date.d.ts +3 -3
- package/dist/components/input-date.js +6 -6
- package/dist/components/input-number.d.ts +7 -6
- package/dist/components/input-number.js +25 -20
- package/dist/components/input.d.ts +5 -4
- package/dist/components/input.js +4 -7
- package/dist/components/inverse-lazy-list.d.ts +3 -3
- package/dist/components/inverse-lazy-list.js +13 -47
- package/dist/components/io-schema-values.d.ts +5 -6
- package/dist/components/io-schema-values.js +28 -65
- package/dist/components/io-schema.d.ts +4 -5
- package/dist/components/io-schema.js +42 -79
- package/dist/components/lazy-list.d.ts +3 -3
- package/dist/components/lazy-list.js +38 -58
- package/dist/components/list-screen.d.ts +3 -8
- package/dist/components/list-screen.js +28 -23
- package/dist/components/loading-indicator.d.ts +1 -2
- package/dist/components/loading-indicator.js +2 -6
- package/dist/components/markdown-editor/autolink-plugin.js +5 -8
- package/dist/components/markdown-editor/editor-inline.d.ts +2 -3
- package/dist/components/markdown-editor/editor-inline.js +2 -6
- package/dist/components/markdown-editor/editor.d.ts +6 -6
- package/dist/components/markdown-editor/editor.js +9 -19
- package/dist/components/markdown-editor/markdown-plugin.d.ts +1 -1
- package/dist/components/markdown-editor/markdown-plugin.js +20 -21
- package/dist/components/markdown-editor/mention-node.d.ts +2 -2
- package/dist/components/markdown-editor/mention-node.js +24 -24
- package/dist/components/markdown-editor/mentions-plugin.d.ts +2 -2
- package/dist/components/markdown-editor/mentions-plugin.js +61 -62
- package/dist/components/markdown-editor/theme.js +28 -28
- package/dist/components/markdown-editor/toolbar.d.ts +2 -3
- package/dist/components/markdown-editor/toolbar.js +32 -49
- package/dist/components/markdown-with-mentions.d.ts +1 -1
- package/dist/components/markdown-with-mentions.js +43 -43
- package/dist/components/message-logs/message-logs.d.ts +1 -2
- package/dist/components/message-logs/message-logs.js +91 -116
- package/dist/components/messages/avatar.d.ts +3 -4
- package/dist/components/messages/avatar.js +37 -46
- package/dist/components/messages/channel-message-list.d.ts +5 -6
- package/dist/components/messages/channel-message-list.js +34 -34
- package/dist/components/messages/channel-view.d.ts +1 -2
- package/dist/components/messages/channel-view.js +23 -57
- package/dist/components/messages/message-compose.d.ts +3 -4
- package/dist/components/messages/message-compose.js +27 -38
- package/dist/components/messages/message-display.d.ts +2 -3
- package/dist/components/messages/message-display.js +42 -95
- package/dist/components/messages/thread-message-list.d.ts +4 -5
- package/dist/components/messages/thread-message-list.js +29 -29
- package/dist/components/router.d.ts +1 -2
- package/dist/components/router.js +58 -66
- package/dist/components/save-button.d.ts +3 -3
- package/dist/components/save-button.js +23 -33
- package/dist/components/sortable-list.d.ts +11 -12
- package/dist/components/sortable-list.js +42 -22
- package/dist/components/tabs.d.ts +3 -3
- package/dist/components/tabs.js +16 -47
- package/dist/components/tooltip.d.ts +4 -4
- package/dist/components/tooltip.js +4 -9
- package/dist/components/trust-level-badge.d.ts +2 -3
- package/dist/components/trust-level-badge.js +16 -16
- package/dist/components/trust-level-dropdown.d.ts +3 -4
- package/dist/components/trust-level-dropdown.js +32 -55
- package/dist/components/typeahead.d.ts +3 -3
- package/dist/components/typeahead.js +48 -89
- package/dist/components/voice-indicator.d.ts +2 -2
- package/dist/components/voice-indicator.js +93 -106
- package/dist/components/voice-subscribe-events.d.ts +32 -0
- package/dist/components/voice-subscribe-events.js +2 -0
- package/dist/globals.d.ts +3 -5
- package/dist/globals.js +22 -33
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +22 -12
- package/dist/hooks.test.js +129 -145
- package/dist/index.d.ts +9 -8
- package/dist/index.js +13 -12
- package/dist/mention-configs.d.ts +2 -2
- package/dist/mention-configs.js +55 -42
- package/dist/screens/assistants/assistant-config.d.ts +2 -3
- package/dist/screens/assistants/assistant-config.js +9 -22
- package/dist/screens/assistants/assistant-details.d.ts +1 -2
- package/dist/screens/assistants/assistant-details.js +13 -28
- package/dist/screens/assistants/assistant-info.d.ts +2 -3
- package/dist/screens/assistants/assistant-info.js +3 -17
- package/dist/screens/assistants/assistant-list.d.ts +1 -2
- package/dist/screens/assistants/assistant-list.js +15 -56
- package/dist/screens/assistants/assistant-tools.d.ts +2 -3
- package/dist/screens/assistants/assistant-tools.js +10 -24
- package/dist/screens/console-logs/console-logs-list.d.ts +1 -2
- package/dist/screens/console-logs/console-logs-list.js +130 -134
- package/dist/screens/console-logs/log-display.d.ts +2 -3
- package/dist/screens/console-logs/log-display.js +40 -42
- package/dist/screens/console-logs/log-filters.d.ts +1 -2
- package/dist/screens/console-logs/log-filters.js +2 -24
- package/dist/screens/console-logs/mobile-log-card.d.ts +2 -3
- package/dist/screens/console-logs/mobile-log-card.js +64 -67
- package/dist/screens/console-logs/resizable-table-header.d.ts +1 -2
- package/dist/screens/console-logs/resizable-table-header.js +31 -67
- package/dist/screens/contacts/contact-details.d.ts +1 -2
- package/dist/screens/contacts/contact-details.js +16 -46
- package/dist/screens/contacts/contact-list.d.ts +1 -2
- package/dist/screens/contacts/contact-list.js +44 -103
- package/dist/screens/contacts/index.d.ts +4 -4
- package/dist/screens/contacts/index.js +1 -1
- package/dist/screens/contacts/user-connect.d.ts +1 -2
- package/dist/screens/contacts/user-connect.js +85 -186
- package/dist/screens/data-explorer/data-explorer.d.ts +1 -2
- package/dist/screens/data-explorer/data-explorer.js +61 -181
- package/dist/screens/data-explorer/index.d.ts +2 -2
- package/dist/screens/data-explorer/query-executor.d.ts +1 -2
- package/dist/screens/data-explorer/query-executor.js +56 -166
- package/dist/screens/groups/group-details.d.ts +1 -2
- package/dist/screens/groups/group-details.js +27 -122
- package/dist/screens/groups/group-invite-listener.d.ts +2 -3
- package/dist/screens/groups/group-invite-listener.js +8 -104
- package/dist/screens/groups/group-list.d.ts +1 -2
- package/dist/screens/groups/group-list.js +56 -133
- package/dist/screens/groups/group-members.d.ts +2 -3
- package/dist/screens/groups/group-members.js +62 -132
- package/dist/screens/groups/index.d.ts +4 -4
- package/dist/screens/groups/index.js +1 -1
- package/dist/screens/join-group/index.d.ts +2 -2
- package/dist/screens/join-group/join-group.d.ts +1 -2
- package/dist/screens/join-group/join-group.js +9 -109
- package/dist/screens/network-viewer/connection-troubleshooter.d.ts +2 -3
- package/dist/screens/network-viewer/connection-troubleshooter.js +89 -193
- package/dist/screens/network-viewer/cpu-usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/cpu-usage-graph.js +60 -99
- package/dist/screens/network-viewer/device-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/device-details-modal.js +25 -177
- package/dist/screens/network-viewer/group-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/group-details-modal.js +31 -142
- package/dist/screens/network-viewer/index.d.ts +4 -4
- package/dist/screens/network-viewer/index.js +3 -3
- package/dist/screens/network-viewer/network-viewer-ipc.d.ts +22 -0
- package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
- package/dist/screens/network-viewer/network-viewer.d.ts +1 -2
- package/dist/screens/network-viewer/network-viewer.js +91 -296
- package/dist/screens/network-viewer/usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/usage-graph.js +78 -110
- package/dist/screens/packages/package-details.d.ts +1 -2
- package/dist/screens/packages/package-details.js +35 -41
- package/dist/screens/packages/package-info.d.ts +2 -2
- package/dist/screens/packages/package-info.js +33 -86
- package/dist/screens/packages/package-list.d.ts +1 -2
- package/dist/screens/packages/package-list.js +42 -106
- package/dist/screens/packages/package-new-local.d.ts +1 -2
- package/dist/screens/packages/package-new-local.js +13 -19
- package/dist/screens/packages/package-versions.d.ts +2 -3
- package/dist/screens/packages/package-versions.js +29 -96
- package/dist/screens/peer-types/peer-type-details.d.ts +3 -4
- package/dist/screens/peer-types/peer-type-details.js +26 -78
- package/dist/screens/peer-types/peer-type-list.d.ts +1 -2
- package/dist/screens/peer-types/peer-type-list.js +13 -24
- package/dist/screens/search/global-search.d.ts +1 -2
- package/dist/screens/search/global-search.js +104 -182
- package/dist/screens/settings/color-mode-dropdown.d.ts +3 -4
- package/dist/screens/settings/color-mode-dropdown.js +18 -37
- package/dist/screens/settings/settings-page.d.ts +1 -1
- package/dist/screens/settings/settings-page.js +86 -213
- package/dist/screens/settings/voice-settings-agent.d.ts +1 -1
- package/dist/screens/settings/voice-settings-agent.js +7 -44
- package/dist/screens/settings/voice-settings-api-keys.d.ts +2 -2
- package/dist/screens/settings/voice-settings-api-keys.js +2 -29
- package/dist/screens/settings/voice-settings-output.d.ts +2 -2
- package/dist/screens/settings/voice-settings-output.js +2 -40
- package/dist/screens/settings/voice-settings-providers.d.ts +2 -2
- package/dist/screens/settings/voice-settings-providers.js +2 -19
- package/dist/screens/settings/voice-settings-types.d.ts +4 -4
- package/dist/screens/settings/voice-settings-types.js +31 -31
- package/dist/screens/settings/voice-settings-wake-word.d.ts +2 -2
- package/dist/screens/settings/voice-settings-wake-word.js +2 -33
- package/dist/screens/settings/voice-settings.d.ts +1 -1
- package/dist/screens/settings/voice-settings.js +35 -112
- package/dist/screens/setup-user.d.ts +1 -2
- package/dist/screens/setup-user.js +38 -116
- package/dist/screens/tools/tool-code.d.ts +2 -3
- package/dist/screens/tools/tool-code.js +9 -13
- package/dist/screens/tools/tool-details.d.ts +1 -2
- package/dist/screens/tools/tool-details.js +26 -39
- package/dist/screens/tools/tool-info.d.ts +2 -3
- package/dist/screens/tools/tool-info.js +9 -48
- package/dist/screens/tools/tool-list.d.ts +1 -2
- package/dist/screens/tools/tool-list.js +33 -65
- package/dist/screens/tools/tool-schema.d.ts +2 -3
- package/dist/screens/tools/tool-schema.js +2 -13
- package/dist/screens/tools/tool-test-details.d.ts +1 -2
- package/dist/screens/tools/tool-test-details.js +12 -28
- package/dist/screens/tools/tool-test-list.d.ts +1 -2
- package/dist/screens/tools/tool-test-list.js +17 -56
- package/dist/screens/variables/variable-details.d.ts +1 -2
- package/dist/screens/variables/variable-details.js +19 -86
- package/dist/screens/variables/variable-list.d.ts +1 -2
- package/dist/screens/variables/variable-list.js +16 -27
- package/dist/screens/welcome-modal.d.ts +1 -2
- package/dist/screens/welcome-modal.js +44 -111
- package/dist/screens/workflows/workflow-details.d.ts +1 -2
- package/dist/screens/workflows/workflow-details.js +17 -31
- package/dist/screens/workflows/workflow-info.d.ts +2 -3
- package/dist/screens/workflows/workflow-info.js +2 -9
- package/dist/screens/workflows/workflow-instructions.d.ts +2 -3
- package/dist/screens/workflows/workflow-instructions.js +23 -55
- package/dist/screens/workflows/workflow-list.d.ts +1 -2
- package/dist/screens/workflows/workflow-list.js +23 -62
- package/dist/setupTests.d.ts +1 -1
- package/dist/setupTests.js +10 -11
- package/dist/system-apps/assistants.app.d.ts +1 -1
- package/dist/system-apps/assistants.app.js +3 -3
- package/dist/system-apps/console-logs.app.d.ts +1 -1
- package/dist/system-apps/console-logs.app.js +3 -3
- package/dist/system-apps/contacts.app.d.ts +1 -1
- package/dist/system-apps/contacts.app.js +4 -4
- package/dist/system-apps/data-explorer.app.d.ts +1 -1
- package/dist/system-apps/data-explorer.app.js +4 -4
- package/dist/system-apps/groups.app.d.ts +1 -1
- package/dist/system-apps/groups.app.js +4 -4
- package/dist/system-apps/index.d.ts +17 -17
- package/dist/system-apps/index.js +52 -52
- package/dist/system-apps/join-group.app.d.ts +1 -1
- package/dist/system-apps/join-group.app.js +4 -4
- package/dist/system-apps/mobile-settings.app.d.ts +1 -1
- package/dist/system-apps/mobile-settings.app.js +3 -3
- package/dist/system-apps/network-viewer.app.d.ts +1 -1
- package/dist/system-apps/network-viewer.app.js +4 -4
- package/dist/system-apps/packages.app.d.ts +1 -1
- package/dist/system-apps/packages.app.js +3 -3
- package/dist/system-apps/search.app.d.ts +1 -1
- package/dist/system-apps/search.app.js +4 -4
- package/dist/system-apps/settings.app.d.ts +1 -1
- package/dist/system-apps/settings.app.js +3 -3
- package/dist/system-apps/threads.app.d.ts +1 -1
- package/dist/system-apps/threads.app.js +3 -3
- package/dist/system-apps/tools.app.d.ts +1 -1
- package/dist/system-apps/tools.app.js +3 -3
- package/dist/system-apps/types.app.d.ts +1 -1
- package/dist/system-apps/types.app.js +3 -3
- package/dist/system-apps/variables.app.d.ts +1 -1
- package/dist/system-apps/variables.app.js +3 -3
- package/dist/system-apps/workflows.app.d.ts +1 -1
- package/dist/system-apps/workflows.app.js +3 -3
- package/dist/tabs-layout/tabs-layout.d.ts +2 -3
- package/dist/tabs-layout/tabs-layout.js +215 -246
- package/dist/tabs-layout/tabs-state.d.ts +2 -2
- package/dist/tabs-layout/tabs-state.js +73 -61
- package/dist/ui-defaults/index.d.ts +2 -2
- package/dist/ui-defaults/list-screen.d.ts +2 -3
- package/dist/ui-defaults/list-screen.js +33 -37
- package/dist/ui-defaults/markdown-field.js +24 -56
- package/dist/ui-router/routes-loader.d.ts +1 -1
- package/dist/ui-router/routes-loader.js +17 -13
- package/dist/ui-router/ui-loader.d.ts +6 -6
- package/dist/ui-router/ui-loader.js +172 -268
- package/dist/utils.js +49 -39
- package/jest.config.js +16 -16
- package/package.json +16 -14
- package/src/command-palette/command-palette-ui.tsx +261 -237
- package/src/command-palette/command-palette.ts +81 -78
- package/src/components/chat-overlay.tsx +366 -261
- package/src/components/checkbox.tsx +15 -12
- package/src/components/group-switcher.tsx +150 -105
- package/src/components/input-date.tsx +17 -16
- package/src/components/input-number.tsx +47 -31
- package/src/components/input.tsx +15 -12
- package/src/components/inverse-lazy-list.tsx +14 -13
- package/src/components/io-schema-values.tsx +51 -69
- package/src/components/io-schema.tsx +94 -69
- package/src/components/lazy-list.tsx +51 -34
- package/src/components/list-screen.tsx +51 -35
- package/src/components/loading-indicator.tsx +2 -4
- package/src/components/markdown-editor/autolink-plugin.tsx +4 -11
- package/src/components/markdown-editor/editor-inline.tsx +3 -4
- package/src/components/markdown-editor/editor.tsx +53 -51
- package/src/components/markdown-editor/markdown-plugin.tsx +48 -40
- package/src/components/markdown-editor/mention-node.ts +39 -38
- package/src/components/markdown-editor/mentions-plugin.tsx +99 -101
- package/src/components/markdown-editor/theme.ts +28 -29
- package/src/components/markdown-editor/toolbar.tsx +53 -47
- package/src/components/markdown-with-mentions.tsx +56 -46
- package/src/components/message-logs/message-logs.tsx +225 -165
- package/src/components/messages/avatar.tsx +70 -52
- package/src/components/messages/channel-message-list.tsx +80 -68
- package/src/components/messages/channel-view.tsx +34 -33
- package/src/components/messages/message-compose.tsx +84 -67
- package/src/components/messages/message-display.tsx +103 -89
- package/src/components/messages/thread-message-list.tsx +53 -44
- package/src/components/router.tsx +42 -43
- package/src/components/save-button.tsx +43 -39
- package/src/components/sortable-list.tsx +77 -49
- package/src/components/tabs.tsx +31 -31
- package/src/components/tooltip.tsx +21 -28
- package/src/components/trust-level-badge.tsx +15 -11
- package/src/components/trust-level-dropdown.tsx +49 -19
- package/src/components/typeahead.tsx +57 -59
- package/src/components/voice-indicator.tsx +158 -141
- package/src/components/voice-subscribe-events.ts +20 -0
- package/src/globals.tsx +42 -40
- package/src/hooks.test.tsx +141 -134
- package/src/hooks.ts +80 -48
- package/src/index.tsx +17 -10
- package/src/mention-configs.ts +122 -68
- package/src/screens/assistants/assistant-config.tsx +28 -18
- package/src/screens/assistants/assistant-details.tsx +35 -36
- package/src/screens/assistants/assistant-info.tsx +16 -11
- package/src/screens/assistants/assistant-list.tsx +37 -34
- package/src/screens/assistants/assistant-tools.tsx +41 -20
- package/src/screens/console-logs/console-logs-list.tsx +173 -140
- package/src/screens/console-logs/log-display.tsx +65 -38
- package/src/screens/console-logs/log-filters.tsx +4 -3
- package/src/screens/console-logs/mobile-log-card.tsx +78 -71
- package/src/screens/console-logs/resizable-table-header.tsx +29 -21
- package/src/screens/contacts/contact-details.tsx +29 -30
- package/src/screens/contacts/contact-list.tsx +71 -60
- package/src/screens/contacts/index.ts +5 -5
- package/src/screens/contacts/user-connect.tsx +177 -171
- package/src/screens/data-explorer/data-explorer.tsx +134 -98
- package/src/screens/data-explorer/index.ts +2 -3
- package/src/screens/data-explorer/query-executor.tsx +90 -80
- package/src/screens/groups/group-details.tsx +120 -101
- package/src/screens/groups/group-invite-listener.tsx +34 -37
- package/src/screens/groups/group-list.tsx +119 -103
- package/src/screens/groups/group-members.tsx +225 -164
- package/src/screens/groups/index.ts +5 -6
- package/src/screens/join-group/index.ts +2 -2
- package/src/screens/join-group/join-group.tsx +41 -39
- package/src/screens/network-viewer/connection-troubleshooter.tsx +145 -104
- package/src/screens/network-viewer/cpu-usage-graph.tsx +39 -43
- package/src/screens/network-viewer/device-details-modal.tsx +46 -59
- package/src/screens/network-viewer/group-details-modal.tsx +68 -49
- package/src/screens/network-viewer/index.ts +4 -5
- package/src/screens/network-viewer/network-viewer-ipc.ts +23 -0
- package/src/screens/network-viewer/network-viewer.tsx +261 -236
- package/src/screens/network-viewer/usage-graph.tsx +57 -49
- package/src/screens/packages/package-details.tsx +43 -35
- package/src/screens/packages/package-info.tsx +107 -66
- package/src/screens/packages/package-list.tsx +175 -98
- package/src/screens/packages/package-new-local.tsx +28 -26
- package/src/screens/packages/package-versions.tsx +102 -77
- package/src/screens/peer-types/peer-type-details.tsx +60 -50
- package/src/screens/peer-types/peer-type-list.tsx +20 -30
- package/src/screens/search/global-search.tsx +153 -137
- package/src/screens/settings/color-mode-dropdown.tsx +52 -35
- package/src/screens/settings/settings-page.tsx +215 -141
- package/src/screens/settings/voice-settings-agent.tsx +13 -12
- package/src/screens/settings/voice-settings-api-keys.tsx +14 -12
- package/src/screens/settings/voice-settings-output.tsx +12 -11
- package/src/screens/settings/voice-settings-providers.tsx +7 -3
- package/src/screens/settings/voice-settings-types.ts +52 -49
- package/src/screens/settings/voice-settings-wake-word.tsx +25 -9
- package/src/screens/settings/voice-settings.tsx +66 -43
- package/src/screens/setup-user.tsx +88 -41
- package/src/screens/tools/tool-code.tsx +12 -17
- package/src/screens/tools/tool-details.tsx +28 -28
- package/src/screens/tools/tool-info.tsx +14 -19
- package/src/screens/tools/tool-list.tsx +58 -40
- package/src/screens/tools/tool-schema.tsx +16 -9
- package/src/screens/tools/tool-test-details.tsx +11 -22
- package/src/screens/tools/tool-test-list.tsx +29 -30
- package/src/screens/variables/variable-details.tsx +63 -51
- package/src/screens/variables/variable-list.tsx +29 -30
- package/src/screens/welcome-modal.tsx +68 -48
- package/src/screens/workflows/workflow-details.tsx +40 -30
- package/src/screens/workflows/workflow-info.tsx +4 -11
- package/src/screens/workflows/workflow-instructions.tsx +35 -28
- package/src/screens/workflows/workflow-list.tsx +50 -40
- package/src/setupTests.ts +14 -13
- package/src/system-apps/assistants.app.ts +5 -5
- package/src/system-apps/console-logs.app.ts +4 -4
- package/src/system-apps/contacts.app.ts +6 -6
- package/src/system-apps/data-explorer.app.ts +5 -5
- package/src/system-apps/groups.app.ts +6 -6
- package/src/system-apps/index.ts +49 -49
- package/src/system-apps/join-group.app.ts +5 -5
- package/src/system-apps/mobile-settings.app.ts +4 -5
- package/src/system-apps/network-viewer.app.ts +5 -5
- package/src/system-apps/packages.app.ts +5 -5
- package/src/system-apps/search.app.ts +6 -6
- package/src/system-apps/settings.app.ts +5 -5
- package/src/system-apps/threads.app.ts +5 -5
- package/src/system-apps/tools.app.ts +5 -5
- package/src/system-apps/types.app.ts +5 -5
- package/src/system-apps/variables.app.ts +5 -5
- package/src/system-apps/workflows.app.ts +5 -5
- package/src/tabs-layout/tabs-layout.tsx +345 -254
- package/src/tabs-layout/tabs-state.ts +100 -81
- package/src/ui-defaults/index.ts +2 -3
- package/src/ui-defaults/list-screen.tsx +45 -40
- package/src/ui-defaults/markdown-field.tsx +22 -26
- package/src/ui-router/routes-loader.ts +40 -24
- package/src/ui-router/ui-loader.tsx +312 -214
- package/src/utils.ts +68 -81
- package/tsconfig.json +5 -10
- package/dist/components/input-datetime.d.ts +0 -7
- package/dist/components/input-datetime.js +0 -35
- package/dist/components/lazy-sortable-list.d.ts +0 -29
- package/dist/components/lazy-sortable-list.js +0 -12
- package/dist/components/left-bar.d.ts +0 -5
- package/dist/components/left-bar.js +0 -207
- package/dist/components/main-content-container.d.ts +0 -2
- package/dist/components/main-content-container.js +0 -92
- package/dist/components/messages/thread-view.d.ts +0 -6
- package/dist/components/messages/thread-view.js +0 -174
- package/dist/components/off-canvas.d.ts +0 -13
- package/dist/components/off-canvas.js +0 -89
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +0 -6
- package/dist/components/text-list-editor.tsx/text-list-editor.js +0 -13
- package/dist/components/top-bar.d.ts +0 -2
- package/dist/components/top-bar.js +0 -51
- package/dist/components/typeahead/mentions-plugin.d.ts +0 -7
- package/dist/components/typeahead/mentions-plugin.js +0 -203
- package/dist/components/typeahead/typeahead-editor.d.ts +0 -15
- package/dist/components/typeahead/typeahead-editor.js +0 -134
- package/dist/components/typeahead/typeahead.d.ts +0 -12
- package/dist/components/typeahead/typeahead.js +0 -94
- package/dist/screens/profile.d.ts +0 -2
- package/dist/screens/profile.js +0 -76
- package/src/components/input-datetime.tsx +0 -41
- package/src/components/lazy-sortable-list.tsx +0 -51
- package/src/components/left-bar.tsx +0 -322
- package/src/components/main-content-container.tsx +0 -79
- package/src/components/messages/thread-view.tsx +0 -214
- package/src/components/off-canvas.tsx +0 -83
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +0 -13
- package/src/components/top-bar.tsx +0 -119
- package/src/components/typeahead/mentions-plugin.tsx +0 -265
- package/src/components/typeahead/typeahead-editor.tsx +0 -140
- package/src/components/typeahead/typeahead.tsx +0 -77
- package/src/screens/profile.tsx +0 -75
|
@@ -1,83 +1,98 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { type Observable, unwrapObservable } from "@peers-app/peers-sdk";
|
|
2
|
+
import { last, sortBy } from "lodash";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import Sortable from "sortablejs";
|
|
6
5
|
|
|
7
6
|
export interface ISortable {
|
|
8
|
-
sortOrder: number
|
|
7
|
+
sortOrder: number;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
interface ISortableListProps<T extends ISortable> {
|
|
12
|
-
items: Observable<T[]> | T[]
|
|
13
|
-
renderItem: (props: { item: T
|
|
14
|
-
listsGroup?: string
|
|
15
|
-
onAdd?: (
|
|
16
|
-
onUpdate?: (
|
|
17
|
-
hidden?: boolean
|
|
18
|
-
containerProps?: Record<string,
|
|
19
|
-
dragHandleClassName?: string
|
|
20
|
-
sortDirection?:
|
|
21
|
-
minHeight?: string | number
|
|
22
|
-
paddingBottom?: string | number
|
|
11
|
+
items: Observable<T[]> | T[];
|
|
12
|
+
renderItem: (props: { item: T; listId: string; sortHandle: string }) => React.ReactNode;
|
|
13
|
+
listsGroup?: string;
|
|
14
|
+
onAdd?: (itemId: string, sortOrder: number) => void;
|
|
15
|
+
onUpdate?: (args: { items: T[]; ixMoved: number[] }) => void;
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
containerProps?: Record<string, unknown>;
|
|
18
|
+
dragHandleClassName?: string;
|
|
19
|
+
sortDirection?: "asc" | "desc";
|
|
20
|
+
minHeight?: string | number;
|
|
21
|
+
paddingBottom?: string | number;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
export class SortableList<T extends ISortable> extends React.Component<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
export class SortableList<T extends ISortable> extends React.Component<
|
|
25
|
+
ISortableListProps<T>,
|
|
26
|
+
Record<string, never>
|
|
27
|
+
> {
|
|
28
|
+
constructor(props: ISortableListProps<T>) {
|
|
29
29
|
super(props);
|
|
30
|
-
this.sortHandle =
|
|
30
|
+
this.sortHandle =
|
|
31
|
+
(this.props.dragHandleClassName && `.${this.props.dragHandleClassName}`) || this.sortHandle;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
items: T[] = [];
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
listId = `${Date.now()}_${Math.round(Math.random()*100000)}`;
|
|
36
|
+
listId = `${Date.now()}_${Math.round(Math.random() * 100000)}`;
|
|
38
37
|
sortHandle = `.sort-handle-${this.listId}`;
|
|
39
38
|
|
|
40
39
|
calculateSortOrder(index: number) {
|
|
41
40
|
const items = this.items;
|
|
42
41
|
if (index === 0) return Date.now();
|
|
43
|
-
if (index >= items.length)
|
|
42
|
+
if (index >= items.length) {
|
|
43
|
+
const tail = last(items);
|
|
44
|
+
return (tail?.sortOrder ?? Date.now()) - 10000;
|
|
45
|
+
}
|
|
44
46
|
const above = items[index - 1].sortOrder ?? Date.now();
|
|
45
47
|
const below = items[index].sortOrder ?? Number.MIN_VALUE;
|
|
46
|
-
if (above === below)
|
|
47
|
-
|
|
48
|
+
if (above === below)
|
|
49
|
+
alert(
|
|
50
|
+
"sort order has converged to the same number in this area. Try moving items to the top or bottom of the list to fix it",
|
|
51
|
+
);
|
|
52
|
+
return above - (above - below) / 2;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
componentDidMount() {
|
|
51
|
-
const
|
|
52
|
-
|
|
56
|
+
const listDiv = document.getElementById(this.listId);
|
|
57
|
+
if (!listDiv) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
53
60
|
|
|
54
61
|
Sortable.create(listDiv, {
|
|
55
62
|
handle: this.sortHandle,
|
|
56
63
|
group: { name: this.props.listsGroup || this.listId, put: !!this.props.onAdd },
|
|
57
64
|
animation: 100,
|
|
58
65
|
|
|
59
|
-
onUpdate: evt => {
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
onUpdate: (evt) => {
|
|
67
|
+
const oldIndex = evt.oldIndex;
|
|
68
|
+
const newIndex = evt.newIndex;
|
|
69
|
+
if (oldIndex === undefined || newIndex === undefined) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const items = this.items;
|
|
73
|
+
const item = items.splice(oldIndex, 1)[0];
|
|
74
|
+
if (!item) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
item.sortOrder = this.calculateSortOrder(newIndex);
|
|
78
|
+
items.splice(newIndex, 0, item);
|
|
64
79
|
// console.log(items.map(i => i.toJS()));
|
|
65
80
|
if (this.props.onUpdate) {
|
|
66
|
-
this.props.onUpdate({ items, ixMoved: [
|
|
81
|
+
this.props.onUpdate({ items, ixMoved: [newIndex] });
|
|
67
82
|
}
|
|
68
83
|
},
|
|
69
84
|
|
|
70
|
-
onAdd: evt => {
|
|
71
|
-
const itemEl = evt.item;
|
|
85
|
+
onAdd: (evt) => {
|
|
86
|
+
const itemEl = evt.item; // dragged HTMLElement
|
|
72
87
|
if (evt.to !== evt.from) {
|
|
73
88
|
// first restore html hierarchy so html doesn't get out of sync with react
|
|
74
89
|
evt.to.removeChild(itemEl);
|
|
75
90
|
evt.from.appendChild(itemEl);
|
|
76
91
|
|
|
77
92
|
// now if we were given an `onAdd` function, call it
|
|
78
|
-
if (this.props.onAdd) {
|
|
93
|
+
if (this.props.onAdd && evt.newIndex !== undefined) {
|
|
79
94
|
const itemId = evt.item.id;
|
|
80
|
-
this.props.onAdd(itemId, this.calculateSortOrder(evt.newIndex
|
|
95
|
+
this.props.onAdd(itemId, this.calculateSortOrder(evt.newIndex));
|
|
81
96
|
}
|
|
82
97
|
}
|
|
83
98
|
},
|
|
@@ -86,17 +101,30 @@ export class SortableList<T extends ISortable> extends React.Component<ISortable
|
|
|
86
101
|
|
|
87
102
|
public render() {
|
|
88
103
|
let items = unwrapObservable(this.props.items);
|
|
89
|
-
if (this.props.sortDirection ===
|
|
90
|
-
items = sortBy(items, i => i.sortOrder ?? -Infinity);
|
|
104
|
+
if (this.props.sortDirection === "asc") {
|
|
105
|
+
items = sortBy(items, (i) => i.sortOrder ?? -Infinity);
|
|
91
106
|
} else {
|
|
92
|
-
// @ts-
|
|
93
|
-
items = sortBy(items, i => -i.sortOrder ?? Infinity);
|
|
107
|
+
// @ts-expect-error
|
|
108
|
+
items = sortBy(items, (i) => -i.sortOrder ?? Infinity);
|
|
94
109
|
}
|
|
95
110
|
this.items = items;
|
|
96
111
|
return (
|
|
97
|
-
<div
|
|
98
|
-
{
|
|
112
|
+
<div
|
|
113
|
+
id={this.listId}
|
|
114
|
+
style={{
|
|
115
|
+
minHeight: this.props.minHeight ?? "25px",
|
|
116
|
+
paddingBottom: this.props.paddingBottom ?? "10px",
|
|
117
|
+
}}
|
|
118
|
+
{...this.props.containerProps}
|
|
119
|
+
>
|
|
120
|
+
{items.map((item) =>
|
|
121
|
+
this.props.renderItem({
|
|
122
|
+
item,
|
|
123
|
+
listId: this.listId,
|
|
124
|
+
sortHandle: this.sortHandle.substring(1),
|
|
125
|
+
}),
|
|
126
|
+
)}
|
|
99
127
|
</div>
|
|
100
|
-
)
|
|
128
|
+
);
|
|
101
129
|
}
|
|
102
|
-
}
|
|
130
|
+
}
|
package/src/components/tabs.tsx
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { useState } from "react";
|
|
2
3
|
import { queryParam } from "../globals";
|
|
3
4
|
|
|
4
5
|
interface ITabsProps {
|
|
5
|
-
tabs: {
|
|
6
|
-
name: string
|
|
7
|
-
content: JSX.Element
|
|
8
|
-
active?: true
|
|
6
|
+
tabs: {
|
|
7
|
+
name: string;
|
|
8
|
+
content: JSX.Element;
|
|
9
|
+
active?: true;
|
|
9
10
|
}[];
|
|
10
11
|
contentClassName?: string;
|
|
11
12
|
activeTabName?: string;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
let lastActive =
|
|
15
|
+
let lastActive = "";
|
|
15
16
|
|
|
16
17
|
export const Tabs = (props: ITabsProps) => {
|
|
17
18
|
const { tabs } = props;
|
|
18
|
-
|
|
19
|
+
|
|
19
20
|
const [activeTab, _setActiveTab] = useState(() => {
|
|
20
|
-
let activeTabName = tabs.find(tab => tab.active)?.name || queryParam(
|
|
21
|
+
let activeTabName = tabs.find((tab) => tab.active)?.name || queryParam("tab") || lastActive;
|
|
21
22
|
activeTabName = activeTabName.toLowerCase();
|
|
22
|
-
const _activeTab = tabs.find(tab => tab.name.toLowerCase() === activeTabName) || tabs[0];
|
|
23
|
+
const _activeTab = tabs.find((tab) => tab.name.toLowerCase() === activeTabName) || tabs[0];
|
|
23
24
|
lastActive = _activeTab.name;
|
|
24
25
|
return _activeTab;
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
// Allow parent to control the active tab imperatively
|
|
28
29
|
const resolvedActiveTab = props.activeTabName
|
|
29
|
-
? (tabs.find(tab => tab.name.toLowerCase() === props.activeTabName
|
|
30
|
+
? (tabs.find((tab) => tab.name.toLowerCase() === props.activeTabName?.toLowerCase()) ??
|
|
31
|
+
activeTab)
|
|
30
32
|
: activeTab;
|
|
31
|
-
|
|
32
|
-
function setActiveTab(tab: { name: string
|
|
33
|
+
|
|
34
|
+
function setActiveTab(tab: { name: string; content: JSX.Element }) {
|
|
33
35
|
_setActiveTab(tab);
|
|
34
36
|
lastActive = tab.name;
|
|
35
37
|
}
|
|
@@ -37,40 +39,38 @@ export const Tabs = (props: ITabsProps) => {
|
|
|
37
39
|
return (
|
|
38
40
|
<>
|
|
39
41
|
<ul className="nav nav-tabs">
|
|
40
|
-
{tabs.map((tab
|
|
42
|
+
{tabs.map((tab) => {
|
|
41
43
|
return (
|
|
42
|
-
<li key={tab.name
|
|
44
|
+
<li key={tab.name} className="nav-item">
|
|
43
45
|
<a
|
|
44
46
|
href="#"
|
|
45
|
-
className={
|
|
46
|
-
onClick={evt =>
|
|
47
|
+
className={`nav-link ${resolvedActiveTab.name === tab.name ? "active" : ""}`}
|
|
48
|
+
onClick={(evt) => {
|
|
49
|
+
evt.preventDefault();
|
|
50
|
+
setActiveTab(tab);
|
|
51
|
+
}}
|
|
47
52
|
>
|
|
48
53
|
{tab.name}
|
|
49
54
|
</a>
|
|
50
55
|
</li>
|
|
51
|
-
)
|
|
56
|
+
);
|
|
52
57
|
})}
|
|
53
58
|
</ul>
|
|
54
|
-
<div className={
|
|
55
|
-
{tabs.map((tab
|
|
59
|
+
<div className={`tab-content ${props.contentClassName ?? "mt-3"}`}>
|
|
60
|
+
{tabs.map((tab) => {
|
|
56
61
|
return (
|
|
57
|
-
<div key={tab.name
|
|
62
|
+
<div key={tab.name} hidden={resolvedActiveTab.name !== tab.name}>
|
|
58
63
|
{tab.content}
|
|
59
64
|
</div>
|
|
60
|
-
)
|
|
65
|
+
);
|
|
61
66
|
})}
|
|
62
67
|
</div>
|
|
63
68
|
</>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
69
|
+
);
|
|
70
|
+
};
|
|
67
71
|
|
|
68
72
|
export const ScreenTabBody = (props: React.PropsWithChildren) => {
|
|
69
73
|
return (
|
|
70
|
-
<div
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{props.children}
|
|
74
|
-
</div>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
74
|
+
<div style={{ maxHeight: "calc(100vh - 138px)", overflowY: "auto" }}>{props.children}</div>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Observable } from "@peers-app/peers-sdk";
|
|
2
|
-
import React from
|
|
3
|
-
import { Popover } from
|
|
4
|
-
import { MarkdownWithMentions } from './markdown-with-mentions';
|
|
1
|
+
import type { Observable } from "@peers-app/peers-sdk";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import { Popover } from "react-tiny-popover";
|
|
5
4
|
import { useObservable, useObservableState } from "../hooks";
|
|
5
|
+
import { MarkdownWithMentions } from "./markdown-with-mentions";
|
|
6
6
|
|
|
7
7
|
interface IProps {
|
|
8
8
|
markdownContent?: string | Observable<string> | Observable<string | undefined>;
|
|
9
9
|
handle?: React.ReactNode;
|
|
10
10
|
handleClassName?: string;
|
|
11
|
-
positions?: (
|
|
12
|
-
genericContent?: React.ReactNode
|
|
11
|
+
positions?: ("right" | "bottom" | "left" | "top")[];
|
|
12
|
+
genericContent?: React.ReactNode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const Tooltip = (props: IProps) => {
|
|
16
16
|
const { handle } = props;
|
|
17
17
|
let [markdownContent] = useObservable(props.markdownContent);
|
|
18
18
|
|
|
19
|
-
markdownContent = markdownContent ??
|
|
19
|
+
markdownContent = markdownContent ?? "";
|
|
20
20
|
|
|
21
21
|
const showPopover = useObservableState(false);
|
|
22
22
|
|
|
@@ -24,27 +24,20 @@ export const Tooltip = (props: IProps) => {
|
|
|
24
24
|
<Popover
|
|
25
25
|
isOpen={showPopover()}
|
|
26
26
|
onClickOutside={() => showPopover(false)}
|
|
27
|
-
positions={props.positions ?? [
|
|
28
|
-
content={
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<MarkdownWithMentions
|
|
37
|
-
content={markdownContent}
|
|
38
|
-
/>
|
|
39
|
-
}
|
|
40
|
-
</div>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
27
|
+
positions={props.positions ?? ["right", "bottom", "left", "top"]}
|
|
28
|
+
content={() => (
|
|
29
|
+
<div
|
|
30
|
+
className="card p-2 bg-light-subtle"
|
|
31
|
+
style={{ maxWidth: 500, maxHeight: 400, overflowY: "auto", zIndex: 1000001 }}
|
|
32
|
+
>
|
|
33
|
+
{props.genericContent || <MarkdownWithMentions content={markdownContent} />}
|
|
34
|
+
</div>
|
|
35
|
+
)}
|
|
43
36
|
>
|
|
44
|
-
<span className={props.handleClassName ??
|
|
45
|
-
{handle ?? <i className="bi bi-info-circle" style={{ cursor:
|
|
37
|
+
<span className={props.handleClassName ?? "p-2"} onClick={() => showPopover(!showPopover())}>
|
|
38
|
+
{handle ?? <i className="bi bi-info-circle" style={{ cursor: "pointer" }}></i>}
|
|
46
39
|
{/* <i className="fa-solid fa-note-sticky" onClick={() => showPopover(!showPopover())}></i> */}
|
|
47
40
|
</span>
|
|
48
|
-
</Popover
|
|
49
|
-
)
|
|
50
|
-
}
|
|
41
|
+
</Popover>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { TrustLevel } from
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import { TrustLevel } from "@peers-app/peers-sdk";
|
|
3
2
|
|
|
4
3
|
interface TrustLevelBadgeProps {
|
|
5
4
|
level: TrustLevel;
|
|
@@ -8,21 +7,26 @@ interface TrustLevelBadgeProps {
|
|
|
8
7
|
export const TrustLevelBadge = ({ level }: TrustLevelBadgeProps) => {
|
|
9
8
|
// Define trust level configurations with their numeric values
|
|
10
9
|
const trustLevelConfigs = [
|
|
11
|
-
{ value: TrustLevel.Self, color:
|
|
12
|
-
{ value: TrustLevel.Trusted, color:
|
|
13
|
-
{ value: TrustLevel.Known, color:
|
|
14
|
-
{ value: TrustLevel.NewDevice, color:
|
|
15
|
-
{ value: TrustLevel.NewUser, color:
|
|
16
|
-
{ value: TrustLevel.Unknown, color:
|
|
17
|
-
{
|
|
18
|
-
|
|
10
|
+
{ value: TrustLevel.Self, color: "success", icon: "bi-shield-fill-check", text: "Self" },
|
|
11
|
+
{ value: TrustLevel.Trusted, color: "success", icon: "bi-shield-check", text: "Trusted" },
|
|
12
|
+
{ value: TrustLevel.Known, color: "primary", icon: "bi-shield-check", text: "Known" },
|
|
13
|
+
{ value: TrustLevel.NewDevice, color: "info", icon: "bi-shield-plus", text: "New Device" },
|
|
14
|
+
{ value: TrustLevel.NewUser, color: "info", icon: "bi-shield-plus", text: "New User" },
|
|
15
|
+
{ value: TrustLevel.Unknown, color: "warning", icon: "bi-shield-exclamation", text: "Unknown" },
|
|
16
|
+
{
|
|
17
|
+
value: TrustLevel.Untrusted,
|
|
18
|
+
color: "danger",
|
|
19
|
+
icon: "bi-shield-exclamation",
|
|
20
|
+
text: "Untrusted",
|
|
21
|
+
},
|
|
22
|
+
{ value: TrustLevel.Malicious, color: "danger", icon: "bi-shield-x", text: "Malicious" },
|
|
19
23
|
];
|
|
20
24
|
|
|
21
25
|
// Sort by trust level value (ascending, so lowest first)
|
|
22
26
|
const sortedConfigs = trustLevelConfigs.sort((a, b) => a.value - b.value);
|
|
23
27
|
|
|
24
28
|
// Find the highest trust level that is at or below the current level
|
|
25
|
-
let config = { color:
|
|
29
|
+
let config = { color: "secondary", icon: "bi-shield", text: "Unknown" };
|
|
26
30
|
for (const trustConfig of sortedConfigs) {
|
|
27
31
|
if (level >= trustConfig.value) {
|
|
28
32
|
config = trustConfig;
|
|
@@ -1,32 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
type DataContext,
|
|
3
|
+
getUserContext,
|
|
4
|
+
getUserTrustLevel,
|
|
5
|
+
setUserTrustLevel,
|
|
6
|
+
TrustLevel,
|
|
7
|
+
} from "@peers-app/peers-sdk";
|
|
8
|
+
import { useEffect, useState } from "react";
|
|
9
|
+
import { LoadingIndicator } from "./loading-indicator";
|
|
4
10
|
|
|
5
11
|
interface TrustLevelDropdownProps {
|
|
6
12
|
userId: string;
|
|
7
13
|
dataContext?: DataContext;
|
|
8
14
|
onChange?: (newLevel: TrustLevel) => void;
|
|
9
|
-
type?:
|
|
15
|
+
type?: "user" | "device";
|
|
10
16
|
}
|
|
11
17
|
|
|
12
|
-
export const TrustLevelDropdown = ({
|
|
18
|
+
export const TrustLevelDropdown = ({
|
|
19
|
+
userId,
|
|
20
|
+
dataContext,
|
|
21
|
+
onChange,
|
|
22
|
+
type = "user",
|
|
23
|
+
}: TrustLevelDropdownProps) => {
|
|
13
24
|
const [trustLevel, setTrustLevelState] = useState<TrustLevel>(TrustLevel.Unknown);
|
|
14
25
|
const [loading, setLoading] = useState(true);
|
|
15
26
|
|
|
16
27
|
const allTrustLevelConfigs = [
|
|
17
|
-
{ value: TrustLevel.Self, color:
|
|
18
|
-
{ value: TrustLevel.Trusted, color:
|
|
19
|
-
{ value: TrustLevel.Known, color:
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
{ value: TrustLevel.Self, color: "success", icon: "bi-shield-fill-check", text: "Self" },
|
|
29
|
+
{ value: TrustLevel.Trusted, color: "success", icon: "bi-shield-check", text: "Trusted" },
|
|
30
|
+
{ value: TrustLevel.Known, color: "primary", icon: "bi-shield-check", text: "Known" },
|
|
31
|
+
{
|
|
32
|
+
value: TrustLevel.NewDevice,
|
|
33
|
+
color: "info",
|
|
34
|
+
icon: "bi-shield-plus",
|
|
35
|
+
text: "New Device",
|
|
36
|
+
showFor: "device",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: TrustLevel.NewUser,
|
|
40
|
+
color: "info",
|
|
41
|
+
icon: "bi-shield-plus",
|
|
42
|
+
text: "New User",
|
|
43
|
+
showFor: "user",
|
|
44
|
+
},
|
|
45
|
+
{ value: TrustLevel.Unknown, color: "warning", icon: "bi-shield-exclamation", text: "Unknown" },
|
|
46
|
+
{
|
|
47
|
+
value: TrustLevel.Untrusted,
|
|
48
|
+
color: "danger",
|
|
49
|
+
icon: "bi-shield-exclamation",
|
|
50
|
+
text: "Untrusted",
|
|
51
|
+
},
|
|
52
|
+
{ value: TrustLevel.Malicious, color: "danger", icon: "bi-shield-x", text: "Malicious" },
|
|
25
53
|
];
|
|
26
54
|
|
|
27
55
|
// Filter configs based on type
|
|
28
|
-
const trustLevelConfigs = allTrustLevelConfigs.filter(
|
|
29
|
-
!config.showFor || config.showFor === type
|
|
56
|
+
const trustLevelConfigs = allTrustLevelConfigs.filter(
|
|
57
|
+
(config) => !config.showFor || config.showFor === type,
|
|
30
58
|
);
|
|
31
59
|
|
|
32
60
|
useEffect(() => {
|
|
@@ -52,7 +80,7 @@ export const TrustLevelDropdown = ({ userId, dataContext, onChange, type = 'user
|
|
|
52
80
|
|
|
53
81
|
// Find current config
|
|
54
82
|
const sortedConfigs = trustLevelConfigs.sort((a, b) => a.value - b.value);
|
|
55
|
-
let currentConfig = { color:
|
|
83
|
+
let currentConfig = { color: "secondary", icon: "bi-shield", text: "Unknown" };
|
|
56
84
|
for (const config of sortedConfigs) {
|
|
57
85
|
if (trustLevel >= config.value) {
|
|
58
86
|
currentConfig = config;
|
|
@@ -85,9 +113,11 @@ export const TrustLevelDropdown = ({ userId, dataContext, onChange, type = 'user
|
|
|
85
113
|
className="dropdown-item p-2"
|
|
86
114
|
onClick={() => handleTrustLevelChange(config.value)}
|
|
87
115
|
>
|
|
88
|
-
<span
|
|
89
|
-
|
|
90
|
-
|
|
116
|
+
<span
|
|
117
|
+
className={`badge bg-${config.color} d-flex align-items-center gap-2 w-100 py-2 px-3 fs-6 ${
|
|
118
|
+
trustLevel === config.value ? "border border-dark border-2" : ""
|
|
119
|
+
}`}
|
|
120
|
+
>
|
|
91
121
|
<i className={config.icon} />
|
|
92
122
|
{config.text}
|
|
93
123
|
</span>
|