@bevel-software/platform-core-frontend 0.7.5 → 0.9.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/LICENSE +202 -202
- package/THIRD-PARTY-NOTICES.md +344 -988
- package/package.json +5 -5
- package/src/core/CoreAppShell.tsx +4 -4
- package/src/core/__tests__/ShellRoutes.test.tsx +1 -1
- package/src/core/__tests__/bootstrap.test.ts +47 -2
- package/src/core/bootstrap.ts +20 -0
- package/src/core/registry.ts +16 -4
- package/src/css-side-effect-imports.d.ts +7 -7
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +1 -1
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +5 -5
- package/src/modules/access/api.ts +5 -5
- package/src/modules/access/components/ManageAccessDialog.tsx +21 -20
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/components/AdminRolesPage.tsx +1 -1
- package/src/modules/admin/state/admin.context.tsx +15 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +2 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +4 -4
- package/src/modules/layout/__tests__/SidebarToggle.test.tsx +4 -4
- package/src/modules/layout/__tests__/breakpoints.test.ts +1 -1
- package/src/modules/layout/components/SidebarFrame.tsx +2 -2
- package/src/modules/library/__tests__/{AddToGroupDialog.test.tsx → AddToPluginDialog.test.tsx} +34 -34
- package/src/modules/library/__tests__/LibraryCard.test.tsx +30 -11
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +84 -59
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +51 -51
- package/src/modules/library/__tests__/{LockedGroupView.test.tsx → LockedPluginView.test.tsx} +33 -33
- package/src/modules/library/__tests__/McpServerSection.test.tsx +138 -0
- package/src/modules/library/__tests__/{NewGroupDialog.test.tsx → NewPluginDialog.test.tsx} +22 -22
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +7 -7
- package/src/modules/library/__tests__/PluginExtras.test.tsx +131 -0
- package/src/modules/library/__tests__/{GroupJoinRequests.test.tsx → PluginJoinRequests.test.tsx} +24 -24
- package/src/modules/library/__tests__/{GroupPage.test.tsx → PluginPage.test.tsx} +197 -106
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +363 -0
- package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +32 -31
- package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +29 -28
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +171 -0
- package/src/modules/library/__tests__/{GroupsSidebarMenu.test.tsx → PluginsSidebarMenu.test.tsx} +18 -18
- package/src/modules/library/__tests__/SkillPage.test.tsx +8 -8
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +2 -2
- package/src/modules/library/__tests__/ToolPage.test.tsx +41 -12
- package/src/modules/library/__tests__/ToolSharePanel.test.tsx +1 -1
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +57 -57
- package/src/modules/library/__tests__/auth-harness.tsx +4 -4
- package/src/modules/library/__tests__/library-data.test.ts +82 -0
- package/src/modules/library/__tests__/status.test.ts +19 -19
- package/src/modules/library/__tests__/tools.api.test.ts +70 -0
- package/src/modules/library/__tests__/useToolPage.test.tsx +4 -4
- package/src/modules/library/components/AccessRequestsBanner.tsx +8 -8
- package/src/modules/library/components/{AddToGroupDialog.tsx → AddToPluginDialog.tsx} +11 -11
- package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
- package/src/modules/library/components/{DeleteGroupDialog.tsx → DeletePluginDialog.tsx} +9 -9
- package/src/modules/library/components/LibraryCard.tsx +26 -2
- package/src/modules/library/components/LibraryLayout.tsx +80 -71
- package/src/modules/library/components/LibraryPage.tsx +8 -8
- package/src/modules/library/components/LockGlyph.tsx +1 -1
- package/src/modules/library/components/{LockedGroupView.tsx → LockedPluginView.tsx} +35 -35
- package/src/modules/library/components/{ManagedGroupRequests.tsx → ManagedPluginRequests.tsx} +13 -13
- package/src/modules/library/components/{NewGroupDialog.tsx → NewPluginDialog.tsx} +24 -24
- package/src/modules/library/components/NewSkillPanel.tsx +23 -5
- package/src/modules/library/components/PageActions.tsx +34 -11
- package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
- package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +29 -19
- package/src/modules/library/components/PluginExtras.tsx +195 -0
- package/src/modules/library/components/{GroupIndexRow.tsx → PluginIndexRow.tsx} +6 -6
- package/src/modules/library/components/PluginJoinRequests.tsx +77 -0
- package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +112 -72
- package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +91 -48
- package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +105 -55
- package/src/modules/library/components/{GroupsSidebarMenu.tsx → PluginsSidebarMenu.tsx} +15 -15
- package/src/modules/library/components/{group-page-parts.tsx → plugin-page-parts.tsx} +218 -27
- package/src/modules/library/components/skill-page/SkillPage.tsx +12 -12
- package/src/modules/library/components/tool-page/McpServerSection.tsx +380 -0
- package/src/modules/library/components/tool-page/ToolPage.tsx +22 -5
- package/src/modules/library/hooks/useJoinRequests.ts +8 -8
- package/src/modules/library/routes/LibraryRoutes.tsx +32 -19
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +24 -24
- package/src/modules/library/routes/library-paths.ts +36 -36
- package/src/modules/library/services/library.api.ts +9 -9
- package/src/modules/library/services/{groups.api.ts → plugins.api.ts} +43 -43
- package/src/modules/library/services/tools.api.ts +54 -0
- package/src/modules/library/state/library-data.tsx +67 -46
- package/src/modules/library/utils/names.ts +1 -1
- package/src/modules/library/utils/{personal-group.ts → personal-plugin.ts} +8 -8
- package/src/modules/library/utils/{group-summary.ts → plugin-summary.ts} +14 -14
- package/src/modules/library/utils/status.ts +17 -17
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +318 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +86 -8
- package/src/modules/onboarding/agent-clients.ts +18 -14
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +143 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +30 -22
- package/src/modules/onboarding/components/WelcomeRoute.tsx +57 -0
- package/src/modules/onboarding/welcome-state.ts +36 -0
- package/src/modules/review/components/MarkdownDiffViewer.tsx +1 -1
- package/src/modules/review/components/ReviewPanel.tsx +11 -11
- package/src/modules/review/components/__tests__/{isGroupItemPath.test.ts → isPluginItemPath.test.ts} +24 -24
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +3 -3
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +1 -1
- package/src/modules/settings/components/SettingsLayout.tsx +1 -1
- package/src/modules/settings/components/SettingsNav.tsx +5 -5
- package/src/modules/setup/__tests__/setup.test.tsx +203 -0
- package/src/modules/setup/components/SetupScreen.tsx +235 -68
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +29 -107
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +1 -1
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +228 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +3 -3
- package/src/modules/workspace/components/FileExplorer.tsx +12 -12
- package/src/modules/workspace/components/FileRoute.tsx +8 -1
- package/src/modules/workspace/components/FileViewer.tsx +95 -38
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +14 -14
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +20 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +227 -18
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +25 -0
- package/src/modules/workspace/routing/kb-routes.ts +23 -1
- package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
- package/src/modules/workspace/utils/fileTree.ts +54 -3
- package/src/shared/components/Surface.tsx +15 -0
- package/src/shared/mcp/ClaudeInstallLink.tsx +88 -0
- package/src/shared/mcp/ConnectionInstructions.tsx +51 -0
- package/src/shared/mcp/CopyBlock.tsx +42 -0
- package/src/shared/mcp/__tests__/ClaudeInstallLink.test.tsx +40 -0
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +431 -0
- package/src/shared/mcp/__tests__/useCopyFeedback.test.ts +112 -0
- package/src/shared/mcp/connect-snippets.ts +353 -0
- package/src/shared/mcp/index.ts +28 -0
- package/src/shared/mcp/useCopyFeedback.ts +46 -0
- package/src/test-setup.ts +11 -0
- package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +0 -283
- package/src/modules/library/__tests__/GroupsSidebar.test.tsx +0 -142
- package/src/modules/library/components/GroupJoinRequests.tsx +0 -56
|
@@ -5,23 +5,24 @@ import { useLibrary, type LibraryItem } from '../state/library-data';
|
|
|
5
5
|
import { useLibraryToast } from '../state/toast.context';
|
|
6
6
|
import { urlForItemFile } from '../routes/library-paths';
|
|
7
7
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
8
|
+
import { personalPluginName } from '../utils/personal-plugin';
|
|
9
|
+
import { EmptySkillsNudge, PluginBreadcrumb, PluginItemSections, PageNote,
|
|
10
|
+
RemoveLibraryItemDialog,
|
|
11
|
+
} from './plugin-page-parts';
|
|
11
12
|
import { PageActions } from './PageActions';
|
|
12
13
|
import { PersonalAddDialog } from './PersonalAddDialog';
|
|
13
14
|
import { copyToClipboard } from '../utils/clipboard';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* A person's own space, as a
|
|
17
|
+
* A person's own space, as a plugin: `/skills-and-tools/yours`.
|
|
17
18
|
*
|
|
18
|
-
* These are the items in NO
|
|
19
|
-
* and the skills no
|
|
20
|
-
* alone", a heading and a flat grid); now they get the same page every
|
|
19
|
+
* These are the items in NO plugin folder — the sign-ins that are yours alone
|
|
20
|
+
* and the skills no plugin has adopted. They were a filtered gallery ("Yours
|
|
21
|
+
* alone", a heading and a flat grid); now they get the same page every plugin
|
|
21
22
|
* gets, because from where you stand it is the same kind of thing: a place
|
|
22
23
|
* with your skills and your tools in it.
|
|
23
24
|
*
|
|
24
|
-
* It carries the same actions every
|
|
25
|
+
* It carries the same actions every plugin page carries, because it is the same
|
|
25
26
|
* kind of thing — with ONE exception, and it is a real one rather than a
|
|
26
27
|
* decision:
|
|
27
28
|
*
|
|
@@ -34,7 +35,7 @@ import { copyToClipboard } from '../utils/clipboard';
|
|
|
34
35
|
* Giving a person's own items a home folder is a backend change, and until
|
|
35
36
|
* that exists this stays absent.
|
|
36
37
|
*/
|
|
37
|
-
export function
|
|
38
|
+
export function PersonalPluginPage() {
|
|
38
39
|
const data = useLibrary();
|
|
39
40
|
const navigate = useNavigate();
|
|
40
41
|
const { kbDirName } = useWorkspace();
|
|
@@ -44,12 +45,12 @@ export function PersonalGroupPage() {
|
|
|
44
45
|
/** The card being removed, while its confirm dialog is up. */
|
|
45
46
|
const [removing, setRemoving] = useState<LibraryItem | null>(null);
|
|
46
47
|
|
|
47
|
-
const name =
|
|
48
|
-
const items = useMemo(() => data.items.filter((i) => i.
|
|
48
|
+
const name = personalPluginName(user?.name);
|
|
49
|
+
const items = useMemo(() => data.items.filter((i) => i.plugin === null), [data.items]);
|
|
49
50
|
/**
|
|
50
51
|
* For the add dialog's name check. Every skill, not only the ungrouped ones:
|
|
51
52
|
* a skill's id is its name and ids are global, so a new skill here collides
|
|
52
|
-
* with a
|
|
53
|
+
* with a plugin's just as surely as with one of your own.
|
|
53
54
|
*/
|
|
54
55
|
const allSkillNames = useMemo(
|
|
55
56
|
() => data.items.filter((i) => i.kind === 'skill').map((i) => i.name),
|
|
@@ -58,7 +59,7 @@ export function PersonalGroupPage() {
|
|
|
58
59
|
const skillItems = items.filter((i) => i.kind === 'skill');
|
|
59
60
|
const toolItems = items.filter((i) => i.kind === 'integration');
|
|
60
61
|
|
|
61
|
-
/** Identical to the gallery's and the
|
|
62
|
+
/** Identical to the gallery's and the plugin page's — one behaviour per card. */
|
|
62
63
|
function openItem(item: LibraryItem) {
|
|
63
64
|
if (kbDirName) navigate(urlForItemFile(kbDirName, item.path));
|
|
64
65
|
}
|
|
@@ -69,9 +70,9 @@ export function PersonalGroupPage() {
|
|
|
69
70
|
|
|
70
71
|
return (
|
|
71
72
|
<div className="pb-14">
|
|
72
|
-
<
|
|
73
|
+
<PluginBreadcrumb name={name} />
|
|
73
74
|
|
|
74
|
-
{/* The same title row every
|
|
75
|
+
{/* The same title row every plugin page has. The description line that
|
|
75
76
|
used to sit under it is gone: "Only you see this" is what the page's
|
|
76
77
|
own name already says, and a subtitle explaining a heading is the
|
|
77
78
|
heading admitting it did not work (proto: the personal list carries
|
|
@@ -87,7 +88,7 @@ export function PersonalGroupPage() {
|
|
|
87
88
|
</div>
|
|
88
89
|
</div>
|
|
89
90
|
|
|
90
|
-
<
|
|
91
|
+
<PluginItemSections
|
|
91
92
|
skillItems={skillItems}
|
|
92
93
|
toolItems={toolItems}
|
|
93
94
|
onOpen={openItem}
|
|
@@ -95,9 +96,18 @@ export function PersonalGroupPage() {
|
|
|
95
96
|
// per-path gate agrees, since your personal folder names you as owner.
|
|
96
97
|
onRemove={setRemoving}
|
|
97
98
|
// An empty room should say what to do in it, not explain its own filing
|
|
98
|
-
// rule.
|
|
99
|
-
//
|
|
100
|
-
|
|
99
|
+
// rule. The nudge's link opens the same add dialog the title row's `+`
|
|
100
|
+
// does, and its chalk arrow points at that `+` — the agent stays in the
|
|
101
|
+
// sentence as the other way a first skill appears.
|
|
102
|
+
emptySkills={
|
|
103
|
+
<EmptySkillsNudge
|
|
104
|
+
lead="No skills of your own yet."
|
|
105
|
+
actionLabel="Add the first skill"
|
|
106
|
+
tail=", or ask your agent to create one."
|
|
107
|
+
agentOnly="No skills of your own yet. Ask your agent to create skills."
|
|
108
|
+
onAction={() => setAddOpen(true)}
|
|
109
|
+
/>
|
|
110
|
+
}
|
|
101
111
|
emptyTools="No sign-ins of your own yet."
|
|
102
112
|
/>
|
|
103
113
|
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import { DEFAULT_BRANCH, PLUGINS_DIR, type FileTreeEntry } from '@bevel-software/platform-shared';
|
|
4
|
+
import { Button } from '../../../shared/components';
|
|
5
|
+
import { listFiles } from '../../workspace/services/workspace.api';
|
|
6
|
+
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
7
|
+
import { findKbRoot } from '../../workspace/utils/fileTree';
|
|
8
|
+
import { kbFileUrl } from '../../workspace/routing/kb-routes';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The plugin page's two smallest sections, both pure REUSE of the Knowledge
|
|
12
|
+
* surface: links are `kbFileUrl` + `rawFile` navigations into the same raw
|
|
13
|
+
* editor the tool page's "Edit the tool file" uses — no new viewer, no new
|
|
14
|
+
* backend. The one exception is a `.tool` file in a namespace listing, which
|
|
15
|
+
* drops the `rawFile` state so the app gate renders its library tool page —
|
|
16
|
+
* the same destination its card in the Tools band reaches.
|
|
17
|
+
*
|
|
18
|
+
* MANIFEST: writers get a button to `plugin.json`. It is a button to the FILE,
|
|
19
|
+
* not a form, deliberately: the fields worth hand-editing (`version`,
|
|
20
|
+
* `description`, `license`) are plain JSON, and the `extensions` block is
|
|
21
|
+
* machine-written by the server editor — a bespoke form would either duplicate
|
|
22
|
+
* that editor or invite hand-edits it then overwrites.
|
|
23
|
+
*
|
|
24
|
+
* EXTENSIONS: the spec reserves reverse-DNS directories for client-specific
|
|
25
|
+
* data any other client must ignore — which cuts both ways: a plugin authored
|
|
26
|
+
* for ANOTHER client can carry `com.example.client/`, and this section is how
|
|
27
|
+
* a person inspects one instead of wondering what it is. Our own namespace's
|
|
28
|
+
* `tools/` contents already appear in the Tools band above, so entries here
|
|
29
|
+
* are typically foreign — exactly when looking inside matters.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** A reverse-DNS namespace directory: at least one dot, per the spec's shape. */
|
|
33
|
+
const isNamespaceDir = (name: string): boolean => name.includes('.');
|
|
34
|
+
|
|
35
|
+
export function ManifestButton({
|
|
36
|
+
kbDirName,
|
|
37
|
+
folder,
|
|
38
|
+
canWrite,
|
|
39
|
+
}: {
|
|
40
|
+
kbDirName: string | null;
|
|
41
|
+
folder: string;
|
|
42
|
+
canWrite: boolean;
|
|
43
|
+
}) {
|
|
44
|
+
const navigate = useNavigate();
|
|
45
|
+
if (!canWrite || !kbDirName) return null;
|
|
46
|
+
return (
|
|
47
|
+
<Button
|
|
48
|
+
variant="quiet"
|
|
49
|
+
size="sm"
|
|
50
|
+
onClick={() =>
|
|
51
|
+
navigate(kbFileUrl(DEFAULT_BRANCH, `${kbDirName}/${PLUGINS_DIR}/${folder}/plugin.json`), {
|
|
52
|
+
state: { rawFile: true },
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
>
|
|
56
|
+
Manifest
|
|
57
|
+
</Button>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface NamespaceListing {
|
|
62
|
+
namespace: string;
|
|
63
|
+
files: string[]; // plugin-relative, e.g. `com.example.client/hooks/on-save.js`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function ClientExtensionsSection({
|
|
67
|
+
kbDirName,
|
|
68
|
+
folder,
|
|
69
|
+
}: {
|
|
70
|
+
kbDirName: string | null;
|
|
71
|
+
folder: string;
|
|
72
|
+
}) {
|
|
73
|
+
// LISTING and LINKS must agree on a branch. The links are pinned to the
|
|
74
|
+
// default branch (plugins are default-branch content), so the tree read is
|
|
75
|
+
// too — the context's workspace may sit on a draft branch, and a listing
|
|
76
|
+
// from there would render files these links then cannot open. Workspace id
|
|
77
|
+
// IS the encoded branch, by the platform's own contract.
|
|
78
|
+
const workspaceId = encodeURIComponent(DEFAULT_BRANCH);
|
|
79
|
+
const navigate = useNavigate();
|
|
80
|
+
const { workspaceId: contextWorkspaceId, fileTree: contextTree } = useWorkspace();
|
|
81
|
+
const [listings, setListings] = useState<NamespaceListing[]>([]);
|
|
82
|
+
|
|
83
|
+
// The workspace context has usually ALREADY loaded this exact tree — it
|
|
84
|
+
// bootstraps on the default branch — so the common case must not pay a
|
|
85
|
+
// second full-tree round-trip per page view. The fetch survives only for
|
|
86
|
+
// the case the reuse cannot cover: a context sitting on a draft branch,
|
|
87
|
+
// whose tree could list files these default-branch links cannot open.
|
|
88
|
+
// The reused tree is as stale as the context's — which is the freshness
|
|
89
|
+
// the file explorer beside this page renders from, deliberately: one
|
|
90
|
+
// section refetching on its own would show files the tree next to it
|
|
91
|
+
// doesn't, and the context refresh cycle is where staleness is fixed.
|
|
92
|
+
const reusableTree = contextWorkspaceId === workspaceId ? contextTree : null;
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
// Reset FIRST: on a folder change or a failed refetch, stale state would
|
|
96
|
+
// keep rendering the previous plugin's files under the new plugin's name.
|
|
97
|
+
setListings([]);
|
|
98
|
+
if (!kbDirName) return;
|
|
99
|
+
if (reusableTree) {
|
|
100
|
+
setListings(namespaceListings(reusableTree, folder));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
let live = true;
|
|
104
|
+
listFiles(workspaceId)
|
|
105
|
+
.then((tree) => {
|
|
106
|
+
if (live) setListings(namespaceListings(tree, folder));
|
|
107
|
+
})
|
|
108
|
+
.catch(() => {
|
|
109
|
+
/* the section renders nothing — a tree fetch failure is not this page's story */
|
|
110
|
+
});
|
|
111
|
+
return () => {
|
|
112
|
+
live = false;
|
|
113
|
+
};
|
|
114
|
+
}, [workspaceId, kbDirName, folder, reusableTree]);
|
|
115
|
+
|
|
116
|
+
if (listings.length === 0) return null;
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<section className="mt-8">
|
|
120
|
+
<h2 className="mb-2.5 text-label font-semibold uppercase text-ink-faint">
|
|
121
|
+
Client-specific extensions
|
|
122
|
+
</h2>
|
|
123
|
+
<p className="mb-2 max-w-[62ch] text-detail text-ink-muted">
|
|
124
|
+
Reverse-DNS directories carry data for a specific client; other clients ignore them. Files
|
|
125
|
+
open in the Knowledge editor; a .tool opens its tool page.
|
|
126
|
+
</p>
|
|
127
|
+
{listings.map((l) => (
|
|
128
|
+
<div key={l.namespace} className="mb-2 rounded-md border border-line px-3.5 py-2.5">
|
|
129
|
+
<p className="font-mono text-detail font-semibold text-ink">{l.namespace}/</p>
|
|
130
|
+
<ul className="mt-1">
|
|
131
|
+
{l.files.map((f) => (
|
|
132
|
+
<li key={f}>
|
|
133
|
+
<button
|
|
134
|
+
type="button"
|
|
135
|
+
className="cursor-pointer font-mono text-detail text-ink-muted hover:text-ink hover:underline"
|
|
136
|
+
onClick={() =>
|
|
137
|
+
// `rawFile` steps past the app gate into the Knowledge
|
|
138
|
+
// editor — right for opaque client data (hooks, configs),
|
|
139
|
+
// wrong for a `.tool`: that file has a first-class tool
|
|
140
|
+
// page, and the same URL without the state renders it
|
|
141
|
+
// here in the library, exactly like its card above.
|
|
142
|
+
navigate(
|
|
143
|
+
kbFileUrl(DEFAULT_BRANCH, `${kbDirName}/${PLUGINS_DIR}/${folder}/${f}`),
|
|
144
|
+
f.toLowerCase().endsWith('.tool') ? undefined : { state: { rawFile: true } },
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
>
|
|
148
|
+
{f.slice(l.namespace.length + 1)}
|
|
149
|
+
</button>
|
|
150
|
+
</li>
|
|
151
|
+
))}
|
|
152
|
+
</ul>
|
|
153
|
+
</div>
|
|
154
|
+
))}
|
|
155
|
+
</section>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Walk the (already-loaded, ACL-filtered) tree down to this plugin's namespace
|
|
161
|
+
* dirs. Through `findKbRoot`, not `[kbDirName, …]` from the literal root: the
|
|
162
|
+
* fileTree can carry workspace/KB-clone wrapper levels above the kb dir, and
|
|
163
|
+
* that helper is how the rest of the codebase reaches the well-known root
|
|
164
|
+
* dirs regardless.
|
|
165
|
+
*/
|
|
166
|
+
function namespaceListings(tree: FileTreeEntry, folder: string): NamespaceListing[] {
|
|
167
|
+
const kbRoot = findKbRoot(tree);
|
|
168
|
+
const pluginDir = kbRoot ? descend(kbRoot, [PLUGINS_DIR, folder]) : null;
|
|
169
|
+
if (!pluginDir?.children) return [];
|
|
170
|
+
const out: NamespaceListing[] = [];
|
|
171
|
+
for (const child of pluginDir.children) {
|
|
172
|
+
if (child.type !== 'directory' || !isNamespaceDir(child.name)) continue;
|
|
173
|
+
const files: string[] = [];
|
|
174
|
+
collectFiles(child, child.name, files);
|
|
175
|
+
if (files.length > 0) out.push({ namespace: child.name, files: files.sort() });
|
|
176
|
+
}
|
|
177
|
+
return out.sort((a, b) => a.namespace.localeCompare(b.namespace));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function descend(tree: FileTreeEntry, segments: string[]): FileTreeEntry | null {
|
|
181
|
+
let node: FileTreeEntry | undefined = tree;
|
|
182
|
+
for (const segment of segments) {
|
|
183
|
+
node = node?.children?.find((c) => c.name === segment);
|
|
184
|
+
if (!node) return null;
|
|
185
|
+
}
|
|
186
|
+
return node ?? null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function collectFiles(node: FileTreeEntry, prefix: string, out: string[]): void {
|
|
190
|
+
for (const child of node.children ?? []) {
|
|
191
|
+
const rel = `${prefix}/${child.name}`;
|
|
192
|
+
if (child.type === 'directory') collectFiles(child, rel, out);
|
|
193
|
+
else out.push(rel);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import { ListRow } from '../../../shared/components';
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface PluginIndexRowProps {
|
|
5
5
|
label: string;
|
|
6
6
|
/** Inline with the label — the `Owner` chip. */
|
|
7
7
|
badge?: ReactNode;
|
|
@@ -9,8 +9,8 @@ export interface GroupIndexRowProps {
|
|
|
9
9
|
/** Right-aligned counts, e.g. `4 skills · 2 tools`. */
|
|
10
10
|
meta?: string;
|
|
11
11
|
/**
|
|
12
|
-
* After the counts: the amber attention count on a
|
|
13
|
-
* on
|
|
12
|
+
* After the counts: the amber attention count on a plugin you are in, or —
|
|
13
|
+
* on a "Request access" row — the `Locked` chip, which becomes `Requested`
|
|
14
14
|
* once the caller has a pending access request. A slot rather than a
|
|
15
15
|
* boolean, which is why those three states cost this file nothing.
|
|
16
16
|
*/
|
|
@@ -19,21 +19,21 @@ export interface GroupIndexRowProps {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* One row on the all-
|
|
22
|
+
* One row on the all-plugins index — a plugin, or one of the two personal views.
|
|
23
23
|
*
|
|
24
24
|
* The whole row is the target, which is why it is a `<button>` and not a card
|
|
25
25
|
* with a link inside it: every row here means exactly one thing, "go there".
|
|
26
26
|
* Counts live in `meta` as plain text so the row's accessible name reads as the
|
|
27
27
|
* sentence it looks like ("GTM Run by Olga Ivanova 4 skills · 2 tools").
|
|
28
28
|
*/
|
|
29
|
-
export function
|
|
29
|
+
export function PluginIndexRow({
|
|
30
30
|
label,
|
|
31
31
|
badge,
|
|
32
32
|
description,
|
|
33
33
|
meta,
|
|
34
34
|
trailing,
|
|
35
35
|
onOpen,
|
|
36
|
-
}:
|
|
36
|
+
}: PluginIndexRowProps) {
|
|
37
37
|
return (
|
|
38
38
|
<ListRow
|
|
39
39
|
as="button"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect } from 'react';
|
|
2
|
+
import { useJoinRequests } from '../hooks/useJoinRequests';
|
|
3
|
+
import { AccessRequestsBanner } from './AccessRequestsBanner';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One plugin's join requests, fetching their own data.
|
|
7
|
+
*
|
|
8
|
+
* A component rather than a hook call in each page because the gallery shows
|
|
9
|
+
* a banner per plugin the caller manages, and a hook cannot be called in a
|
|
10
|
+
* loop. Rendering one of these per plugin keeps that legal and gives the plugin
|
|
11
|
+
* page the identical surface for free.
|
|
12
|
+
*
|
|
13
|
+
* Render it only for plugins the caller MANAGES: the endpoint answers `[]` to
|
|
14
|
+
* everyone else, so an ungated render is harmless but pointlessly chatty.
|
|
15
|
+
*/
|
|
16
|
+
export interface PluginJoinRequestsProps {
|
|
17
|
+
plugin: string;
|
|
18
|
+
/** The plugin's constituent folders — for the Manage-access affordance. */
|
|
19
|
+
folders: string[];
|
|
20
|
+
onManage(folder: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Bump to refetch. The pages raise it after the Manage-access dialog
|
|
23
|
+
* closes: granting there can settle a request, and this surface would
|
|
24
|
+
* otherwise keep offering proposals that have already landed until its
|
|
25
|
+
* next natural fetch.
|
|
26
|
+
*/
|
|
27
|
+
reloadSignal?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Told whether the banner is actually on screen (it renders nothing while
|
|
30
|
+
* no requests pend). The group page listens so the empty band's chalk
|
|
31
|
+
* arrow can stand down when this banner sits in its line of fire — the
|
|
32
|
+
* arrow's aim assumes nothing between the band and the title row.
|
|
33
|
+
*/
|
|
34
|
+
onVisible?(visible: boolean): void;
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function PluginJoinRequests({
|
|
39
|
+
plugin,
|
|
40
|
+
folders,
|
|
41
|
+
onManage,
|
|
42
|
+
reloadSignal = 0,
|
|
43
|
+
onVisible,
|
|
44
|
+
className,
|
|
45
|
+
}: PluginJoinRequestsProps) {
|
|
46
|
+
const requests = useJoinRequests(plugin, folders[0] ?? null);
|
|
47
|
+
const { reload } = requests;
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (reloadSignal > 0) reload();
|
|
51
|
+
}, [reloadSignal, reload]);
|
|
52
|
+
|
|
53
|
+
const visible = requests.requests.length > 0;
|
|
54
|
+
// A LAYOUT effect, because the listener uses this to decide what to draw in
|
|
55
|
+
// the same frame. Requests arrive asynchronously; reported after paint, the
|
|
56
|
+
// banner and the empty band's arrow — which are meant to be mutually
|
|
57
|
+
// exclusive — would both be on screen for one frame. Before paint, the
|
|
58
|
+
// listener's re-render lands in the only frame that is ever drawn.
|
|
59
|
+
useLayoutEffect(() => {
|
|
60
|
+
onVisible?.(visible);
|
|
61
|
+
// Unmounting is the banner leaving the page — say so, or a listener keeps
|
|
62
|
+
// holding a "visible" that nothing on screen backs up.
|
|
63
|
+
return () => onVisible?.(false);
|
|
64
|
+
}, [visible, onVisible]);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<AccessRequestsBanner
|
|
68
|
+
plugin={plugin}
|
|
69
|
+
folders={folders}
|
|
70
|
+
requests={requests.requests}
|
|
71
|
+
onManage={onManage}
|
|
72
|
+
onAccept={(r, p) => void requests.accept(r, p)}
|
|
73
|
+
onDecline={(r) => void requests.decline(r)}
|
|
74
|
+
className={className}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|