@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 { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
5
5
|
import type { AccessResponse } from '../api';
|
|
@@ -34,98 +34,120 @@ const ENTRY: FileTreeEntry = {
|
|
|
34
34
|
} as unknown as FileTreeEntry;
|
|
35
35
|
const A = { name: 'Alice', email: 'alice@x.com' };
|
|
36
36
|
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
/**
|
|
38
|
+
* A public node. The reach line under the field is a STATEMENT — it says the
|
|
39
|
+
* node is public and why — and never a control: every reason it names is a
|
|
40
|
+
* grant with a row below (the Everyone row for a literal line, the plugin's
|
|
41
|
+
* row for a public plugin principal), and the row is the one place any grant
|
|
42
|
+
* is removed, through the same flow as every other principal.
|
|
43
|
+
*/
|
|
44
|
+
describe('ManageAccessDialog: a public node', () => {
|
|
45
|
+
const PUBLIC_VIEW = {
|
|
46
|
+
canRead: true,
|
|
47
|
+
canWrite: true,
|
|
48
|
+
canDownload: false,
|
|
49
|
+
canOwner: true,
|
|
50
|
+
eligible: { roles: [], users: [] },
|
|
51
|
+
owners: { roles: [], users: [] },
|
|
52
|
+
downloaders: { roles: [], users: [] },
|
|
53
|
+
};
|
|
54
|
+
const readers = (publicVia: string[], withPlugin: boolean) => ({
|
|
55
|
+
restricted: false,
|
|
56
|
+
principals: [
|
|
57
|
+
{ name: 'everyone', kind: 'role' as const },
|
|
58
|
+
...(withPlugin ? [{ name: 'plugin/open/read', kind: 'plugin' as const }] : []),
|
|
59
|
+
],
|
|
60
|
+
roles: ['everyone', ...(withPlugin ? ['plugin/open/read'] : [])],
|
|
61
|
+
users: [],
|
|
62
|
+
publicVia,
|
|
63
|
+
});
|
|
64
|
+
/** The one reach line, found by its opening word. */
|
|
65
|
+
const reachLine = () => screen.findByText(/^Public: anyone signed in can read it/);
|
|
45
66
|
|
|
46
|
-
describe('ManageAccessDialog: unchecking an inherited verb on a mixed row', () => {
|
|
47
67
|
beforeEach(() => {
|
|
48
68
|
vi.clearAllMocks();
|
|
49
69
|
api.suggestPrincipals.mockResolvedValue({ roles: [], groups: [], people: [], peopleWithheld: false });
|
|
50
70
|
});
|
|
51
71
|
|
|
52
|
-
it('
|
|
72
|
+
it('a literal grant here: the reach line says so, and the Everyone row removes it like any other row', async () => {
|
|
53
73
|
const user = userEvent.setup();
|
|
54
74
|
api.fetchFileAccess.mockResolvedValue({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
owners: { roles: [], users: [] },
|
|
59
|
-
downloaders: { roles: [], users: [A] },
|
|
60
|
-
sources: {
|
|
61
|
-
'u:alice@x.com': {
|
|
62
|
-
read: [{ kind: 'ancestor', path: 'Sales/access.md' }],
|
|
63
|
-
write: [{ kind: 'ancestor', path: 'Sales/access.md' }],
|
|
64
|
-
download: [{ kind: 'direct' }],
|
|
65
|
-
},
|
|
66
|
-
},
|
|
75
|
+
...PUBLIC_VIEW,
|
|
76
|
+
readers: readers([], false),
|
|
77
|
+
sources: { 'r:everyone': { read: [{ kind: 'direct' }] } },
|
|
67
78
|
} as AccessResponse);
|
|
68
|
-
|
|
69
|
-
api.revokeAccess.mockRejectedValue(
|
|
70
|
-
new GitApiError(409, 'inherited', {
|
|
71
|
-
kind: 'inherited', error: 'inherited',
|
|
72
|
-
sources: { write: [{ kind: 'ancestor', path: 'Sales/access.md' }] },
|
|
73
|
-
}),
|
|
74
|
-
);
|
|
75
|
-
|
|
79
|
+
api.revokeAccess.mockResolvedValue({ ...PUBLIC_VIEW, readers: { restricted: true, roles: [], users: [] }, sources: {} });
|
|
76
80
|
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
77
|
-
await
|
|
81
|
+
const line = await reachLine();
|
|
82
|
+
expect(line.textContent).toBe('Public: anyone signed in can read it — granted here. Editing needs access.');
|
|
83
|
+
// The line itself has nothing to click, and the old separate row is gone.
|
|
84
|
+
expect(within(line.parentElement as HTMLElement).queryByRole('button')).toBeNull();
|
|
85
|
+
expect(screen.queryByText('Anyone can read')).toBeNull();
|
|
78
86
|
|
|
87
|
+
// The row's menu holds exactly the verb Everyone can hold, plus the Deny
|
|
88
|
+
// every row ends with — Remove is its own control beside it, never a menu item.
|
|
89
|
+
expect(screen.getByText('Everyone')).toBeInTheDocument();
|
|
90
|
+
await user.click(screen.getByRole('button', { name: /^can read$/i }));
|
|
91
|
+
const readItem = screen.getAllByRole('button', { name: /^can read$/i }).at(-1)!;
|
|
92
|
+
const menu = readItem.parentElement as HTMLElement;
|
|
93
|
+
expect(within(menu).getAllByRole('button').map((b) => b.textContent?.trim())).toEqual([
|
|
94
|
+
'Can read',
|
|
95
|
+
'Deny',
|
|
96
|
+
]);
|
|
97
|
+
await user.click(screen.getByRole('button', { name: 'Remove access' }));
|
|
79
98
|
await waitFor(() => expect(api.revokeAccess).toHaveBeenCalledTimes(1));
|
|
80
|
-
expect(api.revokeAccess).toHaveBeenCalledWith(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
expect(screen.getByRole('heading', { name: /remove from parent folder\?/i })).toBeInTheDocument(),
|
|
99
|
+
expect(api.revokeAccess).toHaveBeenCalledWith(
|
|
100
|
+
'ws-1',
|
|
101
|
+
expect.objectContaining({ principal: { kind: 'role', role: 'everyone' } }),
|
|
84
102
|
);
|
|
85
103
|
});
|
|
86
104
|
|
|
87
|
-
it('
|
|
88
|
-
const user = userEvent.setup();
|
|
89
|
-
// write is `[direct, ancestor]` — Alice is named on the file AND inherits write.
|
|
105
|
+
it('public through a plugin only: the reach line names the plugin, whose row is the grant — no Everyone row', async () => {
|
|
90
106
|
api.fetchFileAccess.mockResolvedValue({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
owners: { roles: [], users: [] },
|
|
95
|
-
downloaders: { roles: [], users: [A] },
|
|
96
|
-
sources: {
|
|
97
|
-
'u:alice@x.com': {
|
|
98
|
-
read: [{ kind: 'direct' }],
|
|
99
|
-
write: [{ kind: 'direct' }, { kind: 'ancestor', path: 'Sales/access.md' }],
|
|
100
|
-
download: [{ kind: 'direct' }],
|
|
101
|
-
},
|
|
102
|
-
},
|
|
107
|
+
...PUBLIC_VIEW,
|
|
108
|
+
readers: readers(['plugin/open/read'], true),
|
|
109
|
+
sources: { 'r:everyone': {}, 'p:plugin/open/read': { read: [{ kind: 'direct' }] } },
|
|
103
110
|
} as AccessResponse);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
112
|
+
const line = await reachLine();
|
|
113
|
+
expect(line.textContent).toBe(
|
|
114
|
+
'Public: anyone signed in can read it — through open · readers. Editing needs access.',
|
|
115
|
+
);
|
|
116
|
+
expect(screen.getByText('open · readers')).toBeInTheDocument();
|
|
117
|
+
// A derived everyone has no line of its own — no row to remove nothing by,
|
|
118
|
+
// not even a collapsed "through a role" one.
|
|
119
|
+
expect(screen.queryByText('Everyone')).toBeNull();
|
|
120
|
+
expect(screen.queryByRole('button', { name: /People with access through a role/ })).toBeNull();
|
|
121
|
+
expect(within(line.parentElement as HTMLElement).queryByRole('button')).toBeNull();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('both a literal line and a public plugin: the reach line lists both reasons, and both rows are there', async () => {
|
|
125
|
+
api.fetchFileAccess.mockResolvedValue({
|
|
126
|
+
...PUBLIC_VIEW,
|
|
127
|
+
readers: readers(['plugin/open/read'], true),
|
|
111
128
|
sources: {
|
|
112
|
-
'
|
|
113
|
-
|
|
114
|
-
write: [{ kind: 'ancestor', path: 'Sales/access.md' }], // direct gone, inherited remains
|
|
115
|
-
download: [{ kind: 'direct' }],
|
|
116
|
-
},
|
|
129
|
+
'r:everyone': { read: [{ kind: 'direct' }] },
|
|
130
|
+
'p:plugin/open/read': { read: [{ kind: 'direct' }] },
|
|
117
131
|
},
|
|
118
132
|
} as AccessResponse);
|
|
119
|
-
|
|
120
133
|
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
121
|
-
await
|
|
134
|
+
expect((await reachLine()).textContent).toMatch(/granted here, through open · readers\. Editing needs access\.$/);
|
|
135
|
+
expect(screen.getByText('Everyone')).toBeInTheDocument();
|
|
136
|
+
expect(screen.getByText('open · readers')).toBeInTheDocument();
|
|
137
|
+
});
|
|
122
138
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
);
|
|
139
|
+
it('a literal line in a parent: the reach line says where, and the Everyone row is inherited from there', async () => {
|
|
140
|
+
api.fetchFileAccess.mockResolvedValue({
|
|
141
|
+
...PUBLIC_VIEW,
|
|
142
|
+
readers: readers([], false),
|
|
143
|
+
sources: { 'r:everyone': { read: [{ kind: 'ancestor', path: 'Sales/access.md' }] } },
|
|
144
|
+
} as AccessResponse);
|
|
145
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
146
|
+
expect((await reachLine()).textContent).toMatch(/— inherited from Sales\./);
|
|
147
|
+
// The row files under the folder that grants it, like every inherited grant.
|
|
148
|
+
fireEvent.click(screen.getByRole('button', { name: /People invited to Sales/ }));
|
|
149
|
+
expect(screen.getByText('Everyone')).toBeInTheDocument();
|
|
150
|
+
expect(screen.getByText(/via Sales/)).toBeInTheDocument();
|
|
129
151
|
});
|
|
130
152
|
});
|
|
131
153
|
|
|
@@ -294,6 +316,111 @@ describe('ManageAccessDialog: naming the rules', () => {
|
|
|
294
316
|
});
|
|
295
317
|
});
|
|
296
318
|
|
|
319
|
+
/**
|
|
320
|
+
* A file that cannot carry frontmatter (a PDF, a deck, an image) has no rules
|
|
321
|
+
* of its own. The sheet says so in the same sentence the routes refuse with,
|
|
322
|
+
* offers the folder's sheet instead of the field and the rows, and still shows
|
|
323
|
+
* who can open the file.
|
|
324
|
+
*/
|
|
325
|
+
describe('ManageAccessDialog: a file whose folder governs its access', () => {
|
|
326
|
+
beforeEach(() => {
|
|
327
|
+
vi.clearAllMocks();
|
|
328
|
+
api.suggestPrincipals.mockResolvedValue({ roles: [], groups: [], people: [], peopleWithheld: false });
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const DECK: FileTreeEntry = {
|
|
332
|
+
name: 'Deck.pptx',
|
|
333
|
+
relativePath: `${KB}/Sales/Deck.pptx`,
|
|
334
|
+
type: 'file',
|
|
335
|
+
} as unknown as FileTreeEntry;
|
|
336
|
+
|
|
337
|
+
const binaryView = {
|
|
338
|
+
canRead: true, canWrite: true, canDownload: true, canOwner: true,
|
|
339
|
+
eligible: { roles: [], users: [A] },
|
|
340
|
+
readers: { restricted: true, roles: [], users: [A, { name: 'Bo', email: 'bo@x.com' }] },
|
|
341
|
+
owners: { roles: [], users: [] },
|
|
342
|
+
downloaders: { roles: [], users: [] },
|
|
343
|
+
sources: {
|
|
344
|
+
'u:alice@x.com': { read: [{ kind: 'ancestor', path: 'Sales/access.md' }], write: [{ kind: 'ancestor', path: 'Sales/access.md' }] },
|
|
345
|
+
'u:bo@x.com': { read: [{ kind: 'ancestor', path: 'Sales/access.md' }] },
|
|
346
|
+
},
|
|
347
|
+
governedByFolder: 'Sales',
|
|
348
|
+
} as AccessResponse;
|
|
349
|
+
|
|
350
|
+
it('shows the folder sentence and a button to the folder in place of the field and rows, keeping who can open it', async () => {
|
|
351
|
+
const user = userEvent.setup();
|
|
352
|
+
const onManageAncestor = vi.fn();
|
|
353
|
+
api.fetchFileAccess.mockResolvedValue(binaryView);
|
|
354
|
+
render(<ManageAccessDialog entry={DECK} onClose={() => {}} onManageAncestor={onManageAncestor} />);
|
|
355
|
+
|
|
356
|
+
expect(
|
|
357
|
+
await screen.findByText("This file's access comes from its folder. Manage access on Sales instead."),
|
|
358
|
+
).toBeInTheDocument();
|
|
359
|
+
// No field, no editable rows, no per-folder disclosures.
|
|
360
|
+
expect(screen.queryByPlaceholderText(/Add people, groups, roles or plugins/)).not.toBeInTheDocument();
|
|
361
|
+
expect(screen.queryByRole('heading', { name: /On this file/i })).not.toBeInTheDocument();
|
|
362
|
+
expect(screen.queryByRole('button', { name: /People invited to Sales/ })).not.toBeInTheDocument();
|
|
363
|
+
expect(screen.queryByRole('button', { name: /Remove/ })).not.toBeInTheDocument();
|
|
364
|
+
expect(screen.queryByRole('button', { name: /can edit/i })).not.toBeInTheDocument();
|
|
365
|
+
// The read side is still there, read-only.
|
|
366
|
+
expect(screen.getByRole('heading', { name: /Who can open it/i })).toBeInTheDocument();
|
|
367
|
+
expect(screen.getByText('Alice')).toBeInTheDocument();
|
|
368
|
+
expect(screen.getByText('Bo')).toBeInTheDocument();
|
|
369
|
+
|
|
370
|
+
await user.click(screen.getByRole('button', { name: 'Manage access on Sales' }));
|
|
371
|
+
expect(onManageAncestor).toHaveBeenCalledWith(
|
|
372
|
+
expect.objectContaining({ name: 'Sales', relativePath: `${KB}/Sales`, type: 'directory' }),
|
|
373
|
+
);
|
|
374
|
+
expect(api.grantAccess).not.toHaveBeenCalled();
|
|
375
|
+
expect(api.revokeAccess).not.toHaveBeenCalled();
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('a file at the root points at the whole workspace', async () => {
|
|
379
|
+
const user = userEvent.setup();
|
|
380
|
+
const onManageAncestor = vi.fn();
|
|
381
|
+
api.fetchFileAccess.mockResolvedValue({ ...binaryView, governedByFolder: '' });
|
|
382
|
+
const blob = { name: 'blob', relativePath: `${KB}/blob`, type: 'file' } as unknown as FileTreeEntry;
|
|
383
|
+
render(<ManageAccessDialog entry={blob} onClose={() => {}} onManageAncestor={onManageAncestor} />);
|
|
384
|
+
|
|
385
|
+
expect(
|
|
386
|
+
await screen.findByText(
|
|
387
|
+
"This file's access comes from its folder. Manage access on the whole workspace instead.",
|
|
388
|
+
),
|
|
389
|
+
).toBeInTheDocument();
|
|
390
|
+
await user.click(screen.getByRole('button', { name: 'Manage access on the whole workspace' }));
|
|
391
|
+
expect(onManageAncestor).toHaveBeenCalledWith(
|
|
392
|
+
expect.objectContaining({ relativePath: KB, type: 'directory' }),
|
|
393
|
+
);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it('a Markdown note keeps the field and its rows', async () => {
|
|
397
|
+
api.fetchFileAccess.mockResolvedValue({ ...binaryView, governedByFolder: undefined });
|
|
398
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} onManageAncestor={() => {}} />);
|
|
399
|
+
expect(await screen.findByRole('heading', { name: /On this file/i })).toBeInTheDocument();
|
|
400
|
+
expect(screen.getByPlaceholderText(/Add people, groups, roles or plugins/)).toBeInTheDocument();
|
|
401
|
+
expect(screen.queryByText(/access comes from its folder/)).not.toBeInTheDocument();
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
it("the server's ruling decides: a binary saved as .md shows the folder pointer", async () => {
|
|
405
|
+
api.fetchFileAccess.mockResolvedValue({ ...binaryView, governedByFolder: 'Sales' });
|
|
406
|
+
const fake = { name: 'Fake.md', relativePath: `${KB}/Sales/Fake.md`, type: 'file' } as unknown as FileTreeEntry;
|
|
407
|
+
render(<ManageAccessDialog entry={fake} onClose={() => {}} onManageAncestor={() => {}} />);
|
|
408
|
+
expect(
|
|
409
|
+
await screen.findByText("This file's access comes from its folder. Manage access on Sales instead."),
|
|
410
|
+
).toBeInTheDocument();
|
|
411
|
+
expect(screen.queryByPlaceholderText(/Add people, groups, roles or plugins/)).not.toBeInTheDocument();
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it("the server's ruling decides: an overlay-registered kind the server accepts keeps the field", async () => {
|
|
415
|
+
api.fetchFileAccess.mockResolvedValue({ ...binaryView, governedByFolder: undefined });
|
|
416
|
+
const flow = { name: 'Flow.pipeline', relativePath: `${KB}/Sales/Flow.pipeline`, type: 'file' } as unknown as FileTreeEntry;
|
|
417
|
+
render(<ManageAccessDialog entry={flow} onClose={() => {}} onManageAncestor={() => {}} />);
|
|
418
|
+
expect(await screen.findByRole('heading', { name: /On this file/i })).toBeInTheDocument();
|
|
419
|
+
expect(screen.getByPlaceholderText(/Add people, groups, roles or plugins/)).toBeInTheDocument();
|
|
420
|
+
expect(screen.queryByText(/access comes from its folder/)).not.toBeInTheDocument();
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
|
|
297
424
|
// ── group principals in the picker ──
|
|
298
425
|
describe('ManageAccessDialog: group principals', () => {
|
|
299
426
|
const VIEW = {
|
|
@@ -325,7 +452,7 @@ describe('ManageAccessDialog: group principals', () => {
|
|
|
325
452
|
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
326
453
|
|
|
327
454
|
await user.type(
|
|
328
|
-
await screen.findByPlaceholderText(/add people, groups, or
|
|
455
|
+
await screen.findByPlaceholderText(/add people, groups, roles or plugins/i),
|
|
329
456
|
'gtm',
|
|
330
457
|
);
|
|
331
458
|
// The suggestion row carries the "group" tag and chips on click.
|
|
@@ -355,7 +482,7 @@ describe('ManageAccessDialog: group principals', () => {
|
|
|
355
482
|
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
356
483
|
|
|
357
484
|
await user.type(
|
|
358
|
-
await screen.findByPlaceholderText(/add people, groups, or
|
|
485
|
+
await screen.findByPlaceholderText(/add people, groups, roles or plugins/i),
|
|
359
486
|
'adm',
|
|
360
487
|
);
|
|
361
488
|
expect(await screen.findByRole('button', { name: /Admin/ })).toBeInTheDocument();
|
|
@@ -381,7 +508,7 @@ describe('ManageAccessDialog: group principals', () => {
|
|
|
381
508
|
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
382
509
|
|
|
383
510
|
await user.type(
|
|
384
|
-
await screen.findByPlaceholderText(/add people, groups, or
|
|
511
|
+
await screen.findByPlaceholderText(/add people, groups, roles or plugins/i),
|
|
385
512
|
'bo',
|
|
386
513
|
);
|
|
387
514
|
expect(await screen.findByRole('button', { name: /Bo/ })).toBeInTheDocument();
|
|
@@ -396,7 +523,7 @@ describe('ManageAccessDialog: group principals', () => {
|
|
|
396
523
|
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
397
524
|
|
|
398
525
|
await user.type(
|
|
399
|
-
await screen.findByPlaceholderText(/add people, groups, or
|
|
526
|
+
await screen.findByPlaceholderText(/add people, groups, roles or plugins/i),
|
|
400
527
|
'a',
|
|
401
528
|
);
|
|
402
529
|
expect(await screen.findByRole('button', { name: /GTM Team/ })).toBeInTheDocument();
|
|
@@ -538,7 +665,7 @@ describe('ManageAccessDialog: grantee rows badge roles vs groups', () => {
|
|
|
538
665
|
});
|
|
539
666
|
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
540
667
|
|
|
541
|
-
const input = await screen.findByPlaceholderText(/add people, groups, or
|
|
668
|
+
const input = await screen.findByPlaceholderText(/add people, groups, roles or plugins/i);
|
|
542
669
|
await user.type(input, 'prod');
|
|
543
670
|
// The group suggestion (tagged "group") chips first…
|
|
544
671
|
await user.click(await screen.findByRole('button', { name: /Product group/i }));
|
|
@@ -569,3 +696,581 @@ describe('ManageAccessDialog: grantee rows badge roles vs groups', () => {
|
|
|
569
696
|
expect(screen.queryByText('Group')).not.toBeInTheDocument();
|
|
570
697
|
});
|
|
571
698
|
});
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* CLOSING A VERB MENU WITHOUT PICKING ANYTHING.
|
|
702
|
+
*
|
|
703
|
+
* Both permission dropdowns (a grantee row's checklist and the add-row's verb
|
|
704
|
+
* selector) used to stay open until an item inside them was clicked or the
|
|
705
|
+
* trigger was clicked again: a click anywhere else in the dialog left the menu
|
|
706
|
+
* hanging, and Escape closed the whole dialog around it. Outside click and
|
|
707
|
+
* Escape now close the menu — and only the menu.
|
|
708
|
+
*/
|
|
709
|
+
describe('ManageAccessDialog: dismissing a verb menu', () => {
|
|
710
|
+
/** Alice, read + write directly here — her trigger reads "Can edit". */
|
|
711
|
+
const VIEW = {
|
|
712
|
+
canRead: true,
|
|
713
|
+
canWrite: true,
|
|
714
|
+
canDownload: false,
|
|
715
|
+
canOwner: false,
|
|
716
|
+
eligible: { roles: [], users: [A] },
|
|
717
|
+
readers: { restricted: true, roles: [], users: [A] },
|
|
718
|
+
owners: { roles: [], users: [] },
|
|
719
|
+
downloaders: { roles: [], users: [] },
|
|
720
|
+
sources: { 'u:alice@x.com': { read: [{ kind: 'direct' }], write: [{ kind: 'direct' }] } },
|
|
721
|
+
} as AccessResponse;
|
|
722
|
+
|
|
723
|
+
beforeEach(() => {
|
|
724
|
+
vi.clearAllMocks();
|
|
725
|
+
api.suggestPrincipals.mockResolvedValue({ roles: [], groups: [], people: [], peopleWithheld: false });
|
|
726
|
+
api.fetchFileAccess.mockResolvedValue(VIEW);
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
/** The add-row's verb selector reads "Can edit" too; Alice's row trigger is the later one. */
|
|
730
|
+
async function aliceTrigger() {
|
|
731
|
+
const triggers = await screen.findAllByRole('button', { name: /^can edit$/i });
|
|
732
|
+
return triggers[triggers.length - 1];
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
it("a click outside a row's menu closes it and leaves the dialog open", async () => {
|
|
736
|
+
const user = userEvent.setup();
|
|
737
|
+
const onClose = vi.fn();
|
|
738
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={onClose} />);
|
|
739
|
+
|
|
740
|
+
await user.click(await aliceTrigger());
|
|
741
|
+
expect(screen.getByRole('button', { name: /^can download$/i })).toBeInTheDocument();
|
|
742
|
+
|
|
743
|
+
// The dialog's own heading: inside the dialog, outside the menu.
|
|
744
|
+
await user.click(screen.getByRole('dialog'));
|
|
745
|
+
|
|
746
|
+
expect(screen.queryByRole('button', { name: /^can download$/i })).not.toBeInTheDocument();
|
|
747
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
748
|
+
expect(api.grantAccess).not.toHaveBeenCalled();
|
|
749
|
+
expect(api.revokeAccess).not.toHaveBeenCalled();
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
it("a click outside the add-row's verb selector closes it", async () => {
|
|
753
|
+
const user = userEvent.setup();
|
|
754
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
755
|
+
|
|
756
|
+
const [addRowTrigger] = await screen.findAllByRole('button', { name: /^can edit$/i });
|
|
757
|
+
await user.click(addRowTrigger);
|
|
758
|
+
// The open selector adds a "Can download" item; Alice's closed row adds none.
|
|
759
|
+
expect(screen.getByRole('button', { name: /^can download$/i })).toBeInTheDocument();
|
|
760
|
+
|
|
761
|
+
await user.click(screen.getByRole('dialog'));
|
|
762
|
+
|
|
763
|
+
expect(screen.queryByRole('button', { name: /^can download$/i })).not.toBeInTheDocument();
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
it('a menu re-rendered with fresh callbacks still dismisses cleanly, once', async () => {
|
|
767
|
+
// The dismiss hook mirrors a fresh-per-render `onDismiss` arrow into a
|
|
768
|
+
// ref itself. Asserted through the surface a user sees: after re-renders
|
|
769
|
+
// of the OPEN menu (each verb toggle re-renders the dialog with new
|
|
770
|
+
// arrows), one Escape closes the menu — and only the menu, exactly once,
|
|
771
|
+
// with the dialog left standing.
|
|
772
|
+
const user = userEvent.setup();
|
|
773
|
+
const onClose = vi.fn();
|
|
774
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={onClose} />);
|
|
775
|
+
const [addRowTrigger] = await screen.findAllByRole('button', { name: /^can edit$/i });
|
|
776
|
+
|
|
777
|
+
await user.click(addRowTrigger);
|
|
778
|
+
// Two re-renders of the open menu with fresh callback identities.
|
|
779
|
+
await user.click(screen.getByRole('button', { name: /^owner$/i }));
|
|
780
|
+
await user.click(screen.getByRole('button', { name: /^owner$/i }));
|
|
781
|
+
expect(screen.getByRole('button', { name: /^can download$/i })).toBeInTheDocument();
|
|
782
|
+
|
|
783
|
+
await user.keyboard('{Escape}');
|
|
784
|
+
expect(screen.queryByRole('button', { name: /^can download$/i })).not.toBeInTheDocument();
|
|
785
|
+
// The dialog is still up: the menu's layer owned that Escape.
|
|
786
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
787
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
it('the trigger itself still toggles: one click opens, a second closes', async () => {
|
|
791
|
+
const user = userEvent.setup();
|
|
792
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
793
|
+
|
|
794
|
+
const trigger = await aliceTrigger();
|
|
795
|
+
await user.click(trigger);
|
|
796
|
+
expect(screen.getByRole('button', { name: /^can download$/i })).toBeInTheDocument();
|
|
797
|
+
// The outside-click listener must NOT fire on the trigger, or this click
|
|
798
|
+
// would close-then-reopen and the menu would look stuck open.
|
|
799
|
+
await user.click(trigger);
|
|
800
|
+
expect(screen.queryByRole('button', { name: /^can download$/i })).not.toBeInTheDocument();
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* The scrim is the dialog's own outside-click. The menu closes on
|
|
805
|
+
* `mousedown` and pops its modal layer as it unmounts, so by the time the
|
|
806
|
+
* scrim's `click` fires the dialog is the top layer again — and used to
|
|
807
|
+
* close on the same gesture, taking the half-filled add row with it.
|
|
808
|
+
* Escape peels one layer at a time; so does the scrim.
|
|
809
|
+
*/
|
|
810
|
+
it('a click on the scrim closes the menu and only the menu', async () => {
|
|
811
|
+
const user = userEvent.setup();
|
|
812
|
+
const onClose = vi.fn();
|
|
813
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={onClose} />);
|
|
814
|
+
|
|
815
|
+
await user.click(await aliceTrigger());
|
|
816
|
+
expect(screen.getByRole('button', { name: /^can download$/i })).toBeInTheDocument();
|
|
817
|
+
|
|
818
|
+
const scrim = screen.getByRole('dialog').parentElement!;
|
|
819
|
+
await user.click(scrim);
|
|
820
|
+
expect(screen.queryByRole('button', { name: /^can download$/i })).not.toBeInTheDocument();
|
|
821
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
822
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
823
|
+
|
|
824
|
+
// With no menu open, the scrim closes the dialog as it always did.
|
|
825
|
+
await user.click(scrim);
|
|
826
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* A verb click leaves the checklist open while the grant is in flight, with
|
|
831
|
+
* every item frozen. The trigger used to freeze too — and `.focus()` on a
|
|
832
|
+
* disabled button is a no-op, so Escape during that window dropped focus
|
|
833
|
+
* to `document`. The trigger only opens and closes the checklist; it does
|
|
834
|
+
* not need to freeze.
|
|
835
|
+
*/
|
|
836
|
+
it('Escape while a grant is in flight still returns focus to the trigger', async () => {
|
|
837
|
+
const user = userEvent.setup();
|
|
838
|
+
let settle!: (view: AccessResponse) => void;
|
|
839
|
+
api.grantAccess.mockReturnValue(new Promise<AccessResponse>((resolve) => (settle = resolve)));
|
|
840
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
841
|
+
|
|
842
|
+
const trigger = await aliceTrigger();
|
|
843
|
+
await user.click(trigger);
|
|
844
|
+
await user.click(screen.getByRole('button', { name: /^owner$/i }));
|
|
845
|
+
expect(api.grantAccess).toHaveBeenCalledTimes(1);
|
|
846
|
+
// In flight: the checklist's items are frozen, the trigger is not.
|
|
847
|
+
expect(screen.getByRole('button', { name: /^can download$/i })).toBeDisabled();
|
|
848
|
+
expect(trigger).not.toBeDisabled();
|
|
849
|
+
|
|
850
|
+
await user.keyboard('{Escape}');
|
|
851
|
+
expect(screen.queryByRole('button', { name: /^can download$/i })).not.toBeInTheDocument();
|
|
852
|
+
expect(document.activeElement).toBe(trigger);
|
|
853
|
+
|
|
854
|
+
settle(VIEW);
|
|
855
|
+
await waitFor(() => expect(trigger).not.toBeDisabled());
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
it('Escape closes the menu, not the dialog, and returns focus to the trigger', async () => {
|
|
859
|
+
const user = userEvent.setup();
|
|
860
|
+
const onClose = vi.fn();
|
|
861
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={onClose} />);
|
|
862
|
+
|
|
863
|
+
const trigger = await aliceTrigger();
|
|
864
|
+
await user.click(trigger);
|
|
865
|
+
expect(screen.getByRole('button', { name: /^can download$/i })).toBeInTheDocument();
|
|
866
|
+
|
|
867
|
+
await user.keyboard('{Escape}');
|
|
868
|
+
|
|
869
|
+
expect(screen.queryByRole('button', { name: /^can download$/i })).not.toBeInTheDocument();
|
|
870
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
871
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
872
|
+
expect(document.activeElement).toBe(trigger);
|
|
873
|
+
|
|
874
|
+
// With the menu gone the dialog is the top layer again: Escape closes it.
|
|
875
|
+
await user.keyboard('{Escape}');
|
|
876
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
877
|
+
});
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* ONE PRIMARY BUTTON, ONE STATUS LINE, ONE PLACE TO REMOVE.
|
|
882
|
+
*
|
|
883
|
+
* The sheet used to carry a Share button beside the field AND a Done in the
|
|
884
|
+
* footer, a "Restricted" block at the bottom AND an "Anyone can read" row at
|
|
885
|
+
* the top, and a Remove that was a button on inherited rows but a menu item
|
|
886
|
+
* ("Remove access") on direct ones. Each pair is now one thing.
|
|
887
|
+
*/
|
|
888
|
+
describe('ManageAccessDialog: the reworked layout', () => {
|
|
889
|
+
const B = { name: 'Bo', email: 'bo@x.com' };
|
|
890
|
+
/** Alice direct (write), Bo inherited from Sales (read), Engineering a role with no file source. */
|
|
891
|
+
const VIEW = {
|
|
892
|
+
canRead: true,
|
|
893
|
+
canWrite: true,
|
|
894
|
+
canDownload: false,
|
|
895
|
+
canOwner: false,
|
|
896
|
+
eligible: { roles: [], users: [A] },
|
|
897
|
+
readers: {
|
|
898
|
+
restricted: true,
|
|
899
|
+
principals: [{ name: 'Engineering', kind: 'role' }],
|
|
900
|
+
roles: ['Engineering'],
|
|
901
|
+
users: [A, B],
|
|
902
|
+
},
|
|
903
|
+
owners: { roles: [], users: [] },
|
|
904
|
+
downloaders: { roles: [], users: [] },
|
|
905
|
+
sources: {
|
|
906
|
+
'u:alice@x.com': { read: [{ kind: 'direct' }], write: [{ kind: 'direct' }] },
|
|
907
|
+
'u:bo@x.com': { read: [{ kind: 'ancestor', path: 'Sales/access.md' }] },
|
|
908
|
+
},
|
|
909
|
+
} as AccessResponse;
|
|
910
|
+
|
|
911
|
+
beforeEach(() => {
|
|
912
|
+
vi.clearAllMocks();
|
|
913
|
+
api.fetchFileAccess.mockResolvedValue(VIEW);
|
|
914
|
+
api.grantAccess.mockResolvedValue(VIEW);
|
|
915
|
+
api.revokeAccess.mockResolvedValue(VIEW);
|
|
916
|
+
api.suggestPrincipals.mockResolvedValue({
|
|
917
|
+
roles: [],
|
|
918
|
+
groups: ['GTM Team'],
|
|
919
|
+
people: [],
|
|
920
|
+
peopleWithheld: false,
|
|
921
|
+
});
|
|
922
|
+
});
|
|
923
|
+
|
|
924
|
+
async function pickGtm(user: ReturnType<typeof userEvent.setup>) {
|
|
925
|
+
await user.type(await screen.findByPlaceholderText('Add people, groups, roles or plugins…'), 'gtm');
|
|
926
|
+
await user.click(await screen.findByRole('button', { name: /GTM Team/ }));
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
it('reads "Done" with nothing picked, and only closes', async () => {
|
|
930
|
+
const user = userEvent.setup();
|
|
931
|
+
const onClose = vi.fn();
|
|
932
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={onClose} />);
|
|
933
|
+
await screen.findByText('Alice');
|
|
934
|
+
|
|
935
|
+
// One Share-or-Done button in the whole sheet, and it is Done.
|
|
936
|
+
expect(screen.queryByRole('button', { name: /^Share$/ })).toBeNull();
|
|
937
|
+
await user.click(screen.getByRole('button', { name: 'Done' }));
|
|
938
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
939
|
+
expect(api.grantAccess).not.toHaveBeenCalled();
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
it('reads "Share" while something is picked, grants it with the chosen verb and closes', async () => {
|
|
943
|
+
const user = userEvent.setup();
|
|
944
|
+
const onClose = vi.fn();
|
|
945
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={onClose} />);
|
|
946
|
+
await pickGtm(user);
|
|
947
|
+
|
|
948
|
+
// Done became Share — there is still exactly one primary button.
|
|
949
|
+
expect(screen.queryByRole('button', { name: 'Done' })).toBeNull();
|
|
950
|
+
const share = screen.getByRole('button', { name: /^Share$/ });
|
|
951
|
+
// It lives in the footer, after everything in the body in reading order.
|
|
952
|
+
const body = screen.getByText('Restricted: only the people below can open it');
|
|
953
|
+
expect(body.compareDocumentPosition(share) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
954
|
+
|
|
955
|
+
await user.click(share);
|
|
956
|
+
await waitFor(() => expect(onClose).toHaveBeenCalledTimes(1));
|
|
957
|
+
expect(api.grantAccess).toHaveBeenCalledTimes(1);
|
|
958
|
+
expect(api.grantAccess).toHaveBeenCalledWith(
|
|
959
|
+
'ws-1',
|
|
960
|
+
expect.objectContaining({ verb: 'write', principal: { kind: 'group', group: 'GTM Team' } }),
|
|
961
|
+
);
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
it('a failed grant keeps the dialog open, the failure shown and the picks intact', async () => {
|
|
965
|
+
const user = userEvent.setup();
|
|
966
|
+
const onClose = vi.fn();
|
|
967
|
+
api.grantAccess.mockRejectedValue(new Error('No such group'));
|
|
968
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={onClose} />);
|
|
969
|
+
await pickGtm(user);
|
|
970
|
+
|
|
971
|
+
await user.click(screen.getByRole('button', { name: /^Share$/ }));
|
|
972
|
+
expect(await screen.findByRole('alert')).toHaveTextContent(/GTM Team \(write\): No such group/);
|
|
973
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
974
|
+
expect(screen.getByRole('button', { name: 'Remove GTM Team' })).toBeInTheDocument();
|
|
975
|
+
expect(screen.getByRole('button', { name: /^Share$/ })).toBeInTheDocument();
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
it('states a restricted reach in one line, with no footer block and no "Anyone can read" row', async () => {
|
|
979
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
980
|
+
expect(await screen.findByText('Restricted: only the people below can open it')).toBeInTheDocument();
|
|
981
|
+
expect(screen.queryByText('Restricted')).toBeNull();
|
|
982
|
+
expect(screen.queryByText(/Only people granted access can edit/)).toBeNull();
|
|
983
|
+
expect(screen.queryByText('Anyone can read')).toBeNull();
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
it('states the reach for someone who cannot manage too', async () => {
|
|
987
|
+
api.fetchFileAccess.mockResolvedValue({ ...VIEW, canWrite: false });
|
|
988
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
989
|
+
expect(await screen.findByText('Restricted: only the people below can open it')).toBeInTheDocument();
|
|
990
|
+
expect(screen.queryByRole('button', { name: /^remove( access)?$/i })).toBeNull();
|
|
991
|
+
});
|
|
992
|
+
|
|
993
|
+
it('names plugins in the helper line under the field', async () => {
|
|
994
|
+
const user = userEvent.setup();
|
|
995
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
996
|
+
await user.type(await screen.findByPlaceholderText('Add people, groups, roles or plugins…'), 'nobody');
|
|
997
|
+
expect(
|
|
998
|
+
await screen.findByText('Type a full email to add someone, or pick a group, role or plugin from the list.'),
|
|
999
|
+
).toBeInTheDocument();
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
it('a direct row ends in its verb dropdown then Remove, which revokes in place; the dropdown has no Remove', async () => {
|
|
1003
|
+
const user = userEvent.setup();
|
|
1004
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
1005
|
+
await screen.findByText('Alice');
|
|
1006
|
+
|
|
1007
|
+
const triggers = screen.getAllByRole('button', { name: /^can edit$/i });
|
|
1008
|
+
const trigger = triggers[triggers.length - 1];
|
|
1009
|
+
// Only Alice's row is visible (Bo and Engineering sit in collapsed sections).
|
|
1010
|
+
// Its Remove keeps the accessible name the dropdown item had: "Remove access".
|
|
1011
|
+
const remove = screen.getByRole('button', { name: 'Remove access' });
|
|
1012
|
+
expect(remove).toHaveTextContent('Remove');
|
|
1013
|
+
expect(screen.queryByRole('button', { name: 'Remove' })).toBeNull();
|
|
1014
|
+
expect(trigger.compareDocumentPosition(remove) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
1015
|
+
|
|
1016
|
+
// The open dropdown holds the verb sets and Deny — never a Remove, which is
|
|
1017
|
+
// its own control beside the trigger.
|
|
1018
|
+
await user.click(trigger);
|
|
1019
|
+
const menu = screen.getByRole('button', { name: /^can download$/i }).parentElement as HTMLElement;
|
|
1020
|
+
expect(within(menu).getAllByRole('button').map((b) => b.textContent?.trim())).toEqual([
|
|
1021
|
+
'Owner',
|
|
1022
|
+
'Can edit',
|
|
1023
|
+
'Can read',
|
|
1024
|
+
'Can download',
|
|
1025
|
+
'Deny',
|
|
1026
|
+
]);
|
|
1027
|
+
await user.keyboard('{Escape}');
|
|
1028
|
+
|
|
1029
|
+
await user.click(remove);
|
|
1030
|
+
await waitFor(() => expect(api.revokeAccess).toHaveBeenCalledTimes(1));
|
|
1031
|
+
expect(api.revokeAccess).toHaveBeenCalledWith(
|
|
1032
|
+
'ws-1',
|
|
1033
|
+
expect.objectContaining({ principal: { kind: 'user', email: 'alice@x.com', displayName: 'Alice' } }),
|
|
1034
|
+
);
|
|
1035
|
+
expect(screen.queryByRole('heading', { name: /remove from parent folder\?/i })).toBeNull();
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
it('an inherited row ends in its OWN verb menu then Remove, which opens "Remove from parent?"', async () => {
|
|
1039
|
+
const user = userEvent.setup();
|
|
1040
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
1041
|
+
await user.click(await screen.findByRole('button', { name: /People invited to Sales/ }));
|
|
1042
|
+
|
|
1043
|
+
// Bo's verbs used to be read-only text here, which left "give Bo less than
|
|
1044
|
+
// Sales gives him" a thing the sheet could state but not do. It is the same
|
|
1045
|
+
// menu Alice's direct row has.
|
|
1046
|
+
const bosMenu = screen.getAllByRole('button', { name: /^can read$/i }).at(-1)!;
|
|
1047
|
+
// An inherited row's Remove keeps its name, "Remove"; Alice's direct one is "Remove access".
|
|
1048
|
+
const bosRemove = screen.getByRole('button', { name: 'Remove' });
|
|
1049
|
+
expect(screen.getAllByRole('button', { name: 'Remove access' })).toHaveLength(1);
|
|
1050
|
+
expect(bosMenu.compareDocumentPosition(bosRemove) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
1051
|
+
|
|
1052
|
+
await user.click(bosRemove);
|
|
1053
|
+
expect(await screen.findByRole('heading', { name: /remove from parent folder\?/i })).toBeInTheDocument();
|
|
1054
|
+
expect(api.revokeAccess).not.toHaveBeenCalled();
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
it('a role-based grant gets the menu too, but no Remove — there is no entry here to remove', async () => {
|
|
1058
|
+
const user = userEvent.setup();
|
|
1059
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
1060
|
+
await user.click(await screen.findByRole('button', { name: /People with access through a role/ }));
|
|
1061
|
+
|
|
1062
|
+
expect(screen.getByText('Engineering')).toBeInTheDocument();
|
|
1063
|
+
// The menu can still write a restriction (a denial needs no prior entry);
|
|
1064
|
+
// Remove could only strip one, and there is none, so the slot stays empty.
|
|
1065
|
+
expect(screen.getAllByRole('button', { name: /^can read$/i }).at(-1)).toBeInTheDocument();
|
|
1066
|
+
// Alice's Remove only: the role row has none.
|
|
1067
|
+
expect(screen.getAllByRole('button', { name: 'Remove access' })).toHaveLength(1);
|
|
1068
|
+
expect(screen.queryByRole('button', { name: 'Remove' })).toBeNull();
|
|
1069
|
+
});
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
// ── access words, explained where they are met ──
|
|
1073
|
+
//
|
|
1074
|
+
// "Group", "Role" and "Plugin" are app words a business user has no reason to
|
|
1075
|
+
// know, and "the root folder" is a repository word. The dialog calls the root
|
|
1076
|
+
// the whole workspace, explains all four kinds of grantee behind an info
|
|
1077
|
+
// control beside the field, and hangs each kind's line on its tag.
|
|
1078
|
+
describe('ManageAccessDialog: explaining the access words', () => {
|
|
1079
|
+
const HELP = {
|
|
1080
|
+
user: 'People: one person, by email.',
|
|
1081
|
+
group:
|
|
1082
|
+
'Groups: a way to group people together and give them access in the app. A group can be a team or department, like Engineering, or a functional group, like skill reviewers.',
|
|
1083
|
+
role: 'Roles: special app roles that give people extra abilities in the app. They are pre-defined; you can only add or remove people. Example: Admin, which opens the platform and user management screens.',
|
|
1084
|
+
plugin: 'Plugins: the readers, writers or owners of a plugin, whoever they are at the time.',
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
const view = (over: Partial<AccessResponse> = {}): AccessResponse =>
|
|
1088
|
+
({
|
|
1089
|
+
canRead: true,
|
|
1090
|
+
canWrite: true,
|
|
1091
|
+
canDownload: false,
|
|
1092
|
+
canOwner: false,
|
|
1093
|
+
eligible: { roles: [], users: [] },
|
|
1094
|
+
readers: { restricted: true, roles: [], users: [] },
|
|
1095
|
+
owners: { roles: [], users: [] },
|
|
1096
|
+
downloaders: { roles: [], users: [] },
|
|
1097
|
+
sources: {},
|
|
1098
|
+
...over,
|
|
1099
|
+
}) as AccessResponse;
|
|
1100
|
+
|
|
1101
|
+
beforeEach(() => {
|
|
1102
|
+
vi.clearAllMocks();
|
|
1103
|
+
api.suggestPrincipals.mockResolvedValue({
|
|
1104
|
+
roles: ['Admin'],
|
|
1105
|
+
groups: ['GTM Team'],
|
|
1106
|
+
pluginPrincipals: ['crm'],
|
|
1107
|
+
people: [],
|
|
1108
|
+
peopleWithheld: false,
|
|
1109
|
+
});
|
|
1110
|
+
});
|
|
1111
|
+
|
|
1112
|
+
it('calls a grant at the repository root the whole workspace', async () => {
|
|
1113
|
+
const user = userEvent.setup();
|
|
1114
|
+
const onManageAncestor = vi.fn();
|
|
1115
|
+
api.fetchFileAccess.mockResolvedValue(
|
|
1116
|
+
view({
|
|
1117
|
+
eligible: { roles: [], users: [A] },
|
|
1118
|
+
readers: { restricted: true, roles: [], users: [A] },
|
|
1119
|
+
sources: { 'u:alice@x.com': { read: [{ kind: 'ancestor', path: 'access.md' }] } },
|
|
1120
|
+
}),
|
|
1121
|
+
);
|
|
1122
|
+
render(
|
|
1123
|
+
<ManageAccessDialog entry={ENTRY} onClose={() => {}} onManageAncestor={onManageAncestor} />,
|
|
1124
|
+
);
|
|
1125
|
+
|
|
1126
|
+
await user.click(
|
|
1127
|
+
await screen.findByRole('button', { name: /People invited to the whole workspace/ }),
|
|
1128
|
+
);
|
|
1129
|
+
expect(screen.getByText('via the whole workspace')).toBeInTheDocument();
|
|
1130
|
+
expect(
|
|
1131
|
+
screen.getByRole('button', { name: 'Manage the whole workspace →' }),
|
|
1132
|
+
).toBeInTheDocument();
|
|
1133
|
+
expect(screen.queryByText(/root folder/i)).not.toBeInTheDocument();
|
|
1134
|
+
|
|
1135
|
+
await user.click(screen.getByRole('button', { name: /^Remove$/ }));
|
|
1136
|
+
expect(
|
|
1137
|
+
await screen.findByRole('heading', { name: 'Remove from the whole workspace?' }),
|
|
1138
|
+
).toBeInTheDocument();
|
|
1139
|
+
expect(
|
|
1140
|
+
screen.getByRole('button', { name: 'Remove from the whole workspace' }),
|
|
1141
|
+
).toBeInTheDocument();
|
|
1142
|
+
expect(screen.queryByText(/root folder/i)).not.toBeInTheDocument();
|
|
1143
|
+
});
|
|
1144
|
+
|
|
1145
|
+
it('opens the four explanations beside the field, and closes on a second press', async () => {
|
|
1146
|
+
const user = userEvent.setup();
|
|
1147
|
+
api.fetchFileAccess.mockResolvedValue(view());
|
|
1148
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
1149
|
+
|
|
1150
|
+
const trigger = await screen.findByRole('button', { name: 'What can I share with?' });
|
|
1151
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
1152
|
+
await user.click(trigger);
|
|
1153
|
+
|
|
1154
|
+
const list = screen.getByRole('list', { name: 'What can I share with?' });
|
|
1155
|
+
expect(within(list).getAllByRole('listitem').map((li) => li.textContent)).toEqual([
|
|
1156
|
+
HELP.user,
|
|
1157
|
+
HELP.group,
|
|
1158
|
+
HELP.role,
|
|
1159
|
+
HELP.plugin,
|
|
1160
|
+
]);
|
|
1161
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
1162
|
+
|
|
1163
|
+
await user.click(trigger);
|
|
1164
|
+
expect(screen.queryByRole('list', { name: 'What can I share with?' })).not.toBeInTheDocument();
|
|
1165
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
// A press puts focus on the control, so a second press needs no hand-back of
|
|
1169
|
+
// its own; what matters is that closing from the keyboard leaves it there,
|
|
1170
|
+
// ready to open again, rather than dropping it to the page.
|
|
1171
|
+
it('opens and closes from the keyboard with focus kept on the control', async () => {
|
|
1172
|
+
const user = userEvent.setup();
|
|
1173
|
+
api.fetchFileAccess.mockResolvedValue(view());
|
|
1174
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
1175
|
+
|
|
1176
|
+
const trigger = await screen.findByRole('button', { name: 'What can I share with?' });
|
|
1177
|
+
trigger.focus();
|
|
1178
|
+
await user.keyboard('{Enter}');
|
|
1179
|
+
expect(screen.getByRole('list', { name: 'What can I share with?' })).toBeInTheDocument();
|
|
1180
|
+
|
|
1181
|
+
await user.keyboard('{Enter}');
|
|
1182
|
+
expect(screen.queryByRole('list', { name: 'What can I share with?' })).not.toBeInTheDocument();
|
|
1183
|
+
expect(document.activeElement).toBe(trigger);
|
|
1184
|
+
|
|
1185
|
+
await user.keyboard(' ');
|
|
1186
|
+
expect(screen.getByRole('list', { name: 'What can I share with?' })).toBeInTheDocument();
|
|
1187
|
+
});
|
|
1188
|
+
|
|
1189
|
+
it('closes on Escape without closing the dialog, and hands focus back', async () => {
|
|
1190
|
+
const user = userEvent.setup();
|
|
1191
|
+
const onClose = vi.fn();
|
|
1192
|
+
api.fetchFileAccess.mockResolvedValue(view());
|
|
1193
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={onClose} />);
|
|
1194
|
+
|
|
1195
|
+
const trigger = await screen.findByRole('button', { name: 'What can I share with?' });
|
|
1196
|
+
await user.click(trigger);
|
|
1197
|
+
expect(screen.getByRole('list', { name: 'What can I share with?' })).toBeInTheDocument();
|
|
1198
|
+
|
|
1199
|
+
await user.keyboard('{Escape}');
|
|
1200
|
+
expect(screen.queryByRole('list', { name: 'What can I share with?' })).not.toBeInTheDocument();
|
|
1201
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
1202
|
+
expect(document.activeElement).toBe(trigger);
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
// Focus is not pulled back here: the click put it where the user wanted it.
|
|
1206
|
+
it('closes on an outside click, leaving the dialog open', async () => {
|
|
1207
|
+
const user = userEvent.setup();
|
|
1208
|
+
api.fetchFileAccess.mockResolvedValue(view());
|
|
1209
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
1210
|
+
|
|
1211
|
+
const trigger = await screen.findByRole('button', { name: 'What can I share with?' });
|
|
1212
|
+
await user.click(trigger);
|
|
1213
|
+
expect(screen.getByRole('list', { name: 'What can I share with?' })).toBeInTheDocument();
|
|
1214
|
+
|
|
1215
|
+
await user.click(screen.getByRole('dialog'));
|
|
1216
|
+
expect(screen.queryByRole('list', { name: 'What can I share with?' })).not.toBeInTheDocument();
|
|
1217
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
1218
|
+
});
|
|
1219
|
+
|
|
1220
|
+
it("hangs each kind's line on the suggestion tags", async () => {
|
|
1221
|
+
const user = userEvent.setup();
|
|
1222
|
+
api.fetchFileAccess.mockResolvedValue(view());
|
|
1223
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
1224
|
+
|
|
1225
|
+
await user.type(await screen.findByPlaceholderText(/add people, groups, roles or plugins/i), 'a');
|
|
1226
|
+
await screen.findByRole('button', { name: /GTM Team/ });
|
|
1227
|
+
|
|
1228
|
+
const groupTag = screen.getByText('group');
|
|
1229
|
+
expect(groupTag).toHaveAttribute('title', HELP.group);
|
|
1230
|
+
expect(groupTag).toHaveAccessibleDescription(HELP.group);
|
|
1231
|
+
const roleTag = screen.getByText('role');
|
|
1232
|
+
expect(roleTag).toHaveAttribute('title', HELP.role);
|
|
1233
|
+
expect(roleTag).toHaveAccessibleDescription(HELP.role);
|
|
1234
|
+
for (const pluginTag of screen.getAllByText('plugin')) {
|
|
1235
|
+
expect(pluginTag).toHaveAttribute('title', HELP.plugin);
|
|
1236
|
+
expect(pluginTag).toHaveAccessibleDescription(HELP.plugin);
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
it("hangs each kind's line on the grantee row badges", async () => {
|
|
1241
|
+
api.fetchFileAccess.mockResolvedValue(
|
|
1242
|
+
view({
|
|
1243
|
+
eligible: {
|
|
1244
|
+
principals: [{ name: 'GTM Team', kind: 'group' }],
|
|
1245
|
+
roles: ['GTM Team'],
|
|
1246
|
+
users: [],
|
|
1247
|
+
},
|
|
1248
|
+
readers: {
|
|
1249
|
+
restricted: true,
|
|
1250
|
+
principals: [
|
|
1251
|
+
{ name: 'Engineering', kind: 'role' },
|
|
1252
|
+
{ name: 'plugin/crm/read', kind: 'plugin' },
|
|
1253
|
+
],
|
|
1254
|
+
roles: ['Engineering', 'plugin/crm/read'],
|
|
1255
|
+
users: [],
|
|
1256
|
+
},
|
|
1257
|
+
sources: {
|
|
1258
|
+
'r:gtm team': { write: [{ kind: 'direct' }] },
|
|
1259
|
+
'r:engineering': { read: [{ kind: 'direct' }] },
|
|
1260
|
+
'p:plugin/crm/read': { read: [{ kind: 'direct' }] },
|
|
1261
|
+
},
|
|
1262
|
+
} as Partial<AccessResponse>),
|
|
1263
|
+
);
|
|
1264
|
+
render(<ManageAccessDialog entry={ENTRY} onClose={() => {}} />);
|
|
1265
|
+
|
|
1266
|
+
const groupBadge = await screen.findByText('Group');
|
|
1267
|
+
expect(groupBadge).toHaveAttribute('title', HELP.group);
|
|
1268
|
+
expect(groupBadge).toHaveAccessibleDescription(HELP.group);
|
|
1269
|
+
const roleBadge = screen.getByText('Role');
|
|
1270
|
+
expect(roleBadge).toHaveAttribute('title', HELP.role);
|
|
1271
|
+
expect(roleBadge).toHaveAccessibleDescription(HELP.role);
|
|
1272
|
+
const pluginBadge = screen.getByText('Plugin');
|
|
1273
|
+
expect(pluginBadge).toHaveAttribute('title', HELP.plugin);
|
|
1274
|
+
expect(pluginBadge).toHaveAccessibleDescription(HELP.plugin);
|
|
1275
|
+
});
|
|
1276
|
+
});
|