@bevel-software/platform-core-frontend 0.21.0 → 0.23.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 +2 -0
- package/src/core/registry.ts +140 -0
- package/src/lib/api.ts +49 -0
- package/src/modules/access/__tests__/ManageAccessDialog.request.test.tsx +376 -0
- package/src/modules/access/api.ts +6 -4
- package/src/modules/access/components/AccessRequestControl.tsx +155 -0
- package/src/modules/{library → access}/components/AccessRequestsBanner.tsx +62 -24
- package/src/modules/access/components/ManageAccessDialog.tsx +81 -4
- package/src/modules/access/hooks/useAccessRequests.ts +183 -0
- package/src/modules/access/requests.api.ts +121 -0
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +89 -1
- package/src/modules/admin/components/UserAccountsPage.tsx +93 -5
- package/src/modules/auth/components/LoginScreen.tsx +8 -0
- package/src/modules/auth/services/account.api.ts +26 -3
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +171 -38
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +34 -19
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +173 -6
- package/src/modules/change-requests/components/BranchFilePreview.tsx +7 -1
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +155 -98
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +89 -10
- package/src/modules/git/__tests__/HistoryVersionPreview.test.tsx +479 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +52 -65
- package/src/modules/git/components/HistoryVersionPreview.tsx +410 -0
- package/src/modules/layout/__tests__/ReadOnlyBanner.test.tsx +157 -0
- package/src/modules/layout/components/ReadOnlyBanner.tsx +96 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +15 -0
- package/src/modules/library/__tests__/ToolPage.test.tsx +15 -1
- package/src/modules/library/__tests__/title-row-actions.ts +53 -1
- package/src/modules/library/components/PluginJoinRequests.tsx +2 -2
- package/src/modules/library/components/skill-page/SkillPage.tsx +2 -2
- package/src/modules/library/components/tool-page/ToolPage.tsx +11 -1
- package/src/modules/library/hooks/useJoinRequests.ts +26 -101
- package/src/modules/pr/services/pr-merge.api.ts +10 -2
- package/src/modules/settings/components/DeploymentPage.tsx +22 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +72 -4
- package/src/modules/setup/__tests__/setup.first-run.test.tsx +276 -0
- package/src/modules/setup/__tests__/setup.github.test.tsx +416 -0
- package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +275 -0
- package/src/modules/setup/__tests__/setup.repository-change.test.tsx +296 -0
- package/src/modules/setup/__tests__/setup.repository.test.tsx +463 -0
- package/src/modules/setup/__tests__/setup.test.tsx +13 -17
- package/src/modules/setup/components/GitHubRepositoryPanel.tsx +369 -0
- package/src/modules/setup/components/SetupGate.tsx +1 -0
- package/src/modules/setup/components/SetupScreen.tsx +608 -41
- package/src/modules/setup/services/setup.api.ts +171 -3
- package/src/modules/setup/utils/kept-draft.ts +86 -0
- package/src/modules/workspace/components/FileExplorer.tsx +140 -12
- package/src/modules/workspace/components/FileViewer.tsx +11 -1
- package/src/modules/workspace/components/TreeActionConfirm.tsx +5 -7
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +603 -29
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +23 -6
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +41 -8
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +20 -5
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +39 -16
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +27 -7
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +20 -5
- package/src/modules/workspace/components/renderers/RetryReadButton.tsx +37 -0
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +20 -5
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +186 -7
- package/src/modules/workspace/components/renderers/__tests__/readPane.test.tsx +59 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +80 -20
- package/src/modules/workspace/components/renderers/index.ts +6 -1
- package/src/modules/workspace/components/renderers/readPane.ts +22 -0
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +50 -9
- package/src/modules/workspace/components/renderers/useReadRetry.ts +27 -0
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +79 -0
- package/src/modules/workspace/routing/kb-routes.ts +25 -10
- package/src/modules/workspace/services/workspace.api.ts +22 -1
- package/src/shared/components/SlotBoundary.tsx +51 -0
- package/src/shared/markdown/__tests__/hrefs.test.ts +111 -0
- package/src/shared/markdown/hrefs.ts +80 -4
|
@@ -129,6 +129,7 @@ vi.mock('../state/library-data', () => ({
|
|
|
129
129
|
|
|
130
130
|
import { SkillPage } from '../components/skill-page/SkillPage';
|
|
131
131
|
import { LibraryToastProvider } from '../state/toast';
|
|
132
|
+
import { expectTitleRowSpansTheDocumentColumn } from './title-row-actions';
|
|
132
133
|
|
|
133
134
|
const workspace = {
|
|
134
135
|
workspaceId: 'target-company-state',
|
|
@@ -447,6 +448,20 @@ describe('SkillPage', () => {
|
|
|
447
448
|
expect(screen.queryByText('Drafts the Friday newsletter for review.')).toBeNull();
|
|
448
449
|
});
|
|
449
450
|
|
|
451
|
+
/**
|
|
452
|
+
* The third page in the comparison. The criterion names the plugin page and
|
|
453
|
+
* this one as the two controls the tool page's title row is measured
|
|
454
|
+
* against, and they agree only because neither wraps its band in a column
|
|
455
|
+
* narrower than the layout's — which is exactly what the tool page did.
|
|
456
|
+
* Asserted here so the day this page grows its own `max-w`, it is this test
|
|
457
|
+
* that says the row it holds is a control no longer.
|
|
458
|
+
*/
|
|
459
|
+
it('runs its title row to the shared document column', async () => {
|
|
460
|
+
renderPage(false);
|
|
461
|
+
await screen.findByRole('heading', { name: 'newsletter' });
|
|
462
|
+
expectTitleRowSpansTheDocumentColumn();
|
|
463
|
+
});
|
|
464
|
+
|
|
450
465
|
it('marks the open tab selected and loads a bundled file on click', async () => {
|
|
451
466
|
renderPage(false);
|
|
452
467
|
const tab = await screen.findByRole('tab', { name: /sources\.yaml/ });
|
|
@@ -61,7 +61,7 @@ vi.mock('../utils/navigate-external', () => ({ navigateExternal: vi.fn() }));
|
|
|
61
61
|
|
|
62
62
|
import { ToolPage } from '../components/tool-page/ToolPage';
|
|
63
63
|
import { NAME_MIN_WIDTH } from '../components/NameWithBadges';
|
|
64
|
-
import { expectMenuAtTheEndOfTheTitleRow } from './title-row-actions';
|
|
64
|
+
import { expectMenuAtTheEndOfTheTitleRow, expectTitleRowSpansTheDocumentColumn } from './title-row-actions';
|
|
65
65
|
import { TOOL_CREDENTIALS_STALE_EVENT } from '../../../core/events';
|
|
66
66
|
|
|
67
67
|
const GITHUB: ToolSecrets = {
|
|
@@ -234,6 +234,20 @@ describe('ToolPage: frame', () => {
|
|
|
234
234
|
expectMenuAtTheEndOfTheTitleRow();
|
|
235
235
|
});
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* And the right end is the SAME right end. This page used to wrap itself in
|
|
239
|
+
* `max-w-3xl` — a 768px article centred inside the layout's 800px line — so
|
|
240
|
+
* its title row, and the `⋯` at the end of it, stopped 16px short of the
|
|
241
|
+
* plugin page's at every viewport while every structural assertion above
|
|
242
|
+
* passed on both pages.
|
|
243
|
+
*/
|
|
244
|
+
it('runs its title row to the document column, not a narrower one of its own', async () => {
|
|
245
|
+
const { container } = renderPage();
|
|
246
|
+
await screen.findByRole('heading', { name: 'heyreach', level: 1 });
|
|
247
|
+
expectTitleRowSpansTheDocumentColumn();
|
|
248
|
+
expect(container.querySelector('article')!.className).not.toContain('max-w-');
|
|
249
|
+
});
|
|
250
|
+
|
|
237
251
|
it('shows no kicker for a legacy ungrouped path either', async () => {
|
|
238
252
|
secretsMock.listToolSecrets.mockResolvedValue([
|
|
239
253
|
{ ...GITHUB, slug: 'slack', name: 'slack', path: 'Tools/slack.tool' },
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { expect } from 'vitest';
|
|
2
2
|
import { screen, within } from '@testing-library/react';
|
|
3
3
|
import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
|
|
4
|
+
import { DOCUMENT_COLUMN } from '../../../shared/theme/measure';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The one width an item page is allowed to be: the shared document measure,
|
|
8
|
+
* which the Library layout's `<main>` already puts around every page.
|
|
9
|
+
*/
|
|
10
|
+
const SHARED_MEASURE = DOCUMENT_COLUMN.split(' ').filter((c) => c.startsWith('max-w-'));
|
|
4
11
|
|
|
5
12
|
/**
|
|
6
13
|
* Where an item page's `⋯` goes: the right end of the title row.
|
|
@@ -19,7 +26,9 @@ import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
|
|
|
19
26
|
*
|
|
20
27
|
* Size needs no assertion of its own: it is the same `PageActions` component,
|
|
21
28
|
* 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
|
|
29
|
+
* pins — in the band, last, in a group that neither shrinks nor wraps: that,
|
|
30
|
+
* plus {@link expectTitleRowSpansTheDocumentColumn} for the row's WIDTH, is
|
|
31
|
+
* the whole of "the same position".
|
|
23
32
|
*/
|
|
24
33
|
export function expectMenuAtTheEndOfTheTitleRow(): void {
|
|
25
34
|
const band = screen.getByTestId(PAGE_HEADER_TESTID);
|
|
@@ -40,4 +49,47 @@ export function expectMenuAtTheEndOfTheTitleRow(): void {
|
|
|
40
49
|
// the back link is the bug this replaced.
|
|
41
50
|
const header = band.closest('header') ?? band.parentElement!;
|
|
42
51
|
expect(within(header).getAllByRole('button', { name: 'More actions' })).toHaveLength(1);
|
|
52
|
+
|
|
53
|
+
// Last in a right-aligned row says WHERE ON the row; this says where the row
|
|
54
|
+
// ENDS. Both are needed, and only the pair is the criterion.
|
|
55
|
+
expectTitleRowSpansTheDocumentColumn();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The title row runs the full width of the shared document column — the page
|
|
60
|
+
* wraps it in no narrower measure of its own.
|
|
61
|
+
*
|
|
62
|
+
* This is the half of "the same position as on the plugin page" that structure
|
|
63
|
+
* alone cannot see, and the half that shipped broken. The tool page put its
|
|
64
|
+
* band, correctly, last-in-row inside a group with the plugin page's exact
|
|
65
|
+
* classes — and rendered it 16px left of the plugin page's, every viewport,
|
|
66
|
+
* because the article around it was `max-w-3xl` (768px) inside the layout's
|
|
67
|
+
* 800px line. Every structural assertion above passed on both pages while the
|
|
68
|
+
* two menus sat at different points on the screen; staging found it with a
|
|
69
|
+
* ruler, which is not a thing this suite can do.
|
|
70
|
+
*
|
|
71
|
+
* So it asserts the CAUSE rather than the pixels: jsdom computes no layout, but
|
|
72
|
+
* the width of a page's title row is decided entirely by which ancestors
|
|
73
|
+
* constrain it, and the layout's `<main>` is the only one entitled to. Anything
|
|
74
|
+
* else between the band and the document is a second column inside the first,
|
|
75
|
+
* and the row cannot reach the same right edge as a page that has none.
|
|
76
|
+
*/
|
|
77
|
+
export function expectTitleRowSpansTheDocumentColumn(): void {
|
|
78
|
+
const band = screen.getByTestId(PAGE_HEADER_TESTID);
|
|
79
|
+
const narrowed: string[] = [];
|
|
80
|
+
for (let el = band.parentElement; el && el !== document.body; el = el.parentElement) {
|
|
81
|
+
for (const cls of Array.from(el.classList)) {
|
|
82
|
+
// `DOCUMENT_COLUMN` itself is allowed through: a test that renders the
|
|
83
|
+
// page inside `LibraryLayout` passes the shared measure on the way up,
|
|
84
|
+
// and the shared measure is the one width the row is meant to have.
|
|
85
|
+
if (cls.startsWith('max-w-') && !SHARED_MEASURE.includes(cls)) {
|
|
86
|
+
narrowed.push(`<${el.tagName.toLowerCase()} class="${el.className}">`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
expect(
|
|
91
|
+
narrowed,
|
|
92
|
+
`The title row is inside a narrower column than the document measure (${SHARED_MEASURE.join(' ')}), ` +
|
|
93
|
+
'so its right end — and the ⋯ on it — cannot line up with the plugin page\'s.',
|
|
94
|
+
).toEqual([]);
|
|
43
95
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect } from 'react';
|
|
2
2
|
import { useJoinRequests } from '../hooks/useJoinRequests';
|
|
3
|
-
import { AccessRequestsBanner } from '
|
|
3
|
+
import { AccessRequestsBanner } from '../../access/components/AccessRequestsBanner';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* One plugin's join requests, fetching their own data.
|
|
@@ -65,7 +65,7 @@ export function PluginJoinRequests({
|
|
|
65
65
|
|
|
66
66
|
return (
|
|
67
67
|
<AccessRequestsBanner
|
|
68
|
-
|
|
68
|
+
itemName={plugin}
|
|
69
69
|
folders={folders}
|
|
70
70
|
requests={requests.requests}
|
|
71
71
|
onManage={onManage}
|
|
@@ -51,7 +51,7 @@ import { ownersTextOf, pluginLabel } from '../../utils/plugin-summary';
|
|
|
51
51
|
import { neededToolsFor, toolStatus } from '../../utils/status';
|
|
52
52
|
import { StatusDot } from '../StatusDot';
|
|
53
53
|
import { SharedViaPlugins } from './SharedViaPlugins';
|
|
54
|
-
import { AccessRequestsBanner } from '
|
|
54
|
+
import { AccessRequestsBanner } from '../../../access/components/AccessRequestsBanner';
|
|
55
55
|
import { useJoinRequests, type JoinRequestsApi } from '../../hooks/useJoinRequests';
|
|
56
56
|
import { listSkillAccessRequests, reconcileSkillAccessRequest } from '../../services/library.api';
|
|
57
57
|
import { ManageAccessDialog } from '../../../access/components/ManageAccessDialog';
|
|
@@ -710,7 +710,7 @@ export function SkillPage({
|
|
|
710
710
|
Manage access opens it, and both are no-ops against ''. */}
|
|
711
711
|
{canWrite && skillFolderEntry && (
|
|
712
712
|
<AccessRequestsBanner
|
|
713
|
-
|
|
713
|
+
itemName={name}
|
|
714
714
|
folders={[skillPath]}
|
|
715
715
|
requests={accessRequests.requests}
|
|
716
716
|
onManage={() => setManageTarget(skillFolderEntry)}
|
|
@@ -316,9 +316,19 @@ export function ToolPage({
|
|
|
316
316
|
* The reading column. Horizontal and vertical padding come from the Library
|
|
317
317
|
* layout's `<main>`, which already wraps every page under `/skills-and-tools` —
|
|
318
318
|
* repeating them here would double the gutter.
|
|
319
|
+
*
|
|
320
|
+
* And no `max-w` of its own, for the same reason the skill page has none: the
|
|
321
|
+
* layout's `<main>` already holds the shared `DOCUMENT_COLUMN` measure, so a
|
|
322
|
+
* second, narrower width here is a second column inside the first. It was
|
|
323
|
+
* `max-w-3xl` — a 768px article centred in the measure's 800px line — and the
|
|
324
|
+
* 16px that left on each side moved this page's title row in from where the
|
|
325
|
+
* plugin page's and the skill page's are: the same band, the same group, the
|
|
326
|
+
* same `⋯`, ending 16px short of the right edge the other two reach. Where
|
|
327
|
+
* the menu sits on the row is decided by how wide the row is, so the column
|
|
328
|
+
* is where "the same position as on the plugin page" is actually kept.
|
|
319
329
|
*/
|
|
320
330
|
function Article({ children }: { children: ReactNode }) {
|
|
321
|
-
return <article className="
|
|
331
|
+
return <article className="w-full">{children}</article>;
|
|
322
332
|
}
|
|
323
333
|
|
|
324
334
|
function SectionHeading({ children }: { children: ReactNode }) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useAccessRequests,
|
|
4
|
+
type AccessRequestsState,
|
|
5
|
+
} from '../../access/hooks/useAccessRequests';
|
|
5
6
|
import {
|
|
6
7
|
listJoinRequests,
|
|
7
8
|
reconcileJoinRequest,
|
|
@@ -11,31 +12,18 @@ import {
|
|
|
11
12
|
import { useLibraryToast } from '../state/toast.context';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* ACCEPTING IS A GRANT, NOT A MERGE. A proposal is "give this principal this
|
|
18
|
-
* verb on the plugin folder", so accepting it calls the ordinary access-grant
|
|
19
|
-
* API — the same endpoint the Manage-access dialog uses, with the same gate,
|
|
20
|
-
* lock and commit. The request's branch is never merged, so nothing else it
|
|
21
|
-
* carries can ride in on an approval, and a request naming five people can be
|
|
22
|
-
* answered with two yeses and three ignores.
|
|
23
|
-
*
|
|
24
|
-
* The request then retires ITSELF: it is open exactly while its `access.md`
|
|
25
|
-
* grants something the default branch does not, so once the accepted grant
|
|
26
|
-
* lands the diff is empty and the server closes it and deletes the branch.
|
|
27
|
-
* `reconcile` just asks for that check immediately instead of waiting for the
|
|
28
|
-
* next listing (which does it too).
|
|
15
|
+
* The Library's face of {@link useAccessRequests}: one plugin's (or skill's)
|
|
16
|
+
* join requests, with the failures said as Library toasts.
|
|
29
17
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
18
|
+
* Everything about how a request is answered lives in the access module now —
|
|
19
|
+
* accepting is a grant, declining rejects the change request, and the request
|
|
20
|
+
* retires itself. What stays here is where the words go: the Library has a
|
|
21
|
+
* toast host, and the Manage access dialog does not, which is why the generic
|
|
22
|
+
* hook reports failures as state and lets each surface choose.
|
|
33
23
|
*/
|
|
34
24
|
export interface JoinRequestsState {
|
|
35
25
|
requests: JoinRequest[];
|
|
36
|
-
/** Grant one proposal, then settle the request if that was the last one. */
|
|
37
26
|
accept(request: JoinRequest, proposal: JoinProposal): Promise<void>;
|
|
38
|
-
/** Decline the whole request — reject the change request. */
|
|
39
27
|
decline(request: JoinRequest): Promise<void>;
|
|
40
28
|
reload(): void;
|
|
41
29
|
}
|
|
@@ -62,83 +50,20 @@ export function useJoinRequests(
|
|
|
62
50
|
folder: string | null,
|
|
63
51
|
api: JoinRequestsApi = PLUGIN_JOIN_API,
|
|
64
52
|
): JoinRequestsState {
|
|
65
|
-
// Keyed by the plugin they came from: a page that moves from skill A to
|
|
66
|
-
// skill B without unmounting must not show A's requests until B's arrive —
|
|
67
|
-
// a banner that lets an editor grant A's proposal against B's folder.
|
|
68
|
-
const [loaded, setLoaded] = useState<{ plugin: string; rows: JoinRequest[] } | null>(null);
|
|
69
|
-
const requests = loaded?.plugin === plugin ? loaded.rows : [];
|
|
70
|
-
const [revision, setRevision] = useState(0);
|
|
71
53
|
const toast = useLibraryToast();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})
|
|
79
|
-
.catch(() => {
|
|
80
|
-
// Silent: a manager surface that fails must not put an error banner in
|
|
81
|
-
// front of somebody who came to read a skill.
|
|
82
|
-
});
|
|
83
|
-
return () => {
|
|
84
|
-
cancelled = true;
|
|
85
|
-
};
|
|
86
|
-
}, [plugin, revision, api]);
|
|
87
|
-
|
|
88
|
-
const reload = useCallback(() => setRevision((r) => r + 1), []);
|
|
89
|
-
|
|
90
|
-
const accept = useCallback(
|
|
91
|
-
async (request: JoinRequest, proposal: JoinProposal) => {
|
|
92
|
-
if (!folder) return;
|
|
93
|
-
try {
|
|
94
|
-
await grantAccess(encodeURIComponent(DEFAULT_BRANCH), {
|
|
95
|
-
path: folder,
|
|
96
|
-
kind: 'folder',
|
|
97
|
-
verb: proposal.verb,
|
|
98
|
-
principal: proposal.principal,
|
|
99
|
-
});
|
|
100
|
-
} catch (err) {
|
|
101
|
-
toast(err instanceof Error ? err.message : "Couldn't grant that: try again.", 'danger');
|
|
102
|
-
setRevision((r) => r + 1);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
// Drop the accepted proposal locally so the row goes immediately; the
|
|
106
|
-
// refetch below is what makes it true.
|
|
107
|
-
setLoaded((cur) =>
|
|
108
|
-
cur && cur.plugin === plugin
|
|
109
|
-
? {
|
|
110
|
-
...cur,
|
|
111
|
-
rows: cur.rows.map((r) =>
|
|
112
|
-
r.number === request.number
|
|
113
|
-
? {
|
|
114
|
-
...r,
|
|
115
|
-
proposals: r.proposals.filter(
|
|
116
|
-
(p) => !(p.id === proposal.id && p.verb === proposal.verb),
|
|
117
|
-
),
|
|
118
|
-
}
|
|
119
|
-
: r,
|
|
120
|
-
),
|
|
121
|
-
}
|
|
122
|
-
: cur,
|
|
123
|
-
);
|
|
124
|
-
toast(`${proposal.label} now has ${proposal.verb} access.`);
|
|
125
|
-
await api.reconcile(plugin, request.number).catch(() => false);
|
|
126
|
-
setRevision((r) => r + 1);
|
|
127
|
-
},
|
|
128
|
-
[folder, plugin, toast, api],
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
const decline = useCallback(
|
|
132
|
-
async (request: JoinRequest) => {
|
|
133
|
-
try {
|
|
134
|
-
await cancelPullRequest(request.number);
|
|
135
|
-
} catch {
|
|
136
|
-
toast("Couldn't dismiss that: try again.", 'danger');
|
|
137
|
-
}
|
|
138
|
-
setRevision((r) => r + 1);
|
|
139
|
-
},
|
|
140
|
-
[toast],
|
|
54
|
+
const source = useMemo(
|
|
55
|
+
() => ({
|
|
56
|
+
list: () => api.list(plugin),
|
|
57
|
+
reconcile: (number: number) => api.reconcile(plugin, number),
|
|
58
|
+
}),
|
|
59
|
+
[api, plugin],
|
|
141
60
|
);
|
|
142
|
-
|
|
143
|
-
|
|
61
|
+
const state: AccessRequestsState = useAccessRequests({
|
|
62
|
+
itemKey: plugin,
|
|
63
|
+
source,
|
|
64
|
+
grantOn: folder ? { path: folder, kind: 'folder' } : null,
|
|
65
|
+
onError: (message) => toast(message, 'danger'),
|
|
66
|
+
onAccepted: (message) => toast(message),
|
|
67
|
+
});
|
|
68
|
+
return state;
|
|
144
69
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChangeRequestUpdateResult } from '@bevel-software/platform-shared';
|
|
1
2
|
import { authFetch } from '../../../lib/api';
|
|
2
3
|
import { handleApiResponse } from '../../git/services/git.api';
|
|
3
4
|
|
|
@@ -42,9 +43,16 @@ export async function mergePullRequest(
|
|
|
42
43
|
* `change-request-conflicts` error payload (status 409) listing the
|
|
43
44
|
* conflicting paths — the caller catches it via `GitApiError` and
|
|
44
45
|
* routes the agent into the resolution flow.
|
|
46
|
+
*
|
|
47
|
+
* Answers the refreshed detail itself, plus `updatedPaths` — which files the
|
|
48
|
+
* merge changed on the branch. A caller that is already showing the request's
|
|
49
|
+
* files replaces exactly those, and needs no further detail read: this one was
|
|
50
|
+
* assembled after the merge, with the carried approvals in it.
|
|
45
51
|
*/
|
|
46
|
-
export async function refreshChangeRequestFromTarget(
|
|
47
|
-
|
|
52
|
+
export async function refreshChangeRequestFromTarget(
|
|
53
|
+
prNumber: number,
|
|
54
|
+
): Promise<ChangeRequestUpdateResult> {
|
|
55
|
+
return handleApiResponse<ChangeRequestUpdateResult>(
|
|
48
56
|
await authFetch(`/api/workflow/change-requests/${prNumber}/update-from-target`, {
|
|
49
57
|
method: 'POST',
|
|
50
58
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { PageShell } from '../../../shared/components/PageShell';
|
|
2
2
|
import { Banner, Button } from '../../../shared/components';
|
|
3
|
+
import { SlotBoundary } from '../../../shared/components/SlotBoundary';
|
|
3
4
|
import { useAdmin } from '../../admin/state/admin.context';
|
|
4
5
|
import { useSetupStatus } from '../../setup/hooks/useSetupStatus';
|
|
5
6
|
import { SetupScreen } from '../../setup/components/SetupScreen';
|
|
7
|
+
import { useAppRegistry } from '../../../core/registry';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Deployment settings, routed at `/deployment` — the first-run setup screen
|
|
@@ -27,6 +29,8 @@ import { SetupScreen } from '../../setup/components/SetupScreen';
|
|
|
27
29
|
*/
|
|
28
30
|
export function DeploymentPage() {
|
|
29
31
|
const { isAdmin } = useAdmin();
|
|
32
|
+
// What the distribution adds to this page, if anything — see the slot.
|
|
33
|
+
const { deploymentPanel: DeploymentPanel } = useAppRegistry();
|
|
30
34
|
// Read the shared way (`useSetupStatus`: latest read wins, a failed read
|
|
31
35
|
// keeps the last status). Non-admins never read: the endpoint would answer
|
|
32
36
|
// them safely (status without settings), but this page has already told them
|
|
@@ -73,12 +77,30 @@ export function DeploymentPage() {
|
|
|
73
77
|
settings={status.settings}
|
|
74
78
|
sync={status.sync}
|
|
75
79
|
oidcVerification={status.oidcVerification}
|
|
80
|
+
repository={status.repository}
|
|
76
81
|
kbInit={status.kbInit}
|
|
77
82
|
onSaved={refresh}
|
|
78
83
|
variant="settings"
|
|
79
84
|
/>
|
|
80
85
|
</div>
|
|
81
86
|
)}
|
|
87
|
+
|
|
88
|
+
{/* The distribution's panel, last on the page and outside every
|
|
89
|
+
condition above: it does not depend on the settings, so neither a
|
|
90
|
+
load in flight nor a failed one takes it away.
|
|
91
|
+
|
|
92
|
+
And the other way round: the panel is code core did not write, so
|
|
93
|
+
it renders inside a boundary. A throw in it costs its own place on
|
|
94
|
+
the page and not the form above — the form is where an admin fixes
|
|
95
|
+
the sign-in or the repository connection, and must not go down with
|
|
96
|
+
a panel it has nothing to do with. */}
|
|
97
|
+
{DeploymentPanel && (
|
|
98
|
+
<div className="mt-10" data-testid="deployment-panel">
|
|
99
|
+
<SlotBoundary label="workspace panel">
|
|
100
|
+
<DeploymentPanel />
|
|
101
|
+
</SlotBoundary>
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
82
104
|
</PageShell>
|
|
83
105
|
);
|
|
84
106
|
}
|
|
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
|
2
2
|
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import { AdminContext, type AdminContextValue } from '../../../admin/state/admin.context';
|
|
4
4
|
import { KbInitFailed } from '../../../setup/services/setup.api';
|
|
5
|
+
import { AppRegistryContext, EMPTY_REGISTRY, type AppRegistry } from '../../../../core/registry';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The deployment settings page — first-run setup with a permanent address.
|
|
@@ -50,14 +51,22 @@ const COMPLETE_STATUS = {
|
|
|
50
51
|
],
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
function renderPage(value: AdminContextValue) {
|
|
54
|
+
function renderPage(value: AdminContextValue, registry: AppRegistry = EMPTY_REGISTRY) {
|
|
54
55
|
return render(
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
|
|
56
|
+
<AppRegistryContext.Provider value={registry}>
|
|
57
|
+
<AdminContext.Provider value={value}>
|
|
58
|
+
<DeploymentPage />
|
|
59
|
+
</AdminContext.Provider>
|
|
60
|
+
</AppRegistryContext.Provider>,
|
|
58
61
|
);
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
/** What a distribution would put at the foot of the page. */
|
|
65
|
+
function WorkspacePanel() {
|
|
66
|
+
return <section aria-label="Workspace">Delete this workspace</section>;
|
|
67
|
+
}
|
|
68
|
+
const WITH_PANEL: AppRegistry = { ...EMPTY_REGISTRY, deploymentPanel: WorkspacePanel };
|
|
69
|
+
|
|
61
70
|
describe('DeploymentPage', () => {
|
|
62
71
|
beforeEach(() => {
|
|
63
72
|
apiMock.fetchSetupStatus.mockReset();
|
|
@@ -110,6 +119,65 @@ describe('DeploymentPage', () => {
|
|
|
110
119
|
expect(facadeMock.fetchGitHubFacade).not.toHaveBeenCalled();
|
|
111
120
|
});
|
|
112
121
|
|
|
122
|
+
/**
|
|
123
|
+
* The distribution's slot: what a deployment is beyond its settings (a
|
|
124
|
+
* hosted workspace's plan, its deletion) is not core's to know, so the page
|
|
125
|
+
* gives it a place and nothing more.
|
|
126
|
+
*/
|
|
127
|
+
it('renders the distribution panel last on the page, after the form and its save button', async () => {
|
|
128
|
+
renderPage(admin(true), WITH_PANEL);
|
|
129
|
+
const panel = await screen.findByRole('region', { name: 'Workspace' });
|
|
130
|
+
const save = await screen.findByRole('button', { name: 'Save and continue' });
|
|
131
|
+
expect(save.compareDocumentPosition(panel) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
132
|
+
expect(screen.getByTestId('deployment-panel')).toContainElement(panel);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('keeps the distribution panel when the settings cannot be loaded', async () => {
|
|
136
|
+
apiMock.fetchSetupStatus.mockRejectedValueOnce(new Error('down'));
|
|
137
|
+
renderPage(admin(true), WITH_PANEL);
|
|
138
|
+
expect(await screen.findByText(/Couldn't load the deployment settings/)).toBeInTheDocument();
|
|
139
|
+
// A way out of the deployment must not depend on its settings being readable.
|
|
140
|
+
expect(screen.getByRole('region', { name: 'Workspace' })).toBeInTheDocument();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('shows the distribution panel to admins only, and nothing in its place without one', async () => {
|
|
144
|
+
renderPage(admin(false), WITH_PANEL);
|
|
145
|
+
expect(screen.getByText(/Admins only/)).toBeInTheDocument();
|
|
146
|
+
expect(screen.queryByRole('region', { name: 'Workspace' })).toBeNull();
|
|
147
|
+
expect(screen.queryByTestId('deployment-panel')).toBeNull();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('ends with the form when no distribution panel is registered', async () => {
|
|
151
|
+
renderPage(admin(true));
|
|
152
|
+
await screen.findByText('Provider address');
|
|
153
|
+
expect(screen.queryByTestId('deployment-panel')).toBeNull();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The other direction of the same independence: the panel is code core did
|
|
158
|
+
* not write, and a throw in it must cost the panel's own place, not the
|
|
159
|
+
* form an admin came here to use.
|
|
160
|
+
*/
|
|
161
|
+
it('keeps the settings form when the distribution panel throws, and says so in its place', async () => {
|
|
162
|
+
function BrokenPanel(): never {
|
|
163
|
+
throw new Error('the distribution has a bug');
|
|
164
|
+
}
|
|
165
|
+
// React reports a caught render error on the console, and so does the
|
|
166
|
+
// boundary; both are expected here and neither belongs in the run's output.
|
|
167
|
+
const quiet = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
168
|
+
try {
|
|
169
|
+
renderPage(admin(true), { ...EMPTY_REGISTRY, deploymentPanel: BrokenPanel });
|
|
170
|
+
expect(await screen.findByText('Provider address')).toBeInTheDocument();
|
|
171
|
+
expect(screen.getByRole('button', { name: 'Save and continue' })).toBeInTheDocument();
|
|
172
|
+
const slot = screen.getByTestId('deployment-panel');
|
|
173
|
+
expect(slot).toHaveTextContent(/workspace panel couldn.t be shown/);
|
|
174
|
+
expect(slot).toHaveTextContent(/rest of this page is unaffected/);
|
|
175
|
+
expect(quiet).toHaveBeenCalled();
|
|
176
|
+
} finally {
|
|
177
|
+
quiet.mockRestore();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
113
181
|
it('tells a non-admin this is not theirs, and never fetches the settings', () => {
|
|
114
182
|
renderPage(admin(false));
|
|
115
183
|
expect(screen.getByText(/Admins only/)).toBeInTheDocument();
|