@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
|
@@ -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
|
/**
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
} from 'lucide-react';
|
|
29
29
|
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
30
30
|
import {
|
|
31
|
+
currentBranchModel,
|
|
31
32
|
isProtectedBranch,
|
|
32
33
|
validateFilename,
|
|
33
34
|
KNOWLEDGE_BASE_DIR,
|
|
@@ -1822,7 +1823,7 @@ export function TreeChrome({
|
|
|
1822
1823
|
const focusAfterConfirm = useRef<(() => HTMLElement | null) | null>(null);
|
|
1823
1824
|
useEffect(() => {
|
|
1824
1825
|
if (confirmRequest?.kind !== 'move' || !workspaceId || !kbDirName) return;
|
|
1825
|
-
if (!isProtectedBranch(decodeURIComponent(workspaceId))) return;
|
|
1826
|
+
if (!isProtectedBranch(currentBranchModel(), decodeURIComponent(workspaceId))) return;
|
|
1826
1827
|
const prefix = `${kbDirName}/`;
|
|
1827
1828
|
if (!confirmRequest.targetDir.startsWith(prefix)) return;
|
|
1828
1829
|
let cancelled = false;
|
|
@@ -2106,7 +2107,8 @@ function useCanWriteFolder(workspacePath: string | null): boolean {
|
|
|
2106
2107
|
const isKbRoot = workspacePath !== null && workspacePath === kbDirName;
|
|
2107
2108
|
const shortCircuit =
|
|
2108
2109
|
key !== null &&
|
|
2109
|
-
((!isKbRoot && !workspacePath!.startsWith(prefix!)) ||
|
|
2110
|
+
((!isKbRoot && !workspacePath!.startsWith(prefix!)) ||
|
|
2111
|
+
!isProtectedBranch(currentBranchModel(), decodeURIComponent(workspaceId!)));
|
|
2110
2112
|
useEffect(() => {
|
|
2111
2113
|
if (key === null || shortCircuit) return;
|
|
2112
2114
|
let cancelled = false;
|
|
@@ -962,10 +962,15 @@ export function FileViewer() {
|
|
|
962
962
|
|
|
963
963
|
// Which shape the document column takes. A history / comparison panel is a
|
|
964
964
|
// fixed-height viewport with its own scroller (both roots are
|
|
965
|
-
// `flex-1 flex flex-col min-h-0`), so it
|
|
966
|
-
// the
|
|
965
|
+
// `flex-1 flex flex-col min-h-0`), so it needs the definite height a PDF
|
|
966
|
+
// needs — but NOT the full bleed. It is standing in for the document, in the
|
|
967
|
+
// document's place, and a panel that threw the column away took the title,
|
|
968
|
+
// the tab strip and the timeline with it: the heading ran into the pane's
|
|
969
|
+
// left edge and the commit list started flush against it, so going to
|
|
970
|
+
// history and coming back moved every row on the page. `panel` is the
|
|
971
|
+
// reading view's column with full-bleed's height — see `KbDocumentShell`.
|
|
967
972
|
const shellVariant =
|
|
968
|
-
activeTab === 'content' ? getRendererLayout(openFilePath) : '
|
|
973
|
+
activeTab === 'content' ? getRendererLayout(openFilePath) : 'panel';
|
|
969
974
|
|
|
970
975
|
// No-preview routes (legacy Office, ODF) have no editing surface at all —
|
|
971
976
|
// offering Edit/Propose there would acquire a lock for a mode the renderer
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
DOCUMENT_COLUMN,
|
|
5
5
|
DOCUMENT_COLUMN_WIDE,
|
|
6
6
|
documentGutters,
|
|
7
|
+
documentSideGutters,
|
|
7
8
|
} from '../../../shared/theme/measure';
|
|
8
9
|
import { HEADER_COLUMN_TOP } from '../../../shared/theme/header';
|
|
9
10
|
|
|
@@ -22,7 +23,12 @@ import { HEADER_COLUMN_TOP } from '../../../shared/theme/header';
|
|
|
22
23
|
* It mounts inside it BELOW the title bar, though — see `header`.
|
|
23
24
|
*/
|
|
24
25
|
export interface KbDocumentShellProps {
|
|
25
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Widens the column and opens the second track for the rail. Read by the
|
|
28
|
+
* 'prose' and 'full-bleed' variants only: 'panel' is the document column
|
|
29
|
+
* standing in for the document, and the pages that use it (history,
|
|
30
|
+
* comparison) withdraw the rail with the document it describes.
|
|
31
|
+
*/
|
|
26
32
|
rail?: ReactNode;
|
|
27
33
|
/**
|
|
28
34
|
* 'prose' — the shell scrolls, holds the 880/980 measure and the gutters.
|
|
@@ -35,12 +41,22 @@ export interface KbDocumentShellProps {
|
|
|
35
41
|
* auto-height column), image, csv, xlsx, the html sandbox
|
|
36
42
|
* iframe, and the tool form (whose `w-72` aside does not fit
|
|
37
43
|
* inside 880px minus gutters).
|
|
44
|
+
* 'panel' — the reading view's COLUMN with full-bleed's HEIGHT: the same
|
|
45
|
+
* 880px measure and the same side margins as 'prose', and a
|
|
46
|
+
* definite height so a panel that scrolls inside itself gets
|
|
47
|
+
* real pixels. For the file page's history and comparison
|
|
48
|
+
* modes, which are viewports the way a PDF is but which take
|
|
49
|
+
* the DOCUMENT's place and must not move it: switching to
|
|
50
|
+
* history changes what is in the column, not where the column
|
|
51
|
+
* is. They used to take 'full-bleed', which gave the title
|
|
52
|
+
* nothing to stand on at the pane's left edge and started the
|
|
53
|
+
* timeline flush against it.
|
|
38
54
|
*
|
|
39
55
|
* The caller picks from the extension, via `getRendererLayout` in
|
|
40
56
|
* `renderers/index.ts` — the same map `getFileRenderer` uses. Getting this
|
|
41
57
|
* wrong does not type-error; it renders a zero-height PDF.
|
|
42
58
|
*/
|
|
43
|
-
variant?: 'prose' | 'full-bleed';
|
|
59
|
+
variant?: 'prose' | 'full-bleed' | 'panel';
|
|
44
60
|
/**
|
|
45
61
|
* The file tree beside this column is hidden, so the space it gave up should
|
|
46
62
|
* become margin on both sides rather than more line length (proto:709). The
|
|
@@ -54,10 +70,11 @@ export interface KbDocumentShellProps {
|
|
|
54
70
|
* and is the only thing resetting the file lock's idle-release timer for a
|
|
55
71
|
* user who is reading rather than typing. Scroll events do not bubble, so a
|
|
56
72
|
* ref on an element nested *inside* the scroller never fires — which is why
|
|
57
|
-
* the ref lands on this component's outermost box in
|
|
58
|
-
* that box carries `overflow-auto` in
|
|
59
|
-
* exactly `h-full`, so nothing overflows and no
|
|
60
|
-
* listener still catches the renderer's own scroller
|
|
73
|
+
* the ref lands on this component's outermost box in EVERY variant, and why
|
|
74
|
+
* that box carries `overflow-auto` in all of them. In `full-bleed` and
|
|
75
|
+
* `panel` the child is exactly `h-full`, so nothing overflows and no
|
|
76
|
+
* scrollbar appears; the listener still catches the renderer's own scroller
|
|
77
|
+
* during capture.
|
|
61
78
|
*/
|
|
62
79
|
scrollRef?: Ref<HTMLDivElement>;
|
|
63
80
|
/**
|
|
@@ -104,10 +121,35 @@ export function KbDocumentShell({
|
|
|
104
121
|
data-variant={variant}
|
|
105
122
|
className={cn(
|
|
106
123
|
'relative min-h-0 flex-1 overflow-auto',
|
|
107
|
-
variant
|
|
124
|
+
variant !== 'prose' && 'flex flex-col',
|
|
108
125
|
)}
|
|
109
126
|
>
|
|
110
|
-
{variant === '
|
|
127
|
+
{variant === 'panel' ? (
|
|
128
|
+
// The reading view's frame, to the class: `DOCUMENT_COLUMN` and
|
|
129
|
+
// `documentSideGutters` are the same two calls the prose branch below
|
|
130
|
+
// makes, from the same `roomy` flag, so the title, the tab strip and
|
|
131
|
+
// whatever panel follows them all open on the margin the document
|
|
132
|
+
// opens on. The tests compare the two frames rather than restating
|
|
133
|
+
// either — `__tests__/KbDocumentShell.test.tsx` on the component and
|
|
134
|
+
// `__tests__/FileViewer.test.tsx` on the real page going into history
|
|
135
|
+
// and coming back.
|
|
136
|
+
//
|
|
137
|
+
// What differs is the height and the bottom: `h-full min-h-0 flex-col`
|
|
138
|
+
// hands the panel a definite box to scroll inside, exactly as
|
|
139
|
+
// full-bleed does for a PDF, and the 110px rhythm under a document is
|
|
140
|
+
// left off a column that ends where the pane does.
|
|
141
|
+
<div
|
|
142
|
+
className={cn(
|
|
143
|
+
DOCUMENT_COLUMN,
|
|
144
|
+
documentSideGutters(roomy),
|
|
145
|
+
HEADER_COLUMN_TOP,
|
|
146
|
+
'flex h-full min-h-0 flex-col',
|
|
147
|
+
)}
|
|
148
|
+
>
|
|
149
|
+
{header}
|
|
150
|
+
{children}
|
|
151
|
+
</div>
|
|
152
|
+
) : variant === 'full-bleed' ? (
|
|
111
153
|
// A definite height, not a scroll. `h-full` resolves against this
|
|
112
154
|
// component's own (flex-sized, definite) height, so an `h-full` iframe
|
|
113
155
|
// inside gets real pixels instead of collapsing to zero.
|
|
@@ -859,6 +859,55 @@ describe('FileViewer', () => {
|
|
|
859
859
|
expect(screen.getByRole('button', { name: 'Version history' })).toBeInTheDocument();
|
|
860
860
|
});
|
|
861
861
|
|
|
862
|
+
/**
|
|
863
|
+
* The log stands in for the document, in the document's PLACE.
|
|
864
|
+
*
|
|
865
|
+
* It used to take the full-bleed contract — right about the height it
|
|
866
|
+
* needs, wrong about everything else: the column went with it, so the title
|
|
867
|
+
* ran into the pane's left edge and the timeline started flush against it,
|
|
868
|
+
* and going to history and coming back moved every row on the page.
|
|
869
|
+
* `panel` is the reading view's column with full-bleed's height, so the
|
|
870
|
+
* frame is the SAME frame and the assertion can say so without naming a
|
|
871
|
+
* single measurement.
|
|
872
|
+
*/
|
|
873
|
+
it('keeps the document column when the log takes the place of the document', async () => {
|
|
874
|
+
const user = userEvent.setup();
|
|
875
|
+
render(<ViewerHarness initialContent="historic" />);
|
|
876
|
+
|
|
877
|
+
const frameOf = () =>
|
|
878
|
+
[...(screen.getByTestId('kb-document-shell').firstElementChild as HTMLElement).classList]
|
|
879
|
+
// The measure, the side margins and the offset the band opens on —
|
|
880
|
+
// everything that decides WHERE the column is. What the two modes are
|
|
881
|
+
// allowed to differ on is how the box below is sized: a document
|
|
882
|
+
// scrolls and ends on the bottom rhythm, a panel fills the pane.
|
|
883
|
+
.filter((cls) => /^(mx-auto|w-full|max-w-|px-|pt-|max-\[900px\]:px-)/.test(cls))
|
|
884
|
+
.sort();
|
|
885
|
+
|
|
886
|
+
const reading = frameOf();
|
|
887
|
+
// Non-empty, or the filter has stopped matching anything and the two
|
|
888
|
+
// empty lists below would agree about nothing.
|
|
889
|
+
expect(reading).toContain('max-w-[880px]');
|
|
890
|
+
expect(reading).toContain('px-[40px]');
|
|
891
|
+
|
|
892
|
+
await user.click(screen.getByRole('button', { name: 'Version history' }));
|
|
893
|
+
await screen.findByRole('button', { name: /Back to the document/ });
|
|
894
|
+
expect(screen.getByTestId('kb-document-shell').getAttribute('data-variant')).toBe('panel');
|
|
895
|
+
expect(frameOf()).toEqual(reading);
|
|
896
|
+
|
|
897
|
+
// The title is in that column, not beside it — the clipping Juan saw was
|
|
898
|
+
// a heading with no margin to stand on.
|
|
899
|
+
const column = screen.getByTestId('kb-document-shell').firstElementChild as HTMLElement;
|
|
900
|
+
expect(column).toContainElement(screen.getByRole('heading', { level: 1 }));
|
|
901
|
+
// So are the tab strip and the log itself.
|
|
902
|
+
expect(column).toContainElement(screen.getByRole('tablist', { name: 'Open files' }));
|
|
903
|
+
expect(column).toContainElement(screen.getByText(/Timeline:/));
|
|
904
|
+
|
|
905
|
+
// …and back: nothing about the frame moved.
|
|
906
|
+
await user.click(screen.getByRole('button', { name: /Back to the document/ }));
|
|
907
|
+
expect(await screen.findByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
908
|
+
expect(frameOf()).toEqual(reading);
|
|
909
|
+
});
|
|
910
|
+
|
|
862
911
|
it('closes Version history from the pressed clock in the header', async () => {
|
|
863
912
|
const user = userEvent.setup();
|
|
864
913
|
render(<ViewerHarness initialContent="historic" />);
|
|
@@ -24,6 +24,7 @@ describe('KbDocumentShell', () => {
|
|
|
24
24
|
it.each([
|
|
25
25
|
['prose', {}],
|
|
26
26
|
['full-bleed', { variant: 'full-bleed' as const }],
|
|
27
|
+
['panel', { variant: 'panel' as const }],
|
|
27
28
|
['with a rail', { rail: <p>About this file</p> }],
|
|
28
29
|
])('puts the header first in the column (%s)', (_name, props) => {
|
|
29
30
|
render(
|
|
@@ -99,13 +100,60 @@ describe('KbDocumentShell', () => {
|
|
|
99
100
|
expect(box.className).toContain('h-full');
|
|
100
101
|
});
|
|
101
102
|
|
|
103
|
+
/**
|
|
104
|
+
* `panel` is the reading view's COLUMN with full-bleed's HEIGHT — the one
|
|
105
|
+
* variant that has to agree with another one, so it is asserted against the
|
|
106
|
+
* prose column rather than against a list of classes copied out of
|
|
107
|
+
* `measure.ts`.
|
|
108
|
+
*
|
|
109
|
+
* The file page's history and comparison modes use it. They are viewports
|
|
110
|
+
* the way a PDF is, and they took 'full-bleed' for that reason; what they
|
|
111
|
+
* are not is a renderer the document makes room for. They stand IN the
|
|
112
|
+
* document's place, so the column has to stay exactly where the document
|
|
113
|
+
* left it, which is what this compares.
|
|
114
|
+
*/
|
|
115
|
+
it('gives a panel the prose column, minus the rhythm a document ends on', () => {
|
|
116
|
+
const frameOf = (text: string) => (screen.getByText(text).parentElement as HTMLElement).className;
|
|
117
|
+
|
|
118
|
+
const prose = render(
|
|
119
|
+
<KbDocumentShell roomy>
|
|
120
|
+
<p>The document</p>
|
|
121
|
+
</KbDocumentShell>,
|
|
122
|
+
);
|
|
123
|
+
const reading = frameOf('The document');
|
|
124
|
+
prose.unmount();
|
|
125
|
+
|
|
126
|
+
render(
|
|
127
|
+
<KbDocumentShell variant="panel" roomy>
|
|
128
|
+
<p>The log</p>
|
|
129
|
+
</KbDocumentShell>,
|
|
130
|
+
);
|
|
131
|
+
const panel = frameOf('The log');
|
|
132
|
+
|
|
133
|
+
// The measure, the margins and the offset the band opens on: identical,
|
|
134
|
+
// and read off the reading view rather than restated.
|
|
135
|
+
for (const cls of ['mx-auto', 'max-w-[880px]', 'px-[64px]', 'max-[900px]:px-[18px]', 'pt-3']) {
|
|
136
|
+
expect(reading).toContain(cls);
|
|
137
|
+
expect(panel).toContain(cls);
|
|
138
|
+
}
|
|
139
|
+
// `roomy` reaches it too, or a panel would keep the nav's margins on a
|
|
140
|
+
// page that has hidden the nav.
|
|
141
|
+
expect(panel).not.toContain('px-[40px]');
|
|
142
|
+
|
|
143
|
+
// A definite height instead of the bottom rhythm — a column that ends
|
|
144
|
+
// where the pane does has nothing to leave room after.
|
|
145
|
+
expect(panel).toContain('h-full');
|
|
146
|
+
expect(panel).not.toContain('pb-[110px]');
|
|
147
|
+
expect(reading).toContain('pb-[110px]');
|
|
148
|
+
});
|
|
149
|
+
|
|
102
150
|
// The regression this file exists for. `editorContainerRef` carries a
|
|
103
151
|
// capture-phase scroll listener that is the file lock's ONLY activity signal
|
|
104
152
|
// for someone who is reading rather than typing. Scroll events do not
|
|
105
153
|
// bubble, so a ref on an element nested inside the scroller never fires —
|
|
106
154
|
// and nothing type-errors when that happens; locks just silently drop out
|
|
107
155
|
// from under readers after two minutes.
|
|
108
|
-
it.each(['prose', 'full-bleed'] as const)(
|
|
156
|
+
it.each(['prose', 'full-bleed', 'panel'] as const)(
|
|
109
157
|
'lands scrollRef on the element that scrolls (%s)',
|
|
110
158
|
(variant) => {
|
|
111
159
|
const ref = createRef<HTMLDivElement>();
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { useState, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_BRANCH,
|
|
4
|
+
currentBranchModel,
|
|
5
|
+
isProtectedBranch,
|
|
6
|
+
type FileTreeEntry,
|
|
7
|
+
} from '@bevel-software/platform-shared';
|
|
3
8
|
import { useEventBus, canonicalizeWorkspaceId } from '../../workflow/state/event-bus.context';
|
|
4
9
|
import { AuthContext } from '../../auth/state/auth.context';
|
|
5
10
|
import { fetchFileAccess } from '../../access/api';
|
|
@@ -810,7 +815,7 @@ export function useWorkspaceState(): UseWorkspaceStateReturn {
|
|
|
810
815
|
const resolveSuggestionRouting = useCallback(
|
|
811
816
|
async (targetDirectory: string): Promise<KnowledgeSuggestionTarget | null> => {
|
|
812
817
|
if (!workspaceId || !kbDirName || !authUser) return null;
|
|
813
|
-
if (!isProtectedBranch(decodeURIComponent(workspaceId))) return null;
|
|
818
|
+
if (!isProtectedBranch(currentBranchModel(), decodeURIComponent(workspaceId))) return null;
|
|
814
819
|
const prefix = `${kbDirName}/`;
|
|
815
820
|
if (!targetDirectory.startsWith(prefix)) return null;
|
|
816
821
|
const repoRelative = targetDirectory.slice(prefix.length);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
KNOWLEDGE_BASE_DIR,
|
|
3
|
+
currentKbLayout,
|
|
3
4
|
reservedRootDirNames,
|
|
4
5
|
type FileTreeEntry,
|
|
5
6
|
} from '@bevel-software/platform-shared';
|
|
@@ -12,7 +13,7 @@ import type { PendingEntry } from '../state/workspace.context';
|
|
|
12
13
|
// folded into Knowledge as stray content. A function, not a module-scope set:
|
|
13
14
|
// three of the names are configurable and arrive after this module loads.
|
|
14
15
|
export const KB_ROOT_DIRS = {
|
|
15
|
-
has: (name: string): boolean => reservedRootDirNames().has(name),
|
|
16
|
+
has: (name: string): boolean => reservedRootDirNames(currentKbLayout()).has(name),
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
currentKbLayout,
|
|
2
3
|
isPlatformFile,
|
|
3
4
|
isPlatformRestoreShape,
|
|
4
5
|
isRootPlatformFile,
|
|
@@ -41,7 +42,7 @@ export function platformFileMoveRefusal(
|
|
|
41
42
|
): string | null {
|
|
42
43
|
const rel = repoRelative(wsRelativePath, kbDirName);
|
|
43
44
|
if (rel === null) return null;
|
|
44
|
-
return isPlatformFile(rel) ? platformFileRefusal(rel) : null;
|
|
45
|
+
return isPlatformFile(rel, currentKbLayout()) ? platformFileRefusal(rel) : null;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
/**
|
|
@@ -71,7 +72,7 @@ export function platformFileDragRefusal(
|
|
|
71
72
|
const refusal = platformFileMoveRefusal(wsRelativePath, kbDirName);
|
|
72
73
|
if (refusal === null || !isAdmin) return refusal;
|
|
73
74
|
const rel = repoRelative(wsRelativePath, kbDirName);
|
|
74
|
-
return rel === null || isRootPlatformFile(rel) ? refusal : null;
|
|
75
|
+
return rel === null || isRootPlatformFile(rel, currentKbLayout()) ? refusal : null;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
/**
|
|
@@ -303,7 +304,10 @@ export function moveWarnings(opts: {
|
|
|
303
304
|
const from = repoRelative(opts.sourcePath, opts.kbDirName);
|
|
304
305
|
const to = repoRelative(destination, opts.kbDirName);
|
|
305
306
|
const restore =
|
|
306
|
-
opts.isAdmin === true &&
|
|
307
|
+
opts.isAdmin === true &&
|
|
308
|
+
from !== null &&
|
|
309
|
+
to !== null &&
|
|
310
|
+
isPlatformRestoreShape(from, to, currentKbLayout());
|
|
307
311
|
warnings.push(
|
|
308
312
|
restore
|
|
309
313
|
? `You can't write to ${opts.destinationLabel}, but putting ${name} back where the platform reads it is allowed for an Admin.`
|
|
@@ -57,11 +57,32 @@ export const DOCUMENT_COLUMN_WIDE = 'mx-auto w-full max-w-[980px]';
|
|
|
57
57
|
* drops the bottom rhythm from 110px to 90px (proto:623-632) — that part is a
|
|
58
58
|
* genuine viewport rule and stays a media query.
|
|
59
59
|
*/
|
|
60
|
-
const
|
|
60
|
+
const BOTTOM_RHYTHM = 'pb-[110px] max-[900px]:pb-[90px]';
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
+
* The SIDES alone — the column's left and right margins, without the rhythm
|
|
64
|
+
* below the last paragraph.
|
|
65
|
+
*
|
|
66
|
+
* Split out for the column that is a VIEWPORT rather than a document: the
|
|
67
|
+
* file page in history or comparison mode fills the pane's height with a
|
|
68
|
+
* panel that scrolls inside itself, and 110px of padding under a panel like
|
|
69
|
+
* that is not breathing room after the text, it is 110px the timeline does
|
|
70
|
+
* not get. The margins are the part that has to agree with the reading view
|
|
71
|
+
* — they are what "switching to history moves nothing but the content" means
|
|
72
|
+
* — so they are what this returns, and the two callers differ in the bottom
|
|
73
|
+
* rhythm and in nothing else.
|
|
74
|
+
*
|
|
75
|
+
* @param roomy the nav beside this column is hidden, so the space it gave up
|
|
76
|
+
* becomes margin on both sides rather than more line length.
|
|
77
|
+
*/
|
|
78
|
+
export const documentSideGutters = (roomy: boolean): string =>
|
|
79
|
+
`${roomy ? 'px-[64px]' : 'px-[40px]'} max-[900px]:px-[18px]`;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The sides AND the bottom rhythm — a column of prose, which ends.
|
|
83
|
+
*
|
|
63
84
|
* @param roomy the nav beside this column is hidden, so the space it gave up
|
|
64
85
|
* becomes margin on both sides rather than more line length.
|
|
65
86
|
*/
|
|
66
87
|
export const documentGutters = (roomy: boolean): string =>
|
|
67
|
-
`${roomy
|
|
88
|
+
`${documentSideGutters(roomy)} ${BOTTOM_RHYTHM}`;
|