@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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
|
+
import { cn } from '../../../lib/utils';
|
|
3
|
+
import {
|
|
4
|
+
DOCUMENT_COLUMN,
|
|
5
|
+
DOCUMENT_COLUMN_WIDE,
|
|
6
|
+
documentGutters,
|
|
7
|
+
} from '../../../shared/theme/measure';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The Knowledge surface's document column — the prototype's `.wrap.kb`.
|
|
11
|
+
*
|
|
12
|
+
* It holds the measure, the gutters, and the single explicit answer to "who
|
|
13
|
+
* scrolls". Before this existed, the viewer pane was `overflow-hidden` and
|
|
14
|
+
* every renderer owned its own scroller, so a 2000px-wide window gave a
|
|
15
|
+
* markdown document a 2000px line. The measure fixes that — but only for the
|
|
16
|
+
* renderers that produce a document; see `variant`.
|
|
17
|
+
*
|
|
18
|
+
* The tab strip mounts INSIDE it, not above it. That is the prototype's own
|
|
19
|
+
* rule (proto:700-705): one column holds tabs, title and text at the same
|
|
20
|
+
* width, so they share an edge and the page reads as a single centred block.
|
|
21
|
+
*/
|
|
22
|
+
export interface KbDocumentShellProps {
|
|
23
|
+
/** Widens the column and opens the second track for the rail. */
|
|
24
|
+
rail?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* 'prose' — the shell scrolls, holds the 880/980 measure and the gutters.
|
|
27
|
+
* For renderers that produce a document: markdown, text, docx,
|
|
28
|
+
* the HTML source view.
|
|
29
|
+
* 'full-bleed' — the shell yields: no measure, no bottom rhythm, and it gives
|
|
30
|
+
* its child a DEFINITE height instead of scrolling it. For
|
|
31
|
+
* renderers that are already a fixed-height viewport of their
|
|
32
|
+
* own: pdf (an `h-full` iframe that collapses to 0 in an
|
|
33
|
+
* auto-height column), image, csv, xlsx, the html sandbox
|
|
34
|
+
* iframe, and the tool form (whose `w-72` aside does not fit
|
|
35
|
+
* inside 880px minus gutters).
|
|
36
|
+
*
|
|
37
|
+
* The caller picks from the extension, via `getRendererLayout` in
|
|
38
|
+
* `renderers/index.ts` — the same map `getFileRenderer` uses. Getting this
|
|
39
|
+
* wrong does not type-error; it renders a zero-height PDF.
|
|
40
|
+
*/
|
|
41
|
+
variant?: 'prose' | 'full-bleed';
|
|
42
|
+
/**
|
|
43
|
+
* The file tree beside this column is hidden, so the space it gave up should
|
|
44
|
+
* become margin on both sides rather than more line length (proto:709). The
|
|
45
|
+
* caller owns this because only it knows: the pane controller, not a global
|
|
46
|
+
* flag. Defaults to false — the nav is usually there.
|
|
47
|
+
*/
|
|
48
|
+
roomy?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Lands on the element that ACTUALLY scrolls. `FileViewer` passes
|
|
51
|
+
* `editorContainerRef` here: a capture-phase scroll listener is bound to it
|
|
52
|
+
* and is the only thing resetting the file lock's idle-release timer for a
|
|
53
|
+
* user who is reading rather than typing. Scroll events do not bubble, so a
|
|
54
|
+
* ref on an element nested *inside* the scroller never fires — which is why
|
|
55
|
+
* the ref lands on this component's outermost box in BOTH variants, and why
|
|
56
|
+
* that box carries `overflow-auto` in both. In `full-bleed` the child is
|
|
57
|
+
* exactly `h-full`, so nothing overflows and no scrollbar appears; the
|
|
58
|
+
* listener still catches the renderer's own scroller during capture.
|
|
59
|
+
*/
|
|
60
|
+
scrollRef?: Ref<HTMLDivElement>;
|
|
61
|
+
/**
|
|
62
|
+
* The id of the heading that names `rail`, for the `<aside>`'s
|
|
63
|
+
* `aria-labelledby`. The shell cannot read a name out of a `ReactNode`, and
|
|
64
|
+
* an unnamed complementary landmark is one a screen reader can only announce
|
|
65
|
+
* as "complementary" — so the rail names itself and hands the id over.
|
|
66
|
+
*/
|
|
67
|
+
railLabelledBy?: string;
|
|
68
|
+
children: ReactNode;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function KbDocumentShell({
|
|
72
|
+
rail,
|
|
73
|
+
variant = 'prose',
|
|
74
|
+
roomy = false,
|
|
75
|
+
scrollRef,
|
|
76
|
+
railLabelledBy,
|
|
77
|
+
children,
|
|
78
|
+
}: KbDocumentShellProps) {
|
|
79
|
+
return (
|
|
80
|
+
<div
|
|
81
|
+
ref={scrollRef}
|
|
82
|
+
data-testid="kb-document-shell"
|
|
83
|
+
data-variant={variant}
|
|
84
|
+
className={cn(
|
|
85
|
+
'relative min-h-0 flex-1 overflow-auto',
|
|
86
|
+
variant === 'full-bleed' && 'flex flex-col',
|
|
87
|
+
)}
|
|
88
|
+
>
|
|
89
|
+
{variant === 'full-bleed' ? (
|
|
90
|
+
// A definite height, not a scroll. `h-full` resolves against this
|
|
91
|
+
// component's own (flex-sized, definite) height, so an `h-full` iframe
|
|
92
|
+
// inside gets real pixels instead of collapsing to zero.
|
|
93
|
+
//
|
|
94
|
+
// The rail still opens here — the facts it carries (where the file is,
|
|
95
|
+
// who last touched it, who can read it) are as true of a PDF as of a
|
|
96
|
+
// paragraph. It takes a fixed column beside the viewport rather than
|
|
97
|
+
// widening a measure there is none of, and scrolls on its own so a
|
|
98
|
+
// long link list cannot stretch the iframe.
|
|
99
|
+
<div className="flex h-full min-h-0 w-full">
|
|
100
|
+
<div className="flex h-full min-h-0 min-w-0 flex-1 flex-col">{children}</div>
|
|
101
|
+
{rail && (
|
|
102
|
+
<aside
|
|
103
|
+
aria-labelledby={railLabelledBy}
|
|
104
|
+
className="w-[296px] flex-none overflow-y-auto py-4 pr-4"
|
|
105
|
+
>
|
|
106
|
+
{rail}
|
|
107
|
+
</aside>
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
) : rail ? (
|
|
111
|
+
// The wide measure: `minmax(0,620px)` + a 296px rail with a 44px gap
|
|
112
|
+
// (proto:344). The article track is minmax-from-zero so the rail never
|
|
113
|
+
// pushes the column into a horizontal scroll — at 980px minus gutters
|
|
114
|
+
// the article simply takes what is left. Under 900px the rail stacks
|
|
115
|
+
// below the article rather than beside it (proto:633).
|
|
116
|
+
<div
|
|
117
|
+
className={cn(
|
|
118
|
+
DOCUMENT_COLUMN_WIDE,
|
|
119
|
+
documentGutters(roomy),
|
|
120
|
+
'grid grid-cols-1 items-start gap-11 pt-3',
|
|
121
|
+
'max-[900px]:gap-[26px] min-[901px]:grid-cols-[minmax(0,620px)_296px]',
|
|
122
|
+
)}
|
|
123
|
+
>
|
|
124
|
+
<article className="min-w-0">{children}</article>
|
|
125
|
+
<aside aria-labelledby={railLabelledBy} className="min-w-0">
|
|
126
|
+
{rail}
|
|
127
|
+
</aside>
|
|
128
|
+
</div>
|
|
129
|
+
) : (
|
|
130
|
+
// `pt-3` is 12px — Knowledge's own top padding, NOT the app-wide 34px.
|
|
131
|
+
// The top bar already separates the column from the window, so the
|
|
132
|
+
// page's own padding only has to keep the tabs off the bar
|
|
133
|
+
// (`.wrap.kb`, proto:695-699). Do not "fix" this to 34px.
|
|
134
|
+
<div className={cn(DOCUMENT_COLUMN, documentGutters(roomy), 'pt-3')}>{children}</div>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Link2 } from 'lucide-react';
|
|
2
|
+
import type { AccessEligible } from '../../access/api';
|
|
3
|
+
import { Badge } from '../../../shared/components';
|
|
4
|
+
import type { LinkOut } from '../hooks/useLinksOut';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* "About this file" — the facts the client can PROVE about the open document
|
|
8
|
+
* (proto:3859-3875).
|
|
9
|
+
*
|
|
10
|
+
* Every row here is derived from something already on the wire; nothing is
|
|
11
|
+
* fetched to fill a slot, and no row renders when it cannot be filled. That is
|
|
12
|
+
* the rule the rail lives by: a metadata panel that shows "—" for half its
|
|
13
|
+
* rows teaches people to stop reading it.
|
|
14
|
+
*/
|
|
15
|
+
export interface KbFileRailProps {
|
|
16
|
+
path: string;
|
|
17
|
+
/**
|
|
18
|
+
* UTF-16 code units of the loaded text, or null when unknowable (binary, or
|
|
19
|
+
* not yet loaded). NOT bytes — see the row's own note for why it is labelled
|
|
20
|
+
* "Characters" rather than "Size".
|
|
21
|
+
*/
|
|
22
|
+
charCount: number | null;
|
|
23
|
+
lastCommit: { author: string; relative: string } | null;
|
|
24
|
+
/* Spelled out rather than `ReturnType<typeof useFileAccess>`: importing a
|
|
25
|
+
hook into a props type couples the rail to the hook's whole shape, and
|
|
26
|
+
three of that shape's five fields are nothing to do with the rail. */
|
|
27
|
+
owners: AccessEligible;
|
|
28
|
+
/** Derived from the content; may be empty, which renders as no section. */
|
|
29
|
+
linksOut: LinkOut[];
|
|
30
|
+
onOpen(target: string): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function Row({ label, children }: { label: string; children: React.ReactNode }) {
|
|
34
|
+
return (
|
|
35
|
+
<div className="flex gap-3 py-1.5">
|
|
36
|
+
<span className="w-20 flex-none text-meta text-ink-faint">{label}</span>
|
|
37
|
+
<span className="min-w-0 flex-1 text-detail text-ink-muted">{children}</span>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The rail's own heading, so `KbDocumentShell`'s `<aside>` has something to be
|
|
44
|
+
* named by — an unnamed complementary landmark is one a screen reader can only
|
|
45
|
+
* announce as "complementary".
|
|
46
|
+
*/
|
|
47
|
+
export const KB_FILE_RAIL_HEADING_ID = 'kb-file-rail-heading';
|
|
48
|
+
|
|
49
|
+
/* A real `h2`, not a styled div: these are the page's second-level sections
|
|
50
|
+
under `KbPageHeader`'s `h1`, and a heading that is only a font size does not
|
|
51
|
+
appear in the document outline anyone navigates by. */
|
|
52
|
+
function SectionHeading({ id, children }: { id?: string; children: React.ReactNode }) {
|
|
53
|
+
return (
|
|
54
|
+
<h2 id={id} className="mb-2 text-label uppercase text-ink-faint">
|
|
55
|
+
{children}
|
|
56
|
+
</h2>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** "Owned by Ali Raza", "Everyone can read" — whichever the access tree says. */
|
|
61
|
+
function ownersLabel(owners: AccessEligible): string | null {
|
|
62
|
+
const names = [...owners.roles, ...owners.users.map((u) => u.name || u.email)];
|
|
63
|
+
if (names.length === 0) return null;
|
|
64
|
+
if (names.length <= 2) return names.join(' and ');
|
|
65
|
+
return `${names.slice(0, 2).join(', ')} +${names.length - 2}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function KbFileRail({
|
|
69
|
+
path,
|
|
70
|
+
charCount,
|
|
71
|
+
lastCommit,
|
|
72
|
+
owners,
|
|
73
|
+
linksOut,
|
|
74
|
+
onOpen,
|
|
75
|
+
}: KbFileRailProps) {
|
|
76
|
+
const access = ownersLabel(owners);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div className="border-l border-line pl-5">
|
|
80
|
+
<SectionHeading id={KB_FILE_RAIL_HEADING_ID}>About this file</SectionHeading>
|
|
81
|
+
<div className="divide-y divide-line">
|
|
82
|
+
{/* Never truncated. A truncated path is unusable for the one thing
|
|
83
|
+
anyone copies a path for, so it wraps instead. */}
|
|
84
|
+
<Row label="Path">
|
|
85
|
+
<span className="block font-mono text-meta break-all text-ink-muted">{path}</span>
|
|
86
|
+
</Row>
|
|
87
|
+
{/* "Characters", not "Size". `openFileContent` is a string, so its
|
|
88
|
+
length is UTF-16 code units — an em-dash, an accented name or an
|
|
89
|
+
emoji makes it diverge from bytes. A real byte figure is a `stat`
|
|
90
|
+
field on an endpoint that does not carry one yet, and the rail will
|
|
91
|
+
not print a number it cannot compute. */}
|
|
92
|
+
{charCount !== null && <Row label="Characters">{charCount.toLocaleString()}</Row>}
|
|
93
|
+
{lastCommit && (
|
|
94
|
+
<Row label="Edited">
|
|
95
|
+
{lastCommit.relative} by {lastCommit.author}
|
|
96
|
+
</Row>
|
|
97
|
+
)}
|
|
98
|
+
{access && (
|
|
99
|
+
<Row label="Access">
|
|
100
|
+
<Badge tone="outline">{access}</Badge>
|
|
101
|
+
</Row>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
{linksOut.length > 0 && (
|
|
106
|
+
<>
|
|
107
|
+
<div className="mt-6">
|
|
108
|
+
<SectionHeading>Links out</SectionHeading>
|
|
109
|
+
</div>
|
|
110
|
+
<div className="flex flex-col gap-0.5">
|
|
111
|
+
{linksOut.map((link) => (
|
|
112
|
+
<button
|
|
113
|
+
key={link.target}
|
|
114
|
+
type="button"
|
|
115
|
+
title={link.target}
|
|
116
|
+
onClick={() => onOpen(link.target)}
|
|
117
|
+
className="flex items-center gap-2 rounded-sm px-2 py-1.5 text-left text-detail text-ink-muted transition-colors hover:bg-hover hover:text-ink"
|
|
118
|
+
>
|
|
119
|
+
<Link2 size={13} className="flex-none text-ink-faint" />
|
|
120
|
+
<span className="min-w-0 truncate">{link.label}</span>
|
|
121
|
+
</button>
|
|
122
|
+
))}
|
|
123
|
+
</div>
|
|
124
|
+
</>
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Check,
|
|
4
|
+
ChevronDown,
|
|
5
|
+
Clock4,
|
|
6
|
+
Copy,
|
|
7
|
+
History,
|
|
8
|
+
Link2,
|
|
9
|
+
Pencil,
|
|
10
|
+
Users,
|
|
11
|
+
X,
|
|
12
|
+
} from 'lucide-react';
|
|
13
|
+
import { cn } from '../../../lib/utils';
|
|
14
|
+
import { Badge, Button, IconButton, MenuItem, MenuPanel } from '../../../shared/components';
|
|
15
|
+
import { useDismissableMenu } from '../../../shared/components';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The document's title, and the page's actions beside it.
|
|
19
|
+
*
|
|
20
|
+
* Replaces the 40px chrome strip, which named the file at 14px in the corner
|
|
21
|
+
* of a toolbar and put its actions in the opposite corner. A document names
|
|
22
|
+
* itself; chrome does not.
|
|
23
|
+
*
|
|
24
|
+
* Weight follows stakes, not frequency (proto:3781-3783). Share is the ONE
|
|
25
|
+
* bounded button because it is the one action here with a consequence for
|
|
26
|
+
* other people. Copy and Edit are icons — frequent, private, instantly
|
|
27
|
+
* reversible. Everything monthly is behind `⋯`.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** Extensions we strip from the `<h1>`. Anything else stays verbatim. */
|
|
31
|
+
const KNOWN_EXTENSIONS =
|
|
32
|
+
/\.(md|markdown|txt|csv|tsv|json|yaml|yml|html|htm|pdf|docx|xlsx|tool|png|jpe?g|gif|webp|svg)$/i;
|
|
33
|
+
|
|
34
|
+
function titleOf(path: string): string {
|
|
35
|
+
const base = path.slice(path.lastIndexOf('/') + 1);
|
|
36
|
+
return base.replace(KNOWN_EXTENSIONS, '');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface KbPageHeaderProps {
|
|
40
|
+
/** Workspace-relative. */
|
|
41
|
+
path: string;
|
|
42
|
+
/**
|
|
43
|
+
* `boolean | null` — NOT boolean. `useFileAccess` returns null while the
|
|
44
|
+
* lookup is in flight, null when there is no path / kbDirName / workspaceId,
|
|
45
|
+
* and null through the branch-bootstrap window; on error it deliberately
|
|
46
|
+
* falls back to `true`. Only a hard `false` may hide Edit — treating null as
|
|
47
|
+
* false flickers the button out on every file open.
|
|
48
|
+
*/
|
|
49
|
+
canWrite: boolean | null;
|
|
50
|
+
editMode: boolean;
|
|
51
|
+
/** "Loading…" while the lock is acquired. */
|
|
52
|
+
entering: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The reader-without-write-permission editor is open. Mutually exclusive
|
|
55
|
+
* with `editMode` in practice: propose is only offered where Edit is hidden
|
|
56
|
+
* (`canWrite === false`), and Edit only where it isn't.
|
|
57
|
+
*/
|
|
58
|
+
proposeMode: boolean;
|
|
59
|
+
/** The proposal is on the wire — "Send" disables and says so. */
|
|
60
|
+
proposalBusy: boolean;
|
|
61
|
+
onPropose(): void;
|
|
62
|
+
onSendProposal(): void;
|
|
63
|
+
onDiscardProposal(): void;
|
|
64
|
+
/**
|
|
65
|
+
* The write action (Edit / Propose changes / Done) lives in the file pane
|
|
66
|
+
* card's bar instead of here. True for prose documents — the ones that GET
|
|
67
|
+
* a pane card; full-bleed renderers keep the header's controls, because
|
|
68
|
+
* they have no bar to carry them.
|
|
69
|
+
*/
|
|
70
|
+
writeActionInPane?: boolean;
|
|
71
|
+
/** Disables Edit and explains why via `title`. */
|
|
72
|
+
lockedBy: string | null;
|
|
73
|
+
historyAvailable: boolean;
|
|
74
|
+
/** → "Unsaved" badge. */
|
|
75
|
+
isDirty: boolean;
|
|
76
|
+
/** → "Agent update waiting" badge. */
|
|
77
|
+
waitingOnAgentUpdate: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* → "Reviewing agent update" badge, AND no Edit. Not decoration: this GATES
|
|
80
|
+
* the Edit button, and `FileViewer.test.tsx` asserts the badge and the
|
|
81
|
+
* button's absence in the same case.
|
|
82
|
+
*/
|
|
83
|
+
isReviewingPending: boolean;
|
|
84
|
+
activeTab: 'content' | 'history' | 'compare';
|
|
85
|
+
onEdit(): void;
|
|
86
|
+
onDone(): void;
|
|
87
|
+
onOpenHistory(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Opens Manage access on THIS FILE. There is no folder target: sharing a
|
|
90
|
+
* whole folder from a file's page was one click away from handing over
|
|
91
|
+
* everything inside it, so it moved to the folder's own row in the tree.
|
|
92
|
+
*/
|
|
93
|
+
onShare(): void;
|
|
94
|
+
/** The page as Markdown. Absent for a file that has no markdown to copy. */
|
|
95
|
+
onCopyPage?: () => Promise<boolean>;
|
|
96
|
+
/** The canonical URL, via `useCanonicalFileUrl`. The only copy-a-reference
|
|
97
|
+
* action on this page — see the note where the `⋯` menu is built. */
|
|
98
|
+
onCopyLink(): Promise<boolean>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* How a copy reports itself.
|
|
103
|
+
*
|
|
104
|
+
* Option (a) from the plan: local, on the control that was clicked, reusing
|
|
105
|
+
* the pattern the deleted chrome strip already used. Knowledge has no toast
|
|
106
|
+
* provider — `LibraryToastProvider` is mounted in exactly one place, inside
|
|
107
|
+
* the Library's routes — and promoting it to the shell would drag two files
|
|
108
|
+
* this plan does not otherwise touch into scope for a 1.5-second message.
|
|
109
|
+
*
|
|
110
|
+
* `null` is idle, `'ok'` and `'fail'` are the two answers. A copy that fails
|
|
111
|
+
* MUST say so: `navigator.clipboard` rejects outright on a non-secure origin,
|
|
112
|
+
* and a silent no-op is the worst possible answer to "copy this".
|
|
113
|
+
*/
|
|
114
|
+
type CopyState = null | 'ok' | 'fail';
|
|
115
|
+
|
|
116
|
+
/** How long a copy confirmation stays on the control that was clicked. */
|
|
117
|
+
const COPY_FEEDBACK_MS = 1800;
|
|
118
|
+
|
|
119
|
+
export function KbPageHeader({
|
|
120
|
+
path,
|
|
121
|
+
canWrite,
|
|
122
|
+
editMode,
|
|
123
|
+
entering,
|
|
124
|
+
proposeMode,
|
|
125
|
+
proposalBusy,
|
|
126
|
+
onPropose,
|
|
127
|
+
onSendProposal,
|
|
128
|
+
onDiscardProposal,
|
|
129
|
+
writeActionInPane = false,
|
|
130
|
+
lockedBy,
|
|
131
|
+
historyAvailable,
|
|
132
|
+
isDirty,
|
|
133
|
+
waitingOnAgentUpdate,
|
|
134
|
+
isReviewingPending,
|
|
135
|
+
activeTab,
|
|
136
|
+
onEdit,
|
|
137
|
+
onDone,
|
|
138
|
+
onOpenHistory,
|
|
139
|
+
onShare,
|
|
140
|
+
onCopyPage,
|
|
141
|
+
onCopyLink,
|
|
142
|
+
}: KbPageHeaderProps) {
|
|
143
|
+
const [shareOpen, setShareOpen] = useState(false);
|
|
144
|
+
const [dotsOpen, setDotsOpen] = useState(false);
|
|
145
|
+
const [copied, setCopied] = useState<Record<string, CopyState>>({});
|
|
146
|
+
const shareTriggerRef = useRef<HTMLButtonElement>(null);
|
|
147
|
+
const dotsTriggerRef = useRef<HTMLButtonElement>(null);
|
|
148
|
+
|
|
149
|
+
const closeShare = useCallback(() => setShareOpen(false), []);
|
|
150
|
+
const closeDots = useCallback(() => setDotsOpen(false), []);
|
|
151
|
+
const shareRef = useDismissableMenu<HTMLDivElement>({
|
|
152
|
+
open: shareOpen,
|
|
153
|
+
onClose: closeShare,
|
|
154
|
+
returnFocusTo: shareTriggerRef,
|
|
155
|
+
});
|
|
156
|
+
const dotsRef = useDismissableMenu<HTMLDivElement>({
|
|
157
|
+
open: dotsOpen,
|
|
158
|
+
onClose: closeDots,
|
|
159
|
+
returnFocusTo: dotsTriggerRef,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const report = useCallback(async (key: string, run: () => Promise<boolean>) => {
|
|
163
|
+
const ok = await run();
|
|
164
|
+
setCopied((prev) => ({ ...prev, [key]: ok ? 'ok' : 'fail' }));
|
|
165
|
+
window.setTimeout(() => setCopied((prev) => ({ ...prev, [key]: null })), COPY_FEEDBACK_MS);
|
|
166
|
+
}, []);
|
|
167
|
+
|
|
168
|
+
const copyLabel = (key: string, idle: string) =>
|
|
169
|
+
copied[key] === 'ok' ? 'Copied' : copied[key] === 'fail' ? "Couldn't copy" : idle;
|
|
170
|
+
|
|
171
|
+
// Preserved verbatim from the chrome strip this replaces
|
|
172
|
+
// (`FileViewer.tsx:688`). Dropping `isReviewingPending` breaks the test that
|
|
173
|
+
// asserts the review badge and the button's absence together.
|
|
174
|
+
// `writeActionInPane` retires the whole cluster: the pane card's bar owns
|
|
175
|
+
// Edit/Propose for documents, and two controls for one action is a trap.
|
|
176
|
+
const showEdit =
|
|
177
|
+
!writeActionInPane && canWrite !== false && !isReviewingPending && activeTab === 'content';
|
|
178
|
+
// The counterpart for readers: exactly where Edit is REFUSED (a hard
|
|
179
|
+
// `canWrite === false`, never the in-flight null), the page offers the
|
|
180
|
+
// review path instead. Same gates otherwise — same tab, no agent review.
|
|
181
|
+
const showPropose =
|
|
182
|
+
!writeActionInPane && canWrite === false && !isReviewingPending && activeTab === 'content';
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<div className="mb-2 flex flex-wrap items-center gap-3">
|
|
186
|
+
<h1 className="min-w-0 text-display font-semibold text-ink">{titleOf(path)}</h1>
|
|
187
|
+
|
|
188
|
+
{/* The three chips the deleted strip used to carry. */}
|
|
189
|
+
{isDirty && <Badge tone="wait">Unsaved</Badge>}
|
|
190
|
+
{waitingOnAgentUpdate && (
|
|
191
|
+
<Badge tone="wait">
|
|
192
|
+
<Clock4 size={12} />
|
|
193
|
+
Agent update waiting
|
|
194
|
+
</Badge>
|
|
195
|
+
)}
|
|
196
|
+
{isReviewingPending && <Badge tone="ok">Reviewing agent update</Badge>}
|
|
197
|
+
|
|
198
|
+
<div className="ml-auto flex flex-none items-center gap-1.5">
|
|
199
|
+
{/* Share: bounded, and split. Bounded because it is the one action on
|
|
200
|
+
this page with a consequence for other people. The chevron carries
|
|
201
|
+
the quieter sibling errand — copying a link to the page — so that
|
|
202
|
+
the button itself stays one thing: "let someone in". */}
|
|
203
|
+
<div className="relative inline-flex items-stretch rounded-md border border-line-strong">
|
|
204
|
+
<Button
|
|
205
|
+
variant="quiet"
|
|
206
|
+
size="sm"
|
|
207
|
+
leadingIcon={<Users size={13} />}
|
|
208
|
+
className="rounded-r-none rounded-l-md border-0"
|
|
209
|
+
onClick={onShare}
|
|
210
|
+
>
|
|
211
|
+
Share
|
|
212
|
+
</Button>
|
|
213
|
+
<button
|
|
214
|
+
ref={shareTriggerRef}
|
|
215
|
+
type="button"
|
|
216
|
+
aria-haspopup="menu"
|
|
217
|
+
aria-expanded={shareOpen}
|
|
218
|
+
aria-label="More sharing options"
|
|
219
|
+
className={cn(
|
|
220
|
+
'flex w-6 items-center justify-center rounded-r-md border-l border-line',
|
|
221
|
+
'text-ink-faint transition-colors hover:bg-hover hover:text-ink',
|
|
222
|
+
shareOpen && 'bg-hover text-ink',
|
|
223
|
+
)}
|
|
224
|
+
onClick={() => setShareOpen((v) => !v)}
|
|
225
|
+
>
|
|
226
|
+
<ChevronDown size={12} />
|
|
227
|
+
</button>
|
|
228
|
+
{shareOpen && (
|
|
229
|
+
<div ref={shareRef} className="absolute right-0 top-[calc(100%+5px)] z-40">
|
|
230
|
+
<MenuPanel role="menu" aria-label="Sharing options" className="min-w-[212px]">
|
|
231
|
+
<MenuItem role="menuitem" onClick={() => { closeShare(); onShare(); }}>
|
|
232
|
+
<span className="flex items-center gap-2.5"><Users size={14} />Manage access…</span>
|
|
233
|
+
</MenuItem>
|
|
234
|
+
{/* The confirmation for THIS copy lives on the row itself, so
|
|
235
|
+
closing the panel first unmounts the only thing that says
|
|
236
|
+
whether it worked — and a copy that silently fails is the
|
|
237
|
+
worst possible answer. Copy, let the row say so, and take
|
|
238
|
+
the menu away once it has been said. */}
|
|
239
|
+
<MenuItem
|
|
240
|
+
role="menuitem"
|
|
241
|
+
onClick={async () => {
|
|
242
|
+
await report('link', onCopyLink);
|
|
243
|
+
window.setTimeout(closeShare, COPY_FEEDBACK_MS);
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
<span className="flex items-center gap-2.5">
|
|
247
|
+
<Link2 size={14} />
|
|
248
|
+
{copyLabel('link', 'Copy link to this page')}
|
|
249
|
+
</span>
|
|
250
|
+
</MenuItem>
|
|
251
|
+
{/* "Share the whole folder" lived here and was cut. Sharing a
|
|
252
|
+
folder from a file's page is a much bigger act than the row
|
|
253
|
+
it sat in suggested — one click, and everything inside the
|
|
254
|
+
folder changes hands. The folder's own row in the tree is
|
|
255
|
+
where that belongs, behind its right-click → Manage access,
|
|
256
|
+
which is also where you can see what you are about to
|
|
257
|
+
affect. */}
|
|
258
|
+
</MenuPanel>
|
|
259
|
+
</div>
|
|
260
|
+
)}
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
{/* The icon CHANGES on success — it does not merely tint.
|
|
264
|
+
A background shift is the same signal this button already gives on
|
|
265
|
+
hover, so a copy that only tinted read as "nothing happened" and got
|
|
266
|
+
clicked again. A tick is unambiguous, and it is the one confirmation
|
|
267
|
+
people already expect from a copy button. `aria-live` carries the
|
|
268
|
+
same news to a screen reader, which a swapped icon would not. */}
|
|
269
|
+
{onCopyPage && (
|
|
270
|
+
<IconButton
|
|
271
|
+
aria-label={copyLabel('page', 'Copy page as Markdown')}
|
|
272
|
+
title={copyLabel('page', 'Copy page as Markdown')}
|
|
273
|
+
active={copied.page === 'ok'}
|
|
274
|
+
tone={copied.page === 'fail' ? 'danger' : 'default'}
|
|
275
|
+
onClick={() => void report('page', onCopyPage)}
|
|
276
|
+
>
|
|
277
|
+
{copied.page === 'ok' ? (
|
|
278
|
+
<Check size={14} className="text-ok" />
|
|
279
|
+
) : copied.page === 'fail' ? (
|
|
280
|
+
<X size={14} />
|
|
281
|
+
) : (
|
|
282
|
+
<Copy size={14} />
|
|
283
|
+
)}
|
|
284
|
+
</IconButton>
|
|
285
|
+
)}
|
|
286
|
+
{/* Announced once, then cleared with the icon. Outside the button so
|
|
287
|
+
swapping the glyph does not re-announce the label as well. */}
|
|
288
|
+
<span className="sr-only" role="status" aria-live="polite">
|
|
289
|
+
{copied.page === 'ok'
|
|
290
|
+
? 'Page copied as Markdown'
|
|
291
|
+
: copied.page === 'fail'
|
|
292
|
+
? "Couldn't copy the page"
|
|
293
|
+
: ''}
|
|
294
|
+
</span>
|
|
295
|
+
|
|
296
|
+
{/* The reader's write path. Labelled buttons, not icons: proposing is
|
|
297
|
+
neither frequent nor instantly reversible — it opens a change
|
|
298
|
+
request other people will read — so it carries words, the same
|
|
299
|
+
weight rule that keeps Share labelled. */}
|
|
300
|
+
{showPropose &&
|
|
301
|
+
(proposeMode ? (
|
|
302
|
+
<>
|
|
303
|
+
<Button variant="quiet" size="sm" onClick={onDiscardProposal} disabled={proposalBusy}>
|
|
304
|
+
Discard
|
|
305
|
+
</Button>
|
|
306
|
+
<Button
|
|
307
|
+
variant="primary"
|
|
308
|
+
size="sm"
|
|
309
|
+
onClick={onSendProposal}
|
|
310
|
+
disabled={proposalBusy}
|
|
311
|
+
title="Send your proposed change for approval"
|
|
312
|
+
>
|
|
313
|
+
{proposalBusy ? 'Sending…' : 'Send proposal'}
|
|
314
|
+
</Button>
|
|
315
|
+
</>
|
|
316
|
+
) : (
|
|
317
|
+
<Button
|
|
318
|
+
variant="outline"
|
|
319
|
+
size="sm"
|
|
320
|
+
onClick={onPropose}
|
|
321
|
+
leadingIcon={<Pencil size={13} />}
|
|
322
|
+
title="You can't edit this file directly. Propose a change for its owners to approve"
|
|
323
|
+
>
|
|
324
|
+
Propose changes
|
|
325
|
+
</Button>
|
|
326
|
+
))}
|
|
327
|
+
|
|
328
|
+
{showEdit &&
|
|
329
|
+
(editMode ? (
|
|
330
|
+
<IconButton
|
|
331
|
+
aria-label="Done"
|
|
332
|
+
title="Save changes and return to view mode"
|
|
333
|
+
active
|
|
334
|
+
onClick={onDone}
|
|
335
|
+
>
|
|
336
|
+
<Pencil size={14} />
|
|
337
|
+
</IconButton>
|
|
338
|
+
) : (
|
|
339
|
+
<IconButton
|
|
340
|
+
aria-label={entering ? 'Loading…' : 'Edit'}
|
|
341
|
+
disabled={!!lockedBy || entering}
|
|
342
|
+
title={
|
|
343
|
+
lockedBy
|
|
344
|
+
? `Locked by ${lockedBy}`
|
|
345
|
+
: entering
|
|
346
|
+
? 'Acquiring lock and fetching latest content…'
|
|
347
|
+
: 'Click to edit this file'
|
|
348
|
+
}
|
|
349
|
+
onClick={onEdit}
|
|
350
|
+
>
|
|
351
|
+
<Pencil size={14} />
|
|
352
|
+
</IconButton>
|
|
353
|
+
))}
|
|
354
|
+
|
|
355
|
+
{/* Version history is the whole menu now, so the trigger goes where it
|
|
356
|
+
goes: git not ready means there is nothing behind ⋯, and an overflow
|
|
357
|
+
that opens onto an empty panel is worse than no overflow at all. */}
|
|
358
|
+
{historyAvailable && (
|
|
359
|
+
<div className="relative">
|
|
360
|
+
<IconButton
|
|
361
|
+
ref={dotsTriggerRef}
|
|
362
|
+
aria-label="More actions"
|
|
363
|
+
aria-haspopup="menu"
|
|
364
|
+
aria-expanded={dotsOpen}
|
|
365
|
+
active={dotsOpen}
|
|
366
|
+
onClick={() => setDotsOpen((v) => !v)}
|
|
367
|
+
>
|
|
368
|
+
<span aria-hidden className="text-strong leading-none">⋯</span>
|
|
369
|
+
</IconButton>
|
|
370
|
+
{dotsOpen && (
|
|
371
|
+
<div ref={dotsRef} className="absolute right-0 top-[calc(100%+5px)] z-40">
|
|
372
|
+
<MenuPanel role="menu" aria-label="More actions" className="min-w-[212px]">
|
|
373
|
+
<MenuItem role="menuitem" onClick={() => { closeDots(); onOpenHistory(); }}>
|
|
374
|
+
<span className="flex items-center gap-2.5"><History size={14} />Version history</span>
|
|
375
|
+
</MenuItem>
|
|
376
|
+
{/* "Copy path" is NOT here. Copying a reference to this page is
|
|
377
|
+
one errand, and Share already owns it ("Copy link to this
|
|
378
|
+
page"); two menus offering near-identical copies is how a
|
|
379
|
+
user ends up pasting the wrong one. The tree's right-click
|
|
380
|
+
menu keeps its own Copy path, because there it reaches rows
|
|
381
|
+
that are not open — a different job. */}
|
|
382
|
+
</MenuPanel>
|
|
383
|
+
</div>
|
|
384
|
+
)}
|
|
385
|
+
</div>
|
|
386
|
+
)}
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
);
|
|
390
|
+
}
|