@bevel-software/platform-core-frontend 0.4.0 → 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 +130 -95
- 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 +114 -138
- 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 +172 -156
- 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 +361 -353
- 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 +104 -104
- 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 +210 -117
- 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 +71 -47
- 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 +153 -132
- package/src/modules/library/components/LibraryLayout.tsx +344 -0
- package/src/modules/library/components/LibraryPage.tsx +138 -254
- 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 +108 -320
- 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 +199 -116
- 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 +313 -276
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +109 -92
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +82 -51
- 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 +131 -108
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -548
- 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 +1292 -1068
- 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 +1312 -906
- 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 +182 -179
- 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 +54 -51
- 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,112 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import { Button, Dialog, TextField } from '../../../shared/components';
|
|
4
|
+
import { createGroup } from '../services/groups.api';
|
|
5
|
+
import { pathForGroup } from '../routes/library-paths';
|
|
6
|
+
import { useLibraryToast } from '../state/toast.context';
|
|
7
|
+
|
|
8
|
+
export interface NewGroupDialogProps {
|
|
9
|
+
/** Names already taken — readable groups AND locked ones. */
|
|
10
|
+
existing: string[];
|
|
11
|
+
onClose(): void;
|
|
12
|
+
/** The catalog and the group index both have to hear about a new folder. */
|
|
13
|
+
onCreated(): void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Make a group — the prototype's `newSpaceModal` (line 2769).
|
|
18
|
+
*
|
|
19
|
+
* A group IS a folder, and the folder comes from the DEDICATED provisioning
|
|
20
|
+
* endpoint (`POST /api/groups`) — the one privileged door for claiming a name
|
|
21
|
+
* under `Groups/`. The endpoint writes the folder's `access.md` naming the
|
|
22
|
+
* creator under read, write and owner (with the file itself readable by
|
|
23
|
+
* everyone, so the group is discoverable and joinable) and commits it before
|
|
24
|
+
* answering. So there is no access step in this dialog: by the time the
|
|
25
|
+
* response arrives, the group exists and it is yours.
|
|
26
|
+
*/
|
|
27
|
+
export function NewGroupDialog({ existing, onClose, onCreated }: NewGroupDialogProps) {
|
|
28
|
+
const navigate = useNavigate();
|
|
29
|
+
const toast = useLibraryToast();
|
|
30
|
+
const [name, setName] = useState('');
|
|
31
|
+
const [busy, setBusy] = useState(false);
|
|
32
|
+
|
|
33
|
+
const trimmed = name.trim();
|
|
34
|
+
const taken = existing.some((g) => g.toLowerCase() === trimmed.toLowerCase());
|
|
35
|
+
/**
|
|
36
|
+
* A group name becomes a folder name, so the characters a path cannot carry
|
|
37
|
+
* are the characters a name cannot have. Checked here rather than left to the
|
|
38
|
+
* server because `Groups/A/B` would silently create a NESTED folder — which
|
|
39
|
+
* `groupOfPath` would then read as the group "A", not "A/B".
|
|
40
|
+
*/
|
|
41
|
+
const illegal = /[/\\]/.test(trimmed);
|
|
42
|
+
const error = taken
|
|
43
|
+
? 'A group with that name already exists.'
|
|
44
|
+
: illegal
|
|
45
|
+
? "A group name can't contain / or \\."
|
|
46
|
+
: null;
|
|
47
|
+
const canCreate = trimmed.length > 0 && !error && !busy;
|
|
48
|
+
|
|
49
|
+
async function create() {
|
|
50
|
+
if (!canCreate) return;
|
|
51
|
+
setBusy(true);
|
|
52
|
+
try {
|
|
53
|
+
// Navigate with the SERVER's folder name, not the typed one — the
|
|
54
|
+
// endpoint owns the canonical spelling of what it created.
|
|
55
|
+
const { folder } = await createGroup(trimmed);
|
|
56
|
+
onCreated();
|
|
57
|
+
onClose();
|
|
58
|
+
navigate(pathForGroup(folder));
|
|
59
|
+
} catch (err) {
|
|
60
|
+
// The server's refusal names the problem (name taken, reserved
|
|
61
|
+
// prefix…) — worth more than a generic apology.
|
|
62
|
+
const msg = err instanceof Error ? err.message : "Couldn't create that group. Try again.";
|
|
63
|
+
toast(msg, 'danger');
|
|
64
|
+
setBusy(false);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Dialog
|
|
70
|
+
open
|
|
71
|
+
onClose={onClose}
|
|
72
|
+
title="New group"
|
|
73
|
+
size="md"
|
|
74
|
+
busy={busy}
|
|
75
|
+
footer={
|
|
76
|
+
<>
|
|
77
|
+
<Button variant="quiet" onClick={onClose} disabled={busy}>
|
|
78
|
+
Cancel
|
|
79
|
+
</Button>
|
|
80
|
+
<Button variant="primary" onClick={() => void create()} disabled={!canCreate}>
|
|
81
|
+
{busy ? 'Creating…' : 'Create group'}
|
|
82
|
+
</Button>
|
|
83
|
+
</>
|
|
84
|
+
}
|
|
85
|
+
>
|
|
86
|
+
<p className="text-ui text-ink-muted">
|
|
87
|
+
A group carries skills and tools for the people in it. You run the ones you create.
|
|
88
|
+
</p>
|
|
89
|
+
|
|
90
|
+
<TextField
|
|
91
|
+
className="mt-3.5 w-full"
|
|
92
|
+
autoFocus
|
|
93
|
+
aria-label="Group name"
|
|
94
|
+
placeholder="Design, Support, Leadership…"
|
|
95
|
+
value={name}
|
|
96
|
+
onChange={(e) => setName(e.target.value)}
|
|
97
|
+
onKeyDown={(e) => {
|
|
98
|
+
if (e.key === 'Enter') void create();
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
{/* Only after they have typed something: an error under an empty field
|
|
103
|
+
is a complaint about a form nobody has filled in yet. */}
|
|
104
|
+
{trimmed.length > 0 && error && (
|
|
105
|
+
<p role="alert" className="mt-1.5 text-detail text-danger">
|
|
106
|
+
{error}
|
|
107
|
+
</p>
|
|
108
|
+
)}
|
|
109
|
+
|
|
110
|
+
</Dialog>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import { Button, Surface, TextField } from '../../../shared/components';
|
|
4
|
+
import { useAuth } from '../../auth/state/auth.context';
|
|
5
|
+
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
6
|
+
import { kbFileUrl } from '../../workspace/routing/kb-routes';
|
|
7
|
+
import { createEmptySkill } from '../services/library.api';
|
|
8
|
+
import { useLibraryReload } from '../state/library-context';
|
|
9
|
+
import { useLibraryToast } from '../state/toast.context';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Where the new skill lands.
|
|
13
|
+
*
|
|
14
|
+
* - A GROUP destination carries the folder and the caller's write verdict
|
|
15
|
+
* on it. `canWrite: null` (verdict not in yet) is treated as "not a
|
|
16
|
+
* writer", same rule the surrounding dialogs use: the cautious path —
|
|
17
|
+
* a change request — is correct either way, the confident one is not.
|
|
18
|
+
* - PERSONAL means the caller's own folder (`Groups/personal-<id>/`),
|
|
19
|
+
* which `createEmptySkill` ensures via the provisioning endpoint before
|
|
20
|
+
* writing. Always direct: the ensured folder is theirs by construction.
|
|
21
|
+
*/
|
|
22
|
+
export type NewSkillDestination =
|
|
23
|
+
| { parentPath: string; canWrite: boolean | null }
|
|
24
|
+
| { personal: true };
|
|
25
|
+
|
|
26
|
+
export interface NewSkillPanelProps {
|
|
27
|
+
destination: NewSkillDestination;
|
|
28
|
+
/** Every skill name already in the catalog — see the collision check below. */
|
|
29
|
+
existingSkills: string[];
|
|
30
|
+
/** Fired once the file exists; the host dialog closes on it. */
|
|
31
|
+
onCreated(): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* "Start an empty SKILL.md", the admin-only first path in both add dialogs.
|
|
36
|
+
*
|
|
37
|
+
* This used to be a link that opened the destination folder in the workspace
|
|
38
|
+
* and left you there. Opening a folder is not creating a skill: you still had
|
|
39
|
+
* to know that a skill is a folder, that the folder needs a `SKILL.md`, and how
|
|
40
|
+
* to make one. The door now does the thing it was pointing at — it writes the
|
|
41
|
+
* file, and takes you to it with the cursor in an empty body.
|
|
42
|
+
*
|
|
43
|
+
* The name field is not ceremony. A skill's folder name IS its identity (see
|
|
44
|
+
* `resolveDeclaredId` in the backend scan), so there is no correct name to
|
|
45
|
+
* invent on someone's behalf, and a generated one would have to be renamed
|
|
46
|
+
* before the skill was worth anything.
|
|
47
|
+
*/
|
|
48
|
+
export function NewSkillPanel({
|
|
49
|
+
destination,
|
|
50
|
+
existingSkills,
|
|
51
|
+
onCreated,
|
|
52
|
+
}: NewSkillPanelProps) {
|
|
53
|
+
const { user } = useAuth();
|
|
54
|
+
const reloadLibrary = useLibraryReload();
|
|
55
|
+
const navigate = useNavigate();
|
|
56
|
+
const toast = useLibraryToast();
|
|
57
|
+
const [name, setName] = useState('');
|
|
58
|
+
const [busy, setBusy] = useState(false);
|
|
59
|
+
|
|
60
|
+
const trimmed = name.trim();
|
|
61
|
+
/**
|
|
62
|
+
* A skill name becomes a folder name, so the characters a path cannot carry
|
|
63
|
+
* are the characters a name cannot have — the same rule `NewGroupDialog`
|
|
64
|
+
* applies to groups, and the same one the backend enforces (`isSafeName`).
|
|
65
|
+
*/
|
|
66
|
+
const illegal = /[/\\]/.test(trimmed) || trimmed === '.' || trimmed === '..';
|
|
67
|
+
/**
|
|
68
|
+
* Collision is checked against EVERY skill, not just this folder's. A skill's
|
|
69
|
+
* id is its name and ids are global: the backend's scan refuses the second
|
|
70
|
+
* skill to claim one (`dedupeById`), so a duplicate here would not produce a
|
|
71
|
+
* second skill — it would produce a file that never appears anywhere.
|
|
72
|
+
*/
|
|
73
|
+
const taken = existingSkills.some((s) => s.toLowerCase() === trimmed.toLowerCase());
|
|
74
|
+
const error = taken
|
|
75
|
+
? 'A skill with that name already exists.'
|
|
76
|
+
: illegal
|
|
77
|
+
? 'A skill name can\'t contain / or \\, or be "." or "..".'
|
|
78
|
+
: null;
|
|
79
|
+
const canCreate = trimmed.length > 0 && !error && !busy && Boolean(user);
|
|
80
|
+
|
|
81
|
+
async function create() {
|
|
82
|
+
if (!canCreate || !user) return;
|
|
83
|
+
setBusy(true);
|
|
84
|
+
try {
|
|
85
|
+
const created = await createEmptySkill({
|
|
86
|
+
...('personal' in destination
|
|
87
|
+
? { personal: true as const }
|
|
88
|
+
: { parentPath: destination.parentPath, canWrite: destination.canWrite === true }),
|
|
89
|
+
name: trimmed,
|
|
90
|
+
userEmail: user.email,
|
|
91
|
+
userName: user.name,
|
|
92
|
+
});
|
|
93
|
+
// The library is where the result lives, whichever way it went — nobody
|
|
94
|
+
// is bounced to the Knowledge app to meet the thing they just made.
|
|
95
|
+
reloadLibrary();
|
|
96
|
+
onCreated();
|
|
97
|
+
if (created.direct) {
|
|
98
|
+
// Straight into the new skill's page, editor open: an empty SKILL.md
|
|
99
|
+
// is an invitation to write, not a page to admire.
|
|
100
|
+
toast(`Created ${trimmed}: opening it.`, 'ok');
|
|
101
|
+
navigate(kbFileUrl(DEFAULT_BRANCH, created.workspacePath), { state: { startEditing: true } });
|
|
102
|
+
} else {
|
|
103
|
+
// A proposal has no page yet — the skill exists only on the author's
|
|
104
|
+
// branch. It appears right here as an "In review" card (the pending
|
|
105
|
+
// shelf), which is also where its review happens.
|
|
106
|
+
toast(`Created ${trimmed}: sent to the group's owners for review.`, 'ok');
|
|
107
|
+
}
|
|
108
|
+
} catch (err) {
|
|
109
|
+
// The workspace API forwards the backend's own refusal (e.g. "You don't
|
|
110
|
+
// have permission to write to …"), which is worth more than a generic
|
|
111
|
+
// apology — it names the thing to go fix.
|
|
112
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
113
|
+
toast(`Couldn't create that skill: ${msg}`, 'danger');
|
|
114
|
+
setBusy(false);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<Surface tone="sunken" radius="lg" elevation="none" padded className="mt-3.5">
|
|
120
|
+
<span className="block text-strong font-semibold text-ink">Start an empty SKILL.md</span>
|
|
121
|
+
<span className="block text-detail text-ink-muted">
|
|
122
|
+
A skill is a folder: SKILL.md plus whatever it needs. This makes both, and opens the file.
|
|
123
|
+
</span>
|
|
124
|
+
|
|
125
|
+
<div className="mt-2.5 flex items-start gap-2">
|
|
126
|
+
<TextField
|
|
127
|
+
className="flex-1"
|
|
128
|
+
aria-label="Skill name"
|
|
129
|
+
placeholder="weekly-report, rfi, pricing-check…"
|
|
130
|
+
value={name}
|
|
131
|
+
disabled={busy}
|
|
132
|
+
onChange={(e) => setName(e.target.value)}
|
|
133
|
+
onKeyDown={(e) => {
|
|
134
|
+
if (e.key === 'Enter') void create();
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
137
|
+
<Button variant="primary" onClick={() => void create()} disabled={!canCreate}>
|
|
138
|
+
{busy ? 'Creating…' : 'Create'}
|
|
139
|
+
</Button>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
{/* Only once they have typed something: an error under an empty field is
|
|
143
|
+
a complaint about a form nobody has filled in yet. */}
|
|
144
|
+
{trimmed.length > 0 && error && (
|
|
145
|
+
<p role="alert" className="mt-1.5 text-detail text-danger">
|
|
146
|
+
{error}
|
|
147
|
+
</p>
|
|
148
|
+
)}
|
|
149
|
+
</Surface>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { Link2, Plus, Trash2, Users } from 'lucide-react';
|
|
3
|
+
import { cn } from '../../../lib/utils';
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
IconButton,
|
|
7
|
+
MenuItem,
|
|
8
|
+
MenuPanel,
|
|
9
|
+
useDismissableMenu,
|
|
10
|
+
} from '../../../shared/components';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The three actions beside a place's title — the prototype's `spaceActs`
|
|
14
|
+
* (proto:3012-3025).
|
|
15
|
+
*
|
|
16
|
+
* Everyone sees all three, and they do the same thing for everyone. That is
|
|
17
|
+
* the whole point of the component existing: the group page used to render
|
|
18
|
+
* `canWrite ? "Add skills or tools" : "Propose a skill or tool"` — the same
|
|
19
|
+
* button, in the same spot, opening a different flow with different words
|
|
20
|
+
* depending on who pressed it. In the prototype's words, "the person who
|
|
21
|
+
* taught you the app could not tell you what you would see." Who reviews what
|
|
22
|
+
* is a property of the place, not of the door; the dialog behind `+` says so
|
|
23
|
+
* in its own copy.
|
|
24
|
+
*
|
|
25
|
+
* Weight follows stakes. Share is the one bounded button because it is the
|
|
26
|
+
* only action here with a consequence for other people. `+` is an icon —
|
|
27
|
+
* frequent and reversible. Everything else lives behind `⋯`.
|
|
28
|
+
*
|
|
29
|
+
* No chevron on Share, unlike a Knowledge page: a file can be shared at two
|
|
30
|
+
* scopes (itself, or its folder); a place has exactly one thing to share.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export interface PageActionsProps {
|
|
34
|
+
/**
|
|
35
|
+
* Opens Manage access. Omitted when there is no folder to manage — the
|
|
36
|
+
* personal page is the live case: its items are the ones in NO group, so
|
|
37
|
+
* there is no `access.md` behind them and a Share button would promise an
|
|
38
|
+
* editor with nothing to edit.
|
|
39
|
+
*/
|
|
40
|
+
onShare?: () => void;
|
|
41
|
+
/** Opens the add dialog. Never gated on role — see the note above. */
|
|
42
|
+
onAdd(): void;
|
|
43
|
+
/** Copies a link to this page. Resolves false if the clipboard refused. */
|
|
44
|
+
onCopyLink(): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Opens the delete confirmation. Present ONLY when the caller owns the
|
|
47
|
+
* place (`isOwner` — the same verdict the DELETE route enforces), which is
|
|
48
|
+
* the one gating exception to "everyone sees the same menu": an item that
|
|
49
|
+
* 404s for everyone but the owner is a broken promise, not a consistency.
|
|
50
|
+
*/
|
|
51
|
+
onDelete?: () => void;
|
|
52
|
+
/** Names the thing, for the `+` tooltip and the accessible names. */
|
|
53
|
+
addLabel?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function PageActions({
|
|
57
|
+
onShare,
|
|
58
|
+
onAdd,
|
|
59
|
+
onCopyLink,
|
|
60
|
+
onDelete,
|
|
61
|
+
addLabel = 'Add a skill or tool',
|
|
62
|
+
}: PageActionsProps) {
|
|
63
|
+
const [open, setOpen] = useState(false);
|
|
64
|
+
const [copied, setCopied] = useState<null | 'ok' | 'fail'>(null);
|
|
65
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
66
|
+
const close = useCallback(() => setOpen(false), []);
|
|
67
|
+
const menuRef = useDismissableMenu<HTMLDivElement>({
|
|
68
|
+
open,
|
|
69
|
+
onClose: close,
|
|
70
|
+
returnFocusTo: triggerRef,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const copy = useCallback(async () => {
|
|
74
|
+
close();
|
|
75
|
+
const ok = await onCopyLink();
|
|
76
|
+
setCopied(ok ? 'ok' : 'fail');
|
|
77
|
+
window.setTimeout(() => setCopied(null), 1800);
|
|
78
|
+
}, [close, onCopyLink]);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="flex flex-none items-center gap-1.5">
|
|
82
|
+
{onShare && (
|
|
83
|
+
<Button variant="outline" size="sm" onClick={onShare}>
|
|
84
|
+
<Users size={13} />
|
|
85
|
+
Share
|
|
86
|
+
</Button>
|
|
87
|
+
)}
|
|
88
|
+
|
|
89
|
+
<IconButton aria-label={addLabel} title={addLabel} onClick={onAdd}>
|
|
90
|
+
<Plus size={15} />
|
|
91
|
+
</IconButton>
|
|
92
|
+
|
|
93
|
+
<div className="relative">
|
|
94
|
+
<IconButton
|
|
95
|
+
ref={triggerRef}
|
|
96
|
+
aria-label="More actions"
|
|
97
|
+
aria-haspopup="menu"
|
|
98
|
+
aria-expanded={open}
|
|
99
|
+
active={open}
|
|
100
|
+
onClick={() => setOpen((v) => !v)}
|
|
101
|
+
>
|
|
102
|
+
<span aria-hidden className="text-strong leading-none">
|
|
103
|
+
⋯
|
|
104
|
+
</span>
|
|
105
|
+
</IconButton>
|
|
106
|
+
{open && (
|
|
107
|
+
<div ref={menuRef} className="absolute right-0 top-[calc(100%+5px)] z-40">
|
|
108
|
+
<MenuPanel role="menu" aria-label="More actions" className="min-w-[188px]">
|
|
109
|
+
<MenuItem role="menuitem" onClick={() => void copy()}>
|
|
110
|
+
<span className="flex items-center gap-2.5">
|
|
111
|
+
<Link2 size={14} />
|
|
112
|
+
Copy link
|
|
113
|
+
</span>
|
|
114
|
+
</MenuItem>
|
|
115
|
+
{/* "Leave this subscription" (proto:3020) is deliberately NOT
|
|
116
|
+
built yet: no backend endpoint stands behind it, and a menu
|
|
117
|
+
item that cannot do its job is worse than one that is not
|
|
118
|
+
there. The menu exists so it drops in without moving
|
|
119
|
+
anything. */}
|
|
120
|
+
{onDelete && (
|
|
121
|
+
<MenuItem
|
|
122
|
+
role="menuitem"
|
|
123
|
+
tone="danger"
|
|
124
|
+
onClick={() => {
|
|
125
|
+
close();
|
|
126
|
+
onDelete();
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
<span className="flex items-center gap-2.5">
|
|
130
|
+
<Trash2 size={14} />
|
|
131
|
+
Delete group
|
|
132
|
+
</span>
|
|
133
|
+
</MenuItem>
|
|
134
|
+
)}
|
|
135
|
+
</MenuPanel>
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
{/* The copy's answer, announced once. A clipboard write can be refused
|
|
141
|
+
outright on a non-secure origin, and a silent no-op is the worst
|
|
142
|
+
possible reply to "copy this". */}
|
|
143
|
+
<span
|
|
144
|
+
role="status"
|
|
145
|
+
aria-live="polite"
|
|
146
|
+
className={cn(
|
|
147
|
+
'text-meta transition-opacity',
|
|
148
|
+
copied ? 'opacity-100' : 'opacity-0',
|
|
149
|
+
copied === 'fail' ? 'text-danger' : 'text-ink-faint',
|
|
150
|
+
)}
|
|
151
|
+
>
|
|
152
|
+
{copied === 'ok' ? 'Link copied' : copied === 'fail' ? "Couldn't copy" : ''}
|
|
153
|
+
</span>
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DEFAULT_BRANCH, type PullRequestSummary } from '@bevel-software/platform-shared';
|
|
2
|
+
import { ChangeRequestDialog } from '../../change-requests/components/ChangeRequestDialog';
|
|
3
|
+
import { useLibrary, type LibraryItem } from '../state/library-data';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The review surface for a skill that does not exist yet.
|
|
7
|
+
*
|
|
8
|
+
* A released skill opens its own page, and the change requests against it hang
|
|
9
|
+
* off the file they touch. A PROPOSED skill has neither — there is no page,
|
|
10
|
+
* because there is no skill on the default branch to build one from — so the
|
|
11
|
+
* card opens the change request itself, which is the whole of what there is to
|
|
12
|
+
* read and the only place the decision can be made.
|
|
13
|
+
*
|
|
14
|
+
* `ChangeRequestDialog` needs no adapting for this: it always lists every file
|
|
15
|
+
* the request touches and diffs each against the default branch EXCEPT the
|
|
16
|
+
* ones the request adds, and every file of a new skill is added, so it renders
|
|
17
|
+
* the proposal as one green document and its Apply button records the
|
|
18
|
+
* approvals and merges. No scope either — a scope only ADDS a surface's
|
|
19
|
+
* released files to the list, and a proposal has none by definition.
|
|
20
|
+
*/
|
|
21
|
+
export function PendingSkillReview({
|
|
22
|
+
item,
|
|
23
|
+
onClose,
|
|
24
|
+
onResolved,
|
|
25
|
+
}: {
|
|
26
|
+
/** A `LibraryItem` carrying `pending` — anything else renders nothing. */
|
|
27
|
+
item: LibraryItem;
|
|
28
|
+
onClose(): void;
|
|
29
|
+
onResolved(): void;
|
|
30
|
+
}) {
|
|
31
|
+
const data = useLibrary();
|
|
32
|
+
const pending = item.pending;
|
|
33
|
+
if (!pending) return null;
|
|
34
|
+
|
|
35
|
+
// The real summary when the change-request list loaded, a stand-in when it
|
|
36
|
+
// did not. The dialog fetches its own detail and only reads the title,
|
|
37
|
+
// branch and author off this, all of which the pending entry already carries
|
|
38
|
+
// — so a failed list degrades to a plainer header, not to a dead card.
|
|
39
|
+
const cr =
|
|
40
|
+
data.crs.find((c) => c.number === pending.changeRequestNumber) ??
|
|
41
|
+
standInFor(item, pending);
|
|
42
|
+
|
|
43
|
+
return <ChangeRequestDialog cr={cr} onClose={onClose} onResolved={onResolved} />;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function standInFor(
|
|
47
|
+
item: LibraryItem,
|
|
48
|
+
pending: NonNullable<LibraryItem['pending']>,
|
|
49
|
+
): PullRequestSummary {
|
|
50
|
+
return {
|
|
51
|
+
number: pending.changeRequestNumber,
|
|
52
|
+
title: `New skill: ${item.name}`,
|
|
53
|
+
author: { login: '', name: pending.authorName },
|
|
54
|
+
appAuthor: { name: pending.authorName },
|
|
55
|
+
branch: pending.branch,
|
|
56
|
+
base: DEFAULT_BRANCH,
|
|
57
|
+
state: 'open',
|
|
58
|
+
createdAt: '',
|
|
59
|
+
touchedNodePaths: [],
|
|
60
|
+
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
61
|
+
url: `/change-requests/${pending.changeRequestNumber}`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Button, Dialog, Surface } from '../../../shared/components';
|
|
2
|
+
import { useAdmin } from '../../admin/state/admin.context';
|
|
3
|
+
import { NewSkillPanel } from './NewSkillPanel';
|
|
4
|
+
import { useLibraryToast } from '../state/toast.context';
|
|
5
|
+
import { COPIED_TOAST, COPY_FAILED_TOAST, copyToClipboard } from '../utils/clipboard';
|
|
6
|
+
|
|
7
|
+
export interface PersonalAddDialogProps {
|
|
8
|
+
/** The list's own name, e.g. `Juan's List` — the copy says it out loud. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Every skill name already in the catalog. The admin create half rejects collisions. */
|
|
11
|
+
existingSkills: string[];
|
|
12
|
+
onClose(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* "Add a skill or tool" for a person's own list — the prototype's
|
|
17
|
+
* `personalAddModal` (proto:3366-3369).
|
|
18
|
+
*
|
|
19
|
+
* The same role split as a group's add flow. Everyone can copy a prompt for
|
|
20
|
+
* their agent. Admins can also start an empty skill directly; non-admins do
|
|
21
|
+
* not get a placeholder they would have to finish in a separate follow-up.
|
|
22
|
+
*
|
|
23
|
+
* This page used to have no first door at all. The reason was real but narrow:
|
|
24
|
+
* the group dialog's first half was a LINK into the destination folder, and
|
|
25
|
+
* this page is defined as the items in no folder, so there was nothing to open.
|
|
26
|
+
* That objection died with the link: a personal skill has a perfectly definite
|
|
27
|
+
* home — the caller's own `Groups/personal-<id>/` folder, which
|
|
28
|
+
* `createEmptySkill` ensures through the provisioning endpoint before the
|
|
29
|
+
* first write. The folder's seeded access.md names you as its owner, so the
|
|
30
|
+
* write that follows passes the ordinary gate on its own merits — no
|
|
31
|
+
* permission special-case anywhere in this flow.
|
|
32
|
+
*/
|
|
33
|
+
export function PersonalAddDialog({ name, existingSkills, onClose }: PersonalAddDialogProps) {
|
|
34
|
+
const { isAdmin } = useAdmin();
|
|
35
|
+
const toast = useLibraryToast();
|
|
36
|
+
const prompt = `Help me build a new skill or tool at Bevel. Keep it to myself for now. It goes in my own list, not a group.`;
|
|
37
|
+
|
|
38
|
+
async function copyPrompt() {
|
|
39
|
+
const copied = await copyToClipboard(prompt);
|
|
40
|
+
toast(copied ? COPIED_TOAST : COPY_FAILED_TOAST, copied ? 'neutral' : 'danger');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Dialog
|
|
45
|
+
open
|
|
46
|
+
onClose={onClose}
|
|
47
|
+
title="Add a skill or tool"
|
|
48
|
+
footer={
|
|
49
|
+
<>
|
|
50
|
+
<Button variant="quiet" onClick={onClose}>
|
|
51
|
+
Close
|
|
52
|
+
</Button>
|
|
53
|
+
<Button variant="primary" onClick={() => void copyPrompt()}>
|
|
54
|
+
Copy prompt
|
|
55
|
+
</Button>
|
|
56
|
+
</>
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
<p className="text-ui text-ink-muted">
|
|
60
|
+
{`It lands in ${name}. Yours alone until you add it to a group.`}
|
|
61
|
+
</p>
|
|
62
|
+
|
|
63
|
+
{isAdmin && (
|
|
64
|
+
<>
|
|
65
|
+
<NewSkillPanel
|
|
66
|
+
destination={{ personal: true }}
|
|
67
|
+
existingSkills={existingSkills}
|
|
68
|
+
onCreated={onClose}
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
<div className="my-3.5 flex items-center gap-3">
|
|
72
|
+
<span aria-hidden="true" className="h-px flex-1 bg-line" />
|
|
73
|
+
<span className="text-meta text-ink-faint">or</span>
|
|
74
|
+
<span aria-hidden="true" className="h-px flex-1 bg-line" />
|
|
75
|
+
</div>
|
|
76
|
+
</>
|
|
77
|
+
)}
|
|
78
|
+
|
|
79
|
+
<p className="text-ui text-ink-muted">
|
|
80
|
+
Tell your agent what you need. It drafts the skill and puts it here.
|
|
81
|
+
</p>
|
|
82
|
+
|
|
83
|
+
<Surface tone="sunken" radius="md" elevation="none" padded className="mt-2.5">
|
|
84
|
+
<p className="font-mono text-detail text-ink">{prompt}</p>
|
|
85
|
+
</Surface>
|
|
86
|
+
</Dialog>
|
|
87
|
+
);
|
|
88
|
+
}
|