@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,254 +1,138 @@
|
|
|
1
1
|
import { useMemo, useState } from 'react';
|
|
2
2
|
import { useNavigate } from 'react-router-dom';
|
|
3
3
|
import '../library.css';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
toolStatus,
|
|
12
|
-
type AttentionStatus,
|
|
13
|
-
type LibraryCategory,
|
|
14
|
-
} from '../utils/status';
|
|
15
|
-
import { LibraryCard } from './LibraryCard';
|
|
16
|
-
import { LoadoutSidebar, type LoadoutRow } from './LoadoutSidebar';
|
|
17
|
-
import { DetailDialog, type DetailTarget } from './DetailDialog';
|
|
18
|
-
import { flyParticles } from './particles';
|
|
4
|
+
import { useLibrary, type LibraryItem } from '../state/library-data';
|
|
5
|
+
import { urlForItemFile } from '../routes/library-paths';
|
|
6
|
+
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
7
|
+
import { emptyMessageFor, filterLibraryItems, type LibraryFilter } from '../utils/status';
|
|
8
|
+
import { Banner, TextField } from '../../../shared/components';
|
|
9
|
+
import { GroupItemSections } from './group-page-parts';
|
|
10
|
+
import { PendingSkillReview } from './PendingSkillReview';
|
|
19
11
|
|
|
20
12
|
/**
|
|
21
|
-
* The Library — the
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
13
|
+
* The Library gallery — the card grid at `/skills-and-tools/everything` and its
|
|
14
|
+
* filtered views (`/owned`, and a group's cards).
|
|
15
|
+
*
|
|
16
|
+
* This is CONTENT only: the sidebar, the flex shell and the data live in
|
|
17
|
+
* `LibraryLayout` + `LibraryProvider` above it. The filter arrives as a prop
|
|
18
|
+
* because the URL owns selection now — there is no `useState<LibraryFilter>`
|
|
19
|
+
* anywhere, so a deep link, the back button and the sidebar can never disagree
|
|
20
|
+
* about what is selected.
|
|
21
|
+
*
|
|
22
|
+
* Two things it does not have, and won't:
|
|
23
|
+
*
|
|
24
|
+
* - the LOADOUT. It came from a retired mock; the prototype has no such
|
|
25
|
+
* concept, and it was a documented client-side stub, so nothing persisted
|
|
26
|
+
* was lost. Its rail is now the group nav.
|
|
27
|
+
* - Skills / Integrations filter chips. Groups are the structure, and a group
|
|
28
|
+
* owns its skills AND the tools they need, so splitting the catalog by kind
|
|
29
|
+
* showed a group's integrations detached from the reason they exist.
|
|
28
30
|
*/
|
|
29
|
-
export function LibraryPage() {
|
|
30
|
-
return (
|
|
31
|
-
<LoadoutProvider>
|
|
32
|
-
<LibraryToastProvider>
|
|
33
|
-
<LibraryPageInner />
|
|
34
|
-
</LibraryToastProvider>
|
|
35
|
-
</LoadoutProvider>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
/** The h1 names what the sidebar has selected, so the two never disagree. */
|
|
33
|
+
function headingFor(filter: LibraryFilter): string {
|
|
34
|
+
switch (filter.kind) {
|
|
35
|
+
case 'all':
|
|
36
|
+
return 'Everything';
|
|
37
|
+
case 'owned':
|
|
38
|
+
return 'Owned by me';
|
|
39
|
+
case 'ungrouped':
|
|
40
|
+
return 'Yours alone';
|
|
41
|
+
case 'group':
|
|
42
|
+
return filter.group;
|
|
43
|
+
}
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
function
|
|
49
|
-
const data =
|
|
50
|
-
const loadout = useLoadout();
|
|
51
|
-
const toast = useLibraryToast();
|
|
46
|
+
export function LibraryPage({ filter }: { filter: LibraryFilter }) {
|
|
47
|
+
const data = useLibrary();
|
|
52
48
|
const navigate = useNavigate();
|
|
53
|
-
const
|
|
49
|
+
const { kbDirName } = useWorkspace();
|
|
54
50
|
const [query, setQuery] = useState('');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const items: GalleryItem[] = useMemo(() => {
|
|
58
|
-
const skillItems: GalleryItem[] = data.skills.map((s) => ({
|
|
59
|
-
kind: 'skill',
|
|
60
|
-
id: s.name,
|
|
61
|
-
name: s.name,
|
|
62
|
-
description: s.description,
|
|
63
|
-
owned: data.ownedSkills.has(s.name),
|
|
64
|
-
status: skillStatus(
|
|
65
|
-
neededToolsFor({ allowedTools: data.allowedToolsBySkill.get(s.name) }, data.tools),
|
|
66
|
-
),
|
|
67
|
-
}));
|
|
68
|
-
const toolItems: GalleryItem[] = data.tools.map((t) => ({
|
|
69
|
-
kind: 'integration',
|
|
70
|
-
id: t.slug,
|
|
71
|
-
name: t.name,
|
|
72
|
-
// The browser tool surface exposes no human description for a `.tool`
|
|
73
|
-
// manual yet (see report) — the card stays clean, detail lives in ⓘ.
|
|
74
|
-
description: '',
|
|
75
|
-
owned: t.canWrite,
|
|
76
|
-
status: toolStatus(t),
|
|
77
|
-
}));
|
|
78
|
-
return [...skillItems, ...toolItems];
|
|
79
|
-
}, [data.skills, data.tools, data.ownedSkills, data.allowedToolsBySkill]);
|
|
51
|
+
/** The proposed skill being reviewed, if the reader opened one. */
|
|
52
|
+
const [reviewing, setReviewing] = useState<LibraryItem | null>(null);
|
|
80
53
|
|
|
81
54
|
const visible = useMemo(
|
|
82
|
-
() => filterLibraryItems(items,
|
|
83
|
-
[items,
|
|
55
|
+
() => filterLibraryItems(data.items, filter, query),
|
|
56
|
+
[data.items, filter, query],
|
|
84
57
|
);
|
|
85
58
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const byKey = new Map(items.map((i) => [`${i.kind}:${i.id}`, i]));
|
|
97
|
-
const pick = (kind: LoadoutKind, ids: string[]) =>
|
|
98
|
-
ids
|
|
99
|
-
.map((id) => byKey.get(`${kind}:${id}`))
|
|
100
|
-
.filter((i): i is GalleryItem => i !== undefined)
|
|
101
|
-
.map((i) => ({ kind, id: i.id, name: i.name, status: i.status }));
|
|
102
|
-
return [...pick('skill', loadout.skills), ...pick('integration', loadout.integrations)];
|
|
103
|
-
}, [items, loadout.skills, loadout.integrations]);
|
|
104
|
-
|
|
105
|
-
const attentionCount = rows.filter((r) => r.status.state !== 'ok').length;
|
|
106
|
-
|
|
107
|
-
function toggleItem(item: GalleryItem, fromRect?: DOMRect) {
|
|
108
|
-
const added = loadout.toggle(item.kind, item.id);
|
|
109
|
-
if (added) {
|
|
110
|
-
toast(
|
|
111
|
-
item.status.state === 'ok'
|
|
112
|
-
? `${item.name} added — ready to go`
|
|
113
|
-
: `${item.name} added — needs a quick sign-in`,
|
|
114
|
-
);
|
|
115
|
-
if (fromRect) flyParticles(fromRect, item.kind, item.id);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function openDetail(item: GalleryItem) {
|
|
120
|
-
if (item.kind === 'skill') {
|
|
121
|
-
const skill = data.skills.find((s) => s.name === item.id);
|
|
122
|
-
if (skill) setDetail({ kind: 'skill', skill, owned: item.owned });
|
|
123
|
-
} else {
|
|
124
|
-
const tool = data.tools.find((t) => t.slug === item.id);
|
|
125
|
-
if (tool) setDetail({ kind: 'integration', tool });
|
|
59
|
+
/**
|
|
60
|
+
* Both kinds open a PAGE now — the skill page landed alongside the tool one.
|
|
61
|
+
* A PROPOSED skill is the exception: it has no page, because the skill page
|
|
62
|
+
* reads the default branch and the skill is not on it yet. Its card opens the
|
|
63
|
+
* change request instead, which is the only thing there is to read.
|
|
64
|
+
*/
|
|
65
|
+
function openItem(item: LibraryItem) {
|
|
66
|
+
if (item.pending) {
|
|
67
|
+
setReviewing(item);
|
|
68
|
+
return;
|
|
126
69
|
}
|
|
70
|
+
if (kbDirName) navigate(urlForItemFile(kbDirName, item.path));
|
|
127
71
|
}
|
|
128
72
|
|
|
129
|
-
const chip = (cat: LibraryCategory, label: string, count: number) => (
|
|
130
|
-
<button
|
|
131
|
-
key={cat}
|
|
132
|
-
type="button"
|
|
133
|
-
aria-pressed={category === cat}
|
|
134
|
-
className={`flex items-center gap-1.5 rounded-full border px-4 py-1.5 text-[12.5px] font-semibold transition-all ${
|
|
135
|
-
category === cat
|
|
136
|
-
? 'border-[#7fd0c4] bg-gradient-to-br from-[#e6f7f4] to-[#d5f1ec] text-[#0f766e] shadow-[0_2px_10px_rgba(13,148,136,0.22)]'
|
|
137
|
-
: 'border-slate-200 bg-white text-slate-500 hover:border-[#7fd0c4] hover:text-slate-800'
|
|
138
|
-
}`}
|
|
139
|
-
onClick={() => setCategory(cat)}
|
|
140
|
-
>
|
|
141
|
-
{label}
|
|
142
|
-
<span
|
|
143
|
-
className={`rounded-full px-1.5 text-[10.5px] font-bold ${
|
|
144
|
-
category === cat ? 'bg-[#0d948826]' : 'bg-slate-900/5'
|
|
145
|
-
}`}
|
|
146
|
-
>
|
|
147
|
-
{count}
|
|
148
|
-
</span>
|
|
149
|
-
</button>
|
|
150
|
-
);
|
|
151
|
-
|
|
152
73
|
return (
|
|
153
|
-
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
onRemove={(row) => loadout.remove(row.kind, row.id)}
|
|
161
|
-
attentionCount={attentionCount}
|
|
162
|
-
onFinishSetup={() => navigate('/connect')}
|
|
163
|
-
/>
|
|
164
|
-
|
|
165
|
-
<main
|
|
166
|
-
className="min-w-0 flex-1 overflow-y-auto px-8 py-6"
|
|
167
|
-
style={{
|
|
168
|
-
background:
|
|
169
|
-
'radial-gradient(900px 500px at 85% -10%, rgba(13,148,136,.08), transparent 60%), radial-gradient(700px 500px at -10% 110%, rgba(59,130,246,.06), transparent 55%)',
|
|
170
|
-
}}
|
|
171
|
-
>
|
|
172
|
-
<div className="mb-1 flex items-center gap-4">
|
|
173
|
-
<div>
|
|
174
|
-
<h1 className="text-[26px] font-bold tracking-tight">Library</h1>
|
|
175
|
-
<div className="text-[13px] text-slate-500">
|
|
176
|
-
Click a card to add it to your loadout · open a card's details for more.
|
|
177
|
-
</div>
|
|
178
|
-
</div>
|
|
179
|
-
<div className="ml-auto flex w-64 items-center gap-2 rounded-[11px] border border-slate-200 bg-white px-3.5 py-2 shadow-[0_1px_4px_rgba(22,35,58,0.05)]">
|
|
180
|
-
<input
|
|
181
|
-
className="w-full bg-transparent text-[13px] outline-none placeholder:text-slate-400"
|
|
182
|
-
placeholder="Search the library…"
|
|
183
|
-
aria-label="Search the library"
|
|
184
|
-
value={query}
|
|
185
|
-
onChange={(e) => setQuery(e.target.value)}
|
|
186
|
-
/>
|
|
187
|
-
</div>
|
|
74
|
+
<>
|
|
75
|
+
<div className="flex items-start gap-4">
|
|
76
|
+
<div>
|
|
77
|
+
<h1 className="text-display font-semibold">{headingFor(filter)}</h1>
|
|
78
|
+
<p className="mt-0.5 text-ui text-ink-muted">
|
|
79
|
+
{data.loading ? '…' : `${visible.length} ${visible.length === 1 ? 'item' : 'items'}`}
|
|
80
|
+
</p>
|
|
188
81
|
</div>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
{
|
|
82
|
+
<TextField
|
|
83
|
+
className="ml-auto w-64"
|
|
84
|
+
placeholder="Search the library…"
|
|
85
|
+
aria-label="Search the library"
|
|
86
|
+
value={query}
|
|
87
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div className="mt-5" />
|
|
92
|
+
|
|
93
|
+
{data.error ? (
|
|
94
|
+
<Banner role="alert" tone="danger">
|
|
95
|
+
{data.error}
|
|
96
|
+
<button type="button" className="ml-3 font-semibold underline" onClick={data.reload}>
|
|
97
|
+
Try again
|
|
98
|
+
</button>
|
|
99
|
+
</Banner>
|
|
100
|
+
) : data.loading ? (
|
|
101
|
+
<div className="py-16 text-center text-ui text-ink-faint">Loading the library…</div>
|
|
102
|
+
) : visible.length === 0 ? (
|
|
103
|
+
<div className="py-16 text-center text-ui text-ink-faint">
|
|
104
|
+
{emptyMessageFor(filter, query)}
|
|
194
105
|
</div>
|
|
106
|
+
) : (
|
|
107
|
+
// Skills and tools, split — the same two bands a group page has.
|
|
108
|
+
// One undifferentiated grid made you read every card's body to learn
|
|
109
|
+
// what kind of thing it was; the heading does that now, once, for a
|
|
110
|
+
// whole band. A band with nothing in it is dropped rather than shown
|
|
111
|
+
// empty: this is a search result, not an inventory of what could be.
|
|
112
|
+
<div className="pb-14">
|
|
113
|
+
<GroupItemSections
|
|
114
|
+
skillItems={visible.filter((i) => i.kind === 'skill')}
|
|
115
|
+
toolItems={visible.filter((i) => i.kind === 'integration')}
|
|
116
|
+
onOpen={openItem}
|
|
117
|
+
hideEmpty
|
|
118
|
+
emptySkills=""
|
|
119
|
+
/>
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
195
122
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
<div className="py-16 text-center text-sm text-slate-400">Nothing here matches yet.</div>
|
|
207
|
-
) : (
|
|
208
|
-
<div className="lib-grid grid grid-cols-[repeat(auto-fill,minmax(228px,1fr))] gap-5 pb-14">
|
|
209
|
-
{visible.map((item) => (
|
|
210
|
-
<LibraryCard
|
|
211
|
-
key={`${item.kind}:${item.id}`}
|
|
212
|
-
kind={item.kind}
|
|
213
|
-
id={item.id}
|
|
214
|
-
name={item.name}
|
|
215
|
-
description={item.description}
|
|
216
|
-
owned={item.owned}
|
|
217
|
-
status={item.status}
|
|
218
|
-
picked={loadout.isIn(item.kind, item.id)}
|
|
219
|
-
onToggle={(rect) => toggleItem(item, rect)}
|
|
220
|
-
onInfo={() => openDetail(item)}
|
|
221
|
-
/>
|
|
222
|
-
))}
|
|
223
|
-
</div>
|
|
224
|
-
)}
|
|
225
|
-
</main>
|
|
226
|
-
|
|
227
|
-
{detail && (
|
|
228
|
-
<DetailDialog
|
|
229
|
-
target={detail}
|
|
230
|
-
tools={data.tools}
|
|
231
|
-
skills={data.skills}
|
|
232
|
-
allowedToolsBySkill={data.allowedToolsBySkill}
|
|
233
|
-
crs={data.crs}
|
|
234
|
-
myCrNumbers={data.myCrNumbers}
|
|
235
|
-
inLoadout={
|
|
236
|
-
detail.kind === 'skill'
|
|
237
|
-
? loadout.isIn('skill', detail.skill.name)
|
|
238
|
-
: loadout.isIn('integration', detail.tool.slug)
|
|
239
|
-
}
|
|
240
|
-
onToggleLoadout={() => {
|
|
241
|
-
const item = items.find(
|
|
242
|
-
(i) =>
|
|
243
|
-
i.kind === (detail.kind === 'skill' ? 'skill' : 'integration') &&
|
|
244
|
-
i.id === (detail.kind === 'skill' ? detail.skill.name : detail.tool.slug),
|
|
245
|
-
);
|
|
246
|
-
if (item) toggleItem(item);
|
|
123
|
+
{reviewing && (
|
|
124
|
+
<PendingSkillReview
|
|
125
|
+
item={reviewing}
|
|
126
|
+
onClose={() => setReviewing(null)}
|
|
127
|
+
onResolved={() => {
|
|
128
|
+
setReviewing(null);
|
|
129
|
+
// The skill leaves the review shelf and joins the catalog by the
|
|
130
|
+
// same reload — one load answers both, so the card cannot appear
|
|
131
|
+
// twice in the frame between them.
|
|
132
|
+
data.reload();
|
|
247
133
|
}}
|
|
248
|
-
onClose={() => setDetail(null)}
|
|
249
|
-
onDataChanged={data.reload}
|
|
250
134
|
/>
|
|
251
135
|
)}
|
|
252
|
-
|
|
136
|
+
</>
|
|
253
137
|
);
|
|
254
138
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lock. One shape, three places: the sidebar's count box, the `Locked`
|
|
3
|
+
* badge on a group's page, and the all-groups index rows.
|
|
4
|
+
*
|
|
5
|
+
* Inline rather than an icon-library import because it is drawn ~20px wide in
|
|
6
|
+
* a fixed slot and has to inherit `currentColor` from the row it sits in —
|
|
7
|
+
* a dependency for two paths is a dependency for nothing.
|
|
8
|
+
*
|
|
9
|
+
* `aria-hidden` is NOT an oversight: every caller already carries the word in
|
|
10
|
+
* text or in an `aria-label`/`title` ("Finance (locked)", the `Locked` badge).
|
|
11
|
+
* A named glyph beside a named row would say "locked" twice to a screen reader
|
|
12
|
+
* and once to everyone else.
|
|
13
|
+
*/
|
|
14
|
+
export function LockGlyph({ className }: { className?: string }) {
|
|
15
|
+
return (
|
|
16
|
+
<svg
|
|
17
|
+
className={className}
|
|
18
|
+
aria-hidden="true"
|
|
19
|
+
focusable="false"
|
|
20
|
+
viewBox="0 0 24 24"
|
|
21
|
+
fill="none"
|
|
22
|
+
stroke="currentColor"
|
|
23
|
+
strokeWidth={2}
|
|
24
|
+
strokeLinecap="round"
|
|
25
|
+
strokeLinejoin="round"
|
|
26
|
+
>
|
|
27
|
+
<rect x="5" y="11" width="14" height="9" rx="2" />
|
|
28
|
+
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
|
|
29
|
+
</svg>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { Badge, Button, Surface } from '../../../shared/components';
|
|
4
|
+
import { pathForGroupsIndex } from '../routes/library-paths';
|
|
5
|
+
import { ownersTextOf, primaryFolderOf } from '../utils/group-summary';
|
|
6
|
+
import { AlreadyReadableError, requestGroupAccess, type GroupSummary } from '../services/groups.api';
|
|
7
|
+
import { firstNames, joinNames } from '../utils/names';
|
|
8
|
+
import { useLibraryToast } from '../state/toast.context';
|
|
9
|
+
import { LockGlyph } from './LockGlyph';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A group you cannot read, as a place you can still stand in.
|
|
13
|
+
*
|
|
14
|
+
* Reaching this view means the caller could read the group's `access.md`
|
|
15
|
+
* file (the `read: everyone` discovery grant in its frontmatter) but not the
|
|
16
|
+
* folder — the same tier the backend used to include the summary at all. It
|
|
17
|
+
* states four facts and offers one action: the group exists, who runs it,
|
|
18
|
+
* how much is in it, and how to ask. Item names and descriptions stay
|
|
19
|
+
* members-only; asking opens a plain change request that the group's
|
|
20
|
+
* writers approve by merging.
|
|
21
|
+
*
|
|
22
|
+
* It is the SAME frame as the member view — breadcrumb, h1, run-by lede — so
|
|
23
|
+
* the two never read as different products. Only the middle changes.
|
|
24
|
+
*
|
|
25
|
+
* `Manage access` is the escape hatch for a locked-out platform Admin. Admin
|
|
26
|
+
* rescue applies to WRITING `access.md`, not to reading the folder, so an Admin
|
|
27
|
+
* can genuinely be locked out of a group they are nevertheless the right person
|
|
28
|
+
* to unlock. `canWrite` is exactly that verdict, which is why the button hangs
|
|
29
|
+
* off it and not off any role check.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export interface LockedGroupViewProps {
|
|
33
|
+
group: GroupSummary;
|
|
34
|
+
/** A request landed — refetch the index so `hasRequested` comes back true. */
|
|
35
|
+
onRequested(): void;
|
|
36
|
+
/** Access was already granted: reload everything and let the group open. */
|
|
37
|
+
onUnlocked(): void;
|
|
38
|
+
/** Open `ManageAccessDialog` on this repo-relative folder. */
|
|
39
|
+
onManage(folder: string): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function LockedGroupView({ group, onRequested, onUnlocked, onManage }: LockedGroupViewProps) {
|
|
43
|
+
const toast = useLibraryToast();
|
|
44
|
+
const [requesting, setRequesting] = useState(false);
|
|
45
|
+
const [requested, setRequested] = useState(false);
|
|
46
|
+
|
|
47
|
+
const admins = adminNamesOf(group);
|
|
48
|
+
// The prose name for the same people, from the SAME helper the member view
|
|
49
|
+
// uses — a group has to describe itself identically on both sides of the lock.
|
|
50
|
+
const adminsText = ownersTextOf(group);
|
|
51
|
+
const primaryFolder = primaryFolderOf(group);
|
|
52
|
+
const pending = group.hasRequested || requested;
|
|
53
|
+
|
|
54
|
+
async function request() {
|
|
55
|
+
setRequesting(true);
|
|
56
|
+
try {
|
|
57
|
+
await requestGroupAccess(group.name);
|
|
58
|
+
setRequested(true);
|
|
59
|
+
toast(
|
|
60
|
+
`Asked ${admins.length > 0 ? joinNames(firstNames(admins)) : 'the admins'}. You get its skills and tools if they let you in.`,
|
|
61
|
+
);
|
|
62
|
+
onRequested();
|
|
63
|
+
} catch (err) {
|
|
64
|
+
// Access arrived between the page load and the click. Nothing went
|
|
65
|
+
// wrong — the group is simply open now, so open it.
|
|
66
|
+
if (err instanceof AlreadyReadableError) {
|
|
67
|
+
// Released BEFORE handing off, because `onUnlocked` is not guaranteed
|
|
68
|
+
// to swap this view out synchronously — if it kicks off an async
|
|
69
|
+
// reload, this component renders again in the meantime and the button
|
|
70
|
+
// would be stuck disabled with nothing left to re-enable it.
|
|
71
|
+
setRequesting(false);
|
|
72
|
+
onUnlocked();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
toast("Couldn't send that: try again.", 'danger');
|
|
76
|
+
setRequesting(false);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="pb-14">
|
|
82
|
+
<nav aria-label="Breadcrumb" className="flex items-center gap-1.5 text-detail text-ink-faint">
|
|
83
|
+
<Link to={pathForGroupsIndex()} className="rounded-xs hover:text-ink">
|
|
84
|
+
All groups
|
|
85
|
+
</Link>
|
|
86
|
+
<span aria-hidden="true">›</span>
|
|
87
|
+
<span aria-current="page" className="truncate text-ink-muted">
|
|
88
|
+
{group.name}
|
|
89
|
+
</span>
|
|
90
|
+
</nav>
|
|
91
|
+
|
|
92
|
+
<div className="mt-1.5 flex items-center gap-2.5">
|
|
93
|
+
<h1 className="text-display font-semibold">{group.name}</h1>
|
|
94
|
+
<Badge tone="outline" size="sm">
|
|
95
|
+
<LockGlyph className="size-3 shrink-0" />
|
|
96
|
+
Locked
|
|
97
|
+
</Badge>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<p className="mt-1 text-lede text-ink-muted">{`Run by ${adminsText}.`}</p>
|
|
101
|
+
|
|
102
|
+
{/* Volume, never contents. A number tells you whether it is worth asking
|
|
103
|
+
to join; a name would tell you what is inside. */}
|
|
104
|
+
<p className="mt-1 text-ui text-ink-muted">{countsLine(group)}</p>
|
|
105
|
+
|
|
106
|
+
<div className="mt-5">
|
|
107
|
+
{pending ? (
|
|
108
|
+
<Surface tone="sunken" radius="lg" elevation="none" padded className="max-w-lg">
|
|
109
|
+
<p className="text-body">
|
|
110
|
+
{`Requested: ${adminsText} ${admins.length === 1 ? 'decides' : 'decide'} who joins.`}
|
|
111
|
+
</p>
|
|
112
|
+
</Surface>
|
|
113
|
+
) : (
|
|
114
|
+
<Button variant="primary" disabled={requesting} onClick={() => void request()}>
|
|
115
|
+
Subscribe to its skills and tools
|
|
116
|
+
</Button>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
{group.canWrite && primaryFolder && (
|
|
121
|
+
<div className="mt-3">
|
|
122
|
+
<Button variant="quiet" onClick={() => onManage(primaryFolder)}>
|
|
123
|
+
Manage access
|
|
124
|
+
</Button>
|
|
125
|
+
</div>
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* `{n} skills · {n} tools — visible to members only.`
|
|
133
|
+
*
|
|
134
|
+
* Singular is honoured here (unlike the index rows' fixed-width label) because
|
|
135
|
+
* this is a sentence somebody reads, not a column that has to line up.
|
|
136
|
+
*/
|
|
137
|
+
function countsLine(group: Pick<GroupSummary, 'skillCount' | 'toolCount'>): string {
|
|
138
|
+
const skills = `${group.skillCount} ${group.skillCount === 1 ? 'skill' : 'skills'}`;
|
|
139
|
+
const tools = `${group.toolCount} ${group.toolCount === 1 ? 'tool' : 'tools'}`;
|
|
140
|
+
return `${skills} · ${tools}. Visible to members only.`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The people `ownersTextOf` names, as a list.
|
|
145
|
+
*
|
|
146
|
+
* Mirrors that helper's chain exactly — owners, else writers, else nobody — so
|
|
147
|
+
* the sentence and the count of subjects in it can never disagree. It is a
|
|
148
|
+
* separate function only because the toast needs the NAMES (to take first
|
|
149
|
+
* names) and the verb needs the COUNT, and prose gives back neither.
|
|
150
|
+
*/
|
|
151
|
+
function adminNamesOf(group: Pick<GroupSummary, 'owners' | 'writers'>): string[] {
|
|
152
|
+
const owners = [...group.owners.users.map((u) => u.name), ...group.owners.roles];
|
|
153
|
+
const named = owners.filter((s) => s.length > 0);
|
|
154
|
+
if (named.length > 0) return named;
|
|
155
|
+
return [...group.writers.users.map((u) => u.name), ...group.writers.roles].filter(
|
|
156
|
+
(s) => s.length > 0,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { useLibrary } from '../state/library-data';
|
|
3
|
+
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
4
|
+
import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
|
|
5
|
+
import { GroupJoinRequests } from './GroupJoinRequests';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Every pending join request the CALLER can answer, one banner per group they
|
|
9
|
+
* manage.
|
|
10
|
+
*
|
|
11
|
+
* It belongs on whatever page the Library opens on — nobody visits a group to
|
|
12
|
+
* find out that somebody wants into it, so the landing view is the one place a
|
|
13
|
+
* request is guaranteed to be seen. That page is the all-groups index now; it
|
|
14
|
+
* was the Everything gallery before, and this component exists so the surface
|
|
15
|
+
* could move without being rebuilt. The group's own page carries the identical
|
|
16
|
+
* banner for the person who is already there.
|
|
17
|
+
*
|
|
18
|
+
* It fetches per group and renders nothing for a group with nothing pending, so
|
|
19
|
+
* mounting it on a page is not a promise that anything will appear.
|
|
20
|
+
*/
|
|
21
|
+
export function ManagedGroupRequests() {
|
|
22
|
+
const { groupSummaries, reload, reloadGroups } = useLibrary();
|
|
23
|
+
const { kbDirName } = useWorkspace();
|
|
24
|
+
/** Repo-relative folder whose `access.md` the Manage-access dialog is on. */
|
|
25
|
+
const [manageFolder, setManageFolder] = useState<string | null>(null);
|
|
26
|
+
/** Bumped when an access edit lands, so the request surfaces refetch. */
|
|
27
|
+
const [accessRevision, setAccessRevision] = useState(0);
|
|
28
|
+
|
|
29
|
+
const managed = useMemo(
|
|
30
|
+
() =>
|
|
31
|
+
groupSummaries
|
|
32
|
+
.filter((g) => g.canWrite)
|
|
33
|
+
.slice()
|
|
34
|
+
.sort((a, b) => a.name.localeCompare(b.name)),
|
|
35
|
+
[groupSummaries],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
{managed.map((g) => (
|
|
41
|
+
<GroupJoinRequests
|
|
42
|
+
key={g.name}
|
|
43
|
+
group={g.name}
|
|
44
|
+
folders={g.folders}
|
|
45
|
+
onManage={setManageFolder}
|
|
46
|
+
reloadSignal={accessRevision}
|
|
47
|
+
/>
|
|
48
|
+
))}
|
|
49
|
+
|
|
50
|
+
{/* `kbDirName` gates it — the resolver addresses files repo-relative
|
|
51
|
+
and the dialog strips that prefix, so without it the path we hand
|
|
52
|
+
over is not the path we mean. */}
|
|
53
|
+
{manageFolder && kbDirName && (
|
|
54
|
+
<ManageAccessDialog
|
|
55
|
+
entry={{
|
|
56
|
+
name: manageFolder.split('/').pop() ?? manageFolder,
|
|
57
|
+
relativePath: `${kbDirName}/${manageFolder}`,
|
|
58
|
+
type: 'directory',
|
|
59
|
+
}}
|
|
60
|
+
onClose={() => {
|
|
61
|
+
setManageFolder(null);
|
|
62
|
+
reloadGroups();
|
|
63
|
+
reload();
|
|
64
|
+
setAccessRevision((r) => r + 1);
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
}
|