@bevel-software/platform-core-frontend 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -3
- 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,425 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from 'react';
|
|
2
|
-
import { MessageSquarePlus } from 'lucide-react';
|
|
3
|
-
import type { PrReviewComment, PullRequestFile } from '@bevel-software/platform-shared';
|
|
4
|
-
import { parsePatch } from '../utils/parsePatch';
|
|
5
|
-
import { bucketizeComments, type ThreadBucket } from '../utils/bucketize-comments';
|
|
6
|
-
import { PrCommentThread } from './PrCommentThread';
|
|
7
|
-
import { PrCommentComposer } from './PrCommentComposer';
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
file: PullRequestFile | null;
|
|
11
|
-
/**
|
|
12
|
-
* All comments that anchor to a line of this file (i.e. `path === file.path`
|
|
13
|
-
* and `line !== undefined`). Parent filtering + bucketing happens inside.
|
|
14
|
-
*/
|
|
15
|
-
lineComments: PrReviewComment[];
|
|
16
|
-
currentUserEmail: string;
|
|
17
|
-
currentHeadSha: string;
|
|
18
|
-
/** Called for a brand-new top-level comment on `line` (new-file line number). */
|
|
19
|
-
onPostLineComment(line: number, body: string): Promise<void>;
|
|
20
|
-
onReplyComment(parentId: string, body: string): Promise<void>;
|
|
21
|
-
onEditComment(commentId: string, body: string): Promise<void>;
|
|
22
|
-
onDeleteComment(commentId: string): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const MAX_RENDERED_LINES = 5000;
|
|
26
|
-
|
|
27
|
-
type DiffRowKind = 'same' | 'added' | 'removed';
|
|
28
|
-
|
|
29
|
-
interface DiffRow {
|
|
30
|
-
kind: DiffRowKind;
|
|
31
|
-
text: string;
|
|
32
|
-
oldLine: number | null;
|
|
33
|
-
newLine: number | null;
|
|
34
|
-
/** Stable key within the pane — used as the table-row key. */
|
|
35
|
-
key: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface HunkGroup {
|
|
39
|
-
header: string;
|
|
40
|
-
rows: DiffRow[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Flatten hunks into typed rows with pre-resolved line numbers. Done up front so
|
|
45
|
-
* the render pass is pure mapping — no more mutable counters threaded through
|
|
46
|
-
* closures, and the (path, line) → thread lookup needs the resolved `newLine`.
|
|
47
|
-
*/
|
|
48
|
-
function flattenHunks(file: PullRequestFile): HunkGroup[] {
|
|
49
|
-
const hunks = parsePatch(file.patch);
|
|
50
|
-
return hunks.map((hunk, hIdx) => {
|
|
51
|
-
const rows: DiffRow[] = [];
|
|
52
|
-
let oldLine = hunk.oldStart - 1;
|
|
53
|
-
let newLine = hunk.newStart - 1;
|
|
54
|
-
hunk.lines.forEach((l, i) => {
|
|
55
|
-
if (l.type === 'same') {
|
|
56
|
-
oldLine++;
|
|
57
|
-
newLine++;
|
|
58
|
-
rows.push({ kind: 'same', text: l.text, oldLine, newLine, key: `${hIdx}:${i}` });
|
|
59
|
-
} else if (l.type === 'added') {
|
|
60
|
-
newLine++;
|
|
61
|
-
rows.push({ kind: 'added', text: l.text, oldLine: null, newLine, key: `${hIdx}:${i}` });
|
|
62
|
-
} else {
|
|
63
|
-
oldLine++;
|
|
64
|
-
rows.push({ kind: 'removed', text: l.text, oldLine, newLine: null, key: `${hIdx}:${i}` });
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return { header: hunk.header, rows };
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function PrDiffPane({
|
|
72
|
-
file,
|
|
73
|
-
lineComments,
|
|
74
|
-
currentUserEmail,
|
|
75
|
-
currentHeadSha,
|
|
76
|
-
onPostLineComment,
|
|
77
|
-
onReplyComment,
|
|
78
|
-
onEditComment,
|
|
79
|
-
onDeleteComment,
|
|
80
|
-
}: Props) {
|
|
81
|
-
// One composer active at a time. Storing the new-file line number as the
|
|
82
|
-
// discriminator matches how the comment is stored in the DB.
|
|
83
|
-
const [activeComposerLine, setActiveComposerLine] = useState<number | null>(null);
|
|
84
|
-
|
|
85
|
-
const groups = useMemo<HunkGroup[]>(
|
|
86
|
-
() => (file && !file.isBinary && file.patch ? flattenHunks(file) : []),
|
|
87
|
-
[file],
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// Partition inline comments by the new-file line they anchor to. Comments
|
|
91
|
-
// whose anchor line doesn't exist in the current patch (stale pins after a
|
|
92
|
-
// force-push / after new commits) go into `orphaned` — rendered below the
|
|
93
|
-
// diff as a collapsed block so the discussion doesn't vanish.
|
|
94
|
-
const { threadsByLine, orphanedThreads } = useMemo(() => {
|
|
95
|
-
const linesInDiff = new Set<number>();
|
|
96
|
-
for (const g of groups) {
|
|
97
|
-
for (const r of g.rows) {
|
|
98
|
-
if (r.newLine !== null) linesInDiff.add(r.newLine);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const threadsByLine = new Map<number, ThreadBucket[]>();
|
|
102
|
-
const orphaned: ThreadBucket[] = [];
|
|
103
|
-
const buckets = bucketizeComments(lineComments);
|
|
104
|
-
for (const b of buckets) {
|
|
105
|
-
const line = b.root.line;
|
|
106
|
-
if (line === undefined) continue;
|
|
107
|
-
if (linesInDiff.has(line)) {
|
|
108
|
-
const list = threadsByLine.get(line) ?? [];
|
|
109
|
-
list.push(b);
|
|
110
|
-
threadsByLine.set(line, list);
|
|
111
|
-
} else {
|
|
112
|
-
orphaned.push(b);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return { threadsByLine, orphanedThreads: orphaned };
|
|
116
|
-
}, [groups, lineComments]);
|
|
117
|
-
|
|
118
|
-
const totalLines = useMemo(
|
|
119
|
-
() => groups.reduce((sum, g) => sum + g.rows.length, 0),
|
|
120
|
-
[groups],
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
if (!file) {
|
|
124
|
-
return (
|
|
125
|
-
<div className="h-full flex items-center justify-center text-xs text-slate-600">
|
|
126
|
-
Select a file to see what changed.
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (file.isBinary) {
|
|
132
|
-
return (
|
|
133
|
-
<div className="h-full flex flex-col items-center justify-center gap-2 text-slate-600 text-xs px-6 text-center">
|
|
134
|
-
<div className="font-medium text-slate-700">Binary file — preview not available</div>
|
|
135
|
-
<div className="font-mono truncate max-w-full" title={file.path}>{file.path}</div>
|
|
136
|
-
</div>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (!file.patch) {
|
|
141
|
-
return (
|
|
142
|
-
<div className="h-full flex items-center justify-center text-xs text-slate-600 px-6 text-center">
|
|
143
|
-
Can't show what changed inline (file is too large).
|
|
144
|
-
</div>
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (totalLines > MAX_RENDERED_LINES) {
|
|
149
|
-
return (
|
|
150
|
-
<div className="h-full flex items-center justify-center text-xs text-slate-600 px-6 text-center">
|
|
151
|
-
Too many changes to show inline ({totalLines.toLocaleString()} lines).
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<div className="h-full overflow-auto bg-white font-mono text-[12px] leading-[18px]">
|
|
158
|
-
<table className="w-full border-collapse">
|
|
159
|
-
<tbody>
|
|
160
|
-
{groups.map((group, gIdx) => (
|
|
161
|
-
<HunkRows
|
|
162
|
-
key={gIdx}
|
|
163
|
-
group={group}
|
|
164
|
-
threadsByLine={threadsByLine}
|
|
165
|
-
activeComposerLine={activeComposerLine}
|
|
166
|
-
currentUserEmail={currentUserEmail}
|
|
167
|
-
currentHeadSha={currentHeadSha}
|
|
168
|
-
onAddComment={(line) => setActiveComposerLine(line)}
|
|
169
|
-
onCancelComposer={() => setActiveComposerLine(null)}
|
|
170
|
-
onSubmitComposer={async (line, body) => {
|
|
171
|
-
await onPostLineComment(line, body);
|
|
172
|
-
setActiveComposerLine(null);
|
|
173
|
-
}}
|
|
174
|
-
onReplyComment={onReplyComment}
|
|
175
|
-
onEditComment={onEditComment}
|
|
176
|
-
onDeleteComment={onDeleteComment}
|
|
177
|
-
/>
|
|
178
|
-
))}
|
|
179
|
-
</tbody>
|
|
180
|
-
</table>
|
|
181
|
-
|
|
182
|
-
{orphanedThreads.length > 0 && (
|
|
183
|
-
<OrphanedInlineThreads
|
|
184
|
-
threads={orphanedThreads}
|
|
185
|
-
currentUserEmail={currentUserEmail}
|
|
186
|
-
currentHeadSha={currentHeadSha}
|
|
187
|
-
onReplyComment={onReplyComment}
|
|
188
|
-
onEditComment={onEditComment}
|
|
189
|
-
onDeleteComment={onDeleteComment}
|
|
190
|
-
/>
|
|
191
|
-
)}
|
|
192
|
-
</div>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Render one hunk's rows plus any inline threads / open composer that
|
|
198
|
-
* attaches to each line. Nested as its own component so the top-level pane
|
|
199
|
-
* stays a straightforward `groups.map(...)`.
|
|
200
|
-
*/
|
|
201
|
-
function HunkRows({
|
|
202
|
-
group,
|
|
203
|
-
threadsByLine,
|
|
204
|
-
activeComposerLine,
|
|
205
|
-
currentUserEmail,
|
|
206
|
-
currentHeadSha,
|
|
207
|
-
onAddComment,
|
|
208
|
-
onCancelComposer,
|
|
209
|
-
onSubmitComposer,
|
|
210
|
-
onReplyComment,
|
|
211
|
-
onEditComment,
|
|
212
|
-
onDeleteComment,
|
|
213
|
-
}: {
|
|
214
|
-
group: HunkGroup;
|
|
215
|
-
threadsByLine: Map<number, ThreadBucket[]>;
|
|
216
|
-
activeComposerLine: number | null;
|
|
217
|
-
currentUserEmail: string;
|
|
218
|
-
currentHeadSha: string;
|
|
219
|
-
onAddComment(line: number): void;
|
|
220
|
-
onCancelComposer(): void;
|
|
221
|
-
onSubmitComposer(line: number, body: string): Promise<void>;
|
|
222
|
-
onReplyComment(parentId: string, body: string): Promise<void>;
|
|
223
|
-
onEditComment(commentId: string, body: string): Promise<void>;
|
|
224
|
-
onDeleteComment(commentId: string): Promise<void>;
|
|
225
|
-
}) {
|
|
226
|
-
return (
|
|
227
|
-
<>
|
|
228
|
-
<tr className="bg-white border-y border-slate-200">
|
|
229
|
-
<td colSpan={4} className="px-3 py-1 text-[11px] text-slate-600 font-mono">
|
|
230
|
-
{group.header}
|
|
231
|
-
</td>
|
|
232
|
-
</tr>
|
|
233
|
-
{group.rows.map((row) => {
|
|
234
|
-
const threads =
|
|
235
|
-
row.newLine !== null ? threadsByLine.get(row.newLine) ?? [] : [];
|
|
236
|
-
const composerOpen =
|
|
237
|
-
row.newLine !== null && activeComposerLine === row.newLine;
|
|
238
|
-
// Only added + same rows can anchor NEW comments (DB stores the new-
|
|
239
|
-
// file line number). Removed rows render inline threads only when some
|
|
240
|
-
// pre-removal comment happens to have matched — unlikely but harmless.
|
|
241
|
-
const canComment = row.newLine !== null;
|
|
242
|
-
return (
|
|
243
|
-
<DiffLineAndThreads
|
|
244
|
-
key={row.key}
|
|
245
|
-
row={row}
|
|
246
|
-
threads={threads}
|
|
247
|
-
composerOpen={composerOpen}
|
|
248
|
-
canComment={canComment}
|
|
249
|
-
currentUserEmail={currentUserEmail}
|
|
250
|
-
currentHeadSha={currentHeadSha}
|
|
251
|
-
onAddComment={() => row.newLine !== null && onAddComment(row.newLine)}
|
|
252
|
-
onCancelComposer={onCancelComposer}
|
|
253
|
-
onSubmitComposer={(body) =>
|
|
254
|
-
row.newLine !== null ? onSubmitComposer(row.newLine, body) : Promise.resolve()
|
|
255
|
-
}
|
|
256
|
-
onReplyComment={onReplyComment}
|
|
257
|
-
onEditComment={onEditComment}
|
|
258
|
-
onDeleteComment={onDeleteComment}
|
|
259
|
-
/>
|
|
260
|
-
);
|
|
261
|
-
})}
|
|
262
|
-
</>
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function DiffLineAndThreads({
|
|
267
|
-
row,
|
|
268
|
-
threads,
|
|
269
|
-
composerOpen,
|
|
270
|
-
canComment,
|
|
271
|
-
currentUserEmail,
|
|
272
|
-
currentHeadSha,
|
|
273
|
-
onAddComment,
|
|
274
|
-
onCancelComposer,
|
|
275
|
-
onSubmitComposer,
|
|
276
|
-
onReplyComment,
|
|
277
|
-
onEditComment,
|
|
278
|
-
onDeleteComment,
|
|
279
|
-
}: {
|
|
280
|
-
row: DiffRow;
|
|
281
|
-
threads: ThreadBucket[];
|
|
282
|
-
composerOpen: boolean;
|
|
283
|
-
canComment: boolean;
|
|
284
|
-
currentUserEmail: string;
|
|
285
|
-
currentHeadSha: string;
|
|
286
|
-
onAddComment(): void;
|
|
287
|
-
onCancelComposer(): void;
|
|
288
|
-
onSubmitComposer(body: string): Promise<void>;
|
|
289
|
-
onReplyComment(parentId: string, body: string): Promise<void>;
|
|
290
|
-
onEditComment(commentId: string, body: string): Promise<void>;
|
|
291
|
-
onDeleteComment(commentId: string): Promise<void>;
|
|
292
|
-
}) {
|
|
293
|
-
const bg = row.kind === 'added'
|
|
294
|
-
? 'bg-emerald-100'
|
|
295
|
-
: row.kind === 'removed'
|
|
296
|
-
? 'bg-red-100'
|
|
297
|
-
: '';
|
|
298
|
-
const textColor = row.kind === 'added'
|
|
299
|
-
? 'text-emerald-700'
|
|
300
|
-
: row.kind === 'removed'
|
|
301
|
-
? 'text-red-700'
|
|
302
|
-
: 'text-slate-900';
|
|
303
|
-
const marker = row.kind === 'added' ? '+' : row.kind === 'removed' ? '−' : ' ';
|
|
304
|
-
|
|
305
|
-
return (
|
|
306
|
-
<>
|
|
307
|
-
<tr className={`group ${bg}`}>
|
|
308
|
-
<td className="w-12 text-right pr-2 text-slate-500 select-none border-r border-slate-200 relative">
|
|
309
|
-
{row.oldLine ?? ''}
|
|
310
|
-
</td>
|
|
311
|
-
<td className="w-12 text-right pr-2 text-slate-500 select-none border-r border-slate-200 relative">
|
|
312
|
-
{/* Hover affordance for adding a line comment. Anchored to the new-
|
|
313
|
-
line gutter so it only appears on rows the comment model supports. */}
|
|
314
|
-
{canComment && (
|
|
315
|
-
<button
|
|
316
|
-
type="button"
|
|
317
|
-
onClick={onAddComment}
|
|
318
|
-
title="Add a comment on this line"
|
|
319
|
-
className="absolute -left-1 top-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center w-4 h-4 bg-emerald-600 hover:bg-emerald-500 text-white rounded shadow-sm"
|
|
320
|
-
tabIndex={-1}
|
|
321
|
-
>
|
|
322
|
-
<MessageSquarePlus size={10} />
|
|
323
|
-
</button>
|
|
324
|
-
)}
|
|
325
|
-
{row.newLine ?? ''}
|
|
326
|
-
</td>
|
|
327
|
-
<td className={`w-4 text-center ${textColor} select-none`}>{marker}</td>
|
|
328
|
-
<td className={`whitespace-pre-wrap break-words pl-2 pr-3 ${textColor}`}>
|
|
329
|
-
{row.text || '\u00A0'}
|
|
330
|
-
</td>
|
|
331
|
-
</tr>
|
|
332
|
-
|
|
333
|
-
{/* Existing threads on this line. One row per bucket — full table width. */}
|
|
334
|
-
{threads.map((bucket) => (
|
|
335
|
-
<tr key={bucket.root.id} className="bg-white">
|
|
336
|
-
<td colSpan={4} className="px-3 py-2 border-y border-slate-200">
|
|
337
|
-
<div className="text-[12px]">
|
|
338
|
-
<PrCommentThread
|
|
339
|
-
root={bucket.root}
|
|
340
|
-
replies={bucket.replies}
|
|
341
|
-
currentUserEmail={currentUserEmail}
|
|
342
|
-
isStale={bucket.root.headSha !== currentHeadSha}
|
|
343
|
-
onPostReply={onReplyComment}
|
|
344
|
-
onEdit={onEditComment}
|
|
345
|
-
onDelete={onDeleteComment}
|
|
346
|
-
/>
|
|
347
|
-
</div>
|
|
348
|
-
</td>
|
|
349
|
-
</tr>
|
|
350
|
-
))}
|
|
351
|
-
|
|
352
|
-
{composerOpen && (
|
|
353
|
-
<tr className="bg-white">
|
|
354
|
-
<td colSpan={4} className="px-3 py-2 border-y border-slate-200">
|
|
355
|
-
<div className="text-[12px] flex flex-col gap-1.5">
|
|
356
|
-
<div className="text-[10px] uppercase tracking-wider text-slate-600">
|
|
357
|
-
Comment on line {row.newLine}
|
|
358
|
-
</div>
|
|
359
|
-
<PrCommentComposer
|
|
360
|
-
placeholder="Leave a comment on this line…"
|
|
361
|
-
submitLabel="Comment"
|
|
362
|
-
autoFocus
|
|
363
|
-
onSubmit={onSubmitComposer}
|
|
364
|
-
onCancel={onCancelComposer}
|
|
365
|
-
/>
|
|
366
|
-
</div>
|
|
367
|
-
</td>
|
|
368
|
-
</tr>
|
|
369
|
-
)}
|
|
370
|
-
</>
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Fallback render for inline threads whose anchor line doesn't exist in the
|
|
376
|
-
* current patch — typically after a force-push dropped the line or the file
|
|
377
|
-
* was rewritten. Collapsed by default; the "outdated" banner on each thread
|
|
378
|
-
* carries the explanation.
|
|
379
|
-
*/
|
|
380
|
-
function OrphanedInlineThreads({
|
|
381
|
-
threads,
|
|
382
|
-
currentUserEmail,
|
|
383
|
-
currentHeadSha,
|
|
384
|
-
onReplyComment,
|
|
385
|
-
onEditComment,
|
|
386
|
-
onDeleteComment,
|
|
387
|
-
}: {
|
|
388
|
-
threads: ThreadBucket[];
|
|
389
|
-
currentUserEmail: string;
|
|
390
|
-
currentHeadSha: string;
|
|
391
|
-
onReplyComment(parentId: string, body: string): Promise<void>;
|
|
392
|
-
onEditComment(commentId: string, body: string): Promise<void>;
|
|
393
|
-
onDeleteComment(commentId: string): Promise<void>;
|
|
394
|
-
}) {
|
|
395
|
-
const [expanded, setExpanded] = useState(false);
|
|
396
|
-
return (
|
|
397
|
-
<div className="border-t border-slate-200 bg-white/40 px-3 py-2">
|
|
398
|
-
<button
|
|
399
|
-
type="button"
|
|
400
|
-
onClick={() => setExpanded((v) => !v)}
|
|
401
|
-
className="text-[11px] text-amber-700 hover:text-amber-900 flex items-center gap-1.5"
|
|
402
|
-
>
|
|
403
|
-
{expanded ? '▾' : '▸'} {threads.length} outdated inline comment
|
|
404
|
-
{threads.length === 1 ? '' : 's'} (
|
|
405
|
-
{threads.length === 1 ? 'this line no longer exists' : 'these lines no longer exist'})
|
|
406
|
-
</button>
|
|
407
|
-
{expanded && (
|
|
408
|
-
<div className="mt-2 space-y-2">
|
|
409
|
-
{threads.map((bucket) => (
|
|
410
|
-
<PrCommentThread
|
|
411
|
-
key={bucket.root.id}
|
|
412
|
-
root={bucket.root}
|
|
413
|
-
replies={bucket.replies}
|
|
414
|
-
currentUserEmail={currentUserEmail}
|
|
415
|
-
isStale={bucket.root.headSha !== currentHeadSha}
|
|
416
|
-
onPostReply={onReplyComment}
|
|
417
|
-
onEdit={onEditComment}
|
|
418
|
-
onDelete={onDeleteComment}
|
|
419
|
-
/>
|
|
420
|
-
))}
|
|
421
|
-
</div>
|
|
422
|
-
)}
|
|
423
|
-
</div>
|
|
424
|
-
);
|
|
425
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { Check, FileEdit, FilePlus2, FileX2, ArrowRightLeft, FileQuestion, X } from 'lucide-react';
|
|
2
|
-
import type { FileApprovalState, PullRequestFile } from '@bevel-software/platform-shared';
|
|
3
|
-
import { PrApprovalBadge } from './PrApprovalBadge';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
file: PullRequestFile;
|
|
7
|
-
approval?: FileApprovalState;
|
|
8
|
-
active: boolean;
|
|
9
|
-
/** Email of the currently-authenticated user — determines whether to show Approve action. */
|
|
10
|
-
currentUserEmail: string;
|
|
11
|
-
/** Whether an approve/unapprove request is currently pending for this file. */
|
|
12
|
-
busy: boolean;
|
|
13
|
-
onSelect(): void;
|
|
14
|
-
onApprove(): void;
|
|
15
|
-
onUnapprove(): void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function KindIcon({ status }: { status: PullRequestFile['status'] }) {
|
|
19
|
-
const size = 13;
|
|
20
|
-
switch (status) {
|
|
21
|
-
case 'added': return <FilePlus2 size={size} className="text-emerald-600" />;
|
|
22
|
-
case 'removed': return <FileX2 size={size} className="text-red-600" />;
|
|
23
|
-
case 'renamed':
|
|
24
|
-
case 'copied': return <ArrowRightLeft size={size} className="text-bevel" />;
|
|
25
|
-
case 'modified':
|
|
26
|
-
case 'changed': return <FileEdit size={size} className="text-amber-600" />;
|
|
27
|
-
default: return <FileQuestion size={size} className="text-slate-600" />;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function PrFileRow({
|
|
32
|
-
file,
|
|
33
|
-
approval,
|
|
34
|
-
active,
|
|
35
|
-
currentUserEmail,
|
|
36
|
-
busy,
|
|
37
|
-
onSelect,
|
|
38
|
-
onApprove,
|
|
39
|
-
onUnapprove,
|
|
40
|
-
}: Props) {
|
|
41
|
-
const { path, previousPath, status, additions, deletions, isBinary } = file;
|
|
42
|
-
|
|
43
|
-
const normalizedEmail = currentUserEmail.trim().toLowerCase();
|
|
44
|
-
// Authoritative gate: the backend pre-computes `viewerCanApprove` per file
|
|
45
|
-
// by running the same access check `approveFile` does, so the UI only
|
|
46
|
-
// surfaces the Approve button to users whose click would actually succeed.
|
|
47
|
-
// Backwards-compat: older responses may not carry the field; fall back to
|
|
48
|
-
// the direct-user-grant heuristic so the button doesn't disappear during
|
|
49
|
-
// a rolling deploy.
|
|
50
|
-
const eligibleEmails = (approval?.eligibleApprovers.users ?? []).map((u) =>
|
|
51
|
-
u.email.trim().toLowerCase(),
|
|
52
|
-
);
|
|
53
|
-
const hasEligibleApprovers =
|
|
54
|
-
(approval?.eligibleApprovers.roles.length ?? 0) > 0 ||
|
|
55
|
-
(approval?.eligibleApprovers.users.length ?? 0) > 0;
|
|
56
|
-
const isEligible =
|
|
57
|
-
approval?.viewerCanApprove === true ||
|
|
58
|
-
(approval?.viewerCanApprove === undefined && eligibleEmails.includes(normalizedEmail));
|
|
59
|
-
// A current (non-stale) approval from THIS user is what the Unapprove button
|
|
60
|
-
// toggles. Stale rows stay for audit but don't make the button a revoke.
|
|
61
|
-
const hasOwnCurrentApproval = !!approval?.approvedBy.some(
|
|
62
|
-
(a) => a.email.toLowerCase() === normalizedEmail && !a.isStale,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<div
|
|
67
|
-
role="button"
|
|
68
|
-
tabIndex={0}
|
|
69
|
-
onClick={onSelect}
|
|
70
|
-
onKeyDown={(e) => {
|
|
71
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
onSelect();
|
|
74
|
-
}
|
|
75
|
-
}}
|
|
76
|
-
className={`group flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors border ${
|
|
77
|
-
active
|
|
78
|
-
? 'bg-slate-100 border-slate-300'
|
|
79
|
-
: 'bg-white border-transparent hover:bg-slate-100 hover:border-slate-200'
|
|
80
|
-
}`}
|
|
81
|
-
>
|
|
82
|
-
<KindIcon status={status} />
|
|
83
|
-
<div className="flex-1 min-w-0">
|
|
84
|
-
<div className="flex items-center gap-1.5 text-xs text-slate-900 truncate">
|
|
85
|
-
<span className="truncate font-mono" title={path}>{path}</span>
|
|
86
|
-
<span className="text-[10px] uppercase tracking-wider text-slate-600 shrink-0">
|
|
87
|
-
{status}
|
|
88
|
-
</span>
|
|
89
|
-
<PrApprovalBadge state={approval} />
|
|
90
|
-
</div>
|
|
91
|
-
<div className="flex items-center gap-2 text-[10px] text-slate-600 mt-0.5">
|
|
92
|
-
{previousPath && (
|
|
93
|
-
<span className="font-mono truncate" title={previousPath}>
|
|
94
|
-
from {previousPath}
|
|
95
|
-
</span>
|
|
96
|
-
)}
|
|
97
|
-
{isBinary ? (
|
|
98
|
-
<span>binary</span>
|
|
99
|
-
) : (
|
|
100
|
-
<>
|
|
101
|
-
<span className="text-emerald-600">+{additions}</span>
|
|
102
|
-
<span className="text-red-600">−{deletions}</span>
|
|
103
|
-
</>
|
|
104
|
-
)}
|
|
105
|
-
{approval && approval.path.toLowerCase().endsWith('.md') && !hasEligibleApprovers && (
|
|
106
|
-
<span className="text-red-600 shrink-0">no eligible approvers</span>
|
|
107
|
-
)}
|
|
108
|
-
{hasEligibleApprovers && !isEligible && (
|
|
109
|
-
<span
|
|
110
|
-
className="truncate text-slate-500 shrink-0"
|
|
111
|
-
title={[
|
|
112
|
-
...approval!.eligibleApprovers.roles,
|
|
113
|
-
...approval!.eligibleApprovers.users.map((u) => u.email),
|
|
114
|
-
].join(', ')}
|
|
115
|
-
>
|
|
116
|
-
{(() => {
|
|
117
|
-
const roles = approval!.eligibleApprovers.roles;
|
|
118
|
-
const users = approval!.eligibleApprovers.users;
|
|
119
|
-
if (roles.length && users.length) return `${roles[0]} +${users.length}`;
|
|
120
|
-
if (roles.length) return roles.length === 1 ? roles[0] : `${roles[0]} +${roles.length - 1}`;
|
|
121
|
-
const firstUser = users[0].name || users[0].email;
|
|
122
|
-
return users.length === 1 ? firstUser : `${firstUser} +${users.length - 1}`;
|
|
123
|
-
})()}
|
|
124
|
-
</span>
|
|
125
|
-
)}
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
|
|
129
|
-
{isEligible && (
|
|
130
|
-
<div className="flex items-center gap-1 shrink-0 opacity-70 group-hover:opacity-100">
|
|
131
|
-
{hasOwnCurrentApproval ? (
|
|
132
|
-
<button
|
|
133
|
-
type="button"
|
|
134
|
-
disabled={busy}
|
|
135
|
-
onClick={(e) => {
|
|
136
|
-
e.stopPropagation();
|
|
137
|
-
onUnapprove();
|
|
138
|
-
}}
|
|
139
|
-
title="Withdraw your confirmation"
|
|
140
|
-
aria-label="Withdraw your confirmation"
|
|
141
|
-
className="p-1 rounded text-emerald-700 hover:text-red-700 hover:bg-red-100 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
142
|
-
>
|
|
143
|
-
<X size={12} />
|
|
144
|
-
</button>
|
|
145
|
-
) : (
|
|
146
|
-
<button
|
|
147
|
-
type="button"
|
|
148
|
-
disabled={busy}
|
|
149
|
-
onClick={(e) => {
|
|
150
|
-
e.stopPropagation();
|
|
151
|
-
onApprove();
|
|
152
|
-
}}
|
|
153
|
-
title="Confirm this file"
|
|
154
|
-
aria-label="Confirm this file"
|
|
155
|
-
className="p-1 rounded bg-emerald-700 hover:bg-emerald-600 text-white disabled:bg-slate-100 disabled:text-slate-600 disabled:cursor-not-allowed"
|
|
156
|
-
>
|
|
157
|
-
<Check size={12} />
|
|
158
|
-
</button>
|
|
159
|
-
)}
|
|
160
|
-
</div>
|
|
161
|
-
)}
|
|
162
|
-
</div>
|
|
163
|
-
);
|
|
164
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { FileApprovalState, PullRequestFile } from '@bevel-software/platform-shared';
|
|
2
|
-
import { PrFileRow } from './PrFileRow';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
files: PullRequestFile[];
|
|
6
|
-
approvals: FileApprovalState[];
|
|
7
|
-
selectedPath: string | null;
|
|
8
|
-
currentUserEmail: string;
|
|
9
|
-
busyPath: string | null;
|
|
10
|
-
onSelect(path: string): void;
|
|
11
|
-
onApprove(path: string): void;
|
|
12
|
-
onUnapprove(path: string): void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function PrFilesList({
|
|
16
|
-
files,
|
|
17
|
-
approvals,
|
|
18
|
-
selectedPath,
|
|
19
|
-
currentUserEmail,
|
|
20
|
-
busyPath,
|
|
21
|
-
onSelect,
|
|
22
|
-
onApprove,
|
|
23
|
-
onUnapprove,
|
|
24
|
-
}: Props) {
|
|
25
|
-
if (files.length === 0) {
|
|
26
|
-
return (
|
|
27
|
-
<div className="flex-1 flex items-center justify-center text-xs text-slate-600 px-3">
|
|
28
|
-
No file changes.
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Index approvals by path for O(1) lookup during render.
|
|
34
|
-
const approvalByPath = new Map(approvals.map((a) => [a.path, a]));
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div className="flex-1 overflow-y-auto p-2 space-y-1">
|
|
38
|
-
{files.map((file) => (
|
|
39
|
-
<PrFileRow
|
|
40
|
-
key={`${file.status}:${file.previousPath ?? ''}:${file.path}`}
|
|
41
|
-
file={file}
|
|
42
|
-
approval={approvalByPath.get(file.path)}
|
|
43
|
-
active={selectedPath === file.path}
|
|
44
|
-
currentUserEmail={currentUserEmail}
|
|
45
|
-
busy={busyPath === file.path}
|
|
46
|
-
onSelect={() => onSelect(file.path)}
|
|
47
|
-
onApprove={() => onApprove(file.path)}
|
|
48
|
-
onUnapprove={() => onUnapprove(file.path)}
|
|
49
|
-
/>
|
|
50
|
-
))}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { X, GitPullRequest } from 'lucide-react';
|
|
2
|
-
import type { PullRequestDetail } from '@bevel-software/platform-shared';
|
|
3
|
-
import { PrMergeButton } from './PrMergeButton';
|
|
4
|
-
import { PrCancelButton } from './PrCancelButton';
|
|
5
|
-
import { PrRefreshFromTargetButton } from './PrRefreshFromTargetButton';
|
|
6
|
-
import { PrHeaderOverflowMenu } from './PrHeaderOverflowMenu';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
detail: PullRequestDetail;
|
|
10
|
-
/** Dismiss the viewer overlay. Does not change the change request's state. */
|
|
11
|
-
onCloseViewer(): void;
|
|
12
|
-
/** Fired when the change request transitions to a terminal state (applied or cancelled). */
|
|
13
|
-
onResolved(): void;
|
|
14
|
-
/** Fired when the change request's diff changes (refresh-from-target). */
|
|
15
|
-
onRefreshed(): void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function PrHeader({ detail, onCloseViewer, onResolved, onRefreshed }: Props) {
|
|
19
|
-
return (
|
|
20
|
-
<div className="h-10 border-b border-slate-200 flex items-center px-3 gap-2 shrink-0">
|
|
21
|
-
<GitPullRequest size={14} className="text-slate-600 shrink-0" />
|
|
22
|
-
<span className="text-sm font-medium text-slate-900 truncate min-w-0">
|
|
23
|
-
#{detail.number} · {detail.title}
|
|
24
|
-
</span>
|
|
25
|
-
<div className="ml-auto flex items-center gap-2 shrink-0">
|
|
26
|
-
<PrMergeButton detail={detail} onMerged={onResolved} compact />
|
|
27
|
-
{detail.state === 'open' && (
|
|
28
|
-
<PrHeaderOverflowMenu>
|
|
29
|
-
<PrRefreshFromTargetButton detail={detail} onRefreshed={onRefreshed} />
|
|
30
|
-
<PrCancelButton detail={detail} onCancelled={onResolved} />
|
|
31
|
-
</PrHeaderOverflowMenu>
|
|
32
|
-
)}
|
|
33
|
-
<button
|
|
34
|
-
type="button"
|
|
35
|
-
onClick={onCloseViewer}
|
|
36
|
-
className="p-1 rounded hover:bg-slate-100 text-slate-600 hover:text-slate-700 transition-colors"
|
|
37
|
-
title="Close panel"
|
|
38
|
-
aria-label="Close panel"
|
|
39
|
-
>
|
|
40
|
-
<X size={14} aria-hidden="true" />
|
|
41
|
-
</button>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}
|