@bevel-software/platform-core-frontend 0.15.1 → 0.19.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/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +16 -9
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +11 -3
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/email.ts +37 -1
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +140 -6
- package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/connection-keys.api.ts +47 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +108 -3
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
- package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +47 -4
- package/src/modules/library/__tests__/link-membership.test.ts +13 -4
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +146 -45
- package/src/modules/library/components/LibraryLayout.tsx +119 -256
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
- package/src/modules/library/components/LockedPluginView.tsx +62 -34
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +16 -2
- package/src/modules/library/components/PageActions.tsx +11 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
- package/src/modules/library/components/PluginExtras.tsx +140 -17
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +157 -41
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +239 -263
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +141 -28
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +103 -17
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
- package/src/modules/library/routes/library-paths.ts +26 -28
- package/src/modules/library/services/library.api.ts +38 -20
- package/src/modules/library/services/plugins.api.ts +69 -8
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +170 -32
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +75 -9
- package/src/modules/library/utils/status.ts +135 -33
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +10 -30
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
- package/src/modules/settings/services/github-facade.api.ts +23 -0
- package/src/modules/settings/settings-nav-items.tsx +10 -2
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +497 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +521 -43
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +140 -3
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +6 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
- package/src/modules/workspace/components/FileRoute.tsx +353 -36
- package/src/modules/workspace/components/FileViewer.tsx +166 -45
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +331 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +206 -29
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +125 -19
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +112 -36
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +6 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +33 -5
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +25 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState, type FormEvent } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useRef, useState, type FormEvent } from 'react';
|
|
2
2
|
import { PageShell } from '../../../shared/components/PageShell';
|
|
3
3
|
import { Dialog } from '../../../shared/components/Dialog';
|
|
4
4
|
import { useAdmin } from '../state/admin.context';
|
|
@@ -6,21 +6,115 @@ import { useAuth } from '../../auth/state/auth.context';
|
|
|
6
6
|
import {
|
|
7
7
|
createAccount,
|
|
8
8
|
deleteAccount,
|
|
9
|
+
getAccountReferences,
|
|
9
10
|
listAccounts,
|
|
11
|
+
type AccountReferences,
|
|
10
12
|
type AccountSummary,
|
|
11
13
|
} from '../../auth/services/account.api';
|
|
12
14
|
|
|
15
|
+
/**
|
|
16
|
+
* How an account signs in, in the words this page uses everywhere (the row and
|
|
17
|
+
* the delete confirmation). The deployment admin wins over a stored hash: both
|
|
18
|
+
* can be true, and the environment credential is the one that survives.
|
|
19
|
+
*/
|
|
20
|
+
function signInMethodLabel(account: Pick<AccountSummary, 'hasPassword' | 'isEnvAdmin'>): string {
|
|
21
|
+
if (account.isEnvAdmin) return 'Password (deployment admin)';
|
|
22
|
+
if (account.hasPassword) return 'Password';
|
|
23
|
+
return 'No password — signs in with single sign-on';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* What deleting the account means for signing in again, keyed off the same
|
|
28
|
+
* facts as {@link signInMethodLabel} and opening with its wording.
|
|
29
|
+
*/
|
|
30
|
+
function signInAfterDelete(account: AccountSummary): string {
|
|
31
|
+
const label = signInMethodLabel(account);
|
|
32
|
+
if (account.isEnvAdmin) {
|
|
33
|
+
return `${label}: they can still sign in with the deployment admin password, but will start fresh.`;
|
|
34
|
+
}
|
|
35
|
+
if (account.hasPassword) {
|
|
36
|
+
return `${label}: to sign in again they will need an admin to create a new account for them.`;
|
|
37
|
+
}
|
|
38
|
+
return `${label}: they can sign in again later with single sign-on, but will start fresh.`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function plural(n: number, one: string, many: string): string {
|
|
42
|
+
return `${n} ${n === 1 ? one : many}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** "Named in 5 places: 1 role, 1 group, 2 access rules and 1 file grant." */
|
|
46
|
+
function referencesSummary(refs: AccountReferences): string {
|
|
47
|
+
if (refs.total === 0) return 'Their address is not named in any role, group or access rule.';
|
|
48
|
+
const parts = [
|
|
49
|
+
refs.roles > 0 ? plural(refs.roles, 'role', 'roles') : null,
|
|
50
|
+
refs.groups > 0 ? plural(refs.groups, 'group', 'groups') : null,
|
|
51
|
+
refs.accessRules > 0 ? plural(refs.accessRules, 'access rule', 'access rules') : null,
|
|
52
|
+
refs.fileGrants > 0 ? plural(refs.fileGrants, 'file grant', 'file grants') : null,
|
|
53
|
+
].filter((part): part is string => part !== null);
|
|
54
|
+
const list = parts.length > 1 ? `${parts.slice(0, -1).join(', ')} and ${parts.at(-1)}` : parts[0];
|
|
55
|
+
return `Their address is named in ${plural(refs.total, 'place', 'places')}: ${list}.`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The two password actions and everything the page says about each. Setting a
|
|
60
|
+
* first password and replacing one someone signs in with today are different
|
|
61
|
+
* acts — the second takes a working credential away — so they get different
|
|
62
|
+
* labels and different copy, and a reset asks before it does it.
|
|
63
|
+
*
|
|
64
|
+
* The whole branch is `hasPassword`, the flag the list already carries for the
|
|
65
|
+
* sign-in method line: nothing about the credential itself is read here, and
|
|
66
|
+
* nothing more needs to be.
|
|
67
|
+
*/
|
|
68
|
+
type PasswordAction = {
|
|
69
|
+
/** The row button, the dialog title and the confirm button all read this. */
|
|
70
|
+
label: string;
|
|
71
|
+
/** The row button's tooltip. */
|
|
72
|
+
title: string;
|
|
73
|
+
/** What the new password does, said after the account it is for. */
|
|
74
|
+
effect: string;
|
|
75
|
+
/** The question the confirm button answers, or none when there is nothing to lose. */
|
|
76
|
+
confirm: string | null;
|
|
77
|
+
/** The inline banner once it is done. */
|
|
78
|
+
done: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const SET_PASSWORD: PasswordAction = {
|
|
82
|
+
label: 'Set password',
|
|
83
|
+
title: 'Set a sign-in password for this account.',
|
|
84
|
+
effect:
|
|
85
|
+
'They have no password today, so from now on they will be able to sign in with this one as well as with single sign-on.',
|
|
86
|
+
confirm: null,
|
|
87
|
+
done: 'Password set',
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const RESET_PASSWORD: PasswordAction = {
|
|
91
|
+
label: 'Reset password',
|
|
92
|
+
title: 'Replace the sign-in password this account has now.',
|
|
93
|
+
effect:
|
|
94
|
+
'Their current password stops working immediately and this one takes its place, so they are locked out of password sign-in until they have it.',
|
|
95
|
+
confirm: 'Reset it?',
|
|
96
|
+
done: 'Password reset',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
function passwordAction(account: Pick<AccountSummary, 'hasPassword'>): PasswordAction {
|
|
100
|
+
return account.hasPassword ? RESET_PASSWORD : SET_PASSWORD;
|
|
101
|
+
}
|
|
102
|
+
|
|
13
103
|
/**
|
|
14
104
|
* The User Accounts page (`/user-accounts`, admins only) — the ONE
|
|
15
105
|
* account-management surface: every account on the deployment, whether it can
|
|
16
|
-
* sign in with a password, set a user's password (accounts that predate
|
|
17
|
-
* per-user passwords can't sign in until an admin sets one)
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
106
|
+
* sign in with a password, set a user's first password (accounts that predate
|
|
107
|
+
* per-user passwords can't sign in until an admin sets one) or reset the one
|
|
108
|
+
* they have — two acts the page names apart, see {@link PasswordAction} —
|
|
109
|
+
* permanently delete an account (the GDPR erasure path — overlays contribute
|
|
110
|
+
* their data slices via erasure participants), and add a new account. Set,
|
|
111
|
+
* reset and create all go through `POST /api/admin/accounts`, an
|
|
112
|
+
* upsert-by-email that preserves an existing display name when none is
|
|
113
|
+
* supplied. The signed-in admin's own row offers neither action — the backend
|
|
114
|
+
* refuses self-erasure, and their own password lives on the Account page. The
|
|
115
|
+
* deployment admin's row offers no password action either, from any admin:
|
|
116
|
+
* that account's password is set in the deployment environment, and the
|
|
117
|
+
* backend refuses to store one for it.
|
|
24
118
|
*/
|
|
25
119
|
export function UserAccountsPage() {
|
|
26
120
|
const { isAdmin } = useAdmin();
|
|
@@ -31,13 +125,30 @@ export function UserAccountsPage() {
|
|
|
31
125
|
// Dialog. `deleting` keeps the confirm open while the request is in flight.
|
|
32
126
|
const [pendingDelete, setPendingDelete] = useState<AccountSummary | null>(null);
|
|
33
127
|
const [deleting, setDeleting] = useState(false);
|
|
128
|
+
// Where the pending account's address is named, and whether to remove it
|
|
129
|
+
// from those files in the same delete (on by default).
|
|
130
|
+
const [references, setReferences] = useState<AccountReferences | null>(null);
|
|
131
|
+
const [referencesError, setReferencesError] = useState<string | null>(null);
|
|
132
|
+
const [removeFromAccess, setRemoveFromAccess] = useState(true);
|
|
133
|
+
// Which references request the dialog is waiting for — a slower answer
|
|
134
|
+
// for an account opened earlier must not land in a later dialog.
|
|
135
|
+
const referencesRequest = useRef(0);
|
|
136
|
+
// After a delete whose access-file cleanup did not fully land: what went
|
|
137
|
+
// wrong and which files still name the deleted user.
|
|
138
|
+
const [accessNotice, setAccessNotice] = useState<{ message: string; files: string[] } | null>(null);
|
|
34
139
|
// The account whose password is being set; non-null drives the password
|
|
35
140
|
// Dialog. Success feedback surfaces inline above the list.
|
|
36
141
|
const [passwordTarget, setPasswordTarget] = useState<AccountSummary | null>(null);
|
|
37
142
|
const [newPassword, setNewPassword] = useState('');
|
|
38
143
|
const [passwordError, setPasswordError] = useState<string | null>(null);
|
|
39
144
|
const [savingPassword, setSavingPassword] = useState(false);
|
|
40
|
-
|
|
145
|
+
// Which account was just given a password, and which of the two actions it
|
|
146
|
+
// was — the target is cleared when the dialog closes, and "set" and "reset"
|
|
147
|
+
// are not the same news to report.
|
|
148
|
+
const [passwordDone, setPasswordDone] = useState<{
|
|
149
|
+
email: string;
|
|
150
|
+
action: PasswordAction;
|
|
151
|
+
} | null>(null);
|
|
41
152
|
// Add-account form.
|
|
42
153
|
const [addEmail, setAddEmail] = useState('');
|
|
43
154
|
const [addName, setAddName] = useState('');
|
|
@@ -64,12 +175,63 @@ export function UserAccountsPage() {
|
|
|
64
175
|
if (isAdmin) refresh();
|
|
65
176
|
}, [isAdmin, refresh]);
|
|
66
177
|
|
|
178
|
+
function openDeleteDialog(account: AccountSummary) {
|
|
179
|
+
setPendingDelete(account);
|
|
180
|
+
setReferences(null);
|
|
181
|
+
setReferencesError(null);
|
|
182
|
+
setRemoveFromAccess(true);
|
|
183
|
+
const requestId = ++referencesRequest.current;
|
|
184
|
+
getAccountReferences(account.id)
|
|
185
|
+
.then((refs) => {
|
|
186
|
+
if (referencesRequest.current !== requestId) return;
|
|
187
|
+
setReferences(refs);
|
|
188
|
+
if (!refs.removable) setRemoveFromAccess(false);
|
|
189
|
+
})
|
|
190
|
+
.catch((err) => {
|
|
191
|
+
if (referencesRequest.current !== requestId) return;
|
|
192
|
+
setReferencesError(err instanceof Error ? err.message : "Couldn't count where they are named.");
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const removalBlocked = references !== null && !references.removable;
|
|
197
|
+
// Files naming them that this admin may not write: the cleanup skips those,
|
|
198
|
+
// so say it before the delete rather than only in the outcome. `unwritable`
|
|
199
|
+
// is null when that could not be judged — which is not "none".
|
|
200
|
+
const unwritableCount = references?.unwritable?.length ?? 0;
|
|
201
|
+
const unwritableUnknown = references !== null && references.unwritable === null;
|
|
202
|
+
|
|
67
203
|
async function confirmDelete() {
|
|
68
204
|
if (!pendingDelete || deleting) return;
|
|
69
205
|
setDeleting(true);
|
|
70
206
|
setError(null);
|
|
207
|
+
setAccessNotice(null);
|
|
71
208
|
try {
|
|
72
|
-
await deleteAccount(pendingDelete.id
|
|
209
|
+
const outcome = await deleteAccount(pendingDelete.id, {
|
|
210
|
+
removeFromAccess: removeFromAccess && !removalBlocked,
|
|
211
|
+
});
|
|
212
|
+
const unchecked = ' Which files still name them could not be checked — look through roles, groups, access rules and file grants.';
|
|
213
|
+
if (outcome && !outcome.ok) {
|
|
214
|
+
setAccessNotice({
|
|
215
|
+
message: `The account was deleted, but removing them from roles, groups and access rules failed${
|
|
216
|
+
outcome.error ? `: ${outcome.error}` : '.'
|
|
217
|
+
}${outcome.stillNamedIn === null ? unchecked : ''}`,
|
|
218
|
+
files: outcome.stillNamedIn ?? [],
|
|
219
|
+
});
|
|
220
|
+
} else if (outcome) {
|
|
221
|
+
const pending = outcome.publishPending
|
|
222
|
+
? ' The removal is saved; publishing it is being retried.'
|
|
223
|
+
: '';
|
|
224
|
+
if (outcome.stillNamedIn === null) {
|
|
225
|
+
setAccessNotice({ message: `The account was deleted.${pending}${unchecked}`, files: [] });
|
|
226
|
+
} else if (outcome.stillNamedIn.length > 0) {
|
|
227
|
+
setAccessNotice({
|
|
228
|
+
message: `The account was deleted.${pending} Some files still name them and need a manual edit:`,
|
|
229
|
+
files: outcome.stillNamedIn,
|
|
230
|
+
});
|
|
231
|
+
} else if (pending) {
|
|
232
|
+
setAccessNotice({ message: `The account was deleted.${pending}`, files: [] });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
73
235
|
setPendingDelete(null);
|
|
74
236
|
refresh();
|
|
75
237
|
} catch (err) {
|
|
@@ -84,21 +246,21 @@ export function UserAccountsPage() {
|
|
|
84
246
|
setPasswordTarget(account);
|
|
85
247
|
setNewPassword('');
|
|
86
248
|
setPasswordError(null);
|
|
87
|
-
|
|
249
|
+
setPasswordDone(null);
|
|
88
250
|
}
|
|
89
251
|
|
|
90
|
-
async function
|
|
252
|
+
async function confirmPasswordChange() {
|
|
91
253
|
if (!passwordTarget || savingPassword || newPassword.length === 0) return;
|
|
92
254
|
setSavingPassword(true);
|
|
93
255
|
setPasswordError(null);
|
|
94
256
|
try {
|
|
95
257
|
// No name → the upsert keeps the account's existing display name.
|
|
96
258
|
await createAccount(passwordTarget.email, '', newPassword);
|
|
97
|
-
|
|
259
|
+
setPasswordDone({ email: passwordTarget.email, action: passwordAction(passwordTarget) });
|
|
98
260
|
setPasswordTarget(null);
|
|
99
261
|
refresh();
|
|
100
262
|
} catch (err) {
|
|
101
|
-
setPasswordError(err instanceof Error ? err.message : "Couldn't
|
|
263
|
+
setPasswordError(err instanceof Error ? err.message : "Couldn't save the password.");
|
|
102
264
|
} finally {
|
|
103
265
|
setSavingPassword(false);
|
|
104
266
|
}
|
|
@@ -135,6 +297,10 @@ export function UserAccountsPage() {
|
|
|
135
297
|
const inputClass =
|
|
136
298
|
'w-full rounded-md bg-sunken border border-line-strong px-3 py-2 text-sm text-ink focus:outline-none focus:border-accent';
|
|
137
299
|
|
|
300
|
+
// Which of the two the open dialog is. The Dialog renders nothing without a
|
|
301
|
+
// target, so the fallback is never on screen — it just keeps the type honest.
|
|
302
|
+
const passwordDialog = passwordTarget ? passwordAction(passwordTarget) : SET_PASSWORD;
|
|
303
|
+
|
|
138
304
|
return (
|
|
139
305
|
<>
|
|
140
306
|
<PageShell title="User accounts">
|
|
@@ -143,7 +309,8 @@ export function UserAccountsPage() {
|
|
|
143
309
|
Everyone with an account on this deployment. Deleting an account permanently removes
|
|
144
310
|
the person's data and anonymizes their past review activity; their saves in the
|
|
145
311
|
knowledge base keep their history. Setting a password lets someone sign in with
|
|
146
|
-
email + password (existing accounts keep everything else)
|
|
312
|
+
email + password (existing accounts keep everything else); resetting one replaces
|
|
313
|
+
the password they have now.
|
|
147
314
|
</p>
|
|
148
315
|
|
|
149
316
|
{error && (
|
|
@@ -154,12 +321,29 @@ export function UserAccountsPage() {
|
|
|
154
321
|
{error}
|
|
155
322
|
</div>
|
|
156
323
|
)}
|
|
157
|
-
{
|
|
324
|
+
{accessNotice && (
|
|
325
|
+
<div
|
|
326
|
+
className="text-xs text-red-600 bg-red-50 border border-red-200 rounded-sm px-2 py-1.5"
|
|
327
|
+
role="alert"
|
|
328
|
+
>
|
|
329
|
+
{accessNotice.message}
|
|
330
|
+
{accessNotice.files.length > 0 && (
|
|
331
|
+
<ul className="mt-1 list-disc pl-4">
|
|
332
|
+
{accessNotice.files.map((file) => (
|
|
333
|
+
<li key={file} className="font-mono">
|
|
334
|
+
{file}
|
|
335
|
+
</li>
|
|
336
|
+
))}
|
|
337
|
+
</ul>
|
|
338
|
+
)}
|
|
339
|
+
</div>
|
|
340
|
+
)}
|
|
341
|
+
{passwordDone && (
|
|
158
342
|
<div
|
|
159
343
|
className="text-xs text-emerald-700 bg-emerald-50 border border-emerald-200 rounded-sm px-2 py-1.5"
|
|
160
344
|
role="status"
|
|
161
345
|
>
|
|
162
|
-
|
|
346
|
+
{passwordDone.action.done} for {passwordDone.email}.
|
|
163
347
|
</div>
|
|
164
348
|
)}
|
|
165
349
|
|
|
@@ -185,22 +369,33 @@ export function UserAccountsPage() {
|
|
|
185
369
|
</div>
|
|
186
370
|
<div className="text-meta text-ink-muted truncate">
|
|
187
371
|
{account.email} · Joined {new Date(account.createdAt).toLocaleDateString()} ·{' '}
|
|
188
|
-
{account
|
|
372
|
+
{signInMethodLabel(account)}
|
|
189
373
|
</div>
|
|
190
374
|
</div>
|
|
375
|
+
{!isSelf &&
|
|
376
|
+
(account.isEnvAdmin ? (
|
|
377
|
+
// Neither password action for the deployment admin: its
|
|
378
|
+
// password is the environment's, and a stored one
|
|
379
|
+
// would only ADD a credential that outlives rotating
|
|
380
|
+
// ADMIN_PASSWORD. The backend refuses it too — this
|
|
381
|
+
// says why instead of offering a button that fails.
|
|
382
|
+
// `hasPassword` does not change that on this row.
|
|
383
|
+
<span className="text-meta text-ink-muted text-right max-w-[13rem]">
|
|
384
|
+
Password set in the deployment environment
|
|
385
|
+
</span>
|
|
386
|
+
) : (
|
|
387
|
+
<button
|
|
388
|
+
onClick={() => openPasswordDialog(account)}
|
|
389
|
+
className="text-xs px-2 py-1 rounded-sm text-ink hover:bg-hover border border-line"
|
|
390
|
+
title={passwordAction(account).title}
|
|
391
|
+
aria-label={`${passwordAction(account).label} for ${account.email}`}
|
|
392
|
+
>
|
|
393
|
+
{passwordAction(account).label}
|
|
394
|
+
</button>
|
|
395
|
+
))}
|
|
191
396
|
{!isSelf && (
|
|
192
397
|
<button
|
|
193
|
-
onClick={() =>
|
|
194
|
-
className="text-xs px-2 py-1 rounded-sm text-ink hover:bg-hover border border-line"
|
|
195
|
-
title="Set a new sign-in password for this account."
|
|
196
|
-
aria-label={`Set password for ${account.email}`}
|
|
197
|
-
>
|
|
198
|
-
Set password
|
|
199
|
-
</button>
|
|
200
|
-
)}
|
|
201
|
-
{!isSelf && (
|
|
202
|
-
<button
|
|
203
|
-
onClick={() => setPendingDelete(account)}
|
|
398
|
+
onClick={() => openDeleteDialog(account)}
|
|
204
399
|
className="text-xs px-2 py-1 rounded-sm text-red-700 hover:bg-red-50 border border-red-200"
|
|
205
400
|
title="Permanently delete this account and its personal data."
|
|
206
401
|
aria-label={`Delete account ${account.email}`}
|
|
@@ -271,7 +466,7 @@ export function UserAccountsPage() {
|
|
|
271
466
|
<Dialog
|
|
272
467
|
open={passwordTarget !== null}
|
|
273
468
|
onClose={() => setPasswordTarget(null)}
|
|
274
|
-
title=
|
|
469
|
+
title={passwordDialog.label}
|
|
275
470
|
size="sm"
|
|
276
471
|
busy={savingPassword}
|
|
277
472
|
footer={
|
|
@@ -284,11 +479,11 @@ export function UserAccountsPage() {
|
|
|
284
479
|
Cancel
|
|
285
480
|
</button>
|
|
286
481
|
<button
|
|
287
|
-
onClick={
|
|
482
|
+
onClick={confirmPasswordChange}
|
|
288
483
|
disabled={savingPassword || newPassword.length === 0}
|
|
289
484
|
className="px-3 py-1.5 text-sm rounded-sm bg-accent hover:bg-accent-hover text-white disabled:opacity-50"
|
|
290
485
|
>
|
|
291
|
-
{savingPassword ? 'Saving…' :
|
|
486
|
+
{savingPassword ? 'Saving…' : passwordDialog.label}
|
|
292
487
|
</button>
|
|
293
488
|
</>
|
|
294
489
|
}
|
|
@@ -299,7 +494,9 @@ export function UserAccountsPage() {
|
|
|
299
494
|
<span className="font-medium">
|
|
300
495
|
{passwordTarget?.name} ({passwordTarget?.email})
|
|
301
496
|
</span>
|
|
302
|
-
. Share it with them out-of-band; they can change it later on
|
|
497
|
+
. {passwordDialog.effect} Share it with them out-of-band; they can change it later on
|
|
498
|
+
their Account page.
|
|
499
|
+
{passwordDialog.confirm && ` ${passwordDialog.confirm}`}
|
|
303
500
|
</p>
|
|
304
501
|
<label className="block space-y-1">
|
|
305
502
|
<span className="text-xs text-ink-muted">New password</span>
|
|
@@ -351,10 +548,47 @@ export function UserAccountsPage() {
|
|
|
351
548
|
</span>
|
|
352
549
|
? This removes their personal data for good and anonymizes their past review activity.
|
|
353
550
|
Their saves in the knowledge base keep their history.{' '}
|
|
354
|
-
{pendingDelete
|
|
355
|
-
? 'To sign in again they will need an admin to create a new account for them.'
|
|
356
|
-
: 'They can sign in again later with single sign-on, but will start fresh.'}
|
|
551
|
+
{pendingDelete && signInAfterDelete(pendingDelete)}
|
|
357
552
|
</p>
|
|
553
|
+
<div className="mt-3 space-y-1.5 text-xs text-ink leading-snug">
|
|
554
|
+
{references ? (
|
|
555
|
+
<p>{referencesSummary(references)}</p>
|
|
556
|
+
) : referencesError ? (
|
|
557
|
+
<p className="text-ink-muted">{referencesError}</p>
|
|
558
|
+
) : (
|
|
559
|
+
<p className="text-ink-muted">Counting where they are named…</p>
|
|
560
|
+
)}
|
|
561
|
+
<label className="flex items-start gap-2">
|
|
562
|
+
<input
|
|
563
|
+
type="checkbox"
|
|
564
|
+
className="mt-0.5"
|
|
565
|
+
checked={removeFromAccess && !removalBlocked}
|
|
566
|
+
disabled={deleting || removalBlocked}
|
|
567
|
+
onChange={(e) => setRemoveFromAccess(e.target.checked)}
|
|
568
|
+
/>
|
|
569
|
+
<span>Also remove them from roles, groups and access rules</span>
|
|
570
|
+
</label>
|
|
571
|
+
{removalBlocked && references?.blockedReason && (
|
|
572
|
+
<p className="text-ink-muted">{references.blockedReason}</p>
|
|
573
|
+
)}
|
|
574
|
+
{!removalBlocked && removeFromAccess && unwritableCount > 0 && (
|
|
575
|
+
<p className="text-ink-muted">
|
|
576
|
+
{plural(unwritableCount, 'file', 'files')} you cannot write will keep the address:{' '}
|
|
577
|
+
{references?.unwritable?.join(', ')}.
|
|
578
|
+
</p>
|
|
579
|
+
)}
|
|
580
|
+
{!removalBlocked && removeFromAccess && unwritableUnknown && (
|
|
581
|
+
<p className="text-ink-muted">
|
|
582
|
+
Which of these files you can write could not be checked. Any you cannot write will
|
|
583
|
+
keep the address, and are listed afterwards.
|
|
584
|
+
</p>
|
|
585
|
+
)}
|
|
586
|
+
{(!removeFromAccess || removalBlocked) && (
|
|
587
|
+
<p className="text-ink-muted">
|
|
588
|
+
Their address will remain in those files.
|
|
589
|
+
</p>
|
|
590
|
+
)}
|
|
591
|
+
</div>
|
|
358
592
|
</Dialog>
|
|
359
593
|
</>
|
|
360
594
|
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AdminConnectionKey } from '../services/connection-keys.api';
|
|
2
|
+
|
|
3
|
+
export interface AccountGroup {
|
|
4
|
+
user: AdminConnectionKey['user'];
|
|
5
|
+
keys: AdminConnectionKey[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One list from the server, grouped per account in the order the server
|
|
10
|
+
* returned it (owner email). Within an account: live keys first, most
|
|
11
|
+
* recently used at the top, so the row an admin is hunting for — the key
|
|
12
|
+
* that is still being used — is never below the ones that are not.
|
|
13
|
+
*
|
|
14
|
+
* Lives beside {@link ConnectionKeysPage} rather than in it: a component
|
|
15
|
+
* file that also exports a plain function breaks fast refresh.
|
|
16
|
+
*/
|
|
17
|
+
export function groupByAccount(
|
|
18
|
+
keys: AdminConnectionKey[],
|
|
19
|
+
includeRevoked: boolean,
|
|
20
|
+
): AccountGroup[] {
|
|
21
|
+
const groups: AccountGroup[] = [];
|
|
22
|
+
const byUser = new Map<string, AccountGroup>();
|
|
23
|
+
for (const key of keys) {
|
|
24
|
+
if (!includeRevoked && key.revokedAt !== null) continue;
|
|
25
|
+
let group = byUser.get(key.user.id);
|
|
26
|
+
if (!group) {
|
|
27
|
+
group = { user: key.user, keys: [] };
|
|
28
|
+
byUser.set(key.user.id, group);
|
|
29
|
+
groups.push(group);
|
|
30
|
+
}
|
|
31
|
+
group.keys.push(key);
|
|
32
|
+
}
|
|
33
|
+
for (const group of groups) {
|
|
34
|
+
group.keys.sort((a, b) => {
|
|
35
|
+
const aRevoked = a.revokedAt !== null;
|
|
36
|
+
const bRevoked = b.revokedAt !== null;
|
|
37
|
+
if (aRevoked !== bRevoked) return aRevoked ? 1 : -1;
|
|
38
|
+
const byUse = (b.lastUsedAt ?? 0) - (a.lastUsedAt ?? 0);
|
|
39
|
+
return byUse !== 0 ? byUse : b.createdAt - a.createdAt;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return groups;
|
|
43
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Groups & Members page, opened on ONE group — the link the Library
|
|
3
|
+
* sidebar's "Manage members" follows.
|
|
4
|
+
*
|
|
5
|
+
* The group rides in the query string rather than in component state so the
|
|
6
|
+
* link can be shared and survives a reload: whoever opens it lands on the same
|
|
7
|
+
* card. It names the group as the sidebar does (its display name); the page
|
|
8
|
+
* also accepts the canonical name, and matches either without regard to case.
|
|
9
|
+
*
|
|
10
|
+
* Here rather than in `DirectoryGroupsPage`, because a component file that
|
|
11
|
+
* also exports a plain function breaks fast refresh for the whole module.
|
|
12
|
+
*/
|
|
13
|
+
export const GROUP_MEMBERS_PATH = '/directory-groups';
|
|
14
|
+
export const GROUP_PARAM = 'group';
|
|
15
|
+
|
|
16
|
+
export function pathForGroupMembers(group: string): string {
|
|
17
|
+
return `${GROUP_MEMBERS_PATH}?${new URLSearchParams({ [GROUP_PARAM]: group })}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Whether a roster entry is the one a `?group=` value names. */
|
|
21
|
+
export function isNamedGroup(
|
|
22
|
+
entry: { canonical: string; displayName: string },
|
|
23
|
+
name: string | null,
|
|
24
|
+
): boolean {
|
|
25
|
+
if (!name) return false;
|
|
26
|
+
// As the backend canonicalises a group name: case and inner whitespace
|
|
27
|
+
// are not identity, so a link typed or shared with two spaces still lands
|
|
28
|
+
// on the card.
|
|
29
|
+
const fold = (s: string) => s.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
30
|
+
const wanted = fold(name);
|
|
31
|
+
return fold(entry.displayName) === wanted || fold(entry.canonical) === wanted;
|
|
32
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { authFetch } from '../../../lib/api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One row of the admin Connection keys overview
|
|
5
|
+
* (`GET /api/admin/connection-keys`): a key plus the account it belongs to.
|
|
6
|
+
* Never carries the plaintext — that was shown to the owner exactly once.
|
|
7
|
+
*/
|
|
8
|
+
export interface AdminConnectionKey {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
/** `key` for a hand-made key; another kind for one a flow minted (a Claude link). */
|
|
12
|
+
kind: string;
|
|
13
|
+
createdAt: number;
|
|
14
|
+
lastUsedAt: number | null;
|
|
15
|
+
revokedAt: number | null;
|
|
16
|
+
/** Who ended it once revoked: the owner, or an admin. Null while live. */
|
|
17
|
+
revokedBy: 'owner' | 'admin' | null;
|
|
18
|
+
user: {
|
|
19
|
+
id: string;
|
|
20
|
+
email: string;
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function readError(res: Response, fallback: string): Promise<string> {
|
|
26
|
+
const body = await res.json().catch(() => ({}));
|
|
27
|
+
return (body as { error?: string }).error || fallback;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Every connection key on the deployment, ordered by owner email then newest-first. */
|
|
31
|
+
export async function listConnectionKeys(): Promise<AdminConnectionKey[]> {
|
|
32
|
+
const res = await authFetch('/api/admin/connection-keys');
|
|
33
|
+
if (!res.ok) throw new Error(await readError(res, 'Could not load connection keys'));
|
|
34
|
+
const body = (await res.json()) as { keys: AdminConnectionKey[] };
|
|
35
|
+
return body.keys;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Revoke (disconnect) any account's key. The row is kept so its last-used
|
|
40
|
+
* time stays auditable; the agent holding the key loses access at once.
|
|
41
|
+
*/
|
|
42
|
+
export async function revokeConnectionKey(id: string): Promise<void> {
|
|
43
|
+
const res = await authFetch(`/api/admin/connection-keys/${encodeURIComponent(id)}`, {
|
|
44
|
+
method: 'DELETE',
|
|
45
|
+
});
|
|
46
|
+
if (!res.ok) throw new Error(await readError(res, 'Could not revoke this key'));
|
|
47
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { authFetch } from '../../../lib/api';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Typed client for the admin
|
|
4
|
+
* Typed client for the admin App roles surface — MEMBERSHIP editing
|
|
5
5
|
* only (roles are app-defined capabilities; there is no create/rename/delete).
|
|
6
6
|
* Mirrors the backend shape in `roles-admin.service.ts`. Re-declared here
|
|
7
7
|
* (rather than imported from `@bevel-software/platform-shared`) to match the
|
|
@@ -12,6 +12,17 @@ export interface RoleRosterEntry {
|
|
|
12
12
|
displayName: string;
|
|
13
13
|
/** Individual members — emails only; group assignments live in `groups`. */
|
|
14
14
|
members: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Emails the SERVER CONFIGURATION makes members, whatever `roles.yaml` says
|
|
17
|
+
* — the deployment admins (`ADMIN_EMAIL`) on Admin, empty elsewhere. The
|
|
18
|
+
* page renders these first, badged and with no remove control, and refuses
|
|
19
|
+
* to add them as regular members. May overlap `members` (a seeded
|
|
20
|
+
* `roles.yaml` names the deployment admin too); render such an email once.
|
|
21
|
+
*
|
|
22
|
+
* Optional on the wire so a page served against an older backend degrades
|
|
23
|
+
* to today's behaviour instead of crashing on `undefined.map`.
|
|
24
|
+
*/
|
|
25
|
+
fixedMembers?: string[];
|
|
15
26
|
/** Canonical names of groups assigned to this role. */
|
|
16
27
|
groups: string[];
|
|
17
28
|
isAdmin: boolean;
|
|
@@ -3,15 +3,16 @@ import { render, screen } from '@testing-library/react';
|
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { AccountPage } from '../components/AccountPage';
|
|
5
5
|
import { AuthContext, type AuthContextValue } from '../state/auth.context';
|
|
6
|
+
import type { AuthUser } from '@bevel-software/platform-shared';
|
|
6
7
|
import { changePassword } from '../services/account.api';
|
|
7
8
|
|
|
8
9
|
vi.mock('../services/account.api', () => ({
|
|
9
10
|
changePassword: vi.fn(),
|
|
10
11
|
}));
|
|
11
12
|
|
|
12
|
-
function renderPage() {
|
|
13
|
+
function renderPage(user: Partial<AuthUser> = {}) {
|
|
13
14
|
const value: AuthContextValue = {
|
|
14
|
-
user: { id: 'u1', email: 'alice@example.com', name: 'Alice' },
|
|
15
|
+
user: { id: 'u1', email: 'alice@example.com', name: 'Alice', ...user },
|
|
15
16
|
token: 't',
|
|
16
17
|
isLoading: false,
|
|
17
18
|
login: vi.fn(async () => {}),
|
|
@@ -75,3 +76,50 @@ describe('AccountPage', () => {
|
|
|
75
76
|
expect(await screen.findByRole('alert')).toHaveTextContent('Current password is incorrect');
|
|
76
77
|
});
|
|
77
78
|
});
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The three account kinds the page has to tell apart — and it is only two
|
|
82
|
+
* renderings, because role is not one of the distinctions. The Admin role is a
|
|
83
|
+
* `roles.yaml` fact that gates the admin screens; it has never had anything to
|
|
84
|
+
* do with changing your own password, which is what the original report got
|
|
85
|
+
* wrong. The deployment admin is the one that differs.
|
|
86
|
+
*/
|
|
87
|
+
describe('AccountPage — the three account kinds', () => {
|
|
88
|
+
for (const kind of [
|
|
89
|
+
{ label: 'an Admin-role account', user: { email: 'admin-role@example.com' } },
|
|
90
|
+
{ label: 'a business user', user: { email: 'bob@example.com' } },
|
|
91
|
+
]) {
|
|
92
|
+
it(`offers the form to ${kind.label}`, async () => {
|
|
93
|
+
vi.mocked(changePassword).mockResolvedValue(undefined);
|
|
94
|
+
renderPage(kind.user);
|
|
95
|
+
expect(screen.queryByText(/set in the deployment environment/)).not.toBeInTheDocument();
|
|
96
|
+
await userEvent.type(screen.getByLabelText(/Current password/), 'old-password');
|
|
97
|
+
await userEvent.type(screen.getByLabelText(/New password/), 'new-password-1');
|
|
98
|
+
await userEvent.type(screen.getByLabelText(/Confirm new password/), 'new-password-1');
|
|
99
|
+
await userEvent.click(screen.getByRole('button', { name: 'Change password' }));
|
|
100
|
+
expect(await screen.findByRole('status')).toHaveTextContent('Password changed.');
|
|
101
|
+
expect(changePassword).toHaveBeenCalledWith('old-password', 'new-password-1');
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
it('explains instead of asking, and offers no save, for the deployment admin', () => {
|
|
106
|
+
renderPage({ email: 'root@example.com', isEnvAdmin: true });
|
|
107
|
+
expect(screen.getByText(/set in the deployment environment/)).toBeInTheDocument();
|
|
108
|
+
expect(screen.getByText(/cannot be changed here/)).toBeInTheDocument();
|
|
109
|
+
// No form, no fields, and nothing to press — the explanation is the whole
|
|
110
|
+
// surface, so there is no way to reach an API call that would be refused.
|
|
111
|
+
expect(screen.queryByLabelText(/Current password/)).not.toBeInTheDocument();
|
|
112
|
+
expect(screen.queryByLabelText(/New password/)).not.toBeInTheDocument();
|
|
113
|
+
expect(screen.queryByLabelText(/Confirm new password/)).not.toBeInTheDocument();
|
|
114
|
+
expect(screen.queryByRole('button', { name: 'Change password' })).not.toBeInTheDocument();
|
|
115
|
+
expect(changePassword).not.toHaveBeenCalled();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('gives that same account the form once ADMIN_PASSWORD is unset', () => {
|
|
119
|
+
// The flag is derived from configuration, so an SSO-only deployment turns
|
|
120
|
+
// this account back into an ordinary one.
|
|
121
|
+
renderPage({ email: 'root@example.com', isEnvAdmin: false });
|
|
122
|
+
expect(screen.getByRole('button', { name: 'Change password' })).toBeInTheDocument();
|
|
123
|
+
expect(screen.queryByText(/set in the deployment environment/)).not.toBeInTheDocument();
|
|
124
|
+
});
|
|
125
|
+
});
|