@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,373 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Link, useNavigate, useParams } from 'react-router-dom';
|
|
3
|
+
import { Banner, Button } from '../../../shared/components';
|
|
4
|
+
import { attentionOf, useLibrary, type LibraryItem } from '../state/library-data';
|
|
5
|
+
import { useLibraryToast } from '../state/toast.context';
|
|
6
|
+
import {
|
|
7
|
+
decodeGroupSegment,
|
|
8
|
+
pathForGroupsIndex,
|
|
9
|
+
urlForItemFile,
|
|
10
|
+
} from '../routes/library-paths';
|
|
11
|
+
import { primaryFolderOf } from '../utils/group-summary';
|
|
12
|
+
import { GroupJoinRequests } from './GroupJoinRequests';
|
|
13
|
+
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
14
|
+
import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
|
|
15
|
+
import { AddToGroupDialog } from './AddToGroupDialog';
|
|
16
|
+
import { BandControls, GroupBreadcrumb, GroupItemSections, PageNote, RemoveLibraryItemDialog,
|
|
17
|
+
} from './group-page-parts';
|
|
18
|
+
import { DeleteGroupDialog } from './DeleteGroupDialog';
|
|
19
|
+
import { PageActions } from './PageActions';
|
|
20
|
+
import { copyToClipboard } from '../utils/clipboard';
|
|
21
|
+
import { LockedGroupView } from './LockedGroupView';
|
|
22
|
+
import { PendingSkillReview } from './PendingSkillReview';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One group, as a place: `/skills-and-tools/groups/:group`.
|
|
26
|
+
*
|
|
27
|
+
* A group is a KB folder, so this page is the folder made legible — its skills
|
|
28
|
+
* and the tools those skills need, side by side, with who runs it and who it is
|
|
29
|
+
* shared with in one line above them. The sidebar and the gallery could already
|
|
30
|
+
* FILTER to a group; what they could not do is be linked to, bookmarked, or
|
|
31
|
+
* handed to somebody. That is the whole difference this page makes.
|
|
32
|
+
*
|
|
33
|
+
* WHICH VIEW: the page decides member-vs-locked, not the router and not the
|
|
34
|
+
* sidebar. The member view renders when the folder verdict says `canRead`, OR
|
|
35
|
+
* when the caller's catalog already contains an item in the group (a per-file
|
|
36
|
+
* grant can hand somebody one skill inside a folder they cannot read). Locked
|
|
37
|
+
* means: the summary says no AND the catalog agrees — which can only happen
|
|
38
|
+
* for a DISCOVERABLE group, because an undiscoverable one never reaches this
|
|
39
|
+
* page's data at all and renders like one that does not exist.
|
|
40
|
+
*/
|
|
41
|
+
export function GroupPage() {
|
|
42
|
+
const params = useParams();
|
|
43
|
+
const group = decodeGroupSegment(params.group ?? '');
|
|
44
|
+
const data = useLibrary();
|
|
45
|
+
const toast = useLibraryToast();
|
|
46
|
+
const navigate = useNavigate();
|
|
47
|
+
const { kbDirName } = useWorkspace();
|
|
48
|
+
const [addOpen, setAddOpen] = useState(false);
|
|
49
|
+
// The Skills band's two controls. `filterOn` narrows the band to what is
|
|
50
|
+
// waiting on the reader; `refresh` re-reads the catalog and then says when it
|
|
51
|
+
// last did, because "nothing changed" and "nothing was checked" otherwise
|
|
52
|
+
// look identical. Both are page state — neither belongs in the URL, since
|
|
53
|
+
// neither is a place you would link someone to.
|
|
54
|
+
const [filterOn, setFilterOn] = useState(false);
|
|
55
|
+
const [refreshState, setRefreshState] = useState<'idle' | 'spin' | 'done'>('idle');
|
|
56
|
+
/** Repo-relative folder whose `access.md` the Manage-access dialog is on. */
|
|
57
|
+
const [manageFolder, setManageFolder] = useState<string | null>(null);
|
|
58
|
+
/** Bumped when an access edit lands, so the join-request surface refetches. */
|
|
59
|
+
const [accessRevision, setAccessRevision] = useState(0);
|
|
60
|
+
/** The proposed skill being reviewed, if the reader opened one. */
|
|
61
|
+
const [reviewing, setReviewing] = useState<LibraryItem | null>(null);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* "Last updated just now" has to be TRUE.
|
|
65
|
+
*
|
|
66
|
+
* Both refetches behind the refresh button are revision bumps that return
|
|
67
|
+
* `void` — there is no promise to await, so a timer was standing in for
|
|
68
|
+
* completion and would claim success while the catalog was still in flight,
|
|
69
|
+
* or after it had failed outright. The loads report themselves instead:
|
|
70
|
+
* `spin` ends the moment both have settled, and a failure returns the button
|
|
71
|
+
* rather than printing a freshness claim the page cannot back up (the error
|
|
72
|
+
* itself is surfaced by the gallery banner, which owns it).
|
|
73
|
+
*
|
|
74
|
+
* `sawLoading` is the part that is easy to leave out and wrong without: "both
|
|
75
|
+
* loads are settled" is also true of the instant BEFORE the refetch starts,
|
|
76
|
+
* and of an unrelated load that was already in flight settling first. So the
|
|
77
|
+
* spin only ends on a settle that FOLLOWS a loading phase this click caused.
|
|
78
|
+
* `reloadGroups()` raises `groupsLoading` synchronously, so that phase is
|
|
79
|
+
* guaranteed to be observed — and if it somehow were not, the button keeps
|
|
80
|
+
* spinning, which is the failure worth having.
|
|
81
|
+
*/
|
|
82
|
+
const sawLoading = useRef(false);
|
|
83
|
+
const spinning = refreshState === 'spin';
|
|
84
|
+
const loadsSettled = !data.loading && !data.groupsLoading;
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!spinning) return;
|
|
87
|
+
if (!loadsSettled) {
|
|
88
|
+
sawLoading.current = true;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!sawLoading.current) return;
|
|
92
|
+
sawLoading.current = false;
|
|
93
|
+
setRefreshState(data.error || data.groupsError ? 'idle' : 'done');
|
|
94
|
+
}, [spinning, loadsSettled, data.error, data.groupsError]);
|
|
95
|
+
|
|
96
|
+
// The freshness line decays on its own — that one IS a clock, and it is the
|
|
97
|
+
// only timer left. Cleared on unmount rather than left to fire into a
|
|
98
|
+
// component that is gone.
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (refreshState !== 'done') return;
|
|
101
|
+
const timer = window.setTimeout(() => setRefreshState('idle'), 4000);
|
|
102
|
+
return () => window.clearTimeout(timer);
|
|
103
|
+
}, [refreshState]);
|
|
104
|
+
|
|
105
|
+
/** The card being removed, while its confirm dialog is up. */
|
|
106
|
+
const [removing, setRemoving] = useState<LibraryItem | null>(null);
|
|
107
|
+
/** Whether the group's own delete confirmation is up. */
|
|
108
|
+
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
109
|
+
|
|
110
|
+
const summary = useMemo(
|
|
111
|
+
() => data.groupSummaries.find((g) => g.name === group) ?? null,
|
|
112
|
+
[data.groupSummaries, group],
|
|
113
|
+
);
|
|
114
|
+
const groupItems = useMemo(
|
|
115
|
+
() => data.items.filter((i) => i.group === group),
|
|
116
|
+
[data.items, group],
|
|
117
|
+
);
|
|
118
|
+
/** For the add dialog's name check — global, because a skill's id is global. */
|
|
119
|
+
const allSkillNames = useMemo(
|
|
120
|
+
() => data.items.filter((i) => i.kind === 'skill').map((i) => i.name),
|
|
121
|
+
[data.items],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const skillItems = groupItems.filter((i) => i.kind === 'skill');
|
|
125
|
+
const toolItems = groupItems.filter((i) => i.kind === 'integration');
|
|
126
|
+
const attention = attentionOf(data.items, group);
|
|
127
|
+
// What the Skills band actually renders. The filter is a VIEW over the band,
|
|
128
|
+
// not a different query — flipping it back must show exactly what was there.
|
|
129
|
+
const shownSkills = filterOn ? skillItems.filter((i) => i.status.state !== 'ok') : skillItems;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Both kinds open a PAGE — `skills/:name` has landed, so the contract this
|
|
133
|
+
* function used to carry is discharged and the dialog is gone. Kept identical
|
|
134
|
+
* to `LibraryPage.openItem` on purpose: a card must do the same thing
|
|
135
|
+
* wherever you clicked it — including the proposed-skill case, which opens
|
|
136
|
+
* its change request because it has no page to open.
|
|
137
|
+
*/
|
|
138
|
+
function openItem(item: LibraryItem) {
|
|
139
|
+
if (item.pending) {
|
|
140
|
+
setReviewing(item);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (kbDirName) navigate(urlForItemFile(kbDirName, item.path));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* THE access surface — one dialog, two openers: the title row's `Share` and
|
|
148
|
+
* the Manage-access affordances. There is deliberately no read-only sibling:
|
|
149
|
+
* the dialog itself degrades to read-only when the resolved verdict says the
|
|
150
|
+
* caller cannot write, so a second "view access" panel would be the same
|
|
151
|
+
* information twice.
|
|
152
|
+
*
|
|
153
|
+
* `kbDirName` gates it because the resolver addresses files repo-relative and
|
|
154
|
+
* the dialog strips that prefix — without it the path we would hand over is
|
|
155
|
+
* not the path we mean. Same guard the skill dialog uses.
|
|
156
|
+
*/
|
|
157
|
+
const manageDialog =
|
|
158
|
+
manageFolder && kbDirName ? (
|
|
159
|
+
<ManageAccessDialog
|
|
160
|
+
entry={{
|
|
161
|
+
name: manageFolder.split('/').pop() ?? manageFolder,
|
|
162
|
+
relativePath: `${kbDirName}/${manageFolder}`,
|
|
163
|
+
type: 'directory',
|
|
164
|
+
}}
|
|
165
|
+
onClose={() => {
|
|
166
|
+
setManageFolder(null);
|
|
167
|
+
// Granting through the dialog can settle a pending join request —
|
|
168
|
+
// refresh the roster, the catalog and the request surface together.
|
|
169
|
+
data.reloadGroups();
|
|
170
|
+
data.reload();
|
|
171
|
+
setAccessRevision((r) => r + 1);
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
) : null;
|
|
175
|
+
|
|
176
|
+
// Nothing has spoken yet: the catalog is still loading, the group index is
|
|
177
|
+
// still loading, and no item has proven the group exists. Deciding now would
|
|
178
|
+
// flash "doesn't exist" (or a locked splash) at somebody who is simply early.
|
|
179
|
+
if (groupItems.length === 0 && (data.loading || data.groupsLoading)) {
|
|
180
|
+
return <PageNote>Loading the library…</PageNote>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (summary && !summary.canRead && groupItems.length === 0) {
|
|
184
|
+
return (
|
|
185
|
+
<>
|
|
186
|
+
<LockedGroupView
|
|
187
|
+
group={summary}
|
|
188
|
+
onRequested={data.reloadGroups}
|
|
189
|
+
onUnlocked={() => {
|
|
190
|
+
data.reload();
|
|
191
|
+
data.reloadGroups();
|
|
192
|
+
}}
|
|
193
|
+
onManage={setManageFolder}
|
|
194
|
+
/>
|
|
195
|
+
{manageDialog}
|
|
196
|
+
</>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// No summary, no items, and the endpoint did NOT fail — the group really is
|
|
201
|
+
// not there. With a failed endpoint the honest answer is the degraded member
|
|
202
|
+
// view below, because "we couldn't ask" is not "it doesn't exist".
|
|
203
|
+
if (!summary && groupItems.length === 0 && !data.groupsError) {
|
|
204
|
+
return (
|
|
205
|
+
<div className="py-16 text-center">
|
|
206
|
+
<p className="text-ui text-ink-faint">{"This group doesn't exist yet."}</p>
|
|
207
|
+
<Link
|
|
208
|
+
to={pathForGroupsIndex()}
|
|
209
|
+
className="mt-2 inline-block rounded-xs text-ui font-semibold text-ink underline"
|
|
210
|
+
>
|
|
211
|
+
All groups
|
|
212
|
+
</Link>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const primaryFolder = summary ? primaryFolderOf(summary) : null;
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<div className="pb-14">
|
|
221
|
+
<GroupBreadcrumb name={group} />
|
|
222
|
+
|
|
223
|
+
{/* The title row carries the page's one persistent action. `Share` IS
|
|
224
|
+
the manage-access dialog — not a doorway to it. It stays un-gated:
|
|
225
|
+
for a non-writer the dialog renders read-only (its own `canWrite`
|
|
226
|
+
verdict decides), which is exactly what "who is this shared with?"
|
|
227
|
+
should answer. Hidden only when no folder is known to manage. */}
|
|
228
|
+
{/* Three actions, beside the title, for everyone (proto:3012-3025).
|
|
229
|
+
Share stays un-gated: for a non-writer the dialog renders read-only,
|
|
230
|
+
which is exactly what "who is this shared with?" should answer. */}
|
|
231
|
+
<div className="flex items-start justify-between gap-4">
|
|
232
|
+
<h1 className="mt-1.5 text-display font-semibold">{group}</h1>
|
|
233
|
+
<div className="mt-1.5">
|
|
234
|
+
<PageActions
|
|
235
|
+
onShare={primaryFolder ? () => setManageFolder(primaryFolder) : undefined}
|
|
236
|
+
onAdd={() => setAddOpen(true)}
|
|
237
|
+
onCopyLink={() => copyToClipboard(window.location.href)}
|
|
238
|
+
// The OWNER's verb — `isOwner` is the same verdict the DELETE
|
|
239
|
+
// route enforces, so the item appears for exactly the people the
|
|
240
|
+
// backend will let through.
|
|
241
|
+
onDelete={summary?.isOwner ? () => setDeleteOpen(true) : undefined}
|
|
242
|
+
addLabel={`Add a skill or tool to ${group}`}
|
|
243
|
+
/>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
|
|
247
|
+
{/* Somebody is waiting on the person reading this. Rendered only for a
|
|
248
|
+
group manager (canWrite) — every member can see the CRs elsewhere,
|
|
249
|
+
but only the people who can act on a request get its banner. */}
|
|
250
|
+
{summary?.canWrite && (
|
|
251
|
+
<GroupJoinRequests
|
|
252
|
+
group={group}
|
|
253
|
+
folders={summary.folders}
|
|
254
|
+
onManage={setManageFolder}
|
|
255
|
+
reloadSignal={accessRevision}
|
|
256
|
+
className="mt-4"
|
|
257
|
+
/>
|
|
258
|
+
)}
|
|
259
|
+
|
|
260
|
+
{attention > 0 && (
|
|
261
|
+
<Banner role="status" tone="wait" className="mt-4">
|
|
262
|
+
<span>
|
|
263
|
+
{`${attention} ${
|
|
264
|
+
attention === 1
|
|
265
|
+
? 'integration needs setup: connect it'
|
|
266
|
+
: 'integrations need setup: connect them'
|
|
267
|
+
} to unblock this group's skills.`}
|
|
268
|
+
</span>{' '}
|
|
269
|
+
<Button variant="outline" size="tiny" onClick={() => navigate('/connect')}>
|
|
270
|
+
Finish setup
|
|
271
|
+
</Button>
|
|
272
|
+
</Banner>
|
|
273
|
+
)}
|
|
274
|
+
|
|
275
|
+
<GroupItemSections
|
|
276
|
+
skillItems={shownSkills}
|
|
277
|
+
toolItems={toolItems}
|
|
278
|
+
onOpen={openItem}
|
|
279
|
+
// Removal is the GROUP MANAGER's verb — the same canWrite that lets
|
|
280
|
+
// them answer join requests. The backend's per-path gate enforces it
|
|
281
|
+
// for real; this only decides who sees the affordance.
|
|
282
|
+
onRemove={summary?.canWrite ? setRemoving : undefined}
|
|
283
|
+
emptySkills={
|
|
284
|
+
filterOn
|
|
285
|
+
? 'Nothing in this band needs you right now.'
|
|
286
|
+
: `No skills yet. Add one, or ask your agent to write one for ${group}.`
|
|
287
|
+
}
|
|
288
|
+
// The band fades its controls until you hover it, and `opacity`
|
|
289
|
+
// composites — so "the filter stays lit when it is on" has to be said
|
|
290
|
+
// to the wrapper, not to the button inside it. Same for the spinner:
|
|
291
|
+
// a refresh you cannot see is one people click twice.
|
|
292
|
+
skillControlsActive={filterOn || refreshState !== 'idle'}
|
|
293
|
+
skillControls={
|
|
294
|
+
<BandControls
|
|
295
|
+
attention={attention}
|
|
296
|
+
filterOn={filterOn}
|
|
297
|
+
onToggleFilter={() => setFilterOn((v) => !v)}
|
|
298
|
+
refreshState={refreshState}
|
|
299
|
+
onRefresh={() => {
|
|
300
|
+
sawLoading.current = false;
|
|
301
|
+
setRefreshState('spin');
|
|
302
|
+
data.reload();
|
|
303
|
+
data.reloadGroups();
|
|
304
|
+
}}
|
|
305
|
+
/>
|
|
306
|
+
}
|
|
307
|
+
/>
|
|
308
|
+
|
|
309
|
+
{reviewing && (
|
|
310
|
+
<PendingSkillReview
|
|
311
|
+
item={reviewing}
|
|
312
|
+
onClose={() => setReviewing(null)}
|
|
313
|
+
onResolved={() => {
|
|
314
|
+
setReviewing(null);
|
|
315
|
+
// One reload moves it off the review shelf and into the catalog;
|
|
316
|
+
// the group index follows because its skill count just changed.
|
|
317
|
+
data.reload();
|
|
318
|
+
data.reloadGroups();
|
|
319
|
+
}}
|
|
320
|
+
/>
|
|
321
|
+
)}
|
|
322
|
+
|
|
323
|
+
{addOpen && summary && primaryFolder && (
|
|
324
|
+
<AddToGroupDialog
|
|
325
|
+
name={group}
|
|
326
|
+
primaryPath={primaryFolder}
|
|
327
|
+
canWrite={summary.canWrite}
|
|
328
|
+
// Every skill, not just this group's: a skill's id is its name and
|
|
329
|
+
// ids are global, so the collision that matters is with any of them.
|
|
330
|
+
existingSkills={allSkillNames}
|
|
331
|
+
onClose={() => setAddOpen(false)}
|
|
332
|
+
/>
|
|
333
|
+
)}
|
|
334
|
+
|
|
335
|
+
{deleteOpen && summary && (
|
|
336
|
+
<DeleteGroupDialog
|
|
337
|
+
name={group}
|
|
338
|
+
skillCount={summary.skillCount}
|
|
339
|
+
toolCount={summary.toolCount}
|
|
340
|
+
onClose={() => setDeleteOpen(false)}
|
|
341
|
+
onDeleted={() => {
|
|
342
|
+
toast(`Deleted ${group}.`);
|
|
343
|
+
// This page's place just ceased to exist — the index is the
|
|
344
|
+
// honest landing. Reloads follow so the sidebar agrees.
|
|
345
|
+
navigate(pathForGroupsIndex());
|
|
346
|
+
data.reload();
|
|
347
|
+
data.reloadGroups();
|
|
348
|
+
}}
|
|
349
|
+
/>
|
|
350
|
+
)}
|
|
351
|
+
|
|
352
|
+
{removing && (
|
|
353
|
+
<RemoveLibraryItemDialog
|
|
354
|
+
item={removing}
|
|
355
|
+
place={group}
|
|
356
|
+
onClose={() => setRemoving(null)}
|
|
357
|
+
onRemoved={() => {
|
|
358
|
+
toast(`Removed ${removing.name} from ${group}.`);
|
|
359
|
+
// Catalog for the card, group index for the counts.
|
|
360
|
+
data.reload();
|
|
361
|
+
data.reloadGroups();
|
|
362
|
+
}}
|
|
363
|
+
/>
|
|
364
|
+
)}
|
|
365
|
+
|
|
366
|
+
{manageDialog}
|
|
367
|
+
</div>
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { useMemo, type ReactNode } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import { Badge, Banner } from '../../../shared/components';
|
|
4
|
+
import { useAuth } from '../../auth/state/auth.context';
|
|
5
|
+
import { attentionOf, useLibrary, type LibraryItem } from '../state/library-data';
|
|
6
|
+
import { personalGroupName } from '../utils/personal-group';
|
|
7
|
+
import { LIBRARY_ROOT, pathForGroup } from '../routes/library-paths';
|
|
8
|
+
import { ownersTextOf } from '../utils/group-summary';
|
|
9
|
+
import type { GroupSummary } from '../services/groups.api';
|
|
10
|
+
import { GroupIndexRow } from './GroupIndexRow';
|
|
11
|
+
import { LockGlyph } from './LockGlyph';
|
|
12
|
+
import { ManagedGroupRequests } from './ManagedGroupRequests';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The all-groups index — `/skills-and-tools`, where the Library opens.
|
|
16
|
+
*
|
|
17
|
+
* The sidebar can only show groups you are IN. This page also shows the ones
|
|
18
|
+
* you may DISCOVER — the endpoint returns a group exactly when the caller is
|
|
19
|
+
* a member, manages it, or can read its `access.md` (the discovery grant), so
|
|
20
|
+
* a group with none of those is absent here too, not merely unlabelled.
|
|
21
|
+
*
|
|
22
|
+
* Two sources, one list. The `GET /api/groups` summaries are authoritative
|
|
23
|
+
* about existence and access; the caller's own catalog is authoritative about
|
|
24
|
+
* what they can actually see. A group in the catalog but missing from the
|
|
25
|
+
* summaries (endpoint degraded, or a folder the scan hasn't picked up) still
|
|
26
|
+
* gets a row, because the items are right there.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** A group's rows, whichever source could speak for it. */
|
|
30
|
+
interface IndexEntry {
|
|
31
|
+
name: string;
|
|
32
|
+
summary: GroupSummary | null;
|
|
33
|
+
skillCount: number;
|
|
34
|
+
toolCount: number;
|
|
35
|
+
attention: number;
|
|
36
|
+
/** The caller can see inside: folder read, manage rights, or item grants. */
|
|
37
|
+
member: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function GroupsIndexPage() {
|
|
41
|
+
const { items, groupSummaries, groupsLoading, groupsError, reloadGroups } = useLibrary();
|
|
42
|
+
const navigate = useNavigate();
|
|
43
|
+
const { user } = useAuth();
|
|
44
|
+
|
|
45
|
+
const personalName = personalGroupName(user?.name);
|
|
46
|
+
const ungroupedSkills = countKind(items, null, 'skill');
|
|
47
|
+
const ungroupedTools = countKind(items, null, 'integration');
|
|
48
|
+
|
|
49
|
+
const entries = useMemo((): IndexEntry[] => {
|
|
50
|
+
const names = new Set<string>(groupSummaries.map((g) => g.name));
|
|
51
|
+
for (const item of items) if (item.group) names.add(item.group);
|
|
52
|
+
|
|
53
|
+
return [...names]
|
|
54
|
+
.sort((a, b) => a.localeCompare(b))
|
|
55
|
+
.map((name) => {
|
|
56
|
+
const summary = groupSummaries.find((g) => g.name === name) ?? null;
|
|
57
|
+
const derivedSkills = countKind(items, name, 'skill');
|
|
58
|
+
const derivedTools = countKind(items, name, 'integration');
|
|
59
|
+
const hasItems = derivedSkills + derivedTools > 0;
|
|
60
|
+
return {
|
|
61
|
+
name,
|
|
62
|
+
summary,
|
|
63
|
+
// The summary's counts are the group's TOTALS; the catalog's are the
|
|
64
|
+
// caller's slice. Prefer the totals — a member should see the same
|
|
65
|
+
// "4 skills" here as on the group page.
|
|
66
|
+
skillCount: summary ? summary.skillCount : derivedSkills,
|
|
67
|
+
toolCount: summary ? summary.toolCount : derivedTools,
|
|
68
|
+
attention: attentionOf(items, name),
|
|
69
|
+
member: summary ? summary.canRead || summary.canWrite || hasItems : hasItems,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}, [groupSummaries, items]);
|
|
73
|
+
|
|
74
|
+
const mine = entries.filter((e) => e.member);
|
|
75
|
+
const locked = entries.filter((e) => !e.member);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div className="pb-14">
|
|
79
|
+
<h1 className="text-display font-semibold">All groups</h1>
|
|
80
|
+
<p className="mt-0.5 text-ui text-ink-muted">
|
|
81
|
+
A group carries skills and tools for the people in it.
|
|
82
|
+
</p>
|
|
83
|
+
|
|
84
|
+
{/* Somebody asking to join one of these is the news on a page about
|
|
85
|
+
groups, and this is the view the Library opens on — the one place
|
|
86
|
+
the ask is certain to be seen. Renders nothing when nothing pends. */}
|
|
87
|
+
<div className="mt-5 empty:mt-0">
|
|
88
|
+
<ManagedGroupRequests />
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
{/* "Owned by me" used to head this list and does not any more: it is a
|
|
92
|
+
LENS on every group (the things you answer for, wherever they live),
|
|
93
|
+
not a place items belong to. It stays in the sidebar, where lenses
|
|
94
|
+
go. What remains here is the one group that really is yours. */}
|
|
95
|
+
<SectionHead>Yours</SectionHead>
|
|
96
|
+
<RowList>
|
|
97
|
+
<GroupIndexRow
|
|
98
|
+
label={personalName}
|
|
99
|
+
description="Your sign-ins and the skills no group carries"
|
|
100
|
+
meta={countsText(ungroupedSkills, ungroupedTools)}
|
|
101
|
+
onOpen={() => navigate(`${LIBRARY_ROOT}/yours`)}
|
|
102
|
+
/>
|
|
103
|
+
</RowList>
|
|
104
|
+
|
|
105
|
+
{groupsError ? (
|
|
106
|
+
<Banner role="alert" tone="danger" className="mt-6">
|
|
107
|
+
{groupsError}
|
|
108
|
+
<button type="button" className="ml-3 font-semibold underline" onClick={reloadGroups}>
|
|
109
|
+
Try again
|
|
110
|
+
</button>
|
|
111
|
+
</Banner>
|
|
112
|
+
) : groupsLoading && groupSummaries.length === 0 ? (
|
|
113
|
+
<div className="py-16 text-center text-ui text-ink-faint">Loading groups…</div>
|
|
114
|
+
) : (
|
|
115
|
+
<>
|
|
116
|
+
<SectionHead count={mine.length}>{"Groups you're in"}</SectionHead>
|
|
117
|
+
<RowList>
|
|
118
|
+
{mine.map((entry) => (
|
|
119
|
+
<GroupIndexRow
|
|
120
|
+
key={entry.name}
|
|
121
|
+
label={entry.name}
|
|
122
|
+
badge={
|
|
123
|
+
entry.summary?.canWrite ? (
|
|
124
|
+
<Badge tone="outline" size="xs" className="shrink-0 uppercase">
|
|
125
|
+
Owner
|
|
126
|
+
</Badge>
|
|
127
|
+
) : undefined
|
|
128
|
+
}
|
|
129
|
+
{...describe(entry)}
|
|
130
|
+
trailing={
|
|
131
|
+
entry.attention > 0 ? (
|
|
132
|
+
<Badge tone="wait" size="xs">
|
|
133
|
+
{entry.attention}
|
|
134
|
+
</Badge>
|
|
135
|
+
) : undefined
|
|
136
|
+
}
|
|
137
|
+
onOpen={() => navigate(pathForGroup(entry.name))}
|
|
138
|
+
/>
|
|
139
|
+
))}
|
|
140
|
+
</RowList>
|
|
141
|
+
|
|
142
|
+
{locked.length > 0 && (
|
|
143
|
+
<>
|
|
144
|
+
<SectionHead count={locked.length}>Ask to join</SectionHead>
|
|
145
|
+
<RowList>
|
|
146
|
+
{locked.map((entry) => (
|
|
147
|
+
<GroupIndexRow
|
|
148
|
+
key={entry.name}
|
|
149
|
+
label={entry.name}
|
|
150
|
+
{...describe(entry)}
|
|
151
|
+
/* The row has to SAY it is locked, not just look it — the
|
|
152
|
+
glyph is decorative (`aria-hidden`) and the word beside
|
|
153
|
+
it is what a screen reader and the tests both read.
|
|
154
|
+
Once a join CR is open the chip states that instead:
|
|
155
|
+
the one thing this row can tell you that you did not
|
|
156
|
+
already know is whether you have already asked. */
|
|
157
|
+
trailing={
|
|
158
|
+
entry.summary?.hasRequested ? (
|
|
159
|
+
<Badge tone="wait" size="xs" title="Requested" className="uppercase">
|
|
160
|
+
Requested
|
|
161
|
+
</Badge>
|
|
162
|
+
) : (
|
|
163
|
+
<Badge tone="outline" size="xs" title="Locked" className="uppercase">
|
|
164
|
+
<LockGlyph className="size-2.5 shrink-0" />
|
|
165
|
+
Locked
|
|
166
|
+
</Badge>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
onOpen={() => navigate(pathForGroup(entry.name))}
|
|
170
|
+
/>
|
|
171
|
+
))}
|
|
172
|
+
</RowList>
|
|
173
|
+
</>
|
|
174
|
+
)}
|
|
175
|
+
</>
|
|
176
|
+
)}
|
|
177
|
+
</div>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A row's description + meta. With a summary the row leads with WHO runs the
|
|
183
|
+
* group and puts the counts on the right; without one there is no verified
|
|
184
|
+
* principal to name, so the counts move left and the meta slot stays empty
|
|
185
|
+
* rather than inventing a "Run by …" we never resolved.
|
|
186
|
+
*/
|
|
187
|
+
function describe(entry: IndexEntry): { description: string; meta?: string } {
|
|
188
|
+
const counts = countsText(entry.skillCount, entry.toolCount);
|
|
189
|
+
if (!entry.summary) return { description: counts };
|
|
190
|
+
return { description: `Run by ${ownersTextOf(entry.summary)}`, meta: counts };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* `{n} skills · {n} tools`, fixed plural. Not an oversight: the spec's own
|
|
195
|
+
* empty-group example reads `0 skills · 0 tools`, so this is a label for two
|
|
196
|
+
* quantities rather than a sentence about them, and it stays the same width as
|
|
197
|
+
* the row above it.
|
|
198
|
+
*/
|
|
199
|
+
function countsText(skills: number, tools: number): string {
|
|
200
|
+
return `${skills} skills · ${tools} tools`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function countKind(items: LibraryItem[], group: string | null, kind: LibraryItem['kind']): number {
|
|
204
|
+
return items.filter((i) => i.group === group && i.kind === kind).length;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Section label with an optional count cap beside it, not inside it — the
|
|
208
|
+
* heading's accessible name stays the label alone. */
|
|
209
|
+
function SectionHead({ children, count }: { children: ReactNode; count?: number }) {
|
|
210
|
+
return (
|
|
211
|
+
<div className="mb-2.5 mt-7 flex items-baseline gap-2">
|
|
212
|
+
<h2 className="text-label uppercase text-ink-faint">{children}</h2>
|
|
213
|
+
{count !== undefined && (
|
|
214
|
+
<span className="text-meta tabular-nums text-ink-faint">{count}</span>
|
|
215
|
+
)}
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function RowList({ children }: { children: ReactNode }) {
|
|
221
|
+
return <div className="flex flex-col gap-1.5">{children}</div>;
|
|
222
|
+
}
|