@bevel-software/platform-core-frontend 0.19.0 → 0.21.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 +2 -2
- package/src/core/CoreAppShell.tsx +6 -2
- package/src/modules/access/hooks/useFileAccess.ts +2 -2
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
- package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
- package/src/modules/audit/components/AuditLogPage.tsx +373 -0
- package/src/modules/audit/components/principal-grouping.ts +49 -0
- package/src/modules/audit/services/audit.api.ts +98 -0
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/git/components/BranchSwitcher.tsx +9 -3
- package/src/modules/git/components/FileComparisonPanel.tsx +10 -4
- package/src/modules/git/components/PullNeededBanner.tsx +2 -2
- package/src/modules/git/services/error-messages.ts +2 -2
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +110 -9
- package/src/modules/layout/components/SidebarFrame.tsx +26 -9
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +11 -0
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +3 -0
- package/src/modules/library/__tests__/PluginIndexRow.test.tsx +146 -0
- package/src/modules/library/__tests__/PluginPage.test.tsx +110 -3
- package/src/modules/library/__tests__/ToolPage.test.tsx +20 -0
- package/src/modules/library/__tests__/name-with-badges.test.tsx +16 -3
- package/src/modules/library/__tests__/title-row-actions.ts +43 -0
- package/src/modules/library/components/PluginIndexRow.tsx +37 -20
- package/src/modules/library/components/PluginPage.tsx +115 -3
- package/src/modules/library/components/tool-page/ToolPage.tsx +25 -17
- package/src/modules/library/routes/library-paths.ts +9 -2
- package/src/modules/library/services/plugins.api.ts +45 -0
- package/src/modules/library/utils/plugin-summary.ts +7 -2
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +43 -0
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +13 -2
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +3 -2
- package/src/modules/review/components/ReviewPanel.tsx +2 -2
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +2 -1
- package/src/modules/settings/settings-nav-items.tsx +11 -9
- package/src/modules/setup/components/SetupScreen.tsx +11 -0
- package/src/modules/setup/services/setup.api.ts +1 -1
- package/src/modules/toolbar/services/external-api-keys.api.ts +2 -0
- package/src/modules/workspace/components/FileExplorer.tsx +4 -2
- package/src/modules/workspace/components/FileViewer.tsx +14 -4
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -8
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +60 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +99 -0
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +49 -1
- package/src/modules/workspace/hooks/useWorkspaceState.ts +7 -2
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +78 -1
- package/src/modules/workspace/utils/fileTree.ts +2 -1
- package/src/modules/workspace/utils/treeConfirm.ts +7 -3
- package/src/shared/theme/measure.ts +23 -2
- package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +0 -266
- package/src/modules/admin/components/ConnectionKeysPage.tsx +0 -269
- package/src/modules/admin/components/connection-keys-grouping.ts +0 -43
- package/src/modules/admin/services/connection-keys.api.ts +0 -47
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { expect } from 'vitest';
|
|
2
|
+
import { screen, within } from '@testing-library/react';
|
|
3
|
+
import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Where an item page's `⋯` goes: the right end of the title row.
|
|
7
|
+
*
|
|
8
|
+
* Shared between `PluginPage.test.tsx` and `ToolPage.test.tsx` because the
|
|
9
|
+
* acceptance criterion is a COMPARISON — "the same position and size as on the
|
|
10
|
+
* plugin page" — and two hand-written copies of it would be two things that can
|
|
11
|
+
* drift apart while both stay green. One function, asserted on both pages: the
|
|
12
|
+
* day one of them moves its menu, exactly one of the two callers fails and the
|
|
13
|
+
* other says what it was supposed to look like.
|
|
14
|
+
*
|
|
15
|
+
* The tool page used to render `PageActions` as the last child of its
|
|
16
|
+
* `<header>`, after the description paragraph — a menu on its own line under
|
|
17
|
+
* the way back, at the left margin, which is where nothing else on any page
|
|
18
|
+
* is.
|
|
19
|
+
*
|
|
20
|
+
* Size needs no assertion of its own: it is the same `PageActions` component,
|
|
21
|
+
* so the only thing that could differ is where it is put. That is what this
|
|
22
|
+
* pins — in the band, last, in a group that neither shrinks nor wraps.
|
|
23
|
+
*/
|
|
24
|
+
export function expectMenuAtTheEndOfTheTitleRow(): void {
|
|
25
|
+
const band = screen.getByTestId(PAGE_HEADER_TESTID);
|
|
26
|
+
const menu = within(band).getByRole('button', { name: 'More actions' });
|
|
27
|
+
|
|
28
|
+
// LAST in the band. The title before it carries `flex-1`, so "last" is what
|
|
29
|
+
// puts the group against the row's right edge — there is no `ml-auto` doing
|
|
30
|
+
// it invisibly from somewhere else.
|
|
31
|
+
expect(band.lastElementChild).toContainElement(menu);
|
|
32
|
+
|
|
33
|
+
// The group the plugin page puts it in: fixed width, on the band's line.
|
|
34
|
+
const group = band.lastElementChild as HTMLElement;
|
|
35
|
+
expect(group.className).toContain('flex');
|
|
36
|
+
expect(group.className).toContain('flex-none');
|
|
37
|
+
expect(group.className).toContain('items-center');
|
|
38
|
+
|
|
39
|
+
// And nothing else in the page's header renders one — a second `⋯` under
|
|
40
|
+
// the back link is the bug this replaced.
|
|
41
|
+
const header = band.closest('header') ?? band.parentElement!;
|
|
42
|
+
expect(within(header).getAllByRole('button', { name: 'More actions' })).toHaveLength(1);
|
|
43
|
+
}
|
|
@@ -7,10 +7,16 @@ import { NameWithBadges } from './NameWithBadges';
|
|
|
7
7
|
export interface PluginIndexRowProps {
|
|
8
8
|
label: string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* The `Owner` and `Private` chips — LEADING the row's trailing group, on
|
|
11
|
+
* the counts' line.
|
|
12
|
+
*
|
|
13
|
+
* They used to sit beside the label, through `NameWithBadges`, and drop
|
|
14
|
+
* under the name when the two stopped fitting. That is the right rule for a
|
|
15
|
+
* card, whose name is the only thing on its row; on an index row it put the
|
|
16
|
+
* pill one line above the counts it belongs with, on the left, hanging off
|
|
17
|
+
* a title block that is two lines tall the moment a plugin has a
|
|
18
|
+
* description. The chips qualify the row, not the name, so they travel with
|
|
19
|
+
* the rest of what the row's right edge says.
|
|
14
20
|
*/
|
|
15
21
|
badge?: ReactNode;
|
|
16
22
|
description?: string;
|
|
@@ -39,15 +45,23 @@ export interface PluginIndexRowProps {
|
|
|
39
45
|
* The whole row is the target, which is why it is a `<button>` and not a card
|
|
40
46
|
* with a link inside it: every row here means exactly one thing, "go there".
|
|
41
47
|
* Counts live in `meta` as plain text so the row's accessible name reads as the
|
|
42
|
-
* sentence it looks like ("GTM Run by Olga Ivanova 4 skills · 2 tools")
|
|
48
|
+
* sentence it looks like ("GTM Run by Olga Ivanova Owner 4 skills · 2 tools") —
|
|
49
|
+
* the chips are in that group too, and read in the order they are shown.
|
|
50
|
+
*
|
|
51
|
+
* The row's right edge is ONE line: chips, counts and the `…`, centred against
|
|
52
|
+
* the row however tall the title block is. `ListRow` already spaces and
|
|
53
|
+
* centres its `meta` group (`ml-auto flex flex-none items-center`), so
|
|
54
|
+
* everything that belongs at that edge is passed there — which is why `badge`
|
|
55
|
+
* goes to `meta` and not, as it once did, beside the name.
|
|
43
56
|
*
|
|
44
57
|
* When the row has `actions`, a `…` rides its right edge — a SIBLING of the row
|
|
45
|
-
* button, since the row is the button (see `ItemMenuFrame`).
|
|
46
|
-
* the
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
58
|
+
* button, since the row is the button (see `ItemMenuFrame`). It is positioned
|
|
59
|
+
* on the row's mid-line, so it is already ON that one line; what it is not is
|
|
60
|
+
* IN the flex flow, so the row keeps the trailing room clear for it (`pr-10`)
|
|
61
|
+
* instead of letting the menu paint over the counts and the Locked chip it is
|
|
62
|
+
* right beside. The frame itself is always there: which verbs a row has
|
|
63
|
+
* depends on answers that arrive after the first paint, and a frame that came
|
|
64
|
+
* with them would remount the row under whoever was already using it.
|
|
51
65
|
*/
|
|
52
66
|
export function PluginIndexRow({
|
|
53
67
|
label,
|
|
@@ -64,18 +78,21 @@ export function PluginIndexRow({
|
|
|
64
78
|
density="row"
|
|
65
79
|
onClick={onOpen}
|
|
66
80
|
className={cn(actions && actions.length > 0 && 'pr-10')}
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
// which the bare string it used to be could not.
|
|
74
|
-
label={<NameWithBadges name={label} badges={badge} />}
|
|
81
|
+
// No badges here any more — they are part of the trailing group below,
|
|
82
|
+
// so the name has the whole title line to truncate into and needs no
|
|
83
|
+
// floor to defend it. `NameWithBadges` stays for what it still does
|
|
84
|
+
// that a bare string cannot: the name carries its full self in `title`,
|
|
85
|
+
// so a plugin whose name does not fit can still be read.
|
|
86
|
+
label={<NameWithBadges name={label} />}
|
|
75
87
|
description={description}
|
|
88
|
+
// One line at the row's right edge, in reading order: what this plugin
|
|
89
|
+
// is to you, then how much is in it, then the state of your access.
|
|
90
|
+
// `ListRow` centres the group against the row, so a two-line title
|
|
91
|
+
// block moves it not at all.
|
|
76
92
|
meta={
|
|
77
|
-
meta || trailing ? (
|
|
93
|
+
badge || meta || trailing ? (
|
|
78
94
|
<>
|
|
95
|
+
{badge}
|
|
79
96
|
{meta && <span className="whitespace-nowrap tabular-nums">{meta}</span>}
|
|
80
97
|
{trailing}
|
|
81
98
|
</>
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
urlForLibraryItem,
|
|
15
15
|
} from '../routes/library-paths';
|
|
16
16
|
import { pluginLabel, primaryFolderOf } from '../utils/plugin-summary';
|
|
17
|
+
import { joinNames } from '../utils/names';
|
|
18
|
+
import { repairPluginLinks, type LinkRepairReport, type UnrepairedLink } from '../services/plugins.api';
|
|
17
19
|
import { RenamePluginDialog } from './RenamePluginDialog';
|
|
18
20
|
import { PluginJoinRequests } from './PluginJoinRequests';
|
|
19
21
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
@@ -123,6 +125,19 @@ export function PluginPage() {
|
|
|
123
125
|
return () => window.clearTimeout(timer);
|
|
124
126
|
}, [refreshState]);
|
|
125
127
|
|
|
128
|
+
/**
|
|
129
|
+
* What the page-open repair did — null until it has answered, and left null
|
|
130
|
+
* for a viewer who never runs one (see the effect below). Once it is in, it
|
|
131
|
+
* is the truth about this plugin's links: the served `brokenLinks` was
|
|
132
|
+
* counted before the repair wrote anything.
|
|
133
|
+
*/
|
|
134
|
+
const [repairReport, setRepairReport] = useState<LinkRepairReport | null>(null);
|
|
135
|
+
/**
|
|
136
|
+
* The repair could not even be asked for. Then — and only then — the page
|
|
137
|
+
* falls back to the banner it showed before this existed: the served count
|
|
138
|
+
* is all anyone knows.
|
|
139
|
+
*/
|
|
140
|
+
const [repairFailed, setRepairFailed] = useState(false);
|
|
126
141
|
/** The card being removed, while its confirm dialog is up. */
|
|
127
142
|
const [removing, setRemoving] = useState<LibraryItem | null>(null);
|
|
128
143
|
/** Whether the plugin's own delete confirmation is up. */
|
|
@@ -134,6 +149,49 @@ export function PluginPage() {
|
|
|
134
149
|
() => data.pluginSummaries.find((g) => g.name === plugin) ?? null,
|
|
135
150
|
[data.pluginSummaries, plugin],
|
|
136
151
|
);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* THE automatic repair: opening this page as someone who may write the
|
|
155
|
+
* plugin writes back the grants of every link that lost them and that this
|
|
156
|
+
* person may also write. Silent — a repaired link shows nothing at all; what
|
|
157
|
+
* could not be repaired becomes the banner below.
|
|
158
|
+
*
|
|
159
|
+
* Why the page and not the server's read path: the commit lands in the
|
|
160
|
+
* VIEWER's name, so it needs a person, and a page open is the one moment a
|
|
161
|
+
* person with both verbs is known to be here. Why once — `repairedFor` keys
|
|
162
|
+
* the run on the plugin, so a re-render, a reload of the catalog (which this
|
|
163
|
+
* effect itself causes) or a summary arriving late cannot run it twice; the
|
|
164
|
+
* backend's link locks serialise two people opening the page at the same
|
|
165
|
+
* moment, and the second finds the lines already there and writes nothing.
|
|
166
|
+
*
|
|
167
|
+
* A failure is not the reader's problem to act on: the report stays null and
|
|
168
|
+
* the page falls back to the banner it has always shown.
|
|
169
|
+
*/
|
|
170
|
+
const { reload, reloadPlugins } = data;
|
|
171
|
+
const repairedFor = useRef<string | null>(null);
|
|
172
|
+
const canRepairLinks = summary?.canWrite === true && summary.linksAreManaged !== false;
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
if (!canRepairLinks || repairedFor.current === plugin) return;
|
|
175
|
+
repairedFor.current = plugin;
|
|
176
|
+
let live = true;
|
|
177
|
+
void repairPluginLinks(plugin)
|
|
178
|
+
.then((report) => {
|
|
179
|
+
if (!live) return;
|
|
180
|
+
setRepairReport(report);
|
|
181
|
+
// Only a write is worth a refetch: the catalog and the summaries carry
|
|
182
|
+
// the link health this just changed.
|
|
183
|
+
if (report.repaired.length > 0) {
|
|
184
|
+
reload();
|
|
185
|
+
reloadPlugins();
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
.catch(() => {
|
|
189
|
+
if (live) setRepairFailed(true);
|
|
190
|
+
});
|
|
191
|
+
return () => {
|
|
192
|
+
live = false;
|
|
193
|
+
};
|
|
194
|
+
}, [canRepairLinks, plugin, reload, reloadPlugins]);
|
|
137
195
|
// Inline AND linked: a shared skill linked from this plugin's manifest is
|
|
138
196
|
// one of its skills. A link whose grant went missing carries the amber
|
|
139
197
|
// "needs setup" foot note here — the one place the plugin's members look.
|
|
@@ -154,6 +212,16 @@ export function PluginPage() {
|
|
|
154
212
|
// plugin's members out of a skill NOW, so it outranks an integration the
|
|
155
213
|
// reader has not connected for themselves.
|
|
156
214
|
const { total: attention, brokenLinks, warnings: warningCount } = attentionOf(data.items, plugin, data.pluginSummaries);
|
|
215
|
+
/** Links the page-open repair could not put back — the banner's own list. */
|
|
216
|
+
const unrepairedLinks = repairReport?.skipped ?? [];
|
|
217
|
+
/**
|
|
218
|
+
* Whether the served count is still the best thing this page can say. It is
|
|
219
|
+
* not, for a plugin writer who is having their links repaired: the count was
|
|
220
|
+
* taken before the repair wrote anything, so printing it would name links
|
|
221
|
+
* that are already fixed. They get the report's list instead, once it lands.
|
|
222
|
+
*/
|
|
223
|
+
const showServedBrokenLinks =
|
|
224
|
+
brokenLinks > 0 && (!canRepairLinks || repairFailed) && unrepairedLinks.length === 0;
|
|
157
225
|
const integrationsNeedingSetup = attention - brokenLinks - warningCount;
|
|
158
226
|
const definitionWarnings = summary?.warnings ?? [];
|
|
159
227
|
// What the Skills band actually renders. The filter is a VIEW over the band,
|
|
@@ -361,7 +429,27 @@ export function PluginPage() {
|
|
|
361
429
|
/>
|
|
362
430
|
)}
|
|
363
431
|
|
|
364
|
-
{
|
|
432
|
+
{/* What the repair could not put back, one line per skill, naming the
|
|
433
|
+
people who can. A viewer whose repair is still in flight — or who
|
|
434
|
+
repaired everything — is shown nothing at all: the whole point of
|
|
435
|
+
repairing on open is that a link a writer can fix never becomes a
|
|
436
|
+
sentence somebody has to read. Everyone else (a reader, or a writer
|
|
437
|
+
whose repair could not even be asked for) gets the count that was
|
|
438
|
+
served, exactly as before. */}
|
|
439
|
+
{unrepairedLinks.length > 0 && (
|
|
440
|
+
<Banner role="status" tone="urgent" className="mt-4">
|
|
441
|
+
<ul className="grid gap-1">
|
|
442
|
+
{unrepairedLinks.flatMap((link) =>
|
|
443
|
+
link.skills.map((skill) => (
|
|
444
|
+
<li key={`${link.root}:${skill.path}`}>
|
|
445
|
+
{unrepairedText(link, skill.name, label)}
|
|
446
|
+
</li>
|
|
447
|
+
)),
|
|
448
|
+
)}
|
|
449
|
+
</ul>
|
|
450
|
+
</Banner>
|
|
451
|
+
)}
|
|
452
|
+
{showServedBrokenLinks && (
|
|
365
453
|
<Banner role="status" tone="urgent" className="mt-4">
|
|
366
454
|
{`${brokenLinks} ${
|
|
367
455
|
brokenLinks === 1
|
|
@@ -604,6 +692,30 @@ export function PluginPage() {
|
|
|
604
692
|
);
|
|
605
693
|
}
|
|
606
694
|
|
|
695
|
+
/**
|
|
696
|
+
* Who the banner tells the reader to ask — the roles first, then the people,
|
|
697
|
+
* spoken the way a person lists them.
|
|
698
|
+
*
|
|
699
|
+
* "Its editors" is not a placeholder for a list that failed to load: a skill
|
|
700
|
+
* root whose access file names nobody is still writable by the platform's
|
|
701
|
+
* admins through the rescue on `access.md`, so the sentence stays true and
|
|
702
|
+
* stays actionable when the list comes back empty.
|
|
703
|
+
*/
|
|
704
|
+
function editorsText(link: UnrepairedLink): string {
|
|
705
|
+
return joinNames([...link.editors.roles, ...link.editors.users.map((u) => u.name)]) || 'Its editors';
|
|
706
|
+
}
|
|
607
707
|
|
|
608
|
-
|
|
609
|
-
|
|
708
|
+
/**
|
|
709
|
+
* The one line the banner says about a link the repair left broken. Two
|
|
710
|
+
* sentences, by what is actually wrong: a link whose grant lines are missing
|
|
711
|
+
* is repaired from the skill page; a link whose lines are there and denied
|
|
712
|
+
* beside them is not — Repair would write nothing, and the person who can
|
|
713
|
+
* act has to remove the deny.
|
|
714
|
+
*/
|
|
715
|
+
function unrepairedText(link: UnrepairedLink, skill: string, plugin: string): string {
|
|
716
|
+
const who = editorsText(link);
|
|
717
|
+
if (link.reason === 'denied') {
|
|
718
|
+
return `${skill} is denied to ${plugin}'s members in its access rules. ${who} can change that from the skill page.`;
|
|
719
|
+
}
|
|
720
|
+
return `${skill} can't be read by ${plugin}'s members. ${who} can repair the link from the skill page.`;
|
|
721
|
+
}
|
|
@@ -201,29 +201,37 @@ export function ToolPage({
|
|
|
201
201
|
name={tool.name}
|
|
202
202
|
nameClassName="text-display font-semibold text-ink"
|
|
203
203
|
/>
|
|
204
|
+
{/* No `Manage access` here, deliberately. Access is decided at the
|
|
205
|
+
PLUGIN — a tool inherits its folder's `access.md`, so an editor
|
|
206
|
+
on this page would either duplicate the plugin's one or quietly
|
|
207
|
+
write a per-file override that nobody looking at the plugin
|
|
208
|
+
would see. The plugin's `Share` panel is the single place.
|
|
209
|
+
|
|
210
|
+
The `⋯` menu, though, is the same one the plugin page carries,
|
|
211
|
+
and now in the same PLACE: the end of the title row, in the same
|
|
212
|
+
`flex flex-none items-center gap-1` group `PluginPage` puts it
|
|
213
|
+
in, so the three item pages answer the same gesture at the same
|
|
214
|
+
point on the screen. It used to be the last child of this
|
|
215
|
+
`<header>`, below the description — a menu on its own line under
|
|
216
|
+
the way back, which is where nothing else on any page is.
|
|
217
|
+
`onAdd` is absent: there is nothing to add to a tool. */}
|
|
218
|
+
<div className="flex flex-none items-center gap-1">
|
|
219
|
+
<PageActions
|
|
220
|
+
onCopyLink={() => copyToClipboard(window.location.href)}
|
|
221
|
+
// The OWNER's verb, and the same verdict the DELETE route
|
|
222
|
+
// enforces (ownership of the plugin holding the tool) — so the
|
|
223
|
+
// item appears for exactly the people the backend will let
|
|
224
|
+
// through.
|
|
225
|
+
onDelete={canDelete ? () => setDeleteOpen(true) : undefined}
|
|
226
|
+
deleteLabel="Delete tool"
|
|
227
|
+
/>
|
|
228
|
+
</div>
|
|
204
229
|
</div>
|
|
205
230
|
{page.detail?.description && (
|
|
206
231
|
<p className="mt-1.5 max-w-[56ch] text-lede text-ink-muted">
|
|
207
232
|
{page.detail.description}
|
|
208
233
|
</p>
|
|
209
234
|
)}
|
|
210
|
-
{/* No `Manage access` here, deliberately. Access is decided at the
|
|
211
|
-
PLUGIN — a tool inherits its folder's `access.md`, so an editor on
|
|
212
|
-
this page would either duplicate the plugin's one or quietly write a
|
|
213
|
-
per-file override that nobody looking at the plugin would see. The
|
|
214
|
-
plugin's `Share` panel is the single place.
|
|
215
|
-
|
|
216
|
-
The `⋯` menu, though, is the same one the plugin page carries, in
|
|
217
|
-
the same spot — Delete belongs where people already look for it.
|
|
218
|
-
`onAdd` is absent: there is nothing to add to a tool. */}
|
|
219
|
-
<PageActions
|
|
220
|
-
onCopyLink={() => copyToClipboard(window.location.href)}
|
|
221
|
-
// The OWNER's verb, and the same verdict the DELETE route enforces
|
|
222
|
-
// (ownership of the plugin holding the tool) — so the item appears
|
|
223
|
-
// for exactly the people the backend will let through.
|
|
224
|
-
onDelete={canDelete ? () => setDeleteOpen(true) : undefined}
|
|
225
|
-
deleteLabel="Delete tool"
|
|
226
|
-
/>
|
|
227
235
|
</header>
|
|
228
236
|
|
|
229
237
|
{actionError && (
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_BRANCH,
|
|
3
|
+
PLUGINS_DIR,
|
|
4
|
+
SKILLS_DIR,
|
|
5
|
+
currentKbLayout,
|
|
6
|
+
pluginOfPath,
|
|
7
|
+
isPersonalPluginFolder,
|
|
8
|
+
} from '@bevel-software/platform-shared';
|
|
2
9
|
import { matchPath } from 'react-router-dom';
|
|
3
10
|
import { kbFileUrl } from '../../workspace/routing/kb-routes';
|
|
4
11
|
import type { LibraryFilter } from '../utils/status';
|
|
@@ -218,7 +225,7 @@ export function libraryHomeForItemPath(
|
|
|
218
225
|
label: string;
|
|
219
226
|
path: string;
|
|
220
227
|
} {
|
|
221
|
-
const folder = pluginOfPath(repoRelativePath);
|
|
228
|
+
const folder = pluginOfPath(repoRelativePath, currentKbLayout());
|
|
222
229
|
// A personal shelf is decided by the FOLDER, whatever identity the caller
|
|
223
230
|
// resolved (a personal item's identity is null: a shelf is not a plugin).
|
|
224
231
|
if (folder !== null && isPersonalPluginFolder(folder)) {
|
|
@@ -247,6 +247,51 @@ export async function repairSkillLink(plugin: string, skillPath: string): Promis
|
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
/** Who may edit a skill root's access file — who can repair its link. */
|
|
251
|
+
export interface LinkEditors {
|
|
252
|
+
roles: string[];
|
|
253
|
+
users: { name: string; email: string }[];
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** One link the page-open repair left alone, and why — mirrors the backend. */
|
|
257
|
+
export interface UnrepairedLink {
|
|
258
|
+
/** Repo-relative root, as the plugin's manifest declares it. */
|
|
259
|
+
root: string;
|
|
260
|
+
/**
|
|
261
|
+
* `needs-skill-write` — the viewer may not write its access file; `failed`
|
|
262
|
+
* — the write did not land; `denied` — the lines are there and a `deny` of
|
|
263
|
+
* the plugin beside them keeps the link broken, so there is nothing to
|
|
264
|
+
* write and only an editor removing the deny would change it.
|
|
265
|
+
*/
|
|
266
|
+
reason: 'needs-skill-write' | 'failed' | 'denied';
|
|
267
|
+
/** The skills the plugin's members still cannot read through it. */
|
|
268
|
+
skills: { path: string; name: string }[];
|
|
269
|
+
/** Who the banner names as able to repair it. */
|
|
270
|
+
editors: LinkEditors;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** What one page-open repair did, and what is still broken. */
|
|
274
|
+
export interface LinkRepairReport {
|
|
275
|
+
repaired: string[];
|
|
276
|
+
skipped: UnrepairedLink[];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Repair every link of a plugin whose grants are missing — what the plugin
|
|
281
|
+
* page runs, once, on open, for someone who may write the plugin.
|
|
282
|
+
*
|
|
283
|
+
* Silent by design: a repaired link shows nothing, so the only thing the
|
|
284
|
+
* caller does with `repaired` is reload the catalog. `skipped` is the banner.
|
|
285
|
+
* Refused with the ordinary 404 for a caller who may not write the plugin,
|
|
286
|
+
* which is why the page asks only when its summary says they can.
|
|
287
|
+
*/
|
|
288
|
+
export async function repairPluginLinks(plugin: string): Promise<LinkRepairReport> {
|
|
289
|
+
const body = await linkCall(`/api/plugins/${encodeURIComponent(plugin)}/links/repair-all`, {
|
|
290
|
+
method: 'POST',
|
|
291
|
+
});
|
|
292
|
+
return body as unknown as LinkRepairReport;
|
|
293
|
+
}
|
|
294
|
+
|
|
250
295
|
/**
|
|
251
296
|
* Thrown when a join request is refused because access already landed —
|
|
252
297
|
* between the page load and the click. Not an error to show: the right
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
currentKbLayout,
|
|
3
|
+
isPersonalPluginFolder,
|
|
4
|
+
pluginOfPath,
|
|
5
|
+
skillUnderRoot,
|
|
6
|
+
} from '@bevel-software/platform-shared';
|
|
2
7
|
import type { PluginMembership } from '../services/library.api';
|
|
3
8
|
import type { PluginPrincipals, PluginSummary } from '../services/plugins.api';
|
|
4
9
|
|
|
@@ -14,7 +19,7 @@ export function pluginNameForPath(
|
|
|
14
19
|
repoPath: string,
|
|
15
20
|
summaries: readonly Pick<PluginSummary, 'name' | 'folders'>[],
|
|
16
21
|
): string | null {
|
|
17
|
-
const folder = pluginOfPath(repoPath);
|
|
22
|
+
const folder = pluginOfPath(repoPath, currentKbLayout());
|
|
18
23
|
if (folder === null) return null;
|
|
19
24
|
// The catalog is the authority: whatever folder it lists as holding the
|
|
20
25
|
// path names the plugin. Only a path no listed folder holds falls back to
|
|
@@ -14,6 +14,8 @@ import { WELCOME_PATH } from '../paths';
|
|
|
14
14
|
import { resetOnboardingForTests } from '../state/onboarding';
|
|
15
15
|
import { configureMcpUrl } from '../../../shared/mcp';
|
|
16
16
|
import { setSidebarCollapsed, useSidebar } from '../../layout/state/sidebar';
|
|
17
|
+
import { SidebarFrame } from '../../layout/components/SidebarFrame';
|
|
18
|
+
import { SIDEBAR_HEADER_TESTID } from '../../../shared/theme/header';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* The onboarding contract, end to end on the client:
|
|
@@ -835,6 +837,47 @@ describe('ConnectAgentPill', () => {
|
|
|
835
837
|
expect(JSON.parse(String(fetchInit()?.body))).toEqual({ userId: 'u1' });
|
|
836
838
|
});
|
|
837
839
|
|
|
840
|
+
/**
|
|
841
|
+
* The pill fills `SidebarFrame`'s header band, which is spent on a header
|
|
842
|
+
* that DRAWS and collapses (`empty:hidden`) for one that does not. "Does
|
|
843
|
+
* not" is read off the DOM — an element that renders null is still an
|
|
844
|
+
* element — so a pill with nothing to say has to leave the row literally
|
|
845
|
+
* empty, and its dismissal receipt goes to the body rather than sitting in
|
|
846
|
+
* the band invisibly holding 48px open above "Company Context".
|
|
847
|
+
*
|
|
848
|
+
* Both halves in one test on purpose: an empty row that had lost the
|
|
849
|
+
* announcement with it would pass the first assertion and be a regression.
|
|
850
|
+
*/
|
|
851
|
+
it('leaves the header band empty once onboarding is done, and still says so out loud', async () => {
|
|
852
|
+
mount(
|
|
853
|
+
<SidebarFrame label="Library navigation" header={<ConnectAgentPill />}>
|
|
854
|
+
<nav>Company Context</nav>
|
|
855
|
+
</SidebarFrame>,
|
|
856
|
+
newUser(),
|
|
857
|
+
'/skills-and-tools',
|
|
858
|
+
);
|
|
859
|
+
const band = screen.getByTestId(SIDEBAR_HEADER_TESTID);
|
|
860
|
+
expect(band).not.toBeEmptyDOMElement();
|
|
861
|
+
|
|
862
|
+
await userEvent.click(screen.getByRole('button', { name: /^Dismiss/ }));
|
|
863
|
+
|
|
864
|
+
expect(band).toBeEmptyDOMElement();
|
|
865
|
+
expect(
|
|
866
|
+
screen.getAllByRole('status').some((r) => /Reminder dismissed/.test(r.textContent ?? '')),
|
|
867
|
+
).toBe(true);
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
it('leaves it empty for an account that was already done', () => {
|
|
871
|
+
mount(
|
|
872
|
+
<SidebarFrame label="Library navigation" header={<ConnectAgentPill />}>
|
|
873
|
+
<nav>Company Context</nav>
|
|
874
|
+
</SidebarFrame>,
|
|
875
|
+
doneUser(),
|
|
876
|
+
'/skills-and-tools',
|
|
877
|
+
);
|
|
878
|
+
expect(screen.getByTestId(SIDEBAR_HEADER_TESTID)).toBeEmptyDOMElement();
|
|
879
|
+
});
|
|
880
|
+
|
|
838
881
|
/**
|
|
839
882
|
* A write that never landed must not leave the UI claiming it did. The pill
|
|
840
883
|
* comes back immediately, rather than mysteriously reappearing at the next
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
2
3
|
import { useInRouterContext, useLocation, useNavigate } from 'react-router-dom';
|
|
3
4
|
import { X } from 'lucide-react';
|
|
4
5
|
import { cn } from '../../../lib/utils';
|
|
@@ -71,11 +72,21 @@ function RoutedConnectAgentPill() {
|
|
|
71
72
|
// The live region is OUTSIDE the `showPill` guard so it is still mounted at
|
|
72
73
|
// the moment the pill disappears — a region that unmounts in the same commit
|
|
73
74
|
// as the thing it is announcing announces nothing.
|
|
75
|
+
//
|
|
76
|
+
// It goes to the BODY, though, not into the slot this component fills. That
|
|
77
|
+
// slot is `SidebarFrame`'s header band, which reserves its 48px for a header
|
|
78
|
+
// that draws and collapses (`empty:hidden`) for one that does not — and an
|
|
79
|
+
// `sr-only` span is a child like any other, so leaving it here would hold
|
|
80
|
+
// the whole band open, invisibly, for every account that has finished
|
|
81
|
+
// onboarding. That is precisely the empty strip above "Company Context"
|
|
82
|
+
// this file's half of the fix removes. A portal keeps the region mounted,
|
|
83
|
+
// keeps the announcement, and leaves the row with nothing in it.
|
|
74
84
|
if (!onboarding.showPill) {
|
|
75
|
-
return (
|
|
85
|
+
return createPortal(
|
|
76
86
|
<span role="status" aria-live="polite" className="sr-only">
|
|
77
87
|
{announcement}
|
|
78
|
-
</span
|
|
88
|
+
</span>,
|
|
89
|
+
document.body,
|
|
79
90
|
);
|
|
80
91
|
}
|
|
81
92
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
DEFAULT_BRANCH,
|
|
4
|
+
currentBranchModel,
|
|
4
5
|
protectedBranchDisplayName,
|
|
5
6
|
} from '@bevel-software/platform-shared';
|
|
6
7
|
import { Dialog } from '../../../shared/components/Dialog';
|
|
@@ -170,12 +171,12 @@ export function OpenChangeRequestDialog({
|
|
|
170
171
|
>
|
|
171
172
|
{targets.length === 0 && (
|
|
172
173
|
<option value={targetBranch}>
|
|
173
|
-
{protectedBranchDisplayName(targetBranch) ?? targetBranch}
|
|
174
|
+
{protectedBranchDisplayName(currentBranchModel(), targetBranch) ?? targetBranch}
|
|
174
175
|
</option>
|
|
175
176
|
)}
|
|
176
177
|
{targets.map((b) => (
|
|
177
178
|
<option key={b.name} value={b.name}>
|
|
178
|
-
{protectedBranchDisplayName(b.name) ?? b.name}
|
|
179
|
+
{protectedBranchDisplayName(currentBranchModel(), b.name) ?? b.name}
|
|
179
180
|
{b.name === DEFAULT_BRANCH ? ' (default)' : ''}
|
|
180
181
|
</option>
|
|
181
182
|
))}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
stripJunkBeforeKbDir,
|
|
10
10
|
} from '../../workspace/routing/kb-routes';
|
|
11
11
|
import { useWorkspaceImageResolver } from '../../workspace/hooks/useWorkspaceImageResolver';
|
|
12
|
-
import { pluginOfPath, DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
12
|
+
import { pluginOfPath, currentKbLayout, DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
13
13
|
import { cn } from '../../../lib/utils';
|
|
14
14
|
import { DOCUMENT_COLUMN, documentGutters } from '../../../shared/theme/measure';
|
|
15
15
|
import { ReviewFileRow } from './ReviewFileRow';
|
|
@@ -43,7 +43,7 @@ export function isPluginItemPath(path: string, kbDirName: string | null): boolea
|
|
|
43
43
|
kbDirName && withoutJunk.startsWith(`${kbDirName}/`)
|
|
44
44
|
? withoutJunk.slice(kbDirName.length + 1)
|
|
45
45
|
: withoutJunk;
|
|
46
|
-
return pluginOfPath(repoRelative) !== null;
|
|
46
|
+
return pluginOfPath(repoRelative, currentKbLayout()) !== null;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -111,6 +111,7 @@ describe('SettingsLayout', () => {
|
|
|
111
111
|
const links = within(nav()).getAllByRole('link');
|
|
112
112
|
expect(links.map((l) => l.textContent)).toEqual([
|
|
113
113
|
'External agent access',
|
|
114
|
+
'Audit log',
|
|
114
115
|
'Secrets',
|
|
115
116
|
'Browse available tools',
|
|
116
117
|
'Account',
|
|
@@ -242,7 +243,7 @@ describe('SettingsLayout', () => {
|
|
|
242
243
|
renderAt('/secrets');
|
|
243
244
|
expect(document.getElementById(SIDEBAR_DOM_ID)).toBeNull();
|
|
244
245
|
expect(noNav()).not.toBeNull();
|
|
245
|
-
expect(within(nav()).getAllByRole('link')).toHaveLength(
|
|
246
|
+
expect(within(nav()).getAllByRole('link')).toHaveLength(5);
|
|
246
247
|
vi.unstubAllGlobals();
|
|
247
248
|
});
|
|
248
249
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import { Boxes, CircleUserRound, KeyRound, Lock, SlidersHorizontal, Users, UsersRound } from 'lucide-react';
|
|
2
|
+
import { Boxes, CircleUserRound, KeyRound, Lock, ScrollText, SlidersHorizontal, Users, UsersRound } from 'lucide-react';
|
|
3
3
|
import { useAppRegistry, type AdminMenuItem } from '../../core/registry';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -42,6 +42,16 @@ export const CORE_MENU_ITEMS: AdminMenuItem[] = [
|
|
|
42
42
|
label: 'External agent access',
|
|
43
43
|
path: '/external-agent-access',
|
|
44
44
|
},
|
|
45
|
+
{
|
|
46
|
+
// Everyone's row, not an admin's: each person sees their own agents and
|
|
47
|
+
// keys and what those called; admins see every account on the same page.
|
|
48
|
+
// It replaced the admin-only Connection keys row.
|
|
49
|
+
id: 'audit-log',
|
|
50
|
+
order: 45,
|
|
51
|
+
icon: <ScrollText size={15} />,
|
|
52
|
+
label: 'Audit log',
|
|
53
|
+
path: '/audit-log',
|
|
54
|
+
},
|
|
45
55
|
{
|
|
46
56
|
id: 'secrets',
|
|
47
57
|
order: 50,
|
|
@@ -95,14 +105,6 @@ export const CORE_MENU_ITEMS: AdminMenuItem[] = [
|
|
|
95
105
|
label: 'User accounts',
|
|
96
106
|
path: '/user-accounts',
|
|
97
107
|
},
|
|
98
|
-
{
|
|
99
|
-
id: 'connection-keys',
|
|
100
|
-
section: 'admin',
|
|
101
|
-
order: 25,
|
|
102
|
-
icon: <KeyRound size={15} />,
|
|
103
|
-
label: 'Connection keys',
|
|
104
|
-
path: '/connection-keys',
|
|
105
|
-
},
|
|
106
108
|
];
|
|
107
109
|
|
|
108
110
|
/**
|
|
@@ -178,6 +178,11 @@ const FIELDS: Record<
|
|
|
178
178
|
help: 'Only people with an address at these domains can sign in this way. Separate several with commas. Leave blank to allow any address: safe with a provider that only serves your organisation, risky with one that does not.',
|
|
179
179
|
placeholder: 'example.com',
|
|
180
180
|
},
|
|
181
|
+
auditRetentionDays: {
|
|
182
|
+
label: 'Keep events for',
|
|
183
|
+
help: 'How many days an agent’s recorded calls stay in the Audit log before they are removed. Leave it blank, or enter 0, to keep them forever. Applies without a restart.',
|
|
184
|
+
placeholder: 'forever',
|
|
185
|
+
},
|
|
181
186
|
};
|
|
182
187
|
|
|
183
188
|
/**
|
|
@@ -257,6 +262,12 @@ const SECTIONS: { id: SettingStatus['section']; title: string; blurb: string }[]
|
|
|
257
262
|
blurb:
|
|
258
263
|
'Optional, and you can add it later. Lets people sign in with the account they already have instead of a password.',
|
|
259
264
|
},
|
|
265
|
+
{
|
|
266
|
+
id: 'audit',
|
|
267
|
+
title: 'Audit log',
|
|
268
|
+
blurb:
|
|
269
|
+
'The Audit log records which tools, skills and capabilities each connected agent uses. Choose how long those records are kept; unset, they are kept forever.',
|
|
270
|
+
},
|
|
260
271
|
];
|
|
261
272
|
|
|
262
273
|
interface Props {
|