@bevel-software/platform-core-frontend 0.20.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/modules/access/hooks/useFileAccess.ts +2 -2
- 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/workspace/components/FileExplorer.tsx +4 -2
- package/src/modules/workspace/components/FileViewer.tsx +8 -3
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -8
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +49 -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/utils/fileTree.ts +2 -1
- package/src/modules/workspace/utils/treeConfirm.ts +7 -3
- package/src/shared/theme/measure.ts +23 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bevel-software/platform-core-frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Open-source core UI of the Bevel platform (raw TS/TSX source): workspace explorer/viewer, branches & change requests, Library, secrets, tools, access control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"tailwind-merge": "^3.5.0",
|
|
46
46
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
|
47
47
|
"yaml": "^2.9.0",
|
|
48
|
-
"@bevel-software/platform-shared": "0.
|
|
48
|
+
"@bevel-software/platform-shared": "0.21.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import { isProtectedBranch } from '@bevel-software/platform-shared';
|
|
2
|
+
import { currentBranchModel, isProtectedBranch } from '@bevel-software/platform-shared';
|
|
3
3
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
4
4
|
import { fetchFileAccess, type AccessEligible } from '../api';
|
|
5
5
|
|
|
@@ -98,7 +98,7 @@ export function useFileAccess(
|
|
|
98
98
|
setState({ canWrite: null, canDownload: null, eligible: EMPTY_ELIGIBLE, owners: EMPTY_ELIGIBLE, loading: false, error: null });
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
if (!isProtectedBranch(branch)) {
|
|
101
|
+
if (!isProtectedBranch(currentBranchModel(), branch)) {
|
|
102
102
|
// `canDownload: null` — NOT true. The write short-circuits are this
|
|
103
103
|
// hook's own policy, and they match the backend's write gates; the raw
|
|
104
104
|
// endpoint gates EVERY download regardless of branch or path, so
|
|
@@ -12,6 +12,7 @@ const OAUTH_ERROR_MESSAGES: Record<string, string> = {
|
|
|
12
12
|
auth: 'Sign-in failed. Please try again.',
|
|
13
13
|
start: 'Could not start sign-in. Please try again.',
|
|
14
14
|
not_configured: 'Single sign-on is not configured on this deployment.',
|
|
15
|
+
admission: 'This workspace has no seat available for your account. Ask its admin.',
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export function LoginScreen() {
|
|
@@ -2,7 +2,13 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
4
4
|
import { ChevronDown, GitBranch, Plus, Lock, Check, GitPullRequest, Trash2, Loader2 } from 'lucide-react';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
protectedBranchDisplayName,
|
|
7
|
+
currentBranchModel,
|
|
8
|
+
branchAuthorLocalpart,
|
|
9
|
+
isBranchAuthoredBy,
|
|
10
|
+
DEFAULT_BRANCH,
|
|
11
|
+
} from '@bevel-software/platform-shared';
|
|
6
12
|
import { useGit } from '../state/git.context';
|
|
7
13
|
import { parseGitError, type GitErrorInfo } from '../services/error-messages';
|
|
8
14
|
import { useAuth } from '../../auth/state/auth.context';
|
|
@@ -192,7 +198,7 @@ export function BranchSwitcher() {
|
|
|
192
198
|
// shared draft" is wrong, it's the official version everyone sees.
|
|
193
199
|
const branchLabel = (() => {
|
|
194
200
|
if (switchingTo) return `Switching to ${switchingTo}…`;
|
|
195
|
-
const protectedName = protectedBranchDisplayName(git.status?.branch);
|
|
201
|
+
const protectedName = protectedBranchDisplayName(currentBranchModel(), git.status?.branch);
|
|
196
202
|
if (protectedName) return `${protectedName} (official version)`;
|
|
197
203
|
return 'Your active shared draft';
|
|
198
204
|
})();
|
|
@@ -403,7 +409,7 @@ export function BranchSwitcher() {
|
|
|
403
409
|
</div>
|
|
404
410
|
)}
|
|
405
411
|
{targetBranches.map((b) => {
|
|
406
|
-
const displayName = protectedBranchDisplayName(b.name);
|
|
412
|
+
const displayName = protectedBranchDisplayName(currentBranchModel(), b.name);
|
|
407
413
|
// Default destination for shared drafts: visually distinguish
|
|
408
414
|
// the default branch so users see the recommended path without
|
|
409
415
|
// having to read the slug. Others stay available, just quieter.
|
|
@@ -8,7 +8,13 @@ import {
|
|
|
8
8
|
AlertTriangle,
|
|
9
9
|
RefreshCw,
|
|
10
10
|
} from 'lucide-react';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
protectedBranchDisplayName,
|
|
13
|
+
isProtectedBranch,
|
|
14
|
+
currentBranchModel,
|
|
15
|
+
DEFAULT_BRANCH,
|
|
16
|
+
type BranchInfo,
|
|
17
|
+
} from '@bevel-software/platform-shared';
|
|
12
18
|
import { useGit } from '../state/git.context';
|
|
13
19
|
import { UnifiedDiffView } from './UnifiedDiffView';
|
|
14
20
|
import { friendlyGitError } from '../services/error-messages';
|
|
@@ -84,7 +90,7 @@ function defaultFromForCurrent(
|
|
|
84
90
|
// On a protected branch, prefer the default branch as the comparison base so
|
|
85
91
|
// the picker opens on the canonical "official vs official" diff; if we're
|
|
86
92
|
// already on the default branch, any other protected branch works.
|
|
87
|
-
if (isProtectedBranch(currentBranch)) {
|
|
93
|
+
if (isProtectedBranch(currentBranchModel(), currentBranch)) {
|
|
88
94
|
if (currentBranch !== DEFAULT_BRANCH && others.some((b) => b.name === DEFAULT_BRANCH)) {
|
|
89
95
|
return DEFAULT_BRANCH;
|
|
90
96
|
}
|
|
@@ -313,7 +319,7 @@ function BranchPicker({ label, value, branches, onChange }: BranchPickerProps) {
|
|
|
313
319
|
const valueIsProtected = !!value && (
|
|
314
320
|
branches.find((b) => b.name === value)?.isProtected ?? false
|
|
315
321
|
);
|
|
316
|
-
const valueDisplay = value ? protectedBranchDisplayName(value) ?? value : 'Select…';
|
|
322
|
+
const valueDisplay = value ? protectedBranchDisplayName(currentBranchModel(), value) ?? value : 'Select…';
|
|
317
323
|
|
|
318
324
|
return (
|
|
319
325
|
<div ref={ref} className="relative flex-1 min-w-0">
|
|
@@ -341,7 +347,7 @@ function BranchPicker({ label, value, branches, onChange }: BranchPickerProps) {
|
|
|
341
347
|
<div className="px-3 py-2 text-xs text-ink-muted">No branches.</div>
|
|
342
348
|
)}
|
|
343
349
|
{branches.map((b) => {
|
|
344
|
-
const display = protectedBranchDisplayName(b.name);
|
|
350
|
+
const display = protectedBranchDisplayName(currentBranchModel(), b.name);
|
|
345
351
|
const isSelected = b.name === value;
|
|
346
352
|
return (
|
|
347
353
|
<button
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { GitMerge } from 'lucide-react';
|
|
3
|
-
import { isProtectedBranch } from '@bevel-software/platform-shared';
|
|
3
|
+
import { currentBranchModel, isProtectedBranch } from '@bevel-software/platform-shared';
|
|
4
4
|
import { useGit } from '../state/git.context';
|
|
5
5
|
import { useAutoUpdate } from '../state/auto-update.context';
|
|
6
6
|
import { useCrCreationPort } from '../../../core/registry';
|
|
@@ -63,7 +63,7 @@ export function PullNeededBanner() {
|
|
|
63
63
|
// Captured for the handlers below — TS control-flow narrowing on `status`
|
|
64
64
|
// doesn't survive into nested function declarations.
|
|
65
65
|
const branchName = status.branch;
|
|
66
|
-
const onProtectedBranch = isProtectedBranch(status.branch);
|
|
66
|
+
const onProtectedBranch = isProtectedBranch(currentBranchModel(), status.branch);
|
|
67
67
|
const hasUnsavedEditorChanges = !!workspace.hasUnsavedFileChanges;
|
|
68
68
|
// Under save=share the working tree is never dirty and there are no
|
|
69
69
|
// mid-merge conflicts to gate on — the only thing that can still block
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { protectedBranchDisplayName } from '@bevel-software/platform-shared';
|
|
1
|
+
import { currentBranchModel, protectedBranchDisplayName } from '@bevel-software/platform-shared';
|
|
2
2
|
import { GitApiError } from './git.api';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -74,7 +74,7 @@ export function parseGitError(err: unknown): GitErrorInfo {
|
|
|
74
74
|
* "Target company state" instead of `target-company-state`.
|
|
75
75
|
*/
|
|
76
76
|
function friendlyNoSharedHistoryMessage(base: string): string {
|
|
77
|
-
const baseName = protectedBranchDisplayName(base) ?? base;
|
|
77
|
+
const baseName = protectedBranchDisplayName(currentBranchModel(), base) ?? base;
|
|
78
78
|
return (
|
|
79
79
|
`This draft doesn't share history with the ${baseName}. It was likely started ` +
|
|
80
80
|
`from an unrelated point or outside the app. The assistant can investigate and ` +
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* rule the browser would get is the rule this test gets.
|
|
18
18
|
*/
|
|
19
19
|
import { describe, it, expect, beforeAll, beforeEach, afterAll } from 'vitest';
|
|
20
|
+
import type { ReactNode } from 'react';
|
|
20
21
|
import { render, screen } from '@testing-library/react';
|
|
21
22
|
import { readFileSync } from 'node:fs';
|
|
22
23
|
import { createRequire } from 'node:module';
|
|
@@ -115,6 +116,31 @@ function flattenCascadeLayers(css: string): string {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Every class a tree actually renders, harvested off the DOM.
|
|
121
|
+
*
|
|
122
|
+
* The candidate list has to hold every utility these assertions depend on —
|
|
123
|
+
* Tailwind emits no rule for a class nobody names — and the band wears more
|
|
124
|
+
* than `HEADER_BAND`. The sidebar's row adds `empty:hidden`, which is
|
|
125
|
+
* `SidebarFrame`'s own and the whole of the "a header that draws nothing
|
|
126
|
+
* reserves no band" rule; a list that named it by hand would keep compiling it
|
|
127
|
+
* long after the frame stopped using it, and every assertion below it would
|
|
128
|
+
* pass against a stylesheet describing an app that no longer exists.
|
|
129
|
+
*
|
|
130
|
+
* So the list is READ off a render instead. Rendered here before the
|
|
131
|
+
* stylesheet is in the document, which is fine: this only wants the class
|
|
132
|
+
* attributes, and unmounts before any test runs.
|
|
133
|
+
*/
|
|
134
|
+
function classesRendered(tree: ReactNode): string[] {
|
|
135
|
+
const { container, unmount } = render(tree);
|
|
136
|
+
const found = new Set<string>();
|
|
137
|
+
for (const element of container.querySelectorAll<HTMLElement>('*')) {
|
|
138
|
+
for (const cls of element.classList) found.add(cls);
|
|
139
|
+
}
|
|
140
|
+
unmount();
|
|
141
|
+
return [...found];
|
|
142
|
+
}
|
|
143
|
+
|
|
118
144
|
/**
|
|
119
145
|
* `--spacing-header` as the BUILD resolves it, read back out of the compiled
|
|
120
146
|
* CSS. Not out of `tokens.css`: a value a test parses from source is a value
|
|
@@ -151,15 +177,27 @@ let stylesheet: HTMLStyleElement;
|
|
|
151
177
|
beforeAll(async () => {
|
|
152
178
|
// The candidates are the band's own classes, read off the constant the app
|
|
153
179
|
// renders — `flex h-header flex-none items-center` today, whatever it says
|
|
154
|
-
// tomorrow
|
|
155
|
-
//
|
|
156
|
-
|
|
180
|
+
// tomorrow — plus every class a real `SidebarFrame` puts on the row, which
|
|
181
|
+
// is where `empty:hidden` comes from. `HEADER_COLUMN_TOP` rides along
|
|
182
|
+
// because the column's offset is the other half of the seam.
|
|
183
|
+
const css = await compileAppStylesheet([
|
|
184
|
+
...`${HEADER_BAND} ${HEADER_COLUMN_TOP}`.split(/\s+/),
|
|
185
|
+
...classesRendered(
|
|
186
|
+
<SidebarFrame label="File explorer" header={<div>Connect your agent</div>}>
|
|
187
|
+
<nav>tree</nav>
|
|
188
|
+
</SidebarFrame>,
|
|
189
|
+
),
|
|
190
|
+
]);
|
|
157
191
|
|
|
158
192
|
// The compiled output has to CONTAIN the height utility, or the rest of
|
|
159
193
|
// this file is measuring an element with no rule behind it and every
|
|
160
194
|
// `auto === auto` comparison passes. This is the assertion that catches a
|
|
161
195
|
// Tailwind or configuration regression rather than a markup one.
|
|
162
196
|
expect(css).toMatch(/\.h-header\s*\{[^}]*height:\s*var\(--spacing-header\)/);
|
|
197
|
+
// Same for the rule that TAKES the band away again. Without it, the
|
|
198
|
+
// empty-header case below would read an element with no display rule on it
|
|
199
|
+
// and call the band gone on the strength of a default.
|
|
200
|
+
expect(css).toMatch(/:empty\s*\{[^}]*display:\s*none/);
|
|
163
201
|
headerHeight = tokenHeightIn(css);
|
|
164
202
|
|
|
165
203
|
stylesheet = document.createElement('style');
|
|
@@ -242,6 +280,16 @@ const heightOf = (testId: string) =>
|
|
|
242
280
|
/** The column a band opens — the element the band is the first row of. */
|
|
243
281
|
const columnOf = (testId: string) => screen.getByTestId(testId).parentElement!;
|
|
244
282
|
|
|
283
|
+
/**
|
|
284
|
+
* A column's top-padding classes — what decides where its first row starts.
|
|
285
|
+
*
|
|
286
|
+
* Compared between the two columns rather than against a literal: the number
|
|
287
|
+
* lives in `HEADER_COLUMN_TOP` and moving it is allowed, moving it on one
|
|
288
|
+
* side only is the bug.
|
|
289
|
+
*/
|
|
290
|
+
const offsetClassesOf = (column: Element) =>
|
|
291
|
+
[...column.classList].filter((cls) => cls.startsWith('pt-'));
|
|
292
|
+
|
|
245
293
|
/**
|
|
246
294
|
* Everything drawn above a band inside its own column.
|
|
247
295
|
*
|
|
@@ -301,19 +349,72 @@ describe('the sidebar header row and the page title bar', () => {
|
|
|
301
349
|
}
|
|
302
350
|
});
|
|
303
351
|
|
|
304
|
-
it('
|
|
352
|
+
it('spends the row on a header that draws', () => {
|
|
353
|
+
render(
|
|
354
|
+
<SidebarFrame label="File explorer" header={<div>Connect your agent</div>}>
|
|
355
|
+
<nav>tree</nav>
|
|
356
|
+
</SidebarFrame>,
|
|
357
|
+
);
|
|
358
|
+
const band = screen.getByTestId(SIDEBAR_HEADER_TESTID);
|
|
359
|
+
expect(band).not.toBeEmptyDOMElement();
|
|
360
|
+
expect(window.getComputedStyle(band).display).not.toBe('none');
|
|
361
|
+
expect(heightOf(SIDEBAR_HEADER_TESTID)).toBe(headerHeight);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('reserves no row for a header that draws nothing', () => {
|
|
305
365
|
// Knowledge and the Library both pass the connect-your-agent pill, which
|
|
306
|
-
//
|
|
307
|
-
// the
|
|
308
|
-
//
|
|
309
|
-
// who
|
|
366
|
+
// draws NOTHING once onboarding is done. The band used to stay anyway, on
|
|
367
|
+
// the theory that a row coming and going would break the seam — and what
|
|
368
|
+
// it actually did was open the nav a band's height BELOW the page title
|
|
369
|
+
// beside it, for everyone who had finished setting the product up.
|
|
370
|
+
//
|
|
371
|
+
// Measured against the real sheet, not read off the class list: what this
|
|
372
|
+
// has to be true of is the box the browser lays out, and a `hidden`
|
|
373
|
+
// variant that Tailwind stopped emitting would leave the class in place
|
|
374
|
+
// and the strip on the screen.
|
|
310
375
|
const DismissedPill = () => null;
|
|
311
376
|
render(
|
|
312
377
|
<SidebarFrame label="File explorer" header={<DismissedPill />}>
|
|
313
378
|
<nav>tree</nav>
|
|
314
379
|
</SidebarFrame>,
|
|
315
380
|
);
|
|
316
|
-
|
|
381
|
+
const band = screen.getByTestId(SIDEBAR_HEADER_TESTID);
|
|
382
|
+
expect(band).toBeEmptyDOMElement();
|
|
383
|
+
expect(window.getComputedStyle(band).display).toBe('none');
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('opens the nav on the page title band once the header is done drawing', () => {
|
|
387
|
+
// The consequence, in the seam's own terms: with the band gone, the
|
|
388
|
+
// sidebar's first ROW is the first thing in the sidebar's column, and the
|
|
389
|
+
// page's title bar is the first thing in the page's. Both columns open on
|
|
390
|
+
// `HEADER_COLUMN_TOP`, so both start at the same offset — which is AC1's
|
|
391
|
+
// "their top edges align", as structurally as a DOM with no layout engine
|
|
392
|
+
// can put it.
|
|
393
|
+
const DismissedPill = () => null;
|
|
394
|
+
render(
|
|
395
|
+
<>
|
|
396
|
+
<SidebarFrame label="File explorer" header={<DismissedPill />}>
|
|
397
|
+
<nav>Company Context</nav>
|
|
398
|
+
</SidebarFrame>
|
|
399
|
+
<KbDocumentShell header={<PageHeader />}>
|
|
400
|
+
<p>The document</p>
|
|
401
|
+
</KbDocumentShell>
|
|
402
|
+
</>,
|
|
403
|
+
);
|
|
404
|
+
const nav = screen.getByText('Company Context');
|
|
405
|
+
const titleBar = screen.getByTestId(PAGE_HEADER_TESTID);
|
|
406
|
+
const offset = offsetClassesOf(nav.parentElement!);
|
|
407
|
+
// Non-empty first: two columns that have both lost their offset agree
|
|
408
|
+
// about nothing, and an `[] === []` pass is exactly how this assertion
|
|
409
|
+
// would stop noticing.
|
|
410
|
+
expect(offset).toEqual(HEADER_COLUMN_TOP.split(/\s+/));
|
|
411
|
+
expect(offsetClassesOf(titleBar.parentElement!)).toEqual(offset);
|
|
412
|
+
// And nothing between the sidebar column's top edge and that first row
|
|
413
|
+
// takes any height: the collapsed band is all there is, and it is gone.
|
|
414
|
+
for (let node = nav.previousElementSibling; node; node = node.previousElementSibling) {
|
|
415
|
+
expect(window.getComputedStyle(node).display).toBe('none');
|
|
416
|
+
}
|
|
417
|
+
expect(drawnAbove(PAGE_HEADER_TESTID)).toEqual([]);
|
|
317
418
|
});
|
|
318
419
|
|
|
319
420
|
it('renders no band for a surface that declares no header', () => {
|
|
@@ -365,16 +365,33 @@ export function SidebarFrame({
|
|
|
365
365
|
the seam under the toolbar; the page's title bar is the right
|
|
366
366
|
half.
|
|
367
367
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
the connect-your-agent
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
368
|
+
The band is spent on a header that DRAWS, and on nothing else.
|
|
369
|
+
It used to be keyed on whether the surface DECLARED one, on the
|
|
370
|
+
theory that a row coming and going with the connect-your-agent
|
|
371
|
+
pill would pull the nav up by the band's height the moment
|
|
372
|
+
onboarding finished. It does pull it up — onto the page title's
|
|
373
|
+
own band, which is where the nav's first row belongs. What the
|
|
374
|
+
old rule actually bought was an empty 48px strip above "Company
|
|
375
|
+
Context" and above the "Everything" lens, for everyone who had
|
|
376
|
+
finished setting the product up.
|
|
377
|
+
|
|
378
|
+
Settings passes no header at all and gets no band, because it
|
|
379
|
+
has no title bar on the other side of the seam to hold a line
|
|
380
|
+
with. Knowledge and the Library pass a pill that empties itself,
|
|
381
|
+
and get the band back the day it has something to say.
|
|
382
|
+
|
|
383
|
+
`empty:hidden` rather than a check in React, for the same reason
|
|
384
|
+
the footer group below uses it: an element that renders null is
|
|
385
|
+
still an element, so "did this header draw anything" is a
|
|
386
|
+
question only the DOM can answer. Which makes it the header's
|
|
387
|
+
business to leave NOTHING here when it has nothing — see
|
|
388
|
+
`ConnectAgentPill`, whose dismissal receipt goes to the body
|
|
389
|
+
rather than into this row. */}
|
|
376
390
|
{header !== undefined && (
|
|
377
|
-
<div
|
|
391
|
+
<div
|
|
392
|
+
data-testid={SIDEBAR_HEADER_TESTID}
|
|
393
|
+
className={cn(HEADER_BAND, 'w-full empty:hidden')}
|
|
394
|
+
>
|
|
378
395
|
{header}
|
|
379
396
|
</div>
|
|
380
397
|
)}
|
|
@@ -80,6 +80,7 @@ vi.mock('../utils/navigate-external', () => ({ navigateExternal: vi.fn() }));
|
|
|
80
80
|
|
|
81
81
|
import { ToolPage } from '../components/tool-page/ToolPage';
|
|
82
82
|
import { DeleteToolDialog } from '../components/tool-page/DeleteToolDialog';
|
|
83
|
+
import { expectMenuAtTheEndOfTheTitleRow } from './title-row-actions';
|
|
83
84
|
|
|
84
85
|
const TOOL: ToolSecrets = {
|
|
85
86
|
slug: 'heyreach',
|
|
@@ -196,6 +197,16 @@ beforeEach(() => {
|
|
|
196
197
|
});
|
|
197
198
|
|
|
198
199
|
describe('who is offered Delete', () => {
|
|
200
|
+
/**
|
|
201
|
+
* The menu's PLACE does not depend on what is in it. The same assertion
|
|
202
|
+
* `ToolPage.test.tsx` makes for a reader, here for the one caller that
|
|
203
|
+
* really owns the plugin — the spec's "with and without Delete".
|
|
204
|
+
*/
|
|
205
|
+
it('keeps the ⋯ at the right end of the title row for the owner too', async () => {
|
|
206
|
+
expect(await openMenu()).toBeInTheDocument();
|
|
207
|
+
expectMenuAtTheEndOfTheTitleRow();
|
|
208
|
+
});
|
|
209
|
+
|
|
199
210
|
it('offers it to an owner of the plugin holding the tool', async () => {
|
|
200
211
|
expect(await openMenu()).toBeInTheDocument();
|
|
201
212
|
});
|
|
@@ -32,6 +32,9 @@ vi.mock('../services/plugins.api', () => ({
|
|
|
32
32
|
listJoinRequests: pluginsMock.listJoinRequests,
|
|
33
33
|
reconcileJoinRequest: vi.fn(),
|
|
34
34
|
requestPluginAccess: vi.fn(),
|
|
35
|
+
// The plugin page repairs its links on open for a manager; these fixtures
|
|
36
|
+
// are members, so it never fires — but the module still has to export it.
|
|
37
|
+
repairPluginLinks: vi.fn().mockResolvedValue({ repaired: [], skipped: [] }),
|
|
35
38
|
AlreadyReadableError: class AlreadyReadableError extends Error {},
|
|
36
39
|
}));
|
|
37
40
|
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { render, screen, within } from '@testing-library/react';
|
|
3
|
+
import { Badge } from '../../../shared/components';
|
|
4
|
+
import { PluginIndexRow } from '../components/PluginIndexRow';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A plugin row's RIGHT EDGE — everything that is not the name.
|
|
8
|
+
*
|
|
9
|
+
* The bug: the `Owner` chip travelled with the name, through
|
|
10
|
+
* `NameWithBadges`, and the counts travelled with `ListRow`'s `meta`. Two
|
|
11
|
+
* groups, two lines, two vertical alignments. On the plugins index every row
|
|
12
|
+
* with a description is two lines tall, so the chip sat up on the name's line
|
|
13
|
+
* on the LEFT while "2 skills · 0 tools" sat centred on the RIGHT, and neither
|
|
14
|
+
* lined up with the other or with the row.
|
|
15
|
+
*
|
|
16
|
+
* The rule now is one line at the edge: chips, counts, state. `ListRow`
|
|
17
|
+
* already owns the group that does it (`ml-auto flex flex-none items-center`),
|
|
18
|
+
* so what these assert is that everything trailing is IN that one group —
|
|
19
|
+
* which is what makes "on one line, right-aligned, centred against the row"
|
|
20
|
+
* true by construction rather than by three components agreeing.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The row's trailing group: the one element that holds everything at the
|
|
25
|
+
* edge. Found through the counts, which every plugin row has, rather than by
|
|
26
|
+
* a class — the group is `ListRow`'s and its class list is `ListRow`'s to
|
|
27
|
+
* change.
|
|
28
|
+
*/
|
|
29
|
+
function trailingGroup(counts: string): HTMLElement {
|
|
30
|
+
return screen.getByText(counts).parentElement as HTMLElement;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('the trailing controls on a plugin row', () => {
|
|
34
|
+
const COUNTS = '2 skills · 0 tools';
|
|
35
|
+
|
|
36
|
+
it('puts the chip, the counts and the state in ONE group', () => {
|
|
37
|
+
render(
|
|
38
|
+
<PluginIndexRow
|
|
39
|
+
label="Company Handbook"
|
|
40
|
+
badge={<Badge>Owner</Badge>}
|
|
41
|
+
description="Run by Admin"
|
|
42
|
+
meta={COUNTS}
|
|
43
|
+
trailing={<Badge>Locked</Badge>}
|
|
44
|
+
onOpen={vi.fn()}
|
|
45
|
+
/>,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const group = trailingGroup(COUNTS);
|
|
49
|
+
expect(within(group).getByText('Owner')).toBeInTheDocument();
|
|
50
|
+
expect(within(group).getByText('Locked')).toBeInTheDocument();
|
|
51
|
+
// In reading order: what the plugin is to you, how much is in it, where
|
|
52
|
+
// your access stands.
|
|
53
|
+
expect(
|
|
54
|
+
[...group.children].map((child) => child.textContent),
|
|
55
|
+
).toEqual(['Owner', COUNTS, 'Locked']);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('holds that group on one centred line, right-aligned', () => {
|
|
59
|
+
render(
|
|
60
|
+
<PluginIndexRow
|
|
61
|
+
label="Company Handbook"
|
|
62
|
+
badge={<Badge>Owner</Badge>}
|
|
63
|
+
description="Run by Admin"
|
|
64
|
+
meta={COUNTS}
|
|
65
|
+
onOpen={vi.fn()}
|
|
66
|
+
/>,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const group = trailingGroup(COUNTS);
|
|
70
|
+
// `ml-auto` is the right-alignment, `items-center` the centring, and
|
|
71
|
+
// `flex-none` is what stops the group being squeezed into a second line
|
|
72
|
+
// by a long name. No `flex-wrap`: one line is the whole point.
|
|
73
|
+
expect(group.className).toContain('ml-auto');
|
|
74
|
+
expect(group.className).toContain('items-center');
|
|
75
|
+
expect(group.className).toContain('flex-none');
|
|
76
|
+
expect(group.className).not.toContain('flex-wrap');
|
|
77
|
+
// And the row centres it against ITSELF, so the height of the title
|
|
78
|
+
// block is not the group's business.
|
|
79
|
+
const row = group.parentElement as HTMLElement;
|
|
80
|
+
expect(row.className).toContain('items-center');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The reported case, exactly: "Company Handbook" over "Run by Admin" is a
|
|
85
|
+
* two-line title block, and the pill used to ride the first of those lines.
|
|
86
|
+
*/
|
|
87
|
+
it('does not move when the title block is two lines tall', () => {
|
|
88
|
+
const { rerender } = render(
|
|
89
|
+
<PluginIndexRow
|
|
90
|
+
label="Company Handbook"
|
|
91
|
+
badge={<Badge>Owner</Badge>}
|
|
92
|
+
meta={COUNTS}
|
|
93
|
+
onOpen={vi.fn()}
|
|
94
|
+
/>,
|
|
95
|
+
);
|
|
96
|
+
const oneLine = trailingGroup(COUNTS);
|
|
97
|
+
expect(within(oneLine).getByText('Owner')).toBeInTheDocument();
|
|
98
|
+
const shape = oneLine.className;
|
|
99
|
+
|
|
100
|
+
rerender(
|
|
101
|
+
<PluginIndexRow
|
|
102
|
+
label="Company Handbook"
|
|
103
|
+
badge={<Badge>Owner</Badge>}
|
|
104
|
+
description="Run by Admin, Olga Ivanova and Juan Perez"
|
|
105
|
+
meta={COUNTS}
|
|
106
|
+
onOpen={vi.fn()}
|
|
107
|
+
/>,
|
|
108
|
+
);
|
|
109
|
+
const twoLines = trailingGroup(COUNTS);
|
|
110
|
+
// Same group, same classes, and the chip is still in it: the description
|
|
111
|
+
// grew the title block and changed nothing at the edge.
|
|
112
|
+
expect(twoLines.className).toBe(shape);
|
|
113
|
+
expect(within(twoLines).getByText('Owner')).toBeInTheDocument();
|
|
114
|
+
expect(screen.getByText('Run by Admin, Olga Ivanova and Juan Perez')).toBeInTheDocument();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('keeps the trailing room clear for the menu that rides the same line', () => {
|
|
118
|
+
// The `…` is a SIBLING of the row button, positioned on the row's
|
|
119
|
+
// mid-line — the same line the group is centred on — but it is out of the
|
|
120
|
+
// flex flow, so the row reserves its width rather than letting it paint
|
|
121
|
+
// over the counts.
|
|
122
|
+
render(
|
|
123
|
+
<PluginIndexRow
|
|
124
|
+
label="Company Handbook"
|
|
125
|
+
badge={<Badge>Owner</Badge>}
|
|
126
|
+
meta={COUNTS}
|
|
127
|
+
actions={[{ label: 'Share', icon: null, onSelect: vi.fn() }]}
|
|
128
|
+
onOpen={vi.fn()}
|
|
129
|
+
/>,
|
|
130
|
+
);
|
|
131
|
+
const row = trailingGroup(COUNTS).parentElement as HTMLElement;
|
|
132
|
+
expect(row.className).toContain('pr-10');
|
|
133
|
+
// Centred on the row's mid-line, which is the line the group is on.
|
|
134
|
+
const menu = screen.getByRole('button', { name: 'Actions for Company Handbook' });
|
|
135
|
+
expect(menu.className).toContain('top-1/2');
|
|
136
|
+
expect(menu.className).toContain('-translate-y-1/2');
|
|
137
|
+
// …and it really is outside the row, or reserving room for it would be
|
|
138
|
+
// reserving room twice.
|
|
139
|
+
expect(row).not.toContainElement(menu);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('grows no trailing group at all on a row with nothing to put in one', () => {
|
|
143
|
+
render(<PluginIndexRow label="Company Handbook" onOpen={vi.fn()} />);
|
|
144
|
+
expect(screen.queryByText('Owner')).toBeNull();
|
|
145
|
+
});
|
|
146
|
+
});
|