@bevel-software/platform-core-frontend 0.14.0 → 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 +34 -26
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +38 -1
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/email.ts +37 -1
- package/src/lib/utils.ts +2 -0
- 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 +781 -76
- 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__/plugin-token.test.ts +21 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +192 -10
- package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
- 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/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- 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 +109 -4
- 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 +104 -99
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
- 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 +115 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
- 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 +391 -78
- package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
- 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 +183 -0
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +75 -0
- package/src/modules/library/__tests__/link-membership.test.ts +129 -0
- 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 +67 -0
- 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/__tests__/useJoinRequests.test.tsx +46 -0
- 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 +107 -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 +149 -34
- package/src/modules/library/components/LibraryLayout.tsx +120 -247
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
- package/src/modules/library/components/LockedPluginView.tsx +63 -35
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +19 -5
- package/src/modules/library/components/PageActions.tsx +31 -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 +123 -23
- package/src/modules/library/components/PluginExtras.tsx +143 -18
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +234 -38
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +271 -238
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +204 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- 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 +132 -23
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
- 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 +116 -17
- 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/useJoinRequests.ts +48 -18
- 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 +229 -82
- package/src/modules/library/routes/library-paths.ts +46 -35
- package/src/modules/library/services/library.api.ts +89 -17
- package/src/modules/library/services/plugins.api.ts +161 -9
- 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 +268 -37
- 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 +102 -0
- package/src/modules/library/utils/status.ts +204 -35
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
- 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 +154 -0
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +16 -22
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
- 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 +66 -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 +615 -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 +711 -40
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +218 -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 +395 -124
- 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 +659 -36
- 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 +8 -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 +6 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
- package/src/modules/workspace/components/FileRoute.tsx +376 -22
- 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 +768 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -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 +89 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +207 -30
- 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 +130 -16
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
- 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 +126 -52
- 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 +59 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -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 +118 -0
- 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 +34 -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 -265
- 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,5 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from 'react';
|
|
2
|
-
import { FilePlus, FolderPlus, Link2, Trash2, Users } from 'lucide-react';
|
|
2
|
+
import { FilePlus, FolderPlus, Link2, Trash2, Users, UsersRound } from 'lucide-react';
|
|
3
3
|
import { MenuItem, MenuPanel, useDismissableMenu } from '../../../shared/components';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -46,6 +46,11 @@ export interface PluginsSidebarMenuProps {
|
|
|
46
46
|
onManageAccess?(): void;
|
|
47
47
|
/** Opens the delete confirmation. Present ONLY for a plugin the caller owns. */
|
|
48
48
|
onDelete?(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Opens the group's card on the Groups & Members page. Present ONLY for an
|
|
51
|
+
* administrator on a group row — never on Everyone, which nobody edits.
|
|
52
|
+
*/
|
|
53
|
+
onManageMembers?(): void;
|
|
49
54
|
/** The row this menu was opened from — Escape hands focus back to it. */
|
|
50
55
|
returnFocusTo?: RefObject<HTMLElement | null>;
|
|
51
56
|
}
|
|
@@ -60,6 +65,7 @@ export function PluginsSidebarMenu({
|
|
|
60
65
|
onCopyLink,
|
|
61
66
|
onManageAccess,
|
|
62
67
|
onDelete,
|
|
68
|
+
onManageMembers,
|
|
63
69
|
returnFocusTo,
|
|
64
70
|
}: PluginsSidebarMenuProps) {
|
|
65
71
|
const ref = useDismissableMenu<HTMLDivElement>({ open: true, onClose, returnFocusTo });
|
|
@@ -134,6 +140,25 @@ export function PluginsSidebarMenu({
|
|
|
134
140
|
</MenuItem>
|
|
135
141
|
</>
|
|
136
142
|
)}
|
|
143
|
+
{onManageMembers && (
|
|
144
|
+
<>
|
|
145
|
+
{/* Like access, it is about who is here rather than what is — so it
|
|
146
|
+
sits below the rule, after the items the row already had. */}
|
|
147
|
+
<div className="my-1 border-t border-line" />
|
|
148
|
+
<MenuItem
|
|
149
|
+
role="menuitem"
|
|
150
|
+
onClick={() => {
|
|
151
|
+
onManageMembers();
|
|
152
|
+
onClose();
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<span className="flex items-center gap-2">
|
|
156
|
+
<UsersRound size={14} />
|
|
157
|
+
Manage members
|
|
158
|
+
</span>
|
|
159
|
+
</MenuItem>
|
|
160
|
+
</>
|
|
161
|
+
)}
|
|
137
162
|
{onDelete && (
|
|
138
163
|
<>
|
|
139
164
|
{/* Destructive and last, below its own rule — the file tree's menu
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { useId, useState } from 'react';
|
|
2
|
+
import { PERSONAL_PLUGIN_PREFIX, pluginManifestName } from '@bevel-software/platform-shared';
|
|
3
|
+
import { Banner, Button, Dialog, TextField } from '../../../shared/components';
|
|
4
|
+
import { renamePlugin, type PluginSummary } from '../services/plugins.api';
|
|
5
|
+
import { useLibraryToast } from '../state/toast.context';
|
|
6
|
+
|
|
7
|
+
/** The Agent Plugins identifier rule — lowercase kebab-case, nothing else. */
|
|
8
|
+
const IDENTIFIER_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Rename a plugin: its identifier, its display name, or both.
|
|
12
|
+
*
|
|
13
|
+
* The identifier is the plugin — the grants spell it, the URLs key on it,
|
|
14
|
+
* the marketplace publishes it — so changing it rewrites every grant that
|
|
15
|
+
* names the old one, in one commit, and the dialog says so before the click.
|
|
16
|
+
* The display name is only what people see.
|
|
17
|
+
*/
|
|
18
|
+
export function RenamePluginDialog({
|
|
19
|
+
plugin,
|
|
20
|
+
onClose,
|
|
21
|
+
onRenamed,
|
|
22
|
+
}: {
|
|
23
|
+
plugin: Pick<PluginSummary, 'name' | 'displayName' | 'folders'>;
|
|
24
|
+
onClose(): void;
|
|
25
|
+
/** The rename landed; the host reloads and, when the identifier changed, navigates. */
|
|
26
|
+
onRenamed(next: { name: string; displayName: string }): void;
|
|
27
|
+
}) {
|
|
28
|
+
const nameId = useId();
|
|
29
|
+
const displayId = useId();
|
|
30
|
+
const toast = useLibraryToast();
|
|
31
|
+
const [name, setName] = useState(plugin.name);
|
|
32
|
+
const [displayName, setDisplayName] = useState(plugin.displayName ?? plugin.name);
|
|
33
|
+
const [busy, setBusy] = useState(false);
|
|
34
|
+
const [error, setError] = useState<string | null>(null);
|
|
35
|
+
|
|
36
|
+
const trimmedName = name.trim();
|
|
37
|
+
const identifierChanges = trimmedName !== plugin.name;
|
|
38
|
+
// The same three rules the server applies — the identifier shape, the
|
|
39
|
+
// reserved prefix, and that the name is its own slug (the marketplace keys
|
|
40
|
+
// on a 64-character slug; a longer name would be one thing here and
|
|
41
|
+
// another everywhere it is published) — and, like the server, only to a
|
|
42
|
+
// NEW identifier: the current one is whatever the manifest says, and a
|
|
43
|
+
// name that predates a rule must not block a display-name change.
|
|
44
|
+
const nameError = !identifierChanges || !trimmedName
|
|
45
|
+
? null
|
|
46
|
+
: !IDENTIFIER_RE.test(trimmedName)
|
|
47
|
+
? 'Lowercase letters, digits and single hyphens, like sales-team.'
|
|
48
|
+
: trimmedName.startsWith(PERSONAL_PLUGIN_PREFIX)
|
|
49
|
+
? `"${PERSONAL_PLUGIN_PREFIX}" is reserved for personal folders. Pick another identifier.`
|
|
50
|
+
: pluginManifestName(trimmedName) !== trimmedName
|
|
51
|
+
? 'Too long: an identifier is at most 64 characters.'
|
|
52
|
+
: null;
|
|
53
|
+
const changed = identifierChanges || displayName.trim() !== (plugin.displayName ?? plugin.name);
|
|
54
|
+
const canSubmit = trimmedName.length > 0 && nameError === null && changed && !busy;
|
|
55
|
+
|
|
56
|
+
async function submit() {
|
|
57
|
+
if (!canSubmit) return;
|
|
58
|
+
setBusy(true);
|
|
59
|
+
setError(null);
|
|
60
|
+
try {
|
|
61
|
+
const next = await renamePlugin(plugin.name, {
|
|
62
|
+
...(identifierChanges ? { name: trimmedName } : {}),
|
|
63
|
+
displayName: displayName.trim(),
|
|
64
|
+
});
|
|
65
|
+
toast(identifierChanges ? `Renamed ${plugin.name} to ${next.name}.` : `Renamed to ${next.displayName}.`);
|
|
66
|
+
onRenamed(next);
|
|
67
|
+
onClose();
|
|
68
|
+
} catch (err) {
|
|
69
|
+
setError(err instanceof Error ? err.message : "Couldn't rename the plugin.");
|
|
70
|
+
setBusy(false);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Dialog
|
|
76
|
+
open
|
|
77
|
+
onClose={onClose}
|
|
78
|
+
title={`Rename ${plugin.displayName ?? plugin.name}`}
|
|
79
|
+
size="md"
|
|
80
|
+
busy={busy}
|
|
81
|
+
footer={
|
|
82
|
+
<>
|
|
83
|
+
<Button variant="quiet" onClick={onClose} disabled={busy}>
|
|
84
|
+
Cancel
|
|
85
|
+
</Button>
|
|
86
|
+
<Button onClick={() => void submit()} disabled={!canSubmit}>
|
|
87
|
+
{busy ? 'Renaming…' : 'Rename'}
|
|
88
|
+
</Button>
|
|
89
|
+
</>
|
|
90
|
+
}
|
|
91
|
+
>
|
|
92
|
+
<div className="space-y-3">
|
|
93
|
+
<div>
|
|
94
|
+
<label htmlFor={displayId} className="mb-1 block text-detail font-medium text-ink">
|
|
95
|
+
Display name
|
|
96
|
+
</label>
|
|
97
|
+
<TextField
|
|
98
|
+
id={displayId}
|
|
99
|
+
value={displayName}
|
|
100
|
+
onChange={(e) => setDisplayName(e.target.value)}
|
|
101
|
+
placeholder={plugin.folders[0]?.split('/').pop() ?? plugin.name}
|
|
102
|
+
/>
|
|
103
|
+
<p className="mt-1 text-meta text-ink-faint">What people see in the sidebar and on this page.</p>
|
|
104
|
+
</div>
|
|
105
|
+
<div>
|
|
106
|
+
<label htmlFor={nameId} className="mb-1 block text-detail font-medium text-ink">
|
|
107
|
+
Identifier
|
|
108
|
+
</label>
|
|
109
|
+
<TextField
|
|
110
|
+
id={nameId}
|
|
111
|
+
value={name}
|
|
112
|
+
onChange={(e) => setName(e.target.value)}
|
|
113
|
+
aria-invalid={nameError ? true : undefined}
|
|
114
|
+
className="font-mono"
|
|
115
|
+
/>
|
|
116
|
+
<p className="mt-1 text-meta text-ink-faint">
|
|
117
|
+
{nameError ??
|
|
118
|
+
'The name agents install it by, and the one grants use: plugin/<identifier>/read.'}
|
|
119
|
+
</p>
|
|
120
|
+
</div>
|
|
121
|
+
{identifierChanges && !nameError && (
|
|
122
|
+
<Banner tone="wait" role="status">
|
|
123
|
+
Every grant of <span className="font-mono">plugin/{plugin.name}/…</span> in the knowledge base is
|
|
124
|
+
rewritten to <span className="font-mono">plugin/{trimmedName}/…</span> in the same change. The folder
|
|
125
|
+
stays where it is.
|
|
126
|
+
</Banner>
|
|
127
|
+
)}
|
|
128
|
+
{error && (
|
|
129
|
+
<Banner tone="danger" role="alert">
|
|
130
|
+
{error}
|
|
131
|
+
</Banner>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
</Dialog>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Users } from 'lucide-react';
|
|
2
|
+
import { Button } from '../../../shared/components';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Library's Share button: bounded, because it is the one action beside a
|
|
6
|
+
* title with a consequence for other people. It IS the manage-access dialog —
|
|
7
|
+
* not a doorway to it — for a plugin (`PageActions`) and a skill alike, so the
|
|
8
|
+
* two pages cannot drift into two looks for the same verb.
|
|
9
|
+
*/
|
|
10
|
+
export function ShareButton({ onClick }: { onClick(): void }) {
|
|
11
|
+
return (
|
|
12
|
+
<Button variant="outline" size="sm" onClick={onClick}>
|
|
13
|
+
<Users size={13} />
|
|
14
|
+
Share
|
|
15
|
+
</Button>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
3
|
+
import { DEFAULT_BRANCH, PLUGINS_DIR, SKILLS_DIR, type FileTreeEntry } from '@bevel-software/platform-shared';
|
|
4
|
+
import { libraryUploadTarget, useWorkspace } from '../../workspace/state/workspace.context';
|
|
5
|
+
import { checkoutRoot } from '../../workspace/utils/fileTree';
|
|
6
|
+
import { KB_ROUTE_PREFIX, kbFileUrl, safeDecode } from '../../workspace/routing/kb-routes';
|
|
7
|
+
import { useMergedWorkspaceTree } from '../../workspace/hooks/useMergedWorkspaceTree';
|
|
8
|
+
import { Puzzle } from 'lucide-react';
|
|
9
|
+
import {
|
|
10
|
+
EmptyTreeNotice,
|
|
11
|
+
FileTreeNode,
|
|
12
|
+
TreeChrome,
|
|
13
|
+
UploadNotices,
|
|
14
|
+
type TreeMenuItem,
|
|
15
|
+
type TreeNav,
|
|
16
|
+
} from '../../workspace/components/FileExplorer';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* One of the Library's two reserved roots — `Skills/` or `Plugins/` — as a
|
|
20
|
+
* file tree, made of the SAME rows as Knowledge's explorer — right-click menu
|
|
21
|
+
* (new file, new folder, rename, delete, manage access, download), drag to
|
|
22
|
+
* move, drop to upload, the caller's proposed files shown in accent. One tree
|
|
23
|
+
* component in the app, holding a different root.
|
|
24
|
+
*
|
|
25
|
+
* The root is a collapsible folder row named after the folder, exactly as
|
|
26
|
+
* Knowledge and Data are top-level folders in the Knowledge explorer: open
|
|
27
|
+
* by default with its children collapsed under it, a drop target for uploads
|
|
28
|
+
* into the root, the create buttons on hover, the folder's menu on
|
|
29
|
+
* right-click — minus what a platform-owned root must not offer
|
|
30
|
+
* (`FileTreeNode.reserved`: no rename, delete, drag or pin).
|
|
31
|
+
*
|
|
32
|
+
* Two things differ from Knowledge, and both are the surroundings' (see
|
|
33
|
+
* `TreeChrome`), not the rows':
|
|
34
|
+
*
|
|
35
|
+
* - A click opens the file on its ITEM PAGE, here in Skills & Tools — at
|
|
36
|
+
* the item's canonical default-branch URL, whatever branch is checked
|
|
37
|
+
* out. The Library speaks the default branch everywhere; this is no
|
|
38
|
+
* exception. A skill's SKILL.md opens the skill page; a plugin's
|
|
39
|
+
* manifest or a loose file opens the plugin page; a tool file opens the
|
|
40
|
+
* tool page — `WorkspaceItemRoute` decides, from the path alone.
|
|
41
|
+
* - The current row is the file the URL names, not the pane workspace's
|
|
42
|
+
* open tab, which the Library never sets.
|
|
43
|
+
*
|
|
44
|
+
* Renders nothing only while the tree is loading, or while the workspace has
|
|
45
|
+
* no repository checkout in it — there is no folder to draw a row for, and
|
|
46
|
+
* the empty state below says why. Once the checkout is here the folder is
|
|
47
|
+
* always drawn — empty when the knowledge base has none yet, at the path it
|
|
48
|
+
* will get — because the folder is where new things go, and a person cannot
|
|
49
|
+
* put one there if the way there is not on screen. The reserved root is
|
|
50
|
+
* forced visible by the tree filter even to a reader who may open nothing
|
|
51
|
+
* beneath it, so the row is present for everyone.
|
|
52
|
+
*/
|
|
53
|
+
export function RootFolderTree({
|
|
54
|
+
dir,
|
|
55
|
+
testId,
|
|
56
|
+
menuItems,
|
|
57
|
+
}: {
|
|
58
|
+
dir: string;
|
|
59
|
+
testId: string;
|
|
60
|
+
/**
|
|
61
|
+
* The surface's own context-menu items for an entry, injected into the
|
|
62
|
+
* tree's menu after its create verbs — see `TreeNav.menuItems`. The tree
|
|
63
|
+
* itself grows no verb per caller.
|
|
64
|
+
*/
|
|
65
|
+
menuItems?: (entry: FileTreeEntry) => TreeMenuItem[];
|
|
66
|
+
}) {
|
|
67
|
+
const { kbDirName } = useWorkspace();
|
|
68
|
+
const { tree, suggestionOnlyPaths } = useMergedWorkspaceTree();
|
|
69
|
+
const location = useLocation();
|
|
70
|
+
const navigate = useNavigate();
|
|
71
|
+
|
|
72
|
+
// `Skills/` and `Plugins/` are children of the CHECKOUT and of nothing
|
|
73
|
+
// else. A folder of either name sitting beside the checkout is somebody
|
|
74
|
+
// else's directory, and this tree has never had any business rendering it —
|
|
75
|
+
// it did, on core-staging, because the root used to be found by searching
|
|
76
|
+
// the workspace for a folder that looked like a knowledge base.
|
|
77
|
+
const root = useMemo((): { entry: FileTreeEntry; absent: boolean } | null => {
|
|
78
|
+
const kbRoot = checkoutRoot(tree, kbDirName);
|
|
79
|
+
if (!kbRoot) return null;
|
|
80
|
+
const found = kbRoot.children?.find((c) => c.type === 'directory' && c.name === dir);
|
|
81
|
+
if (found) return { entry: found, absent: false };
|
|
82
|
+
// No folder yet (a knowledge base from before the root existed, or one
|
|
83
|
+
// whose folder was removed): the row is drawn anyway, empty, at the
|
|
84
|
+
// path the folder will have. Every write creates its parents, so the
|
|
85
|
+
// first drop, file or subfolder made here creates the folder itself;
|
|
86
|
+
// what would READ the folder (download) is withheld until then.
|
|
87
|
+
// MISSING FOLDER, not missing checkout: the two are different answers and
|
|
88
|
+
// only this one draws a row. A checkout that is not there gets the empty
|
|
89
|
+
// state, because there is no path a first write could even go to.
|
|
90
|
+
return {
|
|
91
|
+
entry: { name: dir, relativePath: `${kbRoot.relativePath}/${dir}`, type: 'directory', children: [] },
|
|
92
|
+
absent: true,
|
|
93
|
+
};
|
|
94
|
+
}, [tree, kbDirName, dir]);
|
|
95
|
+
|
|
96
|
+
const nav = useMemo<TreeNav>(
|
|
97
|
+
() => ({
|
|
98
|
+
activePath: activeWorkspacePath(location.pathname, kbDirName),
|
|
99
|
+
open: (path) => navigate(kbFileUrl(DEFAULT_BRANCH, path)),
|
|
100
|
+
menuItems,
|
|
101
|
+
}),
|
|
102
|
+
[location.pathname, kbDirName, navigate, menuItems],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// No checkout: no root row to draw, and `EmptyTreeNotice` says why — the
|
|
106
|
+
// same surface, and the same reason, as the Knowledge explorer beside it.
|
|
107
|
+
// Still nothing at all while the tree is loading, as before.
|
|
108
|
+
if (!root) {
|
|
109
|
+
if (!tree) return null;
|
|
110
|
+
return (
|
|
111
|
+
<div data-testid={testId}>
|
|
112
|
+
<EmptyTreeNotice rootPath={null} />
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
// The two Library trees sit in ONE sidebar over ONE piece of upload
|
|
119
|
+
// state: each names itself so a drop's banners appear in the tree that
|
|
120
|
+
// took the drop, and only there. Before that, dropping into `Skills/`
|
|
121
|
+
// painted the same notice above `Skills/` AND above `Plugins/`.
|
|
122
|
+
<TreeChrome nav={nav} suggestionOnlyPaths={suggestionOnlyPaths} uploadTarget={libraryUploadTarget(dir)}>
|
|
123
|
+
{/* A right-click that lands between the tree's rows is the tree's, not
|
|
124
|
+
the nav's behind it: with nothing wired for the gap the browser's
|
|
125
|
+
own menu is the honest answer, as in Knowledge. The rows stop their
|
|
126
|
+
own events before reaching here. */}
|
|
127
|
+
<div data-testid={testId} onContextMenu={(e) => e.stopPropagation()}>
|
|
128
|
+
<UploadNotices />
|
|
129
|
+
<FileTreeNode entry={root.entry} depth={0} reserved absent={root.absent} collapseChildren />
|
|
130
|
+
{/* The same listing as Knowledge's explorer, so the same answer when
|
|
131
|
+
it shows nothing — judged on THIS root, with it as where a first
|
|
132
|
+
one goes: an empty Skills tree is empty however full Knowledge is. */}
|
|
133
|
+
<EmptyTreeNotice rootPath={root.entry.relativePath} scope="root" />
|
|
134
|
+
</div>
|
|
135
|
+
</TreeChrome>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The shared `Skills/` root. */
|
|
140
|
+
export function SkillsTree() {
|
|
141
|
+
return <RootFolderTree dir={SKILLS_DIR} testId="skills-tree" />;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The `Plugins/` root — every plugin folder as it is on disk. A GROUPING
|
|
146
|
+
* folder's row (the root, or a folder no plugin owns) offers "New plugin"
|
|
147
|
+
* when the caller wires it, and the plugin is made THERE: the verb carries
|
|
148
|
+
* the folder's path below the plugins root. The one verb this root has that
|
|
149
|
+
* Knowledge's folders do not, injected rather than built into the tree. An
|
|
150
|
+
* intent: the layout owns the dialog.
|
|
151
|
+
*/
|
|
152
|
+
export function PluginsTree({
|
|
153
|
+
onCreatePlugin,
|
|
154
|
+
isGroupingFolder = () => true,
|
|
155
|
+
}: {
|
|
156
|
+
/** Make a plugin in `parent` — a path below the plugins root, `''` for the root. */
|
|
157
|
+
onCreatePlugin?: (parent: string) => void;
|
|
158
|
+
/**
|
|
159
|
+
* Whether a repo-relative folder may HOLD a plugin: the root and folders no
|
|
160
|
+
* plugin owns. A plugin's own folder, or anything beneath one, cannot — a
|
|
161
|
+
* plugin claims its subtree, and a plugin made inside it would be listed
|
|
162
|
+
* nowhere. The layout answers from the plugin index.
|
|
163
|
+
*/
|
|
164
|
+
isGroupingFolder?: (repoRelFolder: string) => boolean;
|
|
165
|
+
} = {}) {
|
|
166
|
+
const { kbDirName } = useWorkspace();
|
|
167
|
+
const menuItems = useMemo(() => {
|
|
168
|
+
if (!onCreatePlugin) return undefined;
|
|
169
|
+
return (entry: FileTreeEntry): TreeMenuItem[] => {
|
|
170
|
+
if (entry.type !== 'directory') return [];
|
|
171
|
+
const rel = repoRelative(entry.relativePath, kbDirName);
|
|
172
|
+
if (rel === null || !isGroupingFolder(rel)) return [];
|
|
173
|
+
const parent = rel === PLUGINS_DIR ? '' : rel.slice(PLUGINS_DIR.length + 1);
|
|
174
|
+
return [{ id: 'new-plugin', label: 'New plugin', icon: <Puzzle size={14} />, onSelect: () => onCreatePlugin(parent) }];
|
|
175
|
+
};
|
|
176
|
+
}, [onCreatePlugin, isGroupingFolder, kbDirName]);
|
|
177
|
+
return <RootFolderTree dir={PLUGINS_DIR} testId="plugins-tree" menuItems={menuItems} />;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* A tree entry's path relative to the REPOSITORY (`Plugins/Teams`), from its
|
|
182
|
+
* workspace-relative one (`<kbDir>/Plugins/Teams`); null when it does not
|
|
183
|
+
* sit under the knowledge base at all.
|
|
184
|
+
*/
|
|
185
|
+
function repoRelative(workspacePath: string, kbDirName: string | null): string | null {
|
|
186
|
+
if (kbDirName === null) return null;
|
|
187
|
+
const prefix = `${kbDirName}/`;
|
|
188
|
+
return workspacePath.startsWith(prefix) ? workspacePath.slice(prefix.length) : null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The workspace-relative path a Library URL names, or null. Library item
|
|
193
|
+
* pages live at `/workspace/<default>/<kbDir>/...` — the inverse of
|
|
194
|
+
* `kbFileUrl`, segment by segment. Any other URL (the index, a lens, a
|
|
195
|
+
* plugin page) names no file, so no row is current.
|
|
196
|
+
*/
|
|
197
|
+
function activeWorkspacePath(pathname: string, kbDirName: string | null): string | null {
|
|
198
|
+
const prefix = `${KB_ROUTE_PREFIX}/`;
|
|
199
|
+
if (!pathname.startsWith(prefix)) return null;
|
|
200
|
+
const [branch, ...rest] = pathname.slice(prefix.length).split('/').map(safeDecode);
|
|
201
|
+
if (branch !== DEFAULT_BRANCH || rest.length < 2) return null;
|
|
202
|
+
if (kbDirName !== null && rest[0] !== kbDirName) return null;
|
|
203
|
+
return rest.join('/');
|
|
204
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useParams } from 'react-router-dom';
|
|
2
|
+
import { decodePluginSegment } from '../routes/library-paths';
|
|
3
|
+
import { LibraryPage } from './LibraryPage';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `teams/:group` — one team's lens on the catalog. The name comes in RAW
|
|
7
|
+
* from the router and is decoded here, the way the plugin page decodes its
|
|
8
|
+
* own segment; the page then slices the catalog by the server's answer for
|
|
9
|
+
* that team (`TeamAccess`), and says so when there is no such team.
|
|
10
|
+
*/
|
|
11
|
+
export function TeamRoute() {
|
|
12
|
+
const { group = '' } = useParams<{ group: string }>();
|
|
13
|
+
const name = decodePluginSegment(group);
|
|
14
|
+
return <LibraryPage key={name} filter={{ kind: 'team', group: name }} />;
|
|
15
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, cleanup, within } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
5
|
+
|
|
6
|
+
const accessMock = vi.hoisted(() => ({ fetchFileAccess: vi.fn() }));
|
|
7
|
+
vi.mock('../../../access/api', () => ({
|
|
8
|
+
fetchFileAccess: accessMock.fetchFileAccess,
|
|
9
|
+
fetchFileAccessBatch: vi.fn(async () => ({ results: {} })),
|
|
10
|
+
}));
|
|
11
|
+
vi.mock('../../../../lib/api', () => ({ authFetch: vi.fn() }));
|
|
12
|
+
|
|
13
|
+
import { PluginsTree, SkillsTree } from '../SkillsTree';
|
|
14
|
+
import {
|
|
15
|
+
WorkspaceContext,
|
|
16
|
+
libraryUploadTarget,
|
|
17
|
+
type UploadError,
|
|
18
|
+
type UploadNotice,
|
|
19
|
+
type WorkspaceContextValue,
|
|
20
|
+
} from '../../../workspace/state/workspace.context';
|
|
21
|
+
import { makeWorkspaceFixture } from '../../../workspace/__tests__/testFixtures';
|
|
22
|
+
import { OpenChangeRequestsContext } from '../../../workspace/state/open-change-requests.context';
|
|
23
|
+
import { AuthContext } from '../../../auth/state/auth.context';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The reported duplicate: one upload, the same "the upload became a
|
|
27
|
+
* suggestion" notice at the top of the sidebar AND further down it.
|
|
28
|
+
*
|
|
29
|
+
* The Library's sidebar holds TWO of the app's file trees — `Skills/` and
|
|
30
|
+
* `Plugins/` — and each renders the pair of upload banners, over one shared
|
|
31
|
+
* piece of workspace state. Untargeted, a single drop painted its notice in
|
|
32
|
+
* both. Each tree names itself now, and a banner is drawn only by the tree
|
|
33
|
+
* whose name it carries.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const KB = 'knowledge-base';
|
|
37
|
+
|
|
38
|
+
const TREE: FileTreeEntry = {
|
|
39
|
+
name: '.',
|
|
40
|
+
relativePath: '.',
|
|
41
|
+
type: 'directory',
|
|
42
|
+
children: [{
|
|
43
|
+
name: KB,
|
|
44
|
+
relativePath: KB,
|
|
45
|
+
type: 'directory',
|
|
46
|
+
children: [
|
|
47
|
+
{ name: 'Skills', relativePath: `${KB}/Skills`, type: 'directory', children: [] },
|
|
48
|
+
{ name: 'Plugins', relativePath: `${KB}/Plugins`, type: 'directory', children: [] },
|
|
49
|
+
],
|
|
50
|
+
}],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function renderSidebar(over: Partial<WorkspaceContextValue>) {
|
|
54
|
+
const workspace = makeWorkspaceFixture({ kbDirName: KB, fileTree: TREE, ...over });
|
|
55
|
+
return render(
|
|
56
|
+
<MemoryRouter>
|
|
57
|
+
<AuthContext.Provider
|
|
58
|
+
value={{ user: null, token: null, isLoading: false, login: async () => {}, logout: () => {} }}
|
|
59
|
+
>
|
|
60
|
+
<WorkspaceContext.Provider value={workspace}>
|
|
61
|
+
<OpenChangeRequestsContext.Provider
|
|
62
|
+
value={{
|
|
63
|
+
paths: new Set(),
|
|
64
|
+
forPath: () => [],
|
|
65
|
+
minePaths: new Map(),
|
|
66
|
+
mineNumbers: new Set(),
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{/* Both of the Library sidebar's trees, as `PluginsSidebar` mounts them. */}
|
|
70
|
+
<SkillsTree />
|
|
71
|
+
<PluginsTree />
|
|
72
|
+
</OpenChangeRequestsContext.Provider>
|
|
73
|
+
</WorkspaceContext.Provider>
|
|
74
|
+
</AuthContext.Provider>
|
|
75
|
+
</MemoryRouter>,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The two trees name themselves through the same helper the trees use. */
|
|
80
|
+
const SKILLS = libraryUploadTarget('Skills');
|
|
81
|
+
const PLUGINS = libraryUploadTarget('Plugins');
|
|
82
|
+
|
|
83
|
+
const SUGGESTION: UploadNotice = {
|
|
84
|
+
kind: 'suggestion',
|
|
85
|
+
message:
|
|
86
|
+
"You can't write to that folder, so the upload became a suggestion: "
|
|
87
|
+
+ 'it is now a change request for the folder’s owners to review.',
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const REFUSAL: UploadError = {
|
|
91
|
+
filename: 'report.pdf',
|
|
92
|
+
reason: 'You do not have permission to write to Skills/house-writing-standards',
|
|
93
|
+
status: 403,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
describe('the Library sidebar shows one upload banner, in the tree that took the drop', () => {
|
|
97
|
+
beforeEach(() => {
|
|
98
|
+
cleanup();
|
|
99
|
+
accessMock.fetchFileAccess.mockReset().mockResolvedValue({ canRead: true, canWrite: true });
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('renders the suggestion notice once, inside the Skills tree', () => {
|
|
103
|
+
renderSidebar({ uploadNotices: new Map([[SKILLS, SUGGESTION]]) });
|
|
104
|
+
const notices = screen.getAllByTestId('upload-notice');
|
|
105
|
+
expect(notices).toHaveLength(1);
|
|
106
|
+
expect(within(screen.getByTestId('skills-tree')).getByTestId('upload-notice')).toBe(notices[0]);
|
|
107
|
+
expect(within(screen.getByTestId('plugins-tree')).queryByTestId('upload-notice')).toBeNull();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('renders the error banner once, inside the Skills tree, reason and all', () => {
|
|
111
|
+
renderSidebar({ uploadErrors: new Map([[SKILLS, REFUSAL]]) });
|
|
112
|
+
const alerts = screen.getAllByRole('alert');
|
|
113
|
+
expect(alerts).toHaveLength(1);
|
|
114
|
+
expect(alerts[0]).toHaveTextContent("Couldn't add report.pdf");
|
|
115
|
+
expect(alerts[0].textContent).toContain(REFUSAL.reason);
|
|
116
|
+
expect(alerts[0]).toHaveTextContent('Try another folder or ask its owner.');
|
|
117
|
+
expect(within(screen.getByTestId('plugins-tree')).queryByRole('alert')).toBeNull();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Two drops in flight at once, one per tree. Over a single shared notice
|
|
121
|
+
// the second drop's dispatch replaced the first's and the first to settle
|
|
122
|
+
// cleared the second's — either way one of the two uploads went silent,
|
|
123
|
+
// which is the failure this page exists to prevent.
|
|
124
|
+
it('shows both trees their own drop when two are in flight at once', () => {
|
|
125
|
+
renderSidebar({
|
|
126
|
+
uploadNotices: new Map([
|
|
127
|
+
[SKILLS, { kind: 'progress', message: 'Adding report.pdf to Skills…' } as UploadNotice],
|
|
128
|
+
[PLUGINS, SUGGESTION],
|
|
129
|
+
]),
|
|
130
|
+
});
|
|
131
|
+
expect(screen.getAllByTestId('upload-notice')).toHaveLength(2);
|
|
132
|
+
expect(within(screen.getByTestId('skills-tree')).getByTestId('upload-notice'))
|
|
133
|
+
.toHaveTextContent('Adding report.pdf to Skills');
|
|
134
|
+
expect(within(screen.getByTestId('plugins-tree')).getByTestId('upload-notice'))
|
|
135
|
+
.toHaveTextContent('became a suggestion');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('puts a Plugins drop’s banner in the Plugins tree instead', () => {
|
|
139
|
+
renderSidebar({ uploadNotices: new Map([[PLUGINS, SUGGESTION]]) });
|
|
140
|
+
expect(screen.getAllByTestId('upload-notice')).toHaveLength(1);
|
|
141
|
+
expect(within(screen.getByTestId('plugins-tree')).getByTestId('upload-notice')).toBeDefined();
|
|
142
|
+
expect(within(screen.getByTestId('skills-tree')).queryByTestId('upload-notice')).toBeNull();
|
|
143
|
+
});
|
|
144
|
+
});
|