@bevel-software/platform-core-frontend 0.15.1 → 0.20.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 +20 -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__/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/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
- package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
- package/src/modules/audit/components/AuditLogPage.tsx +373 -0
- package/src/modules/audit/components/principal-grouping.ts +49 -0
- package/src/modules/audit/services/audit.api.ts +98 -0
- 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 +7 -6
- package/src/modules/settings/services/github-facade.api.ts +23 -0
- package/src/modules/settings/settings-nav-items.tsx +13 -3
- 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 +532 -43
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +141 -4
- 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 +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 +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 +172 -46
- 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 +2533 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -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 +134 -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
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
5
|
+
import type { AccessResponse } from '../api';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A ROW'S MENU IS TWO AXES, AND A CLICK MOVES ONE OF THEM.
|
|
9
|
+
*
|
|
10
|
+
* On core-staging, giving an editor "Can download" took their edit away, and
|
|
11
|
+
* giving a downloader "Can edit" took their download away. Each item applied a
|
|
12
|
+
* fixed whole set — Can edit meant "edit and no download", Can download meant
|
|
13
|
+
* "download and no edit" — so raising one axis wrote a revoke or a denial on
|
|
14
|
+
* the other, in the file, with no prompt.
|
|
15
|
+
*
|
|
16
|
+
* Now the tiers (Owner / Can edit / Can read) are one exclusive axis and
|
|
17
|
+
* download is the other. Clicking an item changes ITS axis and leaves the other
|
|
18
|
+
* alone; clicking the tier a row already holds steps it down one; an item with
|
|
19
|
+
* nothing to do from where the row is renders disabled instead of writing a
|
|
20
|
+
* no-op or a surprise. These tests drive the dialog through the real menu and
|
|
21
|
+
* assert on what reaches the API, because that is where the bug lived.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const api = vi.hoisted(() => ({
|
|
25
|
+
fetchFileAccess: vi.fn(),
|
|
26
|
+
grantAccess: vi.fn(),
|
|
27
|
+
revokeAccess: vi.fn(),
|
|
28
|
+
suggestPrincipals: vi.fn(),
|
|
29
|
+
}));
|
|
30
|
+
vi.mock('../api', async (importOriginal) => {
|
|
31
|
+
const actual = await importOriginal<typeof import('../api')>();
|
|
32
|
+
return { ...actual, ...api };
|
|
33
|
+
});
|
|
34
|
+
vi.mock('../../workspace/state/workspace.context', () => ({
|
|
35
|
+
useWorkspace: () => ({ workspaceId: 'ws-1', kbDirName: 'knowledge-base' }),
|
|
36
|
+
}));
|
|
37
|
+
vi.mock('../../auth/state/auth.context', () => ({
|
|
38
|
+
useAuth: () => ({ user: { email: 'me@x.com', name: 'Me' } }),
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
import { ManageAccessDialog } from '../components/ManageAccessDialog';
|
|
42
|
+
|
|
43
|
+
const FOLDER: FileTreeEntry = {
|
|
44
|
+
name: 'Deals',
|
|
45
|
+
relativePath: 'knowledge-base/Sales/Deals',
|
|
46
|
+
type: 'directory',
|
|
47
|
+
} as unknown as FileTreeEntry;
|
|
48
|
+
const ALICE = { name: 'Alice', email: 'alice@x.com' };
|
|
49
|
+
const ALICE_PRINCIPAL = { kind: 'user', email: 'alice@x.com', displayName: 'Alice' };
|
|
50
|
+
const KEY = 'u:alice@x.com';
|
|
51
|
+
const HERE = { kind: 'direct' } as const;
|
|
52
|
+
|
|
53
|
+
const BLANK = {
|
|
54
|
+
canRead: true,
|
|
55
|
+
canWrite: true,
|
|
56
|
+
canDownload: true,
|
|
57
|
+
canOwner: true,
|
|
58
|
+
eligible: { principals: [], roles: [], users: [] },
|
|
59
|
+
readers: { restricted: true, principals: [], roles: [], users: [] },
|
|
60
|
+
owners: { principals: [], roles: [], users: [] },
|
|
61
|
+
downloaders: { principals: [], roles: [], users: [] },
|
|
62
|
+
sources: {},
|
|
63
|
+
denials: {},
|
|
64
|
+
deniedHere: { principals: [], users: [] },
|
|
65
|
+
} as unknown as AccessResponse;
|
|
66
|
+
|
|
67
|
+
/** Alice holds exactly these verbs, every one granted on this folder itself. */
|
|
68
|
+
function aliceWith(verbs: { owner?: boolean; write?: boolean; read?: boolean; download?: boolean }): AccessResponse {
|
|
69
|
+
const owner = !!verbs.owner;
|
|
70
|
+
const write = owner || !!verbs.write;
|
|
71
|
+
const download = owner || !!verbs.download;
|
|
72
|
+
const read = write || download || !!verbs.read;
|
|
73
|
+
const sources: Record<string, unknown[]> = {};
|
|
74
|
+
if (owner) sources.owner = [HERE];
|
|
75
|
+
if (write) sources.write = [HERE];
|
|
76
|
+
if (download) sources.download = [HERE];
|
|
77
|
+
if (read) sources.read = [HERE];
|
|
78
|
+
return {
|
|
79
|
+
...BLANK,
|
|
80
|
+
eligible: { principals: [], roles: [], users: write ? [ALICE] : [] },
|
|
81
|
+
readers: { restricted: true, principals: [], roles: [], users: read ? [ALICE] : [] },
|
|
82
|
+
owners: { principals: [], roles: [], users: owner ? [ALICE] : [] },
|
|
83
|
+
downloaders: { principals: [], roles: [], users: download ? [ALICE] : [] },
|
|
84
|
+
sources: read ? { [KEY]: sources } : {},
|
|
85
|
+
} as unknown as AccessResponse;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Open Alice's row menu (her trigger reads `summary`) and return the panel holding its items. */
|
|
89
|
+
async function openRowMenu(
|
|
90
|
+
user: ReturnType<typeof userEvent.setup>,
|
|
91
|
+
summary: RegExp,
|
|
92
|
+
): Promise<HTMLElement> {
|
|
93
|
+
const triggers = await screen.findAllByRole('button', { name: summary });
|
|
94
|
+
// The add-row selector can read the same words; a row's trigger is the later one.
|
|
95
|
+
await user.click(triggers[triggers.length - 1]);
|
|
96
|
+
return screen.getAllByRole('button', { name: /^deny$/i }).slice(-1)[0]
|
|
97
|
+
.parentElement as HTMLElement;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function item(menu: HTMLElement, label: RegExp): HTMLElement {
|
|
101
|
+
return within(menu).getByRole('button', { name: label });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
beforeEach(() => {
|
|
105
|
+
vi.clearAllMocks();
|
|
106
|
+
api.suggestPrincipals.mockResolvedValue({ roles: [], groups: [], people: [], peopleWithheld: false });
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('ManageAccessDialog row menu: download is its own axis', () => {
|
|
110
|
+
it('Can download on an editor grants download and leaves edit alone', async () => {
|
|
111
|
+
const user = userEvent.setup();
|
|
112
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ write: true }));
|
|
113
|
+
api.grantAccess.mockResolvedValue(aliceWith({ write: true, download: true }));
|
|
114
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
115
|
+
await screen.findByText('Alice');
|
|
116
|
+
|
|
117
|
+
const menu = await openRowMenu(user, /^can edit$/i);
|
|
118
|
+
await user.click(item(menu, /^can download$/i));
|
|
119
|
+
|
|
120
|
+
// ONE write, a download grant. The bug was a revoke of `write` right here.
|
|
121
|
+
await waitFor(() => expect(api.grantAccess).toHaveBeenCalledTimes(1));
|
|
122
|
+
expect(api.grantAccess).toHaveBeenCalledWith('ws-1', {
|
|
123
|
+
path: FOLDER.relativePath,
|
|
124
|
+
kind: 'folder',
|
|
125
|
+
principal: ALICE_PRINCIPAL,
|
|
126
|
+
verb: 'download',
|
|
127
|
+
});
|
|
128
|
+
expect(api.revokeAccess).not.toHaveBeenCalled();
|
|
129
|
+
// And the row now says both, with both items checked.
|
|
130
|
+
expect(await screen.findByRole('button', { name: /^can edit, can download$/i })).toBeInTheDocument();
|
|
131
|
+
expect(item(menu, /^can edit$/i)).toHaveAttribute('aria-pressed', 'true');
|
|
132
|
+
expect(item(menu, /^can download$/i)).toHaveAttribute('aria-pressed', 'true');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('Can edit on a downloader grants edit and leaves download alone', async () => {
|
|
136
|
+
const user = userEvent.setup();
|
|
137
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ download: true }));
|
|
138
|
+
api.grantAccess.mockResolvedValue(aliceWith({ write: true, download: true }));
|
|
139
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
140
|
+
await screen.findByText('Alice');
|
|
141
|
+
|
|
142
|
+
const menu = await openRowMenu(user, /^can read, can download$/i);
|
|
143
|
+
await user.click(item(menu, /^can edit$/i));
|
|
144
|
+
|
|
145
|
+
await waitFor(() => expect(api.grantAccess).toHaveBeenCalledTimes(1));
|
|
146
|
+
expect(api.grantAccess).toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'write' }));
|
|
147
|
+
// The other half of the bug: no revoke of `download`.
|
|
148
|
+
expect(api.revokeAccess).not.toHaveBeenCalled();
|
|
149
|
+
expect(await screen.findByRole('button', { name: /^can edit, can download$/i })).toBeInTheDocument();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('Can download on a row that has it takes only download away', async () => {
|
|
153
|
+
const user = userEvent.setup();
|
|
154
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ write: true, download: true }));
|
|
155
|
+
api.revokeAccess.mockResolvedValue(aliceWith({ write: true }));
|
|
156
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
157
|
+
await screen.findByText('Alice');
|
|
158
|
+
|
|
159
|
+
const menu = await openRowMenu(user, /^can edit, can download$/i);
|
|
160
|
+
await user.click(item(menu, /^can download$/i));
|
|
161
|
+
|
|
162
|
+
await waitFor(() => expect(api.revokeAccess).toHaveBeenCalledTimes(1));
|
|
163
|
+
// A local grant, so a plain revoke of that one verb — no deny line, no
|
|
164
|
+
// touch on write.
|
|
165
|
+
expect(api.revokeAccess).toHaveBeenCalledWith('ws-1', {
|
|
166
|
+
path: FOLDER.relativePath,
|
|
167
|
+
kind: 'folder',
|
|
168
|
+
principal: ALICE_PRINCIPAL,
|
|
169
|
+
verb: 'download',
|
|
170
|
+
});
|
|
171
|
+
expect(api.grantAccess).not.toHaveBeenCalled();
|
|
172
|
+
// The row's summary drops download, and in the still-open menu the item
|
|
173
|
+
// unchecks while Can edit stays checked.
|
|
174
|
+
await waitFor(() =>
|
|
175
|
+
expect(screen.queryByRole('button', { name: /^can edit, can download$/i })).toBeNull(),
|
|
176
|
+
);
|
|
177
|
+
expect(item(menu, /^can download$/i)).toHaveAttribute('aria-pressed', 'false');
|
|
178
|
+
expect(item(menu, /^can edit$/i)).toHaveAttribute('aria-pressed', 'true');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('under Owner, Can download is conferred, not chosen: checked and disabled', async () => {
|
|
182
|
+
const user = userEvent.setup();
|
|
183
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ owner: true }));
|
|
184
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
185
|
+
await screen.findByText('Alice');
|
|
186
|
+
|
|
187
|
+
// An owner's summary still names download (the resolver folds it in);
|
|
188
|
+
// the menu is where it reads as conferred rather than chosen.
|
|
189
|
+
const menu = await openRowMenu(user, /^owner, can download$/i);
|
|
190
|
+
const download = item(menu, /^can download$/i);
|
|
191
|
+
expect(download).toHaveAttribute('aria-pressed', 'true');
|
|
192
|
+
expect(download).toBeDisabled();
|
|
193
|
+
// The tiers below Owner stay live: each is a demotion, which is an action.
|
|
194
|
+
expect(item(menu, /^can edit$/i)).not.toBeDisabled();
|
|
195
|
+
expect(item(menu, /^can read$/i)).not.toBeDisabled();
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
describe('ManageAccessDialog row menu: the tiers are one axis', () => {
|
|
200
|
+
it('clicking the held tier steps down one: Can edit becomes Can read, download untouched', async () => {
|
|
201
|
+
const user = userEvent.setup();
|
|
202
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ write: true, download: true }));
|
|
203
|
+
api.revokeAccess.mockResolvedValue(aliceWith({ download: true }));
|
|
204
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
205
|
+
await screen.findByText('Alice');
|
|
206
|
+
|
|
207
|
+
const menu = await openRowMenu(user, /^can edit, can download$/i);
|
|
208
|
+
await user.click(item(menu, /^can edit$/i));
|
|
209
|
+
|
|
210
|
+
await waitFor(() => expect(api.revokeAccess).toHaveBeenCalledTimes(1));
|
|
211
|
+
expect(api.revokeAccess).toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'write' }));
|
|
212
|
+
expect(api.revokeAccess).not.toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'download' }));
|
|
213
|
+
// Read is what download and the tier below edit both confer: nothing to grant.
|
|
214
|
+
expect(api.grantAccess).not.toHaveBeenCalled();
|
|
215
|
+
expect(await screen.findByRole('button', { name: /^can read, can download$/i })).toBeInTheDocument();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('clicking Owner on an owner steps down to Can edit, and the download Owner conferred goes with it', async () => {
|
|
219
|
+
const user = userEvent.setup();
|
|
220
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ owner: true }));
|
|
221
|
+
// Revoking the owner line leaves her with nothing here; the dialog then
|
|
222
|
+
// writes the tier the step lands on.
|
|
223
|
+
api.revokeAccess.mockResolvedValue(aliceWith({}));
|
|
224
|
+
api.grantAccess.mockResolvedValue(aliceWith({ write: true }));
|
|
225
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
226
|
+
await screen.findByText('Alice');
|
|
227
|
+
|
|
228
|
+
const menu = await openRowMenu(user, /^owner, can download$/i);
|
|
229
|
+
await user.click(item(menu, /^owner$/i));
|
|
230
|
+
|
|
231
|
+
await waitFor(() => expect(api.grantAccess).toHaveBeenCalledTimes(1));
|
|
232
|
+
expect(api.revokeAccess).toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'owner' }));
|
|
233
|
+
expect(api.grantAccess).toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'write' }));
|
|
234
|
+
// She never held download on its own, so the demotion does not invent it.
|
|
235
|
+
expect(api.grantAccess).not.toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'download' }));
|
|
236
|
+
// The menu re-renders on the fresh view: Owner unchecked, Can edit checked,
|
|
237
|
+
// and download — no longer conferred — unchecked and live again.
|
|
238
|
+
await waitFor(() => expect(item(menu, /^owner$/i)).toHaveAttribute('aria-pressed', 'false'));
|
|
239
|
+
expect(item(menu, /^can edit$/i)).toHaveAttribute('aria-pressed', 'true');
|
|
240
|
+
expect(item(menu, /^can download$/i)).toHaveAttribute('aria-pressed', 'false');
|
|
241
|
+
expect(item(menu, /^can download$/i)).not.toBeDisabled();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('an owner with a download line of their own keeps it through the step-down', async () => {
|
|
245
|
+
const user = userEvent.setup();
|
|
246
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ owner: true }));
|
|
247
|
+
// The view cannot tell an owner's folded download from a line of her own,
|
|
248
|
+
// so the step-down writes nothing for it: here the fresh view after the
|
|
249
|
+
// owner revoke still lists her as a downloader, and that stands.
|
|
250
|
+
api.revokeAccess.mockResolvedValue(aliceWith({ download: true }));
|
|
251
|
+
api.grantAccess.mockResolvedValue(aliceWith({ write: true, download: true }));
|
|
252
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
253
|
+
await screen.findByText('Alice');
|
|
254
|
+
|
|
255
|
+
const menu = await openRowMenu(user, /^owner, can download$/i);
|
|
256
|
+
await user.click(item(menu, /^owner$/i));
|
|
257
|
+
|
|
258
|
+
await waitFor(() => expect(api.grantAccess).toHaveBeenCalledTimes(1));
|
|
259
|
+
// Exactly one revoke (the owner line) and one grant (the tier landed on);
|
|
260
|
+
// download was neither revoked nor re-granted.
|
|
261
|
+
expect(api.revokeAccess).toHaveBeenCalledTimes(1);
|
|
262
|
+
expect(api.revokeAccess).toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'owner' }));
|
|
263
|
+
expect(api.grantAccess).toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'write' }));
|
|
264
|
+
expect(await screen.findByRole('button', { name: /^can edit, can download$/i })).toBeInTheDocument();
|
|
265
|
+
expect(item(menu, /^can download$/i)).toHaveAttribute('aria-pressed', 'true');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('Can read at the top of a row has nothing below it: checked and disabled', async () => {
|
|
269
|
+
const user = userEvent.setup();
|
|
270
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ download: true }));
|
|
271
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
272
|
+
await screen.findByText('Alice');
|
|
273
|
+
|
|
274
|
+
const menu = await openRowMenu(user, /^can read, can download$/i);
|
|
275
|
+
const read = item(menu, /^can read$/i);
|
|
276
|
+
expect(read).toHaveAttribute('aria-pressed', 'true');
|
|
277
|
+
expect(read).toBeDisabled();
|
|
278
|
+
// Taking read away is Remove or Deny's job; download stays a live toggle.
|
|
279
|
+
expect(item(menu, /^can download$/i)).not.toBeDisabled();
|
|
280
|
+
expect(item(menu, /^deny$/i)).not.toBeDisabled();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('a tier above the held one is where the row goes, and download rides along', async () => {
|
|
284
|
+
const user = userEvent.setup();
|
|
285
|
+
api.fetchFileAccess.mockResolvedValue(aliceWith({ download: true }));
|
|
286
|
+
api.grantAccess.mockResolvedValue(aliceWith({ owner: true }));
|
|
287
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
288
|
+
await screen.findByText('Alice');
|
|
289
|
+
|
|
290
|
+
const menu = await openRowMenu(user, /^can read, can download$/i);
|
|
291
|
+
await user.click(item(menu, /^owner$/i));
|
|
292
|
+
|
|
293
|
+
// One grant, the highest tier; owner carries download, so nothing is
|
|
294
|
+
// revoked and nothing else is written.
|
|
295
|
+
await waitFor(() => expect(api.grantAccess).toHaveBeenCalledTimes(1));
|
|
296
|
+
expect(api.grantAccess).toHaveBeenCalledWith('ws-1', expect.objectContaining({ verb: 'owner' }));
|
|
297
|
+
expect(api.revokeAccess).not.toHaveBeenCalled();
|
|
298
|
+
});
|
|
299
|
+
});
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
5
|
+
import type { AccessResponse } from '../api';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A ROW'S MENU IS AS WIDE AS ITS ITEMS, NOT AS ITS TRIGGER.
|
|
9
|
+
*
|
|
10
|
+
* On core-staging the menu under a "Can read" trigger opened at the trigger's
|
|
11
|
+
* width, and an item carrying a note ("from KnowledgeBase") had its LABEL
|
|
12
|
+
* squeezed down to "C…" to make room — the label is the flex child that gives
|
|
13
|
+
* way. The panel now measures its widest item once at `max-content` and pins
|
|
14
|
+
* itself to that, between 200px and 360px; at the cap it is the note that
|
|
15
|
+
* truncates (with the full text on hover), never the label; and the panel
|
|
16
|
+
* re-measures when its items change while it stays open across writes.
|
|
17
|
+
*
|
|
18
|
+
* jsdom does not lay text out, so `offsetWidth` is stubbed to a deterministic
|
|
19
|
+
* width per item (8px a character of its text); what these tests pin is the
|
|
20
|
+
* CONTRACT — which element's width the panel follows, the clamp, what
|
|
21
|
+
* truncates, and the re-measure — not a pixel rendering.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const api = vi.hoisted(() => ({
|
|
25
|
+
fetchFileAccess: vi.fn(),
|
|
26
|
+
grantAccess: vi.fn(),
|
|
27
|
+
revokeAccess: vi.fn(),
|
|
28
|
+
suggestPrincipals: vi.fn(),
|
|
29
|
+
}));
|
|
30
|
+
vi.mock('../api', async (importOriginal) => {
|
|
31
|
+
const actual = await importOriginal<typeof import('../api')>();
|
|
32
|
+
return { ...actual, ...api };
|
|
33
|
+
});
|
|
34
|
+
vi.mock('../../workspace/state/workspace.context', () => ({
|
|
35
|
+
useWorkspace: () => ({ workspaceId: 'ws-1', kbDirName: 'knowledge-base' }),
|
|
36
|
+
}));
|
|
37
|
+
vi.mock('../../auth/state/auth.context', () => ({
|
|
38
|
+
useAuth: () => ({ user: { email: 'me@x.com', name: 'Me' } }),
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
import { ManageAccessDialog } from '../components/ManageAccessDialog';
|
|
42
|
+
|
|
43
|
+
const FOLDER: FileTreeEntry = {
|
|
44
|
+
name: 'Deals',
|
|
45
|
+
relativePath: 'knowledge-base/Sales/Deals',
|
|
46
|
+
type: 'directory',
|
|
47
|
+
} as unknown as FileTreeEntry;
|
|
48
|
+
const ALICE = { name: 'Alice', email: 'alice@x.com' };
|
|
49
|
+
const PX_PER_CHAR = 8;
|
|
50
|
+
const MIN = 200;
|
|
51
|
+
const MAX = 360;
|
|
52
|
+
|
|
53
|
+
const BLANK = {
|
|
54
|
+
canRead: true,
|
|
55
|
+
canWrite: true,
|
|
56
|
+
canDownload: true,
|
|
57
|
+
canOwner: true,
|
|
58
|
+
eligible: { principals: [], roles: [], users: [] },
|
|
59
|
+
readers: { restricted: true, principals: [], roles: [], users: [] },
|
|
60
|
+
owners: { principals: [], roles: [], users: [] },
|
|
61
|
+
downloaders: { principals: [], roles: [], users: [] },
|
|
62
|
+
sources: {},
|
|
63
|
+
denials: {},
|
|
64
|
+
deniedHere: { principals: [], users: [] },
|
|
65
|
+
} as unknown as AccessResponse;
|
|
66
|
+
|
|
67
|
+
/** Alice holds edit (and its read) from the parent folder at `parent`. */
|
|
68
|
+
function editFrom(parent: string): AccessResponse {
|
|
69
|
+
return {
|
|
70
|
+
...BLANK,
|
|
71
|
+
eligible: { principals: [], roles: [], users: [ALICE] },
|
|
72
|
+
readers: { restricted: true, principals: [], roles: [], users: [ALICE] },
|
|
73
|
+
sources: {
|
|
74
|
+
'u:alice@x.com': {
|
|
75
|
+
read: [{ kind: 'ancestor', path: parent }],
|
|
76
|
+
write: [{ kind: 'ancestor', path: parent }],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
} as unknown as AccessResponse;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Alice holds edit granted right here: no notes on any item. */
|
|
83
|
+
const EDIT_HERE = {
|
|
84
|
+
...BLANK,
|
|
85
|
+
eligible: { principals: [], roles: [], users: [ALICE] },
|
|
86
|
+
readers: { restricted: true, principals: [], roles: [], users: [ALICE] },
|
|
87
|
+
sources: { 'u:alice@x.com': { read: [{ kind: 'direct' }], write: [{ kind: 'direct' }] } },
|
|
88
|
+
} as unknown as AccessResponse;
|
|
89
|
+
|
|
90
|
+
/** After `deny write` here: read still from the parent at `parent`, write restricted here. */
|
|
91
|
+
function writeRestrictedHere(parent: string): AccessResponse {
|
|
92
|
+
return {
|
|
93
|
+
...BLANK,
|
|
94
|
+
readers: { restricted: true, principals: [], roles: [], users: [ALICE] },
|
|
95
|
+
sources: { 'u:alice@x.com': { read: [{ kind: 'ancestor', path: parent }] } },
|
|
96
|
+
denials: { 'u:alice@x.com': { write: [{ kind: 'direct' }] } },
|
|
97
|
+
deniedHere: { principals: [], users: [ALICE] },
|
|
98
|
+
} as unknown as AccessResponse;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A folder name long enough that "Can edit · from <it>" measures between the floor and the cap. */
|
|
102
|
+
const MID_PARENT = 'Regional-Sales-Operations/access.md';
|
|
103
|
+
|
|
104
|
+
/** The width the stub gives a panel: its widest item's text, 8px a character. */
|
|
105
|
+
function widestItemPx(panel: HTMLElement): number {
|
|
106
|
+
const items = Array.from(panel.querySelectorAll('button'));
|
|
107
|
+
return Math.max(...items.map((b) => (b.textContent ?? '').length)) * PX_PER_CHAR;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Open Alice's row menu; return the item panel and the positioned wrapper the width is pinned on. */
|
|
111
|
+
async function openRowMenu(
|
|
112
|
+
user: ReturnType<typeof userEvent.setup>,
|
|
113
|
+
summary: RegExp,
|
|
114
|
+
): Promise<{ panel: HTMLElement; wrapper: HTMLElement }> {
|
|
115
|
+
const triggers = await screen.findAllByRole('button', { name: summary });
|
|
116
|
+
await user.click(triggers[triggers.length - 1]);
|
|
117
|
+
const panel = screen.getAllByRole('button', { name: /^deny$/i }).slice(-1)[0]
|
|
118
|
+
.parentElement as HTMLElement;
|
|
119
|
+
return { panel, wrapper: panel.parentElement as HTMLElement };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let offsetWidth: ReturnType<typeof vi.spyOn>;
|
|
123
|
+
|
|
124
|
+
beforeEach(() => {
|
|
125
|
+
vi.clearAllMocks();
|
|
126
|
+
api.suggestPrincipals.mockResolvedValue({ roles: [], groups: [], people: [], peopleWithheld: false });
|
|
127
|
+
// jsdom lays nothing out: every element is 0px wide. Give the positioned
|
|
128
|
+
// wrapper the width its widest item would take — which is what a real
|
|
129
|
+
// `max-content` measurement returns — and leave everything else at 0.
|
|
130
|
+
offsetWidth = vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockImplementation(function (
|
|
131
|
+
this: HTMLElement,
|
|
132
|
+
) {
|
|
133
|
+
return this.classList.contains('fixed') ? widestItemPx(this) : 0;
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
afterEach(() => {
|
|
137
|
+
offsetWidth.mockRestore();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('ManageAccessDialog row menu: width follows the items', () => {
|
|
141
|
+
it('a menu whose items carry notes is as wide as its widest item, wider than the minimum', async () => {
|
|
142
|
+
const user = userEvent.setup();
|
|
143
|
+
api.fetchFileAccess.mockResolvedValue(editFrom(MID_PARENT));
|
|
144
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
145
|
+
await user.click(
|
|
146
|
+
await screen.findByRole('button', { name: /People invited to Regional-Sales-Operations/ }),
|
|
147
|
+
);
|
|
148
|
+
await screen.findByText('Alice');
|
|
149
|
+
|
|
150
|
+
const { panel, wrapper } = await openRowMenu(user, /^can edit$/i);
|
|
151
|
+
const expected = widestItemPx(panel);
|
|
152
|
+
expect(expected).toBeGreaterThan(MIN);
|
|
153
|
+
expect(expected).toBeLessThan(MAX);
|
|
154
|
+
await waitFor(() => expect(wrapper.style.width).toBe(`${expected}px`));
|
|
155
|
+
// The label is whole: it is the note beside it that is bounded.
|
|
156
|
+
const edit = within(panel).getByRole('button', { name: /^can edit$/i });
|
|
157
|
+
expect(edit).toHaveTextContent(/^Can edit/);
|
|
158
|
+
expect(edit.querySelector('[title="from Regional-Sales-Operations"]')).toHaveClass('truncate');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('a menu with no notes sits at the minimum width', async () => {
|
|
162
|
+
const user = userEvent.setup();
|
|
163
|
+
api.fetchFileAccess.mockResolvedValue(EDIT_HERE);
|
|
164
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
165
|
+
await screen.findByText('Alice');
|
|
166
|
+
|
|
167
|
+
const { panel, wrapper } = await openRowMenu(user, /^can edit$/i);
|
|
168
|
+
expect(widestItemPx(panel)).toBeLessThan(MIN);
|
|
169
|
+
await waitFor(() => expect(wrapper.style.width).toBe(`${MIN}px`));
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('a very long folder name stops at the cap, and the note is what truncates, with its full text on hover', async () => {
|
|
173
|
+
const user = userEvent.setup();
|
|
174
|
+
const longParent = 'Very-Long-Department-Name-For-Testing-Purposes/access.md';
|
|
175
|
+
api.fetchFileAccess.mockResolvedValue(editFrom(longParent));
|
|
176
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
177
|
+
await user.click(
|
|
178
|
+
await screen.findByRole('button', { name: /People invited to Very-Long-Department-Name/ }),
|
|
179
|
+
);
|
|
180
|
+
await screen.findByText('Alice');
|
|
181
|
+
|
|
182
|
+
const { panel, wrapper } = await openRowMenu(user, /^can edit$/i);
|
|
183
|
+
expect(widestItemPx(panel)).toBeGreaterThan(MAX);
|
|
184
|
+
await waitFor(() => expect(wrapper.style.width).toBe(`${MAX}px`));
|
|
185
|
+
const note = panel.querySelector('[title="from Very-Long-Department-Name-For-Testing-Purposes"]');
|
|
186
|
+
expect(note).toHaveClass('truncate');
|
|
187
|
+
expect(note).toHaveClass('max-w-44');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('re-measures when the items change while the menu stays open', async () => {
|
|
191
|
+
const user = userEvent.setup();
|
|
192
|
+
// Short notes to start with ("from Sales"): the widest item is under the
|
|
193
|
+
// floor, so the menu opens at the minimum.
|
|
194
|
+
api.fetchFileAccess.mockResolvedValue(editFrom('Sales/access.md'));
|
|
195
|
+
// The fresh view after the write names a longer folder for the read that
|
|
196
|
+
// remains, so the widest item now clears the floor.
|
|
197
|
+
api.revokeAccess.mockResolvedValue(writeRestrictedHere(MID_PARENT));
|
|
198
|
+
render(<ManageAccessDialog entry={FOLDER} onClose={() => {}} />);
|
|
199
|
+
await user.click(await screen.findByRole('button', { name: /People invited to Sales/ }));
|
|
200
|
+
await screen.findByText('Alice');
|
|
201
|
+
|
|
202
|
+
const { panel, wrapper } = await openRowMenu(user, /^can edit$/i);
|
|
203
|
+
expect(widestItemPx(panel)).toBeLessThan(MIN);
|
|
204
|
+
await waitFor(() => expect(wrapper.style.width).toBe(`${MIN}px`));
|
|
205
|
+
|
|
206
|
+
// Picking Can read writes a deny and the fresh view relabels the items:
|
|
207
|
+
// "restricted here" on Can edit, "from Regional-Sales-Operations" on Can
|
|
208
|
+
// read. The menu stays open, so its width has to follow the new widest
|
|
209
|
+
// item — which the observer on the pinned wrapper alone could never see.
|
|
210
|
+
await user.click(within(panel).getByRole('button', { name: /^can read$/i }));
|
|
211
|
+
await waitFor(() => expect(api.revokeAccess).toHaveBeenCalledTimes(1));
|
|
212
|
+
// The restriction makes her a row of THIS folder, so the row — and the
|
|
213
|
+
// open menu with it — remounts in the other section: find it again.
|
|
214
|
+
const relocated = await waitFor(() => {
|
|
215
|
+
const p = screen.getAllByRole('button', { name: /^deny$/i }).slice(-1)[0]
|
|
216
|
+
.parentElement as HTMLElement;
|
|
217
|
+
expect(p.querySelector('[title="restricted here"]')).not.toBeNull();
|
|
218
|
+
return p;
|
|
219
|
+
});
|
|
220
|
+
const after = widestItemPx(relocated);
|
|
221
|
+
expect(after).toBeGreaterThan(MIN);
|
|
222
|
+
await waitFor(() =>
|
|
223
|
+
expect((relocated.parentElement as HTMLElement).style.width).toBe(`${after}px`),
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
});
|