@bevel-software/platform-core-frontend 0.4.1 → 0.5.1
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 +5366 -0
- package/package.json +7 -4
- package/src/core/CoreAppShell.tsx +195 -56
- package/src/core/__tests__/AppChrome.test.tsx +125 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +37 -2
- package/src/core/__tests__/bootstrap.test.ts +63 -0
- package/src/core/bootstrap.ts +73 -0
- package/src/core/events.ts +12 -0
- package/src/core/registry.ts +58 -9
- package/src/index.css +100 -11
- package/src/index.ts +24 -23
- package/src/lib/utils.ts +93 -117
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +281 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +166 -1
- package/src/modules/access/api.ts +49 -0
- package/src/modules/access/components/ManageAccessDialog.tsx +786 -481
- package/src/modules/access/hooks/useFileAccess.ts +1 -1
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +86 -0
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +17 -1
- package/src/modules/admin/__tests__/admin.unread.test.tsx +61 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +44 -38
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +11 -10
- package/src/modules/admin/components/UserAccountsPage.tsx +36 -28
- package/src/modules/admin/state/admin.context.tsx +15 -6
- package/src/modules/auth/components/AccountPage.tsx +11 -11
- package/src/modules/auth/components/LoginScreen.tsx +12 -12
- package/src/modules/auth/services/sso.ts +47 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +277 -0
- package/src/modules/change-requests/__tests__/author.test.ts +48 -0
- package/src/modules/change-requests/__tests__/conflict.test.ts +73 -0
- package/src/modules/change-requests/__tests__/diff.test.ts +134 -0
- package/src/modules/change-requests/__tests__/propose.test.ts +93 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +72 -0
- package/src/modules/change-requests/change-requests.css +22 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +277 -0
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +713 -0
- package/src/modules/change-requests/components/ConflictHelp.tsx +47 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +398 -0
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +168 -0
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +236 -0
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +79 -0
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +80 -0
- package/src/modules/change-requests/services/change-requests.api.ts +45 -0
- package/src/modules/change-requests/services/propose.api.ts +162 -0
- package/src/modules/change-requests/utils/author.ts +47 -0
- package/src/modules/change-requests/utils/conflict.ts +38 -0
- package/src/modules/change-requests/utils/diff.ts +80 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +27 -18
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +36 -83
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +5 -5
- package/src/modules/git/__tests__/PullRequestsForMe.test.tsx +147 -0
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +2 -8
- package/src/modules/git/components/BranchSwitcher.tsx +68 -31
- package/src/modules/git/components/DiffView.tsx +4 -4
- package/src/modules/git/components/FileComparisonPanel.tsx +20 -20
- package/src/modules/git/components/FileHistoryPanel.tsx +71 -107
- package/src/modules/git/components/PullNeededBanner.tsx +6 -13
- package/src/modules/git/components/PullRequestsForMe.tsx +71 -36
- package/src/modules/git/components/UnifiedDiffView.tsx +4 -4
- package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +2 -2
- package/src/modules/git/hooks/useGitState.ts +15 -14
- package/src/modules/git/services/__tests__/error-messages.test.ts +4 -4
- package/src/modules/git/services/error-messages.ts +7 -7
- package/src/modules/git/services/git.api.ts +17 -11
- package/src/modules/git/services/pr-prompts.ts +2 -2
- package/src/modules/git/state/git.context.ts +10 -1
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +224 -0
- package/src/modules/layout/__tests__/SidebarToggle.test.tsx +242 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +56 -0
- package/src/modules/layout/breakpoints.ts +6 -0
- package/src/modules/layout/components/AppLayout.tsx +17 -5
- package/src/modules/layout/components/DemoBanner.tsx +10 -1
- package/src/modules/layout/components/MaintenanceOverlay.tsx +3 -3
- package/src/modules/layout/components/MobileChatLayout.tsx +31 -26
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +59 -24
- package/src/modules/layout/components/SidebarFrame.tsx +317 -0
- package/src/modules/layout/components/SidebarToggle.tsx +86 -0
- package/src/modules/layout/components/SlideOverlay.tsx +1 -1
- package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +40 -2
- package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +19 -3
- package/src/modules/layout/state/sidebar.ts +200 -0
- package/src/modules/library/__tests__/AddToGroupDialog.test.tsx +313 -0
- package/src/modules/library/__tests__/ChangeRequestDock.test.tsx +84 -0
- package/src/modules/library/__tests__/GroupJoinRequests.test.tsx +178 -0
- package/src/modules/library/__tests__/GroupPage.test.tsx +479 -0
- package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +283 -0
- package/src/modules/library/__tests__/GroupsSidebar.contextmenu.test.tsx +175 -0
- package/src/modules/library/__tests__/GroupsSidebar.locked.test.tsx +96 -0
- package/src/modules/library/__tests__/GroupsSidebar.test.tsx +142 -0
- package/src/modules/library/__tests__/GroupsSidebarMenu.test.tsx +142 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +149 -0
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +378 -0
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +347 -0
- package/src/modules/library/__tests__/LockedGroupView.test.tsx +203 -0
- package/src/modules/library/__tests__/NewGroupDialog.test.tsx +114 -0
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +177 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +1063 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +259 -0
- package/src/modules/library/__tests__/ToolLogo.test.tsx +63 -0
- package/src/modules/library/__tests__/ToolPage.test.tsx +315 -0
- package/src/modules/library/__tests__/ToolSharePanel.test.tsx +36 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +260 -0
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +197 -0
- package/src/modules/library/__tests__/auth-harness.tsx +37 -0
- package/src/modules/library/__tests__/oauth-fragment.test.ts +48 -0
- package/src/modules/library/__tests__/status.test.ts +113 -20
- package/src/modules/library/__tests__/useSkillDetail.test.tsx +102 -0
- package/src/modules/library/__tests__/useToolPage.test.tsx +146 -0
- package/src/modules/library/components/AccessRequestsBanner.tsx +101 -0
- package/src/modules/library/components/AddToGroupDialog.tsx +115 -0
- package/src/modules/library/components/ChangeRequestDock.tsx +52 -28
- package/src/modules/library/components/DeleteGroupDialog.tsx +87 -0
- package/src/modules/library/components/GroupIndexRow.tsx +63 -0
- package/src/modules/library/components/GroupJoinRequests.tsx +56 -0
- package/src/modules/library/components/GroupPage.tsx +373 -0
- package/src/modules/library/components/GroupsIndexPage.tsx +222 -0
- package/src/modules/library/components/GroupsSidebar.tsx +338 -0
- package/src/modules/library/components/GroupsSidebarMenu.tsx +160 -0
- package/src/modules/library/components/LibraryCard.tsx +123 -102
- package/src/modules/library/components/LibraryLayout.tsx +344 -0
- package/src/modules/library/components/LibraryPage.tsx +111 -227
- package/src/modules/library/components/LockGlyph.tsx +31 -0
- package/src/modules/library/components/LockedGroupView.tsx +159 -0
- package/src/modules/library/components/ManagedGroupRequests.tsx +70 -0
- package/src/modules/library/components/NewGroupDialog.tsx +112 -0
- package/src/modules/library/components/NewSkillPanel.tsx +151 -0
- package/src/modules/library/components/PageActions.tsx +156 -0
- package/src/modules/library/components/PendingSkillReview.tsx +63 -0
- package/src/modules/library/components/PersonalAddDialog.tsx +88 -0
- package/src/modules/library/components/PersonalGroupPage.tsx +125 -0
- package/src/modules/library/components/StatusDot.tsx +25 -0
- package/src/modules/library/components/ToolLogo.tsx +171 -0
- package/src/modules/library/components/group-page-parts.tsx +419 -0
- package/src/modules/library/components/skill-page/SkillFileEditor.tsx +134 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +117 -0
- package/src/modules/library/components/skill-page/SkillFileTabs.tsx +112 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +673 -0
- package/src/modules/library/components/skill-page/tab-ids.ts +33 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +175 -0
- package/src/modules/library/components/tool-page/ToolPage.tsx +228 -0
- package/src/modules/library/components/tool-page/ToolSharePanel.tsx +45 -0
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +289 -0
- package/src/modules/library/hooks/useJoinRequests.ts +114 -0
- package/src/modules/library/hooks/useLibraryData.ts +134 -119
- package/src/modules/library/hooks/useSkillDetail.ts +119 -74
- package/src/modules/library/hooks/useToolPage.ts +145 -0
- package/src/modules/library/library.css +33 -245
- package/src/modules/library/routes/LibraryRoutes.tsx +134 -0
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +74 -0
- package/src/modules/library/routes/library-paths.ts +191 -0
- package/src/modules/library/services/groups.api.ts +189 -0
- package/src/modules/library/services/library.api.ts +291 -164
- package/src/modules/library/services/tools.api.ts +60 -0
- package/src/modules/library/state/library-context.ts +22 -0
- package/src/modules/library/state/library-data.tsx +223 -0
- package/src/modules/library/state/toast.context.ts +32 -0
- package/src/modules/library/state/toast.tsx +84 -42
- package/src/modules/library/utils/clipboard.ts +33 -0
- package/src/modules/library/utils/group-summary.ts +68 -0
- package/src/modules/library/utils/names.ts +30 -0
- package/src/modules/library/utils/navigate-external.ts +15 -0
- package/src/modules/library/utils/oauth-fragment.ts +32 -0
- package/src/modules/library/utils/personal-group.ts +36 -0
- package/src/modules/library/utils/status.ts +108 -25
- package/src/modules/library/utils/toast-duration.ts +16 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +533 -0
- package/src/modules/onboarding/agent-clients.ts +48 -0
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +133 -0
- package/src/modules/onboarding/components/RootLanding.tsx +54 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +364 -0
- package/src/modules/onboarding/paths.ts +9 -0
- package/src/modules/onboarding/state/onboarding.ts +191 -0
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +10 -10
- package/src/modules/pr/services/pr-approvals.api.ts +19 -0
- package/src/modules/pr/services/pr-cancel.api.ts +11 -0
- package/src/modules/review/components/BinaryChangePlaceholder.tsx +3 -3
- package/src/modules/review/components/DiffViewer.tsx +4 -4
- package/src/modules/review/components/MarkdownDiffViewer.tsx +84 -26
- package/src/modules/review/components/ReviewFileRow.tsx +10 -10
- package/src/modules/review/components/ReviewPanel.tsx +49 -17
- package/src/modules/review/components/ReviewPanelSurface.tsx +1 -1
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +122 -0
- package/src/modules/review/hooks/__tests__/useReviewState.test.ts +1 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +273 -171
- package/src/modules/secrets-vault/components/SecretsPage.tsx +147 -110
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +109 -92
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +35 -4
- package/src/modules/secrets-vault/services/connect.api.ts +24 -3
- package/src/modules/settings/components/DeploymentPage.tsx +90 -0
- package/src/modules/settings/components/SettingsLayout.tsx +135 -0
- package/src/modules/settings/components/SettingsNav.tsx +114 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +110 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +249 -0
- package/src/modules/settings/settings-nav-items.tsx +166 -0
- package/src/modules/setup/__tests__/setup.test.tsx +540 -0
- package/src/modules/setup/components/SetupGate.tsx +67 -0
- package/src/modules/setup/components/SetupScreen.tsx +573 -0
- package/src/modules/setup/services/setup.api.ts +106 -0
- package/src/modules/setup/utils/git-host.ts +34 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +38 -15
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +50 -50
- package/src/modules/toolbar/components/ProfileMenu.tsx +294 -0
- package/src/modules/toolbar/components/Toolbar.tsx +56 -54
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +176 -122
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +252 -77
- package/src/modules/tools/ToolsExplorerPage.tsx +45 -40
- package/src/modules/workspace/__tests__/design-system-parity.test.ts +133 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +2 -0
- package/src/modules/workspace/components/EditorTabs.tsx +82 -50
- package/src/modules/workspace/components/FileExplorer.tsx +413 -189
- package/src/modules/workspace/components/FilePaneCard.tsx +53 -0
- package/src/modules/workspace/components/FileRoute.tsx +89 -84
- package/src/modules/workspace/components/FileViewer.tsx +700 -294
- package/src/modules/workspace/components/KbDocumentShell.tsx +138 -0
- package/src/modules/workspace/components/KbFileRail.tsx +128 -0
- package/src/modules/workspace/components/KbPageHeader.tsx +390 -0
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +87 -3
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +293 -39
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +1 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +462 -44
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +84 -0
- package/src/modules/workspace/components/__tests__/KbFileRail.test.tsx +83 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +192 -0
- package/src/modules/workspace/components/renderers/CopyAnchorButton.tsx +64 -0
- package/src/modules/workspace/components/renderers/CsvRenderer.tsx +8 -8
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +18 -9
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +14 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +2 -2
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +31 -165
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +18 -5
- package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +27 -10
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +2 -2
- package/src/modules/workspace/components/renderers/TextRenderer.tsx +11 -5
- package/src/modules/workspace/components/renderers/ToolForm.tsx +24 -24
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +27 -27
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -11
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +66 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +17 -1
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +1 -1
- package/src/modules/workspace/components/renderers/__tests__/MermaidDiagram.test.tsx +58 -0
- package/src/modules/workspace/components/renderers/__tests__/lazyRenderer.test.tsx +68 -0
- package/src/modules/workspace/components/renderers/__tests__/rendererLayout.test.ts +64 -0
- package/src/modules/workspace/components/renderers/__tests__/sanitizeDocxHtml.test.ts +0 -0
- package/src/modules/workspace/components/renderers/chunk-boundary.tsx +71 -0
- package/src/modules/workspace/components/renderers/index.ts +78 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +241 -0
- package/src/modules/workspace/components/renderers/lazyRenderer.tsx +59 -0
- package/src/modules/workspace/components/renderers/sanitizeDocxHtml.ts +91 -0
- package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +59 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +237 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +185 -0
- package/src/modules/workspace/hooks/useAutoGrowTextarea.ts +30 -0
- package/src/modules/workspace/hooks/useLastCommit.ts +66 -0
- package/src/modules/workspace/hooks/useLinksOut.ts +56 -0
- package/src/modules/workspace/hooks/useOpenChangeRequests.ts +20 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +123 -14
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +1 -1
- package/src/modules/workspace/services/workspace.api.ts +9 -2
- package/src/modules/workspace/state/open-change-requests.context.ts +35 -0
- package/src/modules/workspace/state/open-change-requests.tsx +185 -0
- package/src/modules/workspace/state/workspace.context.ts +9 -0
- package/src/modules/workspace/utils/__tests__/diff.test.ts +87 -0
- package/src/modules/workspace/utils/diff.ts +130 -53
- package/src/modules/workspace/utils/fileTree.ts +7 -4
- package/src/modules/workspace/workspace.css +28 -0
- package/src/shared/components/Badge.tsx +62 -0
- package/src/shared/components/Banner.tsx +58 -0
- package/src/shared/components/Button.tsx +90 -0
- package/src/shared/components/Dialog.tsx +6 -6
- package/src/shared/components/Field.tsx +45 -0
- package/src/shared/components/IconButton.tsx +74 -0
- package/src/shared/components/ListRow.tsx +96 -0
- package/src/shared/components/Menu.tsx +88 -0
- package/src/shared/components/PageShell.tsx +8 -5
- package/src/shared/components/Surface.tsx +86 -0
- package/src/shared/components/__tests__/primitives.test.tsx +333 -0
- package/src/shared/components/index.ts +48 -0
- package/src/shared/components/useDismissableMenu.ts +71 -0
- package/src/shared/theme/__tests__/accent-contrast.test.ts +84 -0
- package/src/shared/theme/index.css +12 -0
- package/src/shared/theme/measure.ts +64 -0
- package/src/shared/theme/shadows.css +34 -0
- package/src/shared/theme/tokens.css +193 -0
- package/src/test-setup.ts +9 -0
- package/src/modules/access/components/AccessRestrictedBanner.tsx +0 -31
- package/src/modules/access/components/NodeOwnersBanner.tsx +0 -30
- package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +0 -82
- package/src/modules/git/components/ProtectedBranchBanner.tsx +0 -42
- package/src/modules/library/__tests__/DetailDialog.test.tsx +0 -200
- package/src/modules/library/__tests__/diff.test.ts +0 -62
- package/src/modules/library/__tests__/loadout.test.tsx +0 -72
- package/src/modules/library/components/CompareView.tsx +0 -357
- package/src/modules/library/components/DetailDialog.tsx +0 -566
- package/src/modules/library/components/GearIcon.tsx +0 -12
- package/src/modules/library/components/LoadoutSidebar.tsx +0 -156
- package/src/modules/library/components/StatusGem.tsx +0 -21
- package/src/modules/library/components/SuggestChange.tsx +0 -171
- package/src/modules/library/components/particles.ts +0 -50
- package/src/modules/library/state/loadout.tsx +0 -129
- package/src/modules/library/utils/diff.ts +0 -102
- package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +0 -93
- package/src/modules/pr/__tests__/PrCancelButton.test.tsx +0 -158
- package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +0 -44
- package/src/modules/pr/__tests__/PrMergeButton.test.tsx +0 -360
- package/src/modules/pr/__tests__/bucketize-comments.test.ts +0 -85
- package/src/modules/pr/__tests__/parsePatch.test.ts +0 -104
- package/src/modules/pr/__tests__/usePrViewerState.test.ts +0 -72
- package/src/modules/pr/components/PrApprovalBadge.tsx +0 -80
- package/src/modules/pr/components/PrCancelButton.tsx +0 -99
- package/src/modules/pr/components/PrCancelConfirmDialog.tsx +0 -119
- package/src/modules/pr/components/PrCommentComposer.tsx +0 -92
- package/src/modules/pr/components/PrCommentThread.tsx +0 -168
- package/src/modules/pr/components/PrCommentsPanel.tsx +0 -143
- package/src/modules/pr/components/PrDiffPane.tsx +0 -425
- package/src/modules/pr/components/PrFileRow.tsx +0 -164
- package/src/modules/pr/components/PrFilesList.tsx +0 -53
- package/src/modules/pr/components/PrHeader.tsx +0 -45
- package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +0 -58
- package/src/modules/pr/components/PrMergeButton.tsx +0 -268
- package/src/modules/pr/components/PrMergeConfirmDialog.tsx +0 -112
- package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +0 -110
- package/src/modules/pr/components/PrViewer.tsx +0 -364
- package/src/modules/pr/hooks/usePrViewerState.ts +0 -150
- package/src/modules/pr/state/pr-viewer.context.ts +0 -34
- package/src/modules/pr/utils/bucketize-comments.ts +0 -55
- package/src/modules/pr/utils/parsePatch.ts +0 -57
- package/src/modules/toolbar/components/AdminMenu.tsx +0 -271
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
} from 'react';
|
|
2
10
|
import { X, Lock, Loader2, ChevronDown, Check, Globe } from 'lucide-react';
|
|
3
11
|
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
12
|
+
import {
|
|
13
|
+
Badge,
|
|
14
|
+
Banner,
|
|
15
|
+
Button,
|
|
16
|
+
Dialog,
|
|
17
|
+
MenuItem,
|
|
18
|
+
MenuPanel,
|
|
19
|
+
} from '../../../shared/components';
|
|
4
20
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
5
21
|
import { useAuth } from '../../auth/state/auth.context';
|
|
6
22
|
import {
|
|
@@ -20,6 +36,29 @@ import {
|
|
|
20
36
|
interface Props {
|
|
21
37
|
entry: FileTreeEntry;
|
|
22
38
|
onClose: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* The workspace (branch) whose access is read and edited. Defaults to the
|
|
41
|
+
* ambient `WorkspaceContext` — which is what the file explorer wants, since
|
|
42
|
+
* it edits the branch the user is looking at.
|
|
43
|
+
*
|
|
44
|
+
* The Library is the other case: its surfaces describe the DEFAULT branch
|
|
45
|
+
* regardless of which branch happens to be open, so a group's access edit
|
|
46
|
+
* has to be pinned to it. Without this the same click would splice
|
|
47
|
+
* `access.md` on whatever branch the context last had open — a rule written
|
|
48
|
+
* into a draft nobody merges, silently doing nothing.
|
|
49
|
+
*/
|
|
50
|
+
workspaceId?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Retarget the sheet at an ancestor folder — the prototype's
|
|
53
|
+
* `Manage <Folder> →` (proto:3647).
|
|
54
|
+
*
|
|
55
|
+
* The dialog cannot do this itself: it takes a fixed `entry`, and the caller
|
|
56
|
+
* owns the state that chooses it. Every existing call site already holds
|
|
57
|
+
* exactly that state, so wiring it is one line each. Omitted ⇒ the link does
|
|
58
|
+
* not render, and an inherited grant stays read-only — which is the honest
|
|
59
|
+
* fallback, not a silent no-op.
|
|
60
|
+
*/
|
|
61
|
+
onManageAncestor?: (entry: FileTreeEntry) => void;
|
|
23
62
|
}
|
|
24
63
|
|
|
25
64
|
type Role = 'Owner' | 'Can edit' | 'Can read' | 'Can download';
|
|
@@ -122,7 +161,19 @@ function ancestorsFromSources(sources: GrantSources | undefined): string[] {
|
|
|
122
161
|
/** The checklist order; download is independent and rendered separately. */
|
|
123
162
|
const TIER_ROLES: Role[] = ['Owner', 'Can edit', 'Can read'];
|
|
124
163
|
|
|
125
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Muted identity tones (bg/fg pairs) — the same family as the Library's
|
|
166
|
+
* monogram marks, so a person's avatar and a tool's logo read as one system
|
|
167
|
+
* instead of one calm grid with saturated Drive-style discs in the middle.
|
|
168
|
+
*/
|
|
169
|
+
const AVATAR_TONES = [
|
|
170
|
+
{ bg: '#eaf1ea', fg: '#4f7a52' },
|
|
171
|
+
{ bg: '#e9eefb', fg: '#4560a8' },
|
|
172
|
+
{ bg: '#fbeeea', fg: '#a85a41' },
|
|
173
|
+
{ bg: '#f2eafa', fg: '#6f4a9b' },
|
|
174
|
+
{ bg: '#e7f2f4', fg: '#3d7783' },
|
|
175
|
+
{ bg: '#faf0e2', fg: '#8a6a2f' },
|
|
176
|
+
];
|
|
126
177
|
|
|
127
178
|
function initials(label: string): string {
|
|
128
179
|
const parts = label.replace(/[<>]/g, '').trim().split(/[\s@.]+/).filter(Boolean);
|
|
@@ -131,10 +182,10 @@ function initials(label: string): string {
|
|
|
131
182
|
return (parts[0][0] + parts[1][0]).toUpperCase();
|
|
132
183
|
}
|
|
133
184
|
|
|
134
|
-
function
|
|
185
|
+
function avatarTone(seed: string): { bg: string; fg: string } {
|
|
135
186
|
let h = 0;
|
|
136
187
|
for (let i = 0; i < seed.length; i++) h = (h * 31 + seed.charCodeAt(i)) | 0;
|
|
137
|
-
return
|
|
188
|
+
return AVATAR_TONES[Math.abs(h) % AVATAR_TONES.length];
|
|
138
189
|
}
|
|
139
190
|
|
|
140
191
|
const EMAIL_RE = /^[^<>\s@]+@[^<>\s@]+\.[^<>\s@]+$/;
|
|
@@ -178,6 +229,136 @@ function summarizeVerbs(v: VerbSet): string {
|
|
|
178
229
|
return parts.length ? parts.join(', ') : 'No access';
|
|
179
230
|
}
|
|
180
231
|
|
|
232
|
+
/** Gap between a trigger and its menu, and the minimum inset from a viewport edge. */
|
|
233
|
+
const MENU_GAP = 4;
|
|
234
|
+
const MENU_MARGIN = 8;
|
|
235
|
+
/**
|
|
236
|
+
* `MenuPanel`'s own `min-w-[200px]`. We position a box and the panel renders
|
|
237
|
+
* inside it, so the two must agree: a narrower requested width would place a
|
|
238
|
+
* 192px box that paints 200px wide, and a right-aligned menu would overhang its
|
|
239
|
+
* trigger by the difference.
|
|
240
|
+
*/
|
|
241
|
+
const MENU_MIN_WIDTH = 200;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A dropdown panel that escapes the dialog's scroll container.
|
|
245
|
+
*
|
|
246
|
+
* `Dialog` renders its body inside `overflow-y-auto` so a long access list
|
|
247
|
+
* scrolls under the pinned header and footer. An ABSOLUTELY positioned menu in
|
|
248
|
+
* that box is clipped by it: open the verb menu on a low grantee row and
|
|
249
|
+
* everything past the first item or two — "Remove access" included — is cut off
|
|
250
|
+
* at the body's edge, unreachable without scrolling the list out from under the
|
|
251
|
+
* menu.
|
|
252
|
+
*
|
|
253
|
+
* `position: fixed` is the fix, because an overflow ancestor doesn't clip a
|
|
254
|
+
* descendant whose containing block is the viewport. Deliberately NOT a portal:
|
|
255
|
+
* the panel stays inside `Dialog`'s focus trap, which queries its own subtree,
|
|
256
|
+
* so the items remain Tab-reachable. Being fixed, it has to be re-anchored to
|
|
257
|
+
* the trigger's measured rect on scroll and resize — the same shape
|
|
258
|
+
* `BranchSwitcher` uses for its portaled menu — and, because both boxes can
|
|
259
|
+
* change size with the menu still open, whenever either one is resized.
|
|
260
|
+
*
|
|
261
|
+
* The anchor is the panel's own DOM PARENT — i.e. render this where the
|
|
262
|
+
* `absolute` panel used to sit, and it lines up against the same box `absolute`
|
|
263
|
+
* measured. That's not just brevity: a ref passed down from the parent is NOT
|
|
264
|
+
* attached yet when this component's layout effect runs (React attaches refs
|
|
265
|
+
* bottom-up, children first), so the first placement would silently no-op and
|
|
266
|
+
* the panel would stay hidden.
|
|
267
|
+
*/
|
|
268
|
+
function AnchoredMenu({
|
|
269
|
+
/**
|
|
270
|
+
* Panel width in px, or `'anchor'` to match the trigger (the combobox case).
|
|
271
|
+
* Clamped up to {@link MENU_MIN_WIDTH} either way.
|
|
272
|
+
*/
|
|
273
|
+
width = MENU_MIN_WIDTH,
|
|
274
|
+
/** Which edge lines up with the anchor's. */
|
|
275
|
+
align = 'right',
|
|
276
|
+
className = '',
|
|
277
|
+
children,
|
|
278
|
+
}: {
|
|
279
|
+
width?: number | 'anchor';
|
|
280
|
+
align?: 'left' | 'right';
|
|
281
|
+
className?: string;
|
|
282
|
+
children: ReactNode;
|
|
283
|
+
}) {
|
|
284
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
285
|
+
const [pos, setPos] = useState<{ top: number; left: number; width: number } | null>(null);
|
|
286
|
+
|
|
287
|
+
useLayoutEffect(() => {
|
|
288
|
+
const panel = panelRef.current;
|
|
289
|
+
const anchorEl = panel?.parentElement ?? null;
|
|
290
|
+
const place = () => {
|
|
291
|
+
const el = panelRef.current;
|
|
292
|
+
const anchor = el?.parentElement?.getBoundingClientRect();
|
|
293
|
+
if (!anchor || !el) return;
|
|
294
|
+
const w = Math.max(width === 'anchor' ? anchor.width : width, MENU_MIN_WIDTH);
|
|
295
|
+
// Width BEFORE height: the panel wraps and grows taller when narrower, so
|
|
296
|
+
// measuring at the wrong width picks the wrong side to open on.
|
|
297
|
+
el.style.width = `${w}px`;
|
|
298
|
+
const h = el.offsetHeight;
|
|
299
|
+
const left = Math.max(
|
|
300
|
+
MENU_MARGIN,
|
|
301
|
+
Math.min(
|
|
302
|
+
align === 'right' ? anchor.right - w : anchor.left,
|
|
303
|
+
window.innerWidth - w - MENU_MARGIN,
|
|
304
|
+
),
|
|
305
|
+
);
|
|
306
|
+
// Below by default. Flip above only when the panel would run off the
|
|
307
|
+
// bottom AND there is actually room up there — otherwise a tall menu on a
|
|
308
|
+
// low trigger would just lose its top instead of its bottom.
|
|
309
|
+
const below = anchor.bottom + MENU_GAP;
|
|
310
|
+
const above = anchor.top - MENU_GAP - h;
|
|
311
|
+
const top =
|
|
312
|
+
below + h > window.innerHeight - MENU_MARGIN && above >= MENU_MARGIN ? above : below;
|
|
313
|
+
// Keep the previous object when nothing moved. `place` runs on every
|
|
314
|
+
// scroll frame and on every observed resize, and a fresh object each time
|
|
315
|
+
// would re-render for nothing — and, since the panel is what's observed,
|
|
316
|
+
// feed the observer its own output.
|
|
317
|
+
setPos((prev) =>
|
|
318
|
+
prev && prev.top === top && prev.left === left && prev.width === w
|
|
319
|
+
? prev
|
|
320
|
+
: { top, left, width: w },
|
|
321
|
+
);
|
|
322
|
+
};
|
|
323
|
+
place();
|
|
324
|
+
// Both measured boxes move under us while the menu is open, and neither
|
|
325
|
+
// move fires scroll or resize. The trigger relabels itself as verbs are
|
|
326
|
+
// toggled ("Can edit" → "Owner, Can download"), which shifts `anchor.right`
|
|
327
|
+
// out from under a right-aligned panel; the panel itself grows and shrinks
|
|
328
|
+
// as the suggestion list follows what's typed, so one measured to fit below
|
|
329
|
+
// ends up hanging off the bottom it was checked against.
|
|
330
|
+
const observer = new ResizeObserver(place);
|
|
331
|
+
if (anchorEl) observer.observe(anchorEl);
|
|
332
|
+
if (panel) observer.observe(panel);
|
|
333
|
+
window.addEventListener('resize', place);
|
|
334
|
+
// Capture phase: the dialog body is what scrolls, and scroll events don't
|
|
335
|
+
// bubble to `window`.
|
|
336
|
+
window.addEventListener('scroll', place, true);
|
|
337
|
+
return () => {
|
|
338
|
+
observer.disconnect();
|
|
339
|
+
window.removeEventListener('resize', place);
|
|
340
|
+
window.removeEventListener('scroll', place, true);
|
|
341
|
+
};
|
|
342
|
+
}, [width, align]);
|
|
343
|
+
|
|
344
|
+
return (
|
|
345
|
+
<div
|
|
346
|
+
ref={panelRef}
|
|
347
|
+
className="fixed z-[60]"
|
|
348
|
+
style={{
|
|
349
|
+
top: pos?.top ?? 0,
|
|
350
|
+
left: pos?.left ?? 0,
|
|
351
|
+
width: pos?.width ?? (typeof width === 'number' ? width : undefined),
|
|
352
|
+
// Covers the measuring pass only. `useLayoutEffect` places the panel
|
|
353
|
+
// before the browser paints, so an unpositioned one is never on screen.
|
|
354
|
+
visibility: pos ? undefined : 'hidden',
|
|
355
|
+
}}
|
|
356
|
+
>
|
|
357
|
+
<MenuPanel className={`w-full ${className}`}>{children}</MenuPanel>
|
|
358
|
+
</div>
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
181
362
|
/**
|
|
182
363
|
* Google-Drive-style "Manage access" sheet. Reads the resolved access for a KB
|
|
183
364
|
* path and lets anyone who can write the path's access config share it: add one
|
|
@@ -189,8 +370,16 @@ function summarizeVerbs(v: VerbSet): string {
|
|
|
189
370
|
* the user can't write the access config, the add affordance is disabled and
|
|
190
371
|
* names the owners to ask.
|
|
191
372
|
*/
|
|
192
|
-
export function ManageAccessDialog({
|
|
193
|
-
|
|
373
|
+
export function ManageAccessDialog({
|
|
374
|
+
entry,
|
|
375
|
+
onClose,
|
|
376
|
+
workspaceId: workspaceIdProp,
|
|
377
|
+
onManageAncestor,
|
|
378
|
+
}: Props) {
|
|
379
|
+
// `kbDirName` stays context-sourced: it names the clone directory, which is
|
|
380
|
+
// the same on every branch.
|
|
381
|
+
const { workspaceId: ctxWorkspaceId, kbDirName } = useWorkspace();
|
|
382
|
+
const workspaceId = workspaceIdProp ?? ctxWorkspaceId;
|
|
194
383
|
const { user } = useAuth();
|
|
195
384
|
const [data, setData] = useState<AccessResponse | null>(null);
|
|
196
385
|
const [loading, setLoading] = useState(true);
|
|
@@ -269,13 +458,9 @@ export function ManageAccessDialog({ entry, onClose }: Props) {
|
|
|
269
458
|
};
|
|
270
459
|
}, [workspaceId, repoRelative, targetKind]);
|
|
271
460
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
};
|
|
276
|
-
document.addEventListener('keydown', onKey);
|
|
277
|
-
return () => document.removeEventListener('keydown', onKey);
|
|
278
|
-
}, [onClose]);
|
|
461
|
+
// Escape / backdrop / focus trapping all belong to the shared `Dialog` now —
|
|
462
|
+
// including the layering that lets the nested "Remove from parent?" modal
|
|
463
|
+
// take Escape without also closing this one.
|
|
279
464
|
|
|
280
465
|
// Debounced autocomplete. People are withheld server-side until q ≥ 2 chars.
|
|
281
466
|
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
@@ -329,10 +514,14 @@ export function ManageAccessDialog({ entry, onClose }: Props) {
|
|
|
329
514
|
const key = `u:${u.email.toLowerCase()}`;
|
|
330
515
|
let row = rows.get(key);
|
|
331
516
|
if (!row) {
|
|
517
|
+
const label = u.name || u.email;
|
|
332
518
|
row = {
|
|
333
519
|
key,
|
|
334
|
-
label
|
|
335
|
-
|
|
520
|
+
label,
|
|
521
|
+
// Only a real display name earns the second line — a nameless user
|
|
522
|
+
// would otherwise render the same email twice, burning a row of the
|
|
523
|
+
// scarce width on a duplicate.
|
|
524
|
+
sub: label.toLowerCase() === u.email.toLowerCase() ? undefined : u.email,
|
|
336
525
|
isRole: false,
|
|
337
526
|
isYou: u.email.toLowerCase() === myEmail,
|
|
338
527
|
principal: { kind: 'user', email: u.email, displayName: u.name || u.email },
|
|
@@ -378,7 +567,56 @@ export function ManageAccessDialog({ entry, onClose }: Props) {
|
|
|
378
567
|
() => principals.filter((p) => p.manage !== 'direct'),
|
|
379
568
|
[principals],
|
|
380
569
|
);
|
|
381
|
-
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* The inherited rows, ONE GROUP PER GRANTING FOLDER — the prototype's shape
|
|
573
|
+
* (proto:3637-3649) and, more to the point, its reasoning:
|
|
574
|
+
*
|
|
575
|
+
* "Inheritance, said as a sentence instead of labelled as a concept.
|
|
576
|
+
* 'People invited to KnowledgeBase' needs no explaining — it names the
|
|
577
|
+
* folder, and the folder is both what it means and where it changes. One
|
|
578
|
+
* collapsed row per granting folder, because two folders granting
|
|
579
|
+
* different people is the normal case and merging them would hide which
|
|
580
|
+
* one to open."
|
|
581
|
+
*
|
|
582
|
+
* This used to be a single "Inherited access (N) — from parent folders &
|
|
583
|
+
* roles" disclosure. That heading names the CONCEPT, which the reader either
|
|
584
|
+
* already understands or is not helped by, and merging every ancestor into
|
|
585
|
+
* one list threw away the only fact that makes an inherited grant
|
|
586
|
+
* actionable: which folder to go and edit.
|
|
587
|
+
*
|
|
588
|
+
* A principal granted by two folders appears under BOTH, deliberately — that
|
|
589
|
+
* is the truth, and it is exactly the case a merged list hides.
|
|
590
|
+
*
|
|
591
|
+
* Rows with no ancestor at all (a role that grants at the workspace level,
|
|
592
|
+
* `manage: 'external'`) have no folder to file under, so they keep a group of
|
|
593
|
+
* their own at the end rather than being dropped.
|
|
594
|
+
*/
|
|
595
|
+
const inheritedByFolder = useMemo(() => {
|
|
596
|
+
const byFolder = new Map<string, PrincipalRow[]>();
|
|
597
|
+
const external: PrincipalRow[] = [];
|
|
598
|
+
for (const row of inheritedRows) {
|
|
599
|
+
if (row.ancestors.length === 0) {
|
|
600
|
+
external.push(row);
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
for (const a of row.ancestors) {
|
|
604
|
+
const list = byFolder.get(a);
|
|
605
|
+
if (list) list.push(row);
|
|
606
|
+
else byFolder.set(a, [row]);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
// Deepest folder first: the nearest ancestor is the one most likely to be
|
|
610
|
+
// the one you meant, and it is the one whose rule wins.
|
|
611
|
+
const folders = [...byFolder.entries()].sort(
|
|
612
|
+
(a, b) => b[0].split('/').length - a[0].split('/').length,
|
|
613
|
+
);
|
|
614
|
+
return { folders, external };
|
|
615
|
+
}, [inheritedRows]);
|
|
616
|
+
|
|
617
|
+
/** Which folder group is expanded, or `'roles'`, or null. One at a time —
|
|
618
|
+
* as in the prototype, where `state.accOpen` holds a single value. */
|
|
619
|
+
const [openGroup, setOpenGroup] = useState<string | null>(null);
|
|
382
620
|
|
|
383
621
|
const governed = repoRelative !== null;
|
|
384
622
|
// The dialog can mutate only if the current user can write this path's access
|
|
@@ -459,7 +697,7 @@ export function ManageAccessDialog({ entry, onClose }: Props) {
|
|
|
459
697
|
// picked (e.g. only "Can download"): record it as a failure so the chip
|
|
460
698
|
// stays visible and the user is told why, rather than a no-op clear.
|
|
461
699
|
if (isEveryoneRole(principal) && verbsForPrincipal.length === 0) {
|
|
462
|
-
failures.push(`${label}: "Everyone" can only be granted read access
|
|
700
|
+
failures.push(`${label}: "Everyone" can only be granted read access. Select "Can read".`);
|
|
463
701
|
continue;
|
|
464
702
|
}
|
|
465
703
|
for (const verb of verbsForPrincipal) {
|
|
@@ -718,515 +956,582 @@ export function ManageAccessDialog({ entry, onClose }: Props) {
|
|
|
718
956
|
|
|
719
957
|
// One grantee row. Direct rows get the inline verb editor; inherited rows are
|
|
720
958
|
// read-only with a Remove that opens the cascade flow; external rows are
|
|
721
|
-
// read-only with no action.
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
{p.isRole && (
|
|
736
|
-
<span className="ml-1.5 text-[10px] uppercase tracking-wide text-slate-400">role</span>
|
|
737
|
-
)}
|
|
738
|
-
</div>
|
|
739
|
-
{p.sub && <div className="text-xs text-slate-500 truncate">{p.sub}</div>}
|
|
740
|
-
</div>
|
|
741
|
-
{canManage && p.manage === 'inherited' ? (
|
|
742
|
-
// Inherited from a parent folder — read-only here. Leaf folder name only
|
|
743
|
-
// (full path on hover); Remove opens the "Remove from parent?" flow.
|
|
744
|
-
<div className="flex items-center gap-2 shrink-0">
|
|
959
|
+
// read-only with no action.
|
|
960
|
+
const renderRow = (p: PrincipalRow) => {
|
|
961
|
+
const tone = avatarTone(p.label);
|
|
962
|
+
return (
|
|
963
|
+
// Wrapping, with a floor under the name block: on a narrow panel the meta
|
|
964
|
+
// cluster (via… / verbs / Remove) drops to its own line rather than
|
|
965
|
+
// squeezing the name to zero width — which left the `Role` badge sitting
|
|
966
|
+
// on top of the "via …" label and pushed Remove off the panel's edge.
|
|
967
|
+
<div key={p.key} className="flex flex-wrap items-center gap-x-3 gap-y-1 py-2">
|
|
968
|
+
{p.isRole ? (
|
|
969
|
+
<span className="flex size-9 shrink-0 items-center justify-center rounded-full bg-sunken text-detail font-bold text-ink-muted">
|
|
970
|
+
{initials(p.label)}
|
|
971
|
+
</span>
|
|
972
|
+
) : (
|
|
745
973
|
<span
|
|
746
|
-
className="
|
|
747
|
-
|
|
974
|
+
className="flex size-9 shrink-0 items-center justify-center rounded-full text-detail font-bold"
|
|
975
|
+
style={{ backgroundColor: tone.bg, color: tone.fg }}
|
|
748
976
|
>
|
|
749
|
-
|
|
977
|
+
{initials(p.label)}
|
|
750
978
|
</span>
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
979
|
+
)}
|
|
980
|
+
<div className="min-w-36 flex-1">
|
|
981
|
+
<div className="flex min-w-0 items-center gap-1.5">
|
|
982
|
+
<span className="truncate text-ui font-medium text-ink">{p.label}</span>
|
|
983
|
+
{p.isYou && <span className="shrink-0 text-ui text-ink-faint">(you)</span>}
|
|
984
|
+
{p.isRole && (
|
|
985
|
+
<Badge tone="outline" size="xs" className="shrink-0 uppercase">
|
|
986
|
+
Role
|
|
987
|
+
</Badge>
|
|
988
|
+
)}
|
|
989
|
+
</div>
|
|
990
|
+
{p.sub && <div className="truncate text-detail text-ink-muted">{p.sub}</div>}
|
|
760
991
|
</div>
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
disabled={busy}
|
|
775
|
-
|
|
776
|
-
|
|
992
|
+
{canManage && p.manage === 'inherited' ? (
|
|
993
|
+
// Inherited from a parent folder — read-only here. Leaf folder name only
|
|
994
|
+
// (full path on hover); Remove opens the "Remove from parent?" flow.
|
|
995
|
+
<div className="ml-auto flex max-w-full shrink-0 items-center gap-2">
|
|
996
|
+
<span
|
|
997
|
+
className="min-w-0 max-w-40 truncate text-detail italic text-ink-faint"
|
|
998
|
+
title={p.ancestors.map(folderPath).join(', ')}
|
|
999
|
+
>
|
|
1000
|
+
via {p.ancestors.map(folderLabel).join(', ')}
|
|
1001
|
+
</span>
|
|
1002
|
+
<span className="whitespace-nowrap text-detail text-ink-faint">
|
|
1003
|
+
{summarizeVerbs(p.verbs)}
|
|
1004
|
+
</span>
|
|
1005
|
+
<Button variant="danger" size="tiny" disabled={busy} onClick={() => doRevoke(p)}>
|
|
1006
|
+
Remove
|
|
1007
|
+
</Button>
|
|
1008
|
+
</div>
|
|
1009
|
+
) : canManage && p.manage === 'external' ? (
|
|
1010
|
+
// No file-backed grant to remove here — managed elsewhere (a group's
|
|
1011
|
+
// membership, the everyone policy, or admin rescue).
|
|
1012
|
+
<span
|
|
1013
|
+
className="ml-auto shrink-0 text-detail text-ink-faint"
|
|
1014
|
+
title="Granted via a role or policy. Manage it there"
|
|
777
1015
|
>
|
|
778
1016
|
{summarizeVerbs(p.verbs)}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
<
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
<
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
1017
|
+
</span>
|
|
1018
|
+
) : canManage ? (
|
|
1019
|
+
<div className="ml-auto shrink-0">
|
|
1020
|
+
<Button
|
|
1021
|
+
variant="quiet"
|
|
1022
|
+
size="sm"
|
|
1023
|
+
disabled={busy}
|
|
1024
|
+
onClick={() => setOpenRowKey((k) => (k === p.key ? null : p.key))}
|
|
1025
|
+
trailingIcon={<ChevronDown size={14} />}
|
|
1026
|
+
>
|
|
1027
|
+
{summarizeVerbs(p.verbs)}
|
|
1028
|
+
</Button>
|
|
1029
|
+
{openRowKey === p.key && (
|
|
1030
|
+
<AnchoredMenu>
|
|
1031
|
+
{TIER_ROLES.map((role) => {
|
|
1032
|
+
const k = ROLE_TO_KEY[role];
|
|
1033
|
+
const checked = p.verbs[k];
|
|
1034
|
+
const disabled =
|
|
1035
|
+
busy ||
|
|
1036
|
+
(role === 'Can edit' && p.verbs.owner) ||
|
|
1037
|
+
(role === 'Can read' && (p.verbs.owner || p.verbs.write));
|
|
1038
|
+
return (
|
|
1039
|
+
<MenuItem
|
|
1040
|
+
key={role}
|
|
1041
|
+
disabled={disabled}
|
|
1042
|
+
active={checked}
|
|
1043
|
+
onClick={() => doToggleVerb(p.principal, role, checked)}
|
|
1044
|
+
trailing={checked ? <Check size={14} className="text-accent" /> : undefined}
|
|
1045
|
+
>
|
|
1046
|
+
{role}
|
|
1047
|
+
</MenuItem>
|
|
1048
|
+
);
|
|
1049
|
+
})}
|
|
1050
|
+
<div className="my-1 border-t border-line" />
|
|
1051
|
+
{(() => {
|
|
1052
|
+
const checked = p.verbs.download;
|
|
1053
|
+
const disabled = busy || p.verbs.owner;
|
|
1054
|
+
return (
|
|
1055
|
+
<MenuItem
|
|
1056
|
+
disabled={disabled}
|
|
1057
|
+
active={checked}
|
|
1058
|
+
onClick={() => doToggleVerb(p.principal, 'Can download', checked)}
|
|
1059
|
+
trailing={checked ? <Check size={14} className="text-accent" /> : undefined}
|
|
1060
|
+
>
|
|
1061
|
+
Can download
|
|
1062
|
+
</MenuItem>
|
|
1063
|
+
);
|
|
1064
|
+
})()}
|
|
1065
|
+
<div className="my-1 border-t border-line" />
|
|
1066
|
+
<MenuItem
|
|
1067
|
+
tone="danger"
|
|
1068
|
+
disabled={busy}
|
|
1069
|
+
onClick={() => {
|
|
1070
|
+
setOpenRowKey(null);
|
|
1071
|
+
doRevoke(p);
|
|
1072
|
+
}}
|
|
1073
|
+
>
|
|
1074
|
+
Remove access
|
|
1075
|
+
</MenuItem>
|
|
1076
|
+
</AnchoredMenu>
|
|
1077
|
+
)}
|
|
1078
|
+
</div>
|
|
1079
|
+
) : (
|
|
1080
|
+
<span className="ml-auto shrink-0 text-detail text-ink-muted">
|
|
1081
|
+
{summarizeVerbs(p.verbs)}
|
|
1082
|
+
</span>
|
|
1083
|
+
)}
|
|
1084
|
+
</div>
|
|
1085
|
+
);
|
|
1086
|
+
};
|
|
843
1087
|
|
|
844
1088
|
return (
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
1089
|
+
<>
|
|
1090
|
+
<Dialog
|
|
1091
|
+
open
|
|
1092
|
+
onClose={onClose}
|
|
1093
|
+
title="Manage access"
|
|
1094
|
+
size="lg"
|
|
1095
|
+
footer={
|
|
1096
|
+
<Button variant="primary" size="sm" onClick={onClose}>
|
|
1097
|
+
Done
|
|
1098
|
+
</Button>
|
|
1099
|
+
}
|
|
856
1100
|
>
|
|
857
|
-
<
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
Manage access
|
|
861
|
-
</h2>
|
|
862
|
-
<div className="mt-0.5 text-sm text-slate-500 truncate" title={entry.relativePath}>
|
|
863
|
-
{entry.name}
|
|
864
|
-
</div>
|
|
865
|
-
</div>
|
|
866
|
-
<button
|
|
867
|
-
type="button"
|
|
868
|
-
onClick={onClose}
|
|
869
|
-
className="p-1.5 rounded hover:bg-slate-100 text-slate-600 hover:text-slate-900 shrink-0"
|
|
870
|
-
aria-label="Close"
|
|
871
|
-
>
|
|
872
|
-
<X size={16} />
|
|
873
|
-
</button>
|
|
874
|
-
</div>
|
|
1101
|
+
<p className="truncate text-detail text-ink-muted" title={entry.relativePath}>
|
|
1102
|
+
{entry.name}
|
|
1103
|
+
</p>
|
|
875
1104
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
>
|
|
896
|
-
<X size={12} />
|
|
897
|
-
</button>
|
|
898
|
-
</span>
|
|
899
|
-
);
|
|
900
|
-
})}
|
|
901
|
-
<input
|
|
902
|
-
value={query}
|
|
903
|
-
onChange={(e) => setQuery(e.target.value)}
|
|
904
|
-
onKeyDown={(e) => {
|
|
905
|
-
if (e.key === 'Enter' && addPending) {
|
|
906
|
-
e.preventDefault();
|
|
907
|
-
addChip(addPending);
|
|
908
|
-
}
|
|
909
|
-
}}
|
|
910
|
-
placeholder={pickedChips.length ? '' : 'Add people or roles…'}
|
|
911
|
-
className="flex-1 min-w-[8rem] px-1 py-1 text-sm focus:outline-none"
|
|
912
|
-
/>
|
|
913
|
-
</div>
|
|
914
|
-
{query.trim() && suggest && (suggest.groups.length > 0 || suggest.people.length > 0) && (
|
|
915
|
-
<div className="absolute z-10 left-0 right-0 mt-1 bg-white border border-slate-200 rounded-lg shadow-lg max-h-56 overflow-auto">
|
|
916
|
-
{suggest.groups.map((g) => (
|
|
1105
|
+
{governed && canManage && (
|
|
1106
|
+
<div className="mt-3">
|
|
1107
|
+
{/* `items-start`, not `items-stretch`: the buttons are `rounded-full`,
|
|
1108
|
+
so stretching them to match the chip box turned Share into a
|
|
1109
|
+
circle the moment a chip wrapped the box onto a second line.
|
|
1110
|
+
`flex-wrap` lets them drop below the box rather than crushing it. */}
|
|
1111
|
+
<div className="relative flex flex-wrap items-start gap-1.5">
|
|
1112
|
+
<div className="relative min-w-48 flex-1">
|
|
1113
|
+
{/* A TextField that grew chips: same border, radius and focus
|
|
1114
|
+
treatment as the primitive, wrapped so the chips can wrap. */}
|
|
1115
|
+
<div className="flex w-full flex-wrap items-center gap-1.5 rounded-md border border-line-strong bg-surface px-2 py-1 focus-within:border-transparent focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-accent">
|
|
1116
|
+
{pickedChips.map((c) => {
|
|
1117
|
+
const label = c.kind === 'role' ? c.role : c.displayName || c.email;
|
|
1118
|
+
return (
|
|
1119
|
+
<span
|
|
1120
|
+
key={principalKey(c)}
|
|
1121
|
+
className="inline-flex items-center gap-1 rounded-sm bg-sunken px-2 py-0.5 text-detail text-ink"
|
|
1122
|
+
>
|
|
1123
|
+
{label}
|
|
917
1124
|
<button
|
|
918
|
-
key={`g:${g}`}
|
|
919
1125
|
type="button"
|
|
920
|
-
onClick={() =>
|
|
921
|
-
className="
|
|
1126
|
+
onClick={() => removeChip(c)}
|
|
1127
|
+
className="rounded-xs text-ink-faint hover:text-danger"
|
|
1128
|
+
aria-label={`Remove ${label}`}
|
|
922
1129
|
>
|
|
923
|
-
<
|
|
924
|
-
{initials(g)}
|
|
925
|
-
</span>
|
|
926
|
-
<span className="flex-1">{g}</span>
|
|
927
|
-
<span className="text-[10px] uppercase tracking-wide text-slate-400">
|
|
928
|
-
role
|
|
929
|
-
</span>
|
|
1130
|
+
<X size={12} />
|
|
930
1131
|
</button>
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1132
|
+
</span>
|
|
1133
|
+
);
|
|
1134
|
+
})}
|
|
1135
|
+
<input
|
|
1136
|
+
value={query}
|
|
1137
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
1138
|
+
onKeyDown={(e) => {
|
|
1139
|
+
if (e.key === 'Enter' && addPending) {
|
|
1140
|
+
e.preventDefault();
|
|
1141
|
+
addChip(addPending);
|
|
1142
|
+
}
|
|
1143
|
+
}}
|
|
1144
|
+
placeholder={pickedChips.length ? '' : 'Add people or roles…'}
|
|
1145
|
+
className="min-w-32 flex-1 bg-transparent px-1 py-1 text-ui text-ink placeholder:text-ink-faint focus:outline-none"
|
|
1146
|
+
/>
|
|
1147
|
+
</div>
|
|
1148
|
+
{query.trim() && suggest && (suggest.groups.length > 0 || suggest.people.length > 0) && (
|
|
1149
|
+
<AnchoredMenu width="anchor" align="left" className="max-h-56 overflow-auto">
|
|
1150
|
+
{suggest.groups.map((g) => (
|
|
1151
|
+
<MenuItem
|
|
1152
|
+
key={`g:${g}`}
|
|
1153
|
+
onClick={() => addChip({ kind: 'role', role: g })}
|
|
1154
|
+
trailing={
|
|
1155
|
+
<span className="text-label uppercase text-ink-faint">role</span>
|
|
1156
|
+
}
|
|
1157
|
+
>
|
|
1158
|
+
<span className="flex size-6 shrink-0 items-center justify-center rounded-full bg-sunken text-label font-bold text-ink-muted">
|
|
1159
|
+
{initials(g)}
|
|
1160
|
+
</span>
|
|
1161
|
+
<span className="min-w-0 flex-1 truncate">{g}</span>
|
|
1162
|
+
</MenuItem>
|
|
1163
|
+
))}
|
|
1164
|
+
{suggest.people.map((p) => {
|
|
1165
|
+
const tone = avatarTone(p.name || p.email);
|
|
1166
|
+
return (
|
|
1167
|
+
<MenuItem
|
|
934
1168
|
key={`p:${p.email}`}
|
|
935
|
-
type="button"
|
|
936
1169
|
onClick={() => addChip({ kind: 'user', email: p.email, displayName: p.name })}
|
|
937
|
-
|
|
1170
|
+
trailing={
|
|
1171
|
+
<span className="max-w-40 truncate text-meta text-ink-faint">
|
|
1172
|
+
{p.email}
|
|
1173
|
+
</span>
|
|
1174
|
+
}
|
|
938
1175
|
>
|
|
939
1176
|
<span
|
|
940
|
-
className="
|
|
941
|
-
style={{
|
|
1177
|
+
className="flex size-6 shrink-0 items-center justify-center rounded-full text-label font-bold"
|
|
1178
|
+
style={{ backgroundColor: tone.bg, color: tone.fg }}
|
|
942
1179
|
>
|
|
943
1180
|
{initials(p.name || p.email)}
|
|
944
1181
|
</span>
|
|
945
|
-
<span className="flex-1 truncate">{p.name || p.email}</span>
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1182
|
+
<span className="min-w-0 flex-1 truncate">{p.name || p.email}</span>
|
|
1183
|
+
</MenuItem>
|
|
1184
|
+
);
|
|
1185
|
+
})}
|
|
1186
|
+
</AnchoredMenu>
|
|
1187
|
+
)}
|
|
1188
|
+
</div>
|
|
1189
|
+
|
|
1190
|
+
<div className="shrink-0">
|
|
1191
|
+
<Button
|
|
1192
|
+
variant="outline"
|
|
1193
|
+
size="sm"
|
|
1194
|
+
className="max-w-44"
|
|
1195
|
+
onClick={() => setVerbOpen((o) => !o)}
|
|
1196
|
+
trailingIcon={<ChevronDown size={14} className="shrink-0" />}
|
|
1197
|
+
>
|
|
1198
|
+
<span className="truncate">{summarizeVerbs(effectiveNewVerbs)}</span>
|
|
1199
|
+
</Button>
|
|
1200
|
+
{verbOpen && (
|
|
1201
|
+
<AnchoredMenu>
|
|
1202
|
+
{TIER_ROLES.map((role) => {
|
|
1203
|
+
const k = ROLE_TO_KEY[role];
|
|
1204
|
+
const checked = effectiveNewVerbs[k];
|
|
1205
|
+
const disabled =
|
|
1206
|
+
(role === 'Can edit' && effectiveNewVerbs.owner) ||
|
|
1207
|
+
(role === 'Can read' && (effectiveNewVerbs.owner || effectiveNewVerbs.write));
|
|
1208
|
+
return (
|
|
1209
|
+
<MenuItem
|
|
1210
|
+
key={role}
|
|
1211
|
+
disabled={disabled}
|
|
1212
|
+
active={checked}
|
|
1213
|
+
aria-pressed={checked}
|
|
1214
|
+
onClick={() => setNewVerbs((v) => ({ ...v, [k]: !v[k] }))}
|
|
1215
|
+
trailing={checked ? <Check size={14} className="text-accent" /> : undefined}
|
|
1216
|
+
>
|
|
1217
|
+
{role}
|
|
1218
|
+
</MenuItem>
|
|
1219
|
+
);
|
|
1220
|
+
})}
|
|
1221
|
+
<div className="my-1 border-t border-line" />
|
|
1222
|
+
<MenuItem
|
|
1223
|
+
disabled={effectiveNewVerbs.owner}
|
|
1224
|
+
active={effectiveNewVerbs.download}
|
|
1225
|
+
aria-pressed={effectiveNewVerbs.download}
|
|
1226
|
+
onClick={() => setNewVerbs((v) => ({ ...v, download: !v.download }))}
|
|
1227
|
+
trailing={
|
|
1228
|
+
effectiveNewVerbs.download ? (
|
|
1229
|
+
<Check size={14} className="text-accent" />
|
|
1230
|
+
) : undefined
|
|
1231
|
+
}
|
|
1232
|
+
>
|
|
1233
|
+
Can download
|
|
1234
|
+
</MenuItem>
|
|
1235
|
+
</AnchoredMenu>
|
|
1236
|
+
)}
|
|
1237
|
+
</div>
|
|
1238
|
+
|
|
1239
|
+
<Button
|
|
1240
|
+
variant="primary"
|
|
1241
|
+
size="sm"
|
|
1242
|
+
className="shrink-0"
|
|
1243
|
+
disabled={pickedChips.length === 0 || grantVerbs.length === 0 || busy}
|
|
1244
|
+
onClick={doGrant}
|
|
1245
|
+
leadingIcon={busy ? <Loader2 size={14} className="animate-spin" /> : undefined}
|
|
1246
|
+
>
|
|
1247
|
+
Share
|
|
1248
|
+
</Button>
|
|
1249
|
+
</div>
|
|
1250
|
+
{query.trim() && !addPending && !suggest?.peopleWithheld && (
|
|
1251
|
+
<p className="mt-1.5 text-detail text-ink-muted">
|
|
1252
|
+
Type a full email to add someone, or pick a role from the list.
|
|
1253
|
+
</p>
|
|
1254
|
+
)}
|
|
1255
|
+
{pickedChips.some(isEveryoneRole) && (
|
|
1256
|
+
<p className="mt-1.5 text-detail text-ink-muted">
|
|
1257
|
+
“Everyone” makes this {targetKind} publicly readable: it can only be granted read access.
|
|
1258
|
+
</p>
|
|
1259
|
+
)}
|
|
1260
|
+
{mutateError && (
|
|
1261
|
+
<Banner tone="danger" role="alert" className="mt-2 whitespace-pre-line">
|
|
1262
|
+
{mutateError}
|
|
1263
|
+
</Banner>
|
|
1264
|
+
)}
|
|
1265
|
+
</div>
|
|
1266
|
+
)}
|
|
952
1267
|
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1268
|
+
{!governed ? (
|
|
1269
|
+
<p className="py-8 text-center text-ui text-ink-muted">
|
|
1270
|
+
This item isn't part of the knowledge base, so it isn't governed by access control.
|
|
1271
|
+
</p>
|
|
1272
|
+
) : loading ? (
|
|
1273
|
+
<p className="flex items-center justify-center gap-2 py-8 text-ui text-ink-muted">
|
|
1274
|
+
<Loader2 size={16} className="animate-spin" /> Loading access…
|
|
1275
|
+
</p>
|
|
1276
|
+
) : error ? (
|
|
1277
|
+
<Banner tone="danger" role="alert" className="my-3">
|
|
1278
|
+
Couldn't load access: {error}
|
|
1279
|
+
</Banner>
|
|
1280
|
+
) : (
|
|
1281
|
+
<>
|
|
1282
|
+
{!canManage && (
|
|
1283
|
+
<Banner tone="neutral" role="note" className="mt-3">
|
|
1284
|
+
Only people with edit access can share this {targetKind}.
|
|
1285
|
+
{ownerNames && <> Ask an owner: {ownerNames}.</>}
|
|
1286
|
+
</Banner>
|
|
1287
|
+
)}
|
|
1288
|
+
|
|
1289
|
+
{/* Names WHICH RULE you are editing, and adapts to the target
|
|
1290
|
+
(proto:3625: `On this ` + file|folder). The sheet mixes rules
|
|
1291
|
+
set HERE with rules inherited from above, so a heading that
|
|
1292
|
+
says only "People with access" leaves the reader to work out
|
|
1293
|
+
which of the two lists below is which. The count rides it, as
|
|
1294
|
+
on every band in the app. */}
|
|
1295
|
+
<h3 className="mb-1 mt-4 flex items-baseline gap-2 text-label uppercase text-ink-faint">
|
|
1296
|
+
On this {targetKind}
|
|
1297
|
+
{directRows.length > 0 && (
|
|
1298
|
+
<span className="text-meta normal-case tabular-nums">{directRows.length}</span>
|
|
1299
|
+
)}
|
|
1300
|
+
</h3>
|
|
1301
|
+
|
|
1302
|
+
{data && !data.readers.restricted && (
|
|
1303
|
+
<div className="flex items-center gap-3 py-1.5">
|
|
1304
|
+
<span className="flex size-8 shrink-0 items-center justify-center rounded-full bg-ok-soft text-ok">
|
|
1305
|
+
<Globe size={16} />
|
|
1306
|
+
</span>
|
|
1307
|
+
<div className="min-w-0 flex-1">
|
|
1308
|
+
<div className="text-ui text-ink">Anyone can read</div>
|
|
1309
|
+
<div className="text-detail text-ink-muted">
|
|
1310
|
+
Public: every signed-in user can read this {targetKind}
|
|
1311
|
+
</div>
|
|
1312
|
+
</div>
|
|
1313
|
+
{canManage && (
|
|
1314
|
+
<Button
|
|
1315
|
+
variant="danger"
|
|
1316
|
+
size="tiny"
|
|
1317
|
+
className="shrink-0"
|
|
1318
|
+
disabled={busy}
|
|
1319
|
+
onClick={removePublicRead}
|
|
958
1320
|
>
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
</span>
|
|
982
|
-
<span className="flex-1 text-left">{role}</span>
|
|
983
|
-
</button>
|
|
984
|
-
);
|
|
985
|
-
})}
|
|
986
|
-
<div className="border-t border-slate-100 my-1" />
|
|
1321
|
+
Remove
|
|
1322
|
+
</Button>
|
|
1323
|
+
)}
|
|
1324
|
+
</div>
|
|
1325
|
+
)}
|
|
1326
|
+
|
|
1327
|
+
{directRows.length === 0 ? (
|
|
1328
|
+
<p className="py-2 text-ui text-ink-muted">
|
|
1329
|
+
{inheritedRows.length > 0
|
|
1330
|
+
? 'No one is granted directly here. Everyone below inherits access from a parent folder.'
|
|
1331
|
+
: 'No explicit grants at this path.'}
|
|
1332
|
+
</p>
|
|
1333
|
+
) : (
|
|
1334
|
+
directRows.map(renderRow)
|
|
1335
|
+
)}
|
|
1336
|
+
|
|
1337
|
+
{inheritedRows.length > 0 && (
|
|
1338
|
+
<div className="mt-3 border-t border-line pt-2">
|
|
1339
|
+
{inheritedByFolder.folders.map(([ancestor, rows]) => {
|
|
1340
|
+
const open = openGroup === ancestor;
|
|
1341
|
+
return (
|
|
1342
|
+
<div key={ancestor}>
|
|
987
1343
|
<button
|
|
988
1344
|
type="button"
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
onClick={() =>
|
|
992
|
-
className="w-full
|
|
1345
|
+
aria-expanded={open}
|
|
1346
|
+
title={folderPath(ancestor)}
|
|
1347
|
+
onClick={() => setOpenGroup(open ? null : ancestor)}
|
|
1348
|
+
className="flex w-full items-center gap-1.5 rounded-xs py-1 text-detail text-ink-muted hover:text-ink"
|
|
993
1349
|
>
|
|
994
|
-
<
|
|
995
|
-
|
|
1350
|
+
<ChevronDown
|
|
1351
|
+
size={14}
|
|
1352
|
+
className={`shrink-0 transition-transform ${open ? 'rotate-180' : '-rotate-90'}`}
|
|
1353
|
+
/>
|
|
1354
|
+
<span className="min-w-0 truncate">
|
|
1355
|
+
People invited to <b className="font-semibold">{folderLabel(ancestor)}</b>
|
|
1356
|
+
</span>
|
|
1357
|
+
<span className="ml-auto shrink-0 tabular-nums text-ink-faint">
|
|
1358
|
+
{rows.length}
|
|
996
1359
|
</span>
|
|
997
|
-
<span className="flex-1 text-left">Can download</span>
|
|
998
1360
|
</button>
|
|
1361
|
+
{open && (
|
|
1362
|
+
<div className="mb-1">
|
|
1363
|
+
{rows.map(renderRow)}
|
|
1364
|
+
{/* The folder is both what the heading means and
|
|
1365
|
+
where it changes (proto:3647). Without this the
|
|
1366
|
+
only act available on an inherited grant is the
|
|
1367
|
+
destructive one behind Remove. */}
|
|
1368
|
+
{onManageAncestor && kbDirName && (
|
|
1369
|
+
<Button
|
|
1370
|
+
variant="quiet"
|
|
1371
|
+
size="tiny"
|
|
1372
|
+
className="mt-0.5"
|
|
1373
|
+
onClick={() => {
|
|
1374
|
+
const dir = ancestor.replace(/\/?access\.md$/, '');
|
|
1375
|
+
onManageAncestor({
|
|
1376
|
+
// The same name the button just said. A
|
|
1377
|
+
// root-level `access.md` leaves `dir` empty,
|
|
1378
|
+
// and `''.split('/').pop()` is `''` — a
|
|
1379
|
+
// dialog with no title.
|
|
1380
|
+
name: folderLabel(ancestor),
|
|
1381
|
+
relativePath: `${kbDirName}/${dir}`,
|
|
1382
|
+
type: 'directory',
|
|
1383
|
+
});
|
|
1384
|
+
}}
|
|
1385
|
+
>
|
|
1386
|
+
{`Manage ${folderLabel(ancestor)} →`}
|
|
1387
|
+
</Button>
|
|
1388
|
+
)}
|
|
1389
|
+
</div>
|
|
1390
|
+
)}
|
|
999
1391
|
</div>
|
|
1000
|
-
)
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
<button
|
|
1004
|
-
type="button"
|
|
1005
|
-
disabled={pickedChips.length === 0 || grantVerbs.length === 0 || busy}
|
|
1006
|
-
onClick={doGrant}
|
|
1007
|
-
className="px-4 rounded-lg text-sm font-medium bg-bevel hover:bg-bevel-deep text-white disabled:bg-bevel/40 disabled:cursor-not-allowed flex items-center gap-1.5"
|
|
1008
|
-
>
|
|
1009
|
-
{busy && <Loader2 size={14} className="animate-spin" />}
|
|
1010
|
-
Share
|
|
1011
|
-
</button>
|
|
1012
|
-
</div>
|
|
1013
|
-
{query.trim() && !addPending && !suggest?.peopleWithheld && (
|
|
1014
|
-
<div className="mt-1.5 text-xs text-slate-500">
|
|
1015
|
-
Type a full email to add someone, or pick a role from the list.
|
|
1016
|
-
</div>
|
|
1017
|
-
)}
|
|
1018
|
-
{pickedChips.some(isEveryoneRole) && (
|
|
1019
|
-
<div className="mt-1.5 text-xs text-slate-500">
|
|
1020
|
-
“Everyone” makes this {targetKind} publicly readable — it can only be granted read access.
|
|
1021
|
-
</div>
|
|
1022
|
-
)}
|
|
1023
|
-
{mutateError && (
|
|
1024
|
-
<div className="mt-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2">
|
|
1025
|
-
{mutateError}
|
|
1026
|
-
</div>
|
|
1027
|
-
)}
|
|
1028
|
-
</div>
|
|
1029
|
-
)}
|
|
1030
|
-
|
|
1031
|
-
{!governed ? (
|
|
1032
|
-
<div className="py-8 text-center text-sm text-slate-500">
|
|
1033
|
-
This item isn't part of the knowledge base, so it isn't governed by access control.
|
|
1034
|
-
</div>
|
|
1035
|
-
) : loading ? (
|
|
1036
|
-
<div className="flex items-center gap-2 py-8 justify-center text-sm text-slate-500">
|
|
1037
|
-
<Loader2 size={16} className="animate-spin" /> Loading access…
|
|
1038
|
-
</div>
|
|
1039
|
-
) : error ? (
|
|
1040
|
-
<div className="py-6 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3">
|
|
1041
|
-
Couldn't load access: {error}
|
|
1042
|
-
</div>
|
|
1043
|
-
) : (
|
|
1044
|
-
<>
|
|
1045
|
-
{!canManage && (
|
|
1046
|
-
<div className="flex items-center gap-3 bg-bevel-soft rounded-lg px-3 py-2.5 mb-3 text-sm text-bevel-deep">
|
|
1047
|
-
<span className="flex-1">
|
|
1048
|
-
Only people with edit access can share this {targetKind}.
|
|
1049
|
-
{ownerNames && <> Ask an owner: {ownerNames}.</>}
|
|
1050
|
-
</span>
|
|
1051
|
-
</div>
|
|
1052
|
-
)}
|
|
1053
|
-
|
|
1054
|
-
<div className="text-sm font-bold text-slate-700 my-2">People with access</div>
|
|
1392
|
+
);
|
|
1393
|
+
})}
|
|
1055
1394
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
<div className="flex-1 min-w-0">
|
|
1062
|
-
<div className="text-sm text-slate-800">Anyone can read</div>
|
|
1063
|
-
<div className="text-xs text-slate-500">Public — every signed-in user can read this {targetKind}</div>
|
|
1064
|
-
</div>
|
|
1065
|
-
{canManage && (
|
|
1395
|
+
{/* A role that grants at the workspace level belongs to no
|
|
1396
|
+
folder, so it cannot be filed under one. Named for what it
|
|
1397
|
+
is rather than swept into the folder groups. */}
|
|
1398
|
+
{inheritedByFolder.external.length > 0 && (
|
|
1399
|
+
<div>
|
|
1066
1400
|
<button
|
|
1067
1401
|
type="button"
|
|
1068
|
-
|
|
1069
|
-
onClick={
|
|
1070
|
-
className="
|
|
1402
|
+
aria-expanded={openGroup === 'roles'}
|
|
1403
|
+
onClick={() => setOpenGroup(openGroup === 'roles' ? null : 'roles')}
|
|
1404
|
+
className="flex w-full items-center gap-1.5 rounded-xs py-1 text-detail text-ink-muted hover:text-ink"
|
|
1071
1405
|
>
|
|
1072
|
-
|
|
1406
|
+
<ChevronDown
|
|
1407
|
+
size={14}
|
|
1408
|
+
className={`shrink-0 transition-transform ${openGroup === 'roles' ? 'rotate-180' : '-rotate-90'}`}
|
|
1409
|
+
/>
|
|
1410
|
+
<span className="min-w-0 truncate">People with access through a role</span>
|
|
1411
|
+
<span className="ml-auto shrink-0 tabular-nums text-ink-faint">
|
|
1412
|
+
{inheritedByFolder.external.length}
|
|
1413
|
+
</span>
|
|
1073
1414
|
</button>
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
{directRows.length === 0 ? (
|
|
1079
|
-
<div className="text-sm text-slate-500 py-2">
|
|
1080
|
-
{inheritedRows.length > 0
|
|
1081
|
-
? 'No one is granted directly here — everyone below inherits access from a parent folder.'
|
|
1082
|
-
: 'No explicit grants at this path.'}
|
|
1083
|
-
</div>
|
|
1084
|
-
) : (
|
|
1085
|
-
directRows.map(renderRow)
|
|
1086
|
-
)}
|
|
1087
|
-
|
|
1088
|
-
{inheritedRows.length > 0 && (
|
|
1089
|
-
<div className="mt-3 border-t border-slate-100 pt-2">
|
|
1090
|
-
<button
|
|
1091
|
-
type="button"
|
|
1092
|
-
onClick={() => setShowInherited((v) => !v)}
|
|
1093
|
-
className="w-full flex items-center gap-1.5 py-1 text-sm font-medium text-slate-500 hover:text-slate-700"
|
|
1094
|
-
>
|
|
1095
|
-
<ChevronDown
|
|
1096
|
-
size={14}
|
|
1097
|
-
className={`transition-transform ${showInherited ? 'rotate-180' : ''}`}
|
|
1098
|
-
/>
|
|
1099
|
-
Inherited access ({inheritedRows.length})
|
|
1100
|
-
<span className="font-normal text-slate-400">
|
|
1101
|
-
— from parent folders & roles
|
|
1102
|
-
</span>
|
|
1103
|
-
</button>
|
|
1104
|
-
{showInherited && <div className="mt-1">{inheritedRows.map(renderRow)}</div>}
|
|
1105
|
-
</div>
|
|
1106
|
-
)}
|
|
1107
|
-
|
|
1108
|
-
<div className="flex items-center gap-3 border-t border-slate-100 mt-4 pt-4">
|
|
1109
|
-
<div className="w-9 h-9 rounded-full bg-slate-100 text-slate-600 flex items-center justify-center shrink-0">
|
|
1110
|
-
<Lock size={16} />
|
|
1111
|
-
</div>
|
|
1112
|
-
<div className="flex-1">
|
|
1113
|
-
<div className="text-sm font-semibold text-slate-800">Restricted</div>
|
|
1114
|
-
<div className="text-xs text-slate-500">
|
|
1115
|
-
Only people granted access can edit this item.
|
|
1415
|
+
{openGroup === 'roles' && (
|
|
1416
|
+
<div className="mb-1">{inheritedByFolder.external.map(renderRow)}</div>
|
|
1417
|
+
)}
|
|
1116
1418
|
</div>
|
|
1117
|
-
|
|
1419
|
+
)}
|
|
1118
1420
|
</div>
|
|
1119
|
-
|
|
1120
|
-
)}
|
|
1121
|
-
</div>
|
|
1421
|
+
)}
|
|
1122
1422
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1423
|
+
<div className="mt-4 flex items-center gap-3 border-t border-line pt-4">
|
|
1424
|
+
<span className="flex size-9 shrink-0 items-center justify-center rounded-full bg-sunken text-ink-muted">
|
|
1425
|
+
<Lock size={16} />
|
|
1426
|
+
</span>
|
|
1427
|
+
<div className="flex-1">
|
|
1428
|
+
<div className="text-ui font-semibold text-ink">Restricted</div>
|
|
1429
|
+
<div className="text-detail text-ink-muted">
|
|
1430
|
+
Only people granted access can edit this item.
|
|
1431
|
+
</div>
|
|
1432
|
+
</div>
|
|
1433
|
+
</div>
|
|
1434
|
+
</>
|
|
1435
|
+
)}
|
|
1436
|
+
</Dialog>
|
|
1133
1437
|
|
|
1134
1438
|
{confirmRemove && (
|
|
1135
|
-
<
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1439
|
+
<Dialog
|
|
1440
|
+
open
|
|
1441
|
+
busy={busy}
|
|
1442
|
+
onClose={() => setConfirmRemove(null)}
|
|
1443
|
+
size="md"
|
|
1444
|
+
title={
|
|
1445
|
+
confirmRemove.ancestors.length ? 'Remove from parent folder?' : 'Restrict access here?'
|
|
1446
|
+
}
|
|
1140
1447
|
>
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
{confirmRemove.
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
</>
|
|
1172
|
-
);
|
|
1173
|
-
})()}
|
|
1448
|
+
{(() => {
|
|
1449
|
+
// When the flow was triggered by unchecking ONE verb, the whole
|
|
1450
|
+
// confirmation is scoped to it ("their EDIT access", "remove EDIT
|
|
1451
|
+
// from the parent"); otherwise it's the whole principal.
|
|
1452
|
+
const va = confirmRemove.verb ? `${VERB_NOUN[confirmRemove.verb]} access` : 'access';
|
|
1453
|
+
return (
|
|
1454
|
+
<p className="text-ui leading-relaxed text-ink-muted">
|
|
1455
|
+
{confirmRemove.ancestors.length ? (
|
|
1456
|
+
<>
|
|
1457
|
+
{confirmRemove.label}'s {va} here is inherited from{' '}
|
|
1458
|
+
<span
|
|
1459
|
+
className="font-medium text-ink"
|
|
1460
|
+
title={confirmRemove.ancestors.map(folderPath).join(', ')}
|
|
1461
|
+
>
|
|
1462
|
+
{confirmRemove.ancestors.map(folderLabel).join(', ')}
|
|
1463
|
+
</span>
|
|
1464
|
+
. Remove their {va} from the parent: which also removes it from other items in
|
|
1465
|
+
that folder: or restrict just this {targetKind} while leaving the parent grant
|
|
1466
|
+
intact.
|
|
1467
|
+
</>
|
|
1468
|
+
) : (
|
|
1469
|
+
<>
|
|
1470
|
+
{confirmRemove.label}'s {va} here comes from a role or policy, not a grant on
|
|
1471
|
+
this {targetKind}. You can't remove it here. But you can restrict their {va} on
|
|
1472
|
+
just this {targetKind} by adding a block.
|
|
1473
|
+
</>
|
|
1474
|
+
)}
|
|
1475
|
+
</p>
|
|
1476
|
+
);
|
|
1477
|
+
})()}
|
|
1174
1478
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1479
|
+
{mutateError && (
|
|
1480
|
+
<Banner tone="danger" role="alert" className="mt-3 whitespace-pre-line">
|
|
1481
|
+
{mutateError}
|
|
1482
|
+
</Banner>
|
|
1483
|
+
)}
|
|
1180
1484
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
onClick={() => doRemoveFromParent(confirmRemove.principal, confirmRemove.ancestors[0], confirmRemove.verb)}
|
|
1187
|
-
className="w-full px-4 py-2.5 rounded-lg text-sm font-medium bg-bevel hover:bg-bevel-deep text-white disabled:bg-bevel/40 disabled:cursor-not-allowed"
|
|
1188
|
-
>
|
|
1189
|
-
Remove from {folderLabel(confirmRemove.ancestors[0])}
|
|
1190
|
-
</button>
|
|
1191
|
-
)}
|
|
1192
|
-
{confirmRemove.ancestors.length > 1 && (
|
|
1193
|
-
<>
|
|
1194
|
-
<div className="text-xs text-slate-500">
|
|
1195
|
-
Inherited from multiple folders — remove from one at a time:
|
|
1196
|
-
</div>
|
|
1197
|
-
{confirmRemove.ancestors.map((a) => (
|
|
1198
|
-
<button
|
|
1199
|
-
key={a}
|
|
1200
|
-
type="button"
|
|
1201
|
-
disabled={busy}
|
|
1202
|
-
onClick={() => doRemoveFromParent(confirmRemove.principal, a, confirmRemove.verb)}
|
|
1203
|
-
className="w-full px-4 py-2.5 rounded-lg text-sm font-medium bg-bevel hover:bg-bevel-deep text-white disabled:bg-bevel/40 disabled:cursor-not-allowed"
|
|
1204
|
-
>
|
|
1205
|
-
Remove from {folderLabel(a)}
|
|
1206
|
-
</button>
|
|
1207
|
-
))}
|
|
1208
|
-
</>
|
|
1209
|
-
)}
|
|
1210
|
-
<button
|
|
1211
|
-
type="button"
|
|
1212
|
-
disabled={busy}
|
|
1213
|
-
onClick={() => doDenyHere(confirmRemove.principal, confirmRemove.verb)}
|
|
1214
|
-
className="w-full px-4 py-2.5 rounded-lg text-sm font-medium border border-slate-300 text-slate-700 hover:bg-slate-50 disabled:cursor-not-allowed"
|
|
1215
|
-
>
|
|
1216
|
-
Restrict just this {targetKind}
|
|
1217
|
-
</button>
|
|
1218
|
-
<button
|
|
1219
|
-
type="button"
|
|
1485
|
+
<div className="mt-4 flex flex-col gap-2">
|
|
1486
|
+
{confirmRemove.ancestors.length === 1 && (
|
|
1487
|
+
<Button
|
|
1488
|
+
variant="primary"
|
|
1489
|
+
className="w-full"
|
|
1220
1490
|
disabled={busy}
|
|
1221
|
-
onClick={() =>
|
|
1222
|
-
|
|
1491
|
+
onClick={() =>
|
|
1492
|
+
doRemoveFromParent(confirmRemove.principal, confirmRemove.ancestors[0], confirmRemove.verb)
|
|
1493
|
+
}
|
|
1223
1494
|
>
|
|
1224
|
-
|
|
1225
|
-
</
|
|
1226
|
-
|
|
1495
|
+
Remove from {folderLabel(confirmRemove.ancestors[0])}
|
|
1496
|
+
</Button>
|
|
1497
|
+
)}
|
|
1498
|
+
{confirmRemove.ancestors.length > 1 && (
|
|
1499
|
+
<>
|
|
1500
|
+
<p className="text-detail text-ink-muted">
|
|
1501
|
+
Inherited from multiple folders. Remove from one at a time:
|
|
1502
|
+
</p>
|
|
1503
|
+
{confirmRemove.ancestors.map((a) => (
|
|
1504
|
+
<Button
|
|
1505
|
+
key={a}
|
|
1506
|
+
variant="primary"
|
|
1507
|
+
className="w-full"
|
|
1508
|
+
disabled={busy}
|
|
1509
|
+
onClick={() => doRemoveFromParent(confirmRemove.principal, a, confirmRemove.verb)}
|
|
1510
|
+
>
|
|
1511
|
+
Remove from {folderLabel(a)}
|
|
1512
|
+
</Button>
|
|
1513
|
+
))}
|
|
1514
|
+
</>
|
|
1515
|
+
)}
|
|
1516
|
+
<Button
|
|
1517
|
+
variant="outline"
|
|
1518
|
+
className="w-full"
|
|
1519
|
+
disabled={busy}
|
|
1520
|
+
onClick={() => doDenyHere(confirmRemove.principal, confirmRemove.verb)}
|
|
1521
|
+
>
|
|
1522
|
+
Restrict just this {targetKind}
|
|
1523
|
+
</Button>
|
|
1524
|
+
<Button
|
|
1525
|
+
variant="quiet"
|
|
1526
|
+
className="w-full"
|
|
1527
|
+
disabled={busy}
|
|
1528
|
+
onClick={() => setConfirmRemove(null)}
|
|
1529
|
+
>
|
|
1530
|
+
Cancel
|
|
1531
|
+
</Button>
|
|
1227
1532
|
</div>
|
|
1228
|
-
</
|
|
1533
|
+
</Dialog>
|
|
1229
1534
|
)}
|
|
1230
|
-
|
|
1535
|
+
</>
|
|
1231
1536
|
);
|
|
1232
1537
|
}
|