@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
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { useEffect, useRef, useState, type FormEvent } from 'react';
|
|
1
|
+
import { useEffect, useRef, useState, type FormEvent, type KeyboardEvent, type ReactNode } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
DEFAULT_KB_LAYOUT,
|
|
4
4
|
agentsFilePointerSentence,
|
|
5
5
|
type KbLayout,
|
|
6
6
|
} from '@bevel-software/platform-shared';
|
|
7
7
|
import { Banner, Button, Surface, TextField } from '../../../shared/components';
|
|
8
|
+
import { SlotBoundary } from '../../../shared/components/SlotBoundary';
|
|
8
9
|
import { tokenUsernameForHost } from '../utils/git-host';
|
|
9
10
|
import { isRootFolderSuggestion, rootFolderState, type RootFolderState } from '../utils/root-folders';
|
|
10
11
|
import { copyToClipboard } from '../../../lib/clipboard';
|
|
12
|
+
import { GitHubRepositoryPanel } from './GitHubRepositoryPanel';
|
|
13
|
+
import { forgetDraft, keepDraft, keptDraft } from '../utils/kept-draft';
|
|
14
|
+
import { useAppRegistry } from '../../../core/registry';
|
|
11
15
|
import { MarketplaceSection } from '../../settings/components/MarketplaceSection';
|
|
12
16
|
import {
|
|
13
17
|
saveSettings,
|
|
@@ -16,12 +20,17 @@ import {
|
|
|
16
20
|
testConnection,
|
|
17
21
|
KbInitFailed,
|
|
18
22
|
testOidc,
|
|
23
|
+
RepositoryChangeNeedsConfirmation,
|
|
19
24
|
SettingsProblems,
|
|
20
25
|
type ConnectionTest,
|
|
21
26
|
type KbInitFailure,
|
|
22
27
|
type LastSync,
|
|
23
28
|
type OidcTest,
|
|
24
29
|
type OidcVerification,
|
|
30
|
+
type GitMode,
|
|
31
|
+
type RepositoryChangeChoice,
|
|
32
|
+
type RepositoryChangeResult,
|
|
33
|
+
type RepositoryStatus,
|
|
25
34
|
type SettingStatus,
|
|
26
35
|
type SyncNowResult,
|
|
27
36
|
type SyncStatus,
|
|
@@ -175,7 +184,7 @@ const FIELDS: Record<
|
|
|
175
184
|
},
|
|
176
185
|
allowedEmailDomains: {
|
|
177
186
|
label: 'Allowed email domains',
|
|
178
|
-
help: 'Only people with an address at these domains can sign in this
|
|
187
|
+
help: 'Only people with an address at these domains can sign in through this provider. Separate several with commas. Leave blank to allow any address: safe with a provider that only serves your organisation, risky with one that does not.',
|
|
179
188
|
placeholder: 'example.com',
|
|
180
189
|
},
|
|
181
190
|
auditRetentionDays: {
|
|
@@ -193,6 +202,16 @@ const FIELDS: Record<
|
|
|
193
202
|
*/
|
|
194
203
|
const REQUIRED_KEYS = ['kbRepoUrl', 'gitToken', 'defaultBranch', 'protectedBranches'];
|
|
195
204
|
|
|
205
|
+
/** The half of those every deployment owes, however it has its repository. */
|
|
206
|
+
const BRANCH_MODEL_KEYS = ['defaultBranch', 'protectedBranches'];
|
|
207
|
+
|
|
208
|
+
/** What each way of having a repository is called on its tab. */
|
|
209
|
+
const GIT_MODE_LABEL: Record<GitMode, string> = {
|
|
210
|
+
managed: 'Managed for you',
|
|
211
|
+
'github-app': 'GitHub',
|
|
212
|
+
token: 'Address and token',
|
|
213
|
+
};
|
|
214
|
+
|
|
196
215
|
/**
|
|
197
216
|
* The answers a connection test actually proves — the address, the credential
|
|
198
217
|
* and the name that goes beside it.
|
|
@@ -204,6 +223,17 @@ const REQUIRED_KEYS = ['kbRepoUrl', 'gitToken', 'defaultBranch', 'protectedBranc
|
|
|
204
223
|
*/
|
|
205
224
|
const CONNECTION_KEYS = ['kbRepoUrl', 'gitToken', 'gitUsername'];
|
|
206
225
|
|
|
226
|
+
/**
|
|
227
|
+
* The settings each way of having a repository is answered by, on its tab.
|
|
228
|
+
* What belongs to a tab is sent only while that tab is open, and a refusal
|
|
229
|
+
* about it opens that tab.
|
|
230
|
+
*/
|
|
231
|
+
const TAB_KEYS: Record<GitMode, readonly string[]> = {
|
|
232
|
+
managed: [],
|
|
233
|
+
'github-app': ['githubRepository'],
|
|
234
|
+
token: CONNECTION_KEYS,
|
|
235
|
+
};
|
|
236
|
+
|
|
207
237
|
/**
|
|
208
238
|
* The answers the sign-in check proves. Editing one invalidates its result on
|
|
209
239
|
* screen; the scopes, the button text and the allowed domains are not among
|
|
@@ -270,6 +300,56 @@ const SECTIONS: { id: SettingStatus['section']; title: string; blurb: string }[]
|
|
|
270
300
|
},
|
|
271
301
|
];
|
|
272
302
|
|
|
303
|
+
/**
|
|
304
|
+
* What the first run asks: where the knowledge lives, which the gate waits
|
|
305
|
+
* on, and how people sign in, which decides who can follow the admin in.
|
|
306
|
+
* Everything else is a preference with a working default. It is set on the
|
|
307
|
+
* Deployment page, by someone who has seen the product it configures; on the
|
|
308
|
+
* first screen it only made two questions look like five.
|
|
309
|
+
*/
|
|
310
|
+
const FIRST_RUN_SECTIONS: readonly SettingStatus['section'][] = ['knowledge-base', 'sign-in'];
|
|
311
|
+
|
|
312
|
+
/** The two ways of signing in the section can show, when the distribution runs one. */
|
|
313
|
+
type SignInTab = 'managed' | 'own';
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* A section's fields. Alone in their section they are its content as it has
|
|
317
|
+
* always been; beside a distribution's tab they are the panel of theirs, so
|
|
318
|
+
* the tab that names them has something to name.
|
|
319
|
+
*/
|
|
320
|
+
function SectionFields({
|
|
321
|
+
panel,
|
|
322
|
+
children,
|
|
323
|
+
}: {
|
|
324
|
+
/** The tab these fields are the panel of: which set of tabs, and which one. Null: no tabs. */
|
|
325
|
+
panel: { group: 'sign-in' | 'repository'; id: string } | null;
|
|
326
|
+
children: ReactNode;
|
|
327
|
+
}) {
|
|
328
|
+
if (panel === null) return <>{children}</>;
|
|
329
|
+
return (
|
|
330
|
+
<div
|
|
331
|
+
role="tabpanel"
|
|
332
|
+
id={`${panel.group}-panel-${panel.id}`}
|
|
333
|
+
aria-labelledby={`${panel.group}-tab-${panel.id}`}
|
|
334
|
+
className="space-y-6"
|
|
335
|
+
>
|
|
336
|
+
{children}
|
|
337
|
+
</div>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* The distribution's panel sits inside the settings form, and a browser
|
|
343
|
+
* submits a form when Enter is pressed in any text input in it. On first
|
|
344
|
+
* run that submit finishes setup and leaves the screen, from a field that
|
|
345
|
+
* had nothing to do with it. Held here once, so no panel has to remember:
|
|
346
|
+
* Enter in one of its inputs is the panel's own key. A text area keeps its
|
|
347
|
+
* new line and a button its press, neither of which submits anything.
|
|
348
|
+
*/
|
|
349
|
+
function keepEnterFromTheForm(event: KeyboardEvent<HTMLElement>) {
|
|
350
|
+
if (event.key === 'Enter' && event.target instanceof HTMLInputElement) event.preventDefault();
|
|
351
|
+
}
|
|
352
|
+
|
|
273
353
|
interface Props {
|
|
274
354
|
settings: SettingStatus[];
|
|
275
355
|
/**
|
|
@@ -305,6 +385,12 @@ interface Props {
|
|
|
305
385
|
kbInit?: KbInitFailure;
|
|
306
386
|
/** Whether the single sign-on configuration in effect is proven. Absent from an older server. */
|
|
307
387
|
oidcVerification?: OidcVerification;
|
|
388
|
+
/**
|
|
389
|
+
* The ways this deployment can have its repository, and the one it is on.
|
|
390
|
+
* Absent from a server that knows one way only: the address and the token,
|
|
391
|
+
* drawn as they always were, with no tabs.
|
|
392
|
+
*/
|
|
393
|
+
repository?: RepositoryStatus;
|
|
308
394
|
}
|
|
309
395
|
|
|
310
396
|
/**
|
|
@@ -328,8 +414,39 @@ function sameFailure(a: KbInitFailure, b: KbInitFailure): boolean {
|
|
|
328
414
|
return a.kind === b.kind && a.cause === b.cause;
|
|
329
415
|
}
|
|
330
416
|
|
|
331
|
-
export function SetupScreen({
|
|
332
|
-
|
|
417
|
+
export function SetupScreen({
|
|
418
|
+
settings,
|
|
419
|
+
onSaved,
|
|
420
|
+
variant = 'setup',
|
|
421
|
+
sync,
|
|
422
|
+
kbInit,
|
|
423
|
+
oidcVerification,
|
|
424
|
+
repository,
|
|
425
|
+
}: Props) {
|
|
426
|
+
/** Whether a setting is a secret: what is never written to the browser's storage. */
|
|
427
|
+
const isSecret = (key: string) => settings.find((s) => s.key === key)?.secret !== false;
|
|
428
|
+
/**
|
|
429
|
+
* What was typed before the browser left for GitHub, put back now that it
|
|
430
|
+
* has returned (see `kept-draft.ts`). Only on a return from GitHub, which
|
|
431
|
+
* the address says: what was kept for a trip that was abandoned is not
|
|
432
|
+
* sprung on someone who opens the screen later. And only for settings
|
|
433
|
+
* that are still this form's to edit.
|
|
434
|
+
*/
|
|
435
|
+
const [restored] = useState(() => {
|
|
436
|
+
const back = new URLSearchParams(window.location.search ?? '').has('github');
|
|
437
|
+
const kept = back ? keptDraft(isSecret) : { draft: {}, dropped: [] };
|
|
438
|
+
const editableNow = (key: string) => settings.some((s) => s.key === key && s.source !== 'env');
|
|
439
|
+
return {
|
|
440
|
+
draft: Object.fromEntries(Object.entries(kept.draft).filter(([key]) => editableNow(key))),
|
|
441
|
+
dropped: kept.dropped.filter(editableNow),
|
|
442
|
+
};
|
|
443
|
+
});
|
|
444
|
+
// Read once, then gone: in an effect, since the page may be built twice
|
|
445
|
+
// before it is shown and must find the same thing both times.
|
|
446
|
+
useEffect(() => forgetDraft(), []);
|
|
447
|
+
const [draft, setDraft] = useState<Record<string, string>>(restored.draft);
|
|
448
|
+
/** The secrets that were typed before the trip and not kept, until each is entered again. */
|
|
449
|
+
const toEnterAgain = restored.dropped.filter((key) => !draft[key]?.trim());
|
|
333
450
|
/**
|
|
334
451
|
* The initialization failure on screen: the status endpoint's, until a save
|
|
335
452
|
* or a retry from this screen answers more recently. A fresh status read
|
|
@@ -359,6 +476,31 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
359
476
|
setInitFailure(kbInit);
|
|
360
477
|
}
|
|
361
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* The move to another repository the server has REFUSED until it is
|
|
481
|
+
* confirmed: how many change requests were open at that moment, and the
|
|
482
|
+
* way left and the way moved to when the server tells them apart. Null
|
|
483
|
+
* when there is nothing to confirm.
|
|
484
|
+
*
|
|
485
|
+
* THE ONE QUESTION A MOVE IS ASKED, whichever kind it is: another address,
|
|
486
|
+
* another repository on GitHub, another way of having one. The server
|
|
487
|
+
* decides what is a move, so the screen does not guess at it beforehand.
|
|
488
|
+
*
|
|
489
|
+
* Nothing was saved and nothing was destroyed while this stands: the answer
|
|
490
|
+
* is a decision only the admin can make, and the draft is kept exactly as
|
|
491
|
+
* typed so the confirmed save re-sends it.
|
|
492
|
+
*/
|
|
493
|
+
const [repositoryChange, setRepositoryChange] = useState<{
|
|
494
|
+
openChangeRequests: number;
|
|
495
|
+
from?: GitMode;
|
|
496
|
+
to?: GitMode;
|
|
497
|
+
/** The move the question was asked about, so it is not shown for another one. */
|
|
498
|
+
target: string;
|
|
499
|
+
} | null>(null);
|
|
500
|
+
/** What to do with the open change requests. Keeping them is the safe default: nothing closes by hesitating. */
|
|
501
|
+
const [changeChoice, setChangeChoice] = useState<RepositoryChangeChoice>('keep');
|
|
502
|
+
/** What the save that changed the repository did, so the screen can say so afterwards. */
|
|
503
|
+
const [repositoryChanged, setRepositoryChanged] = useState<RepositoryChangeResult | null>(null);
|
|
362
504
|
const [retrying, setRetrying] = useState(false);
|
|
363
505
|
const [syncing, setSyncing] = useState(false);
|
|
364
506
|
/** What the last "Sync now" from THIS page came back with (a failure to ask is `error`). */
|
|
@@ -416,6 +558,128 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
416
558
|
|
|
417
559
|
const editable = settings.filter((s) => s.source !== 'env');
|
|
418
560
|
const fromEnv = settings.filter((s) => s.source === 'env');
|
|
561
|
+
const sections = variant === 'setup' ? SECTIONS.filter((s) => FIRST_RUN_SECTIONS.includes(s.id)) : SECTIONS;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* The distribution's own way of signing in, when it runs one, and which of
|
|
565
|
+
* the two tabs is open. The section opens on the way that is in effect: the
|
|
566
|
+
* deployment's own provider once it has one, the distribution's until then.
|
|
567
|
+
* Chosen once, from what was stored when the screen opened, so typing an
|
|
568
|
+
* issuer does not move the reader to another tab.
|
|
569
|
+
*/
|
|
570
|
+
const { signInOption } = useAppRegistry();
|
|
571
|
+
const ownProviderConfigured = OIDC_KEYS.every((key) => settings.find((s) => s.key === key)?.configured === true);
|
|
572
|
+
const [signInTab, setSignInTab] = useState<SignInTab>(
|
|
573
|
+
// What was being typed about the deployment's own provider is shown, not put back out of sight.
|
|
574
|
+
ownProviderConfigured || [...Object.keys(restored.draft), ...restored.dropped].some((key) => OIDC_KEYS.includes(key))
|
|
575
|
+
? 'own'
|
|
576
|
+
: 'managed',
|
|
577
|
+
);
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* The way the deployment has its repository, and which one's tab is open.
|
|
581
|
+
* THE TAB IS THE CHOICE: what is open when Save is pressed is what the
|
|
582
|
+
* deployment is on afterwards. It opens on the way CHOSEN, so a
|
|
583
|
+
* deployment that is configured stays as it is unless its admin opens
|
|
584
|
+
* another tab, and on the first way offered for one that has none.
|
|
585
|
+
* Absent from a server that knows one way only, which is then the only
|
|
586
|
+
* thing drawn.
|
|
587
|
+
*
|
|
588
|
+
* Two ways are told apart: the one IN EFFECT, which the running
|
|
589
|
+
* deployment is on, and the one chosen. A move takes effect on the save
|
|
590
|
+
* that confirms it, so they differ only where the server reports a choice
|
|
591
|
+
* it has not put in effect, which a restart then does.
|
|
592
|
+
*/
|
|
593
|
+
const inEffect = repository?.mode ?? null;
|
|
594
|
+
const chosen = repository ? (repository.chosen ?? repository.mode) : null;
|
|
595
|
+
const [gitTab, setGitTab] = useState<GitMode>(() => {
|
|
596
|
+
// Back from a round trip to GitHub: that tab is where it started, and
|
|
597
|
+
// where what came of it is said.
|
|
598
|
+
const backFromGitHub =
|
|
599
|
+
!repository?.pinned &&
|
|
600
|
+
repository?.modes.includes('github-app') &&
|
|
601
|
+
new URLSearchParams(window.location.search ?? '').has('github');
|
|
602
|
+
return backFromGitHub ? 'github-app' : (chosen ?? repository?.modes[0] ?? 'token');
|
|
603
|
+
});
|
|
604
|
+
/** The tab a setting is answered on, for the ones that belong to one way of having a repository. */
|
|
605
|
+
const tabOf = (key: string): GitMode | null =>
|
|
606
|
+
repository ? ((Object.keys(TAB_KEYS) as GitMode[]).find((mode) => TAB_KEYS[mode].includes(key)) ?? null) : null;
|
|
607
|
+
/** Whether the repository is reached by an address and a token: the fields, the test, the proof. */
|
|
608
|
+
const byAddress = !repository || gitTab === 'token';
|
|
609
|
+
/** A way was chosen that the server has not put in effect: the deployment is still on the way it was. */
|
|
610
|
+
const movePending = inEffect !== null && chosen !== inEffect;
|
|
611
|
+
/**
|
|
612
|
+
* Saving NOW would choose another way than the one chosen, on a deployment
|
|
613
|
+
* that has a repository: a move, or a move taken back. Said on the tab
|
|
614
|
+
* before the button is pressed; the question itself is the server's, asked
|
|
615
|
+
* when the save arrives, because an open tab is not a decision.
|
|
616
|
+
*/
|
|
617
|
+
const savingMoves = inEffect !== null && gitTab !== chosen;
|
|
618
|
+
const movingFrom = inEffect ? GIT_MODE_LABEL[inEffect] : '';
|
|
619
|
+
/**
|
|
620
|
+
* What a move is a move TO, as far as the screen can tell: the tab, and
|
|
621
|
+
* the address or the repository on GitHub typed on it.
|
|
622
|
+
*/
|
|
623
|
+
const moveTarget = [gitTab, draft.kbRepoUrl ?? '', draft.githubRepository ?? ''].join('\n');
|
|
624
|
+
/**
|
|
625
|
+
* The question, while it is still about the move on screen. A yes to one
|
|
626
|
+
* move is not a yes to another: another tab, another address or another
|
|
627
|
+
* repository on GitHub is another move, and the next save asks afresh.
|
|
628
|
+
*/
|
|
629
|
+
const moveAsked = repositoryChange?.target === moveTarget ? repositoryChange : null;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* What a save sends about the repository, given what was typed: the way
|
|
633
|
+
* chosen, when it is not the one in effect, and only the answers of the
|
|
634
|
+
* tab that is open. Something entered on a tab that was then left is not
|
|
635
|
+
* an answer, and must not be stored beside the choice of another.
|
|
636
|
+
*/
|
|
637
|
+
function chosenRepository(typed: Record<string, string>): Record<string, string> {
|
|
638
|
+
if (!repository) return typed;
|
|
639
|
+
const kept = Object.fromEntries(
|
|
640
|
+
Object.entries(typed).filter(([key]) => {
|
|
641
|
+
const tab = tabOf(key);
|
|
642
|
+
return tab === null || tab === gitTab;
|
|
643
|
+
}),
|
|
644
|
+
);
|
|
645
|
+
// Against the way CHOSEN: a move that is pending was already sent, and
|
|
646
|
+
// opening the tab of the way in effect is how it is taken back.
|
|
647
|
+
return gitTab === chosen ? kept : { ...kept, gitMode: gitTab };
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Whether the form has a place for this field at all: it is the admin's to
|
|
652
|
+
* edit, and its section is one this variant shows. A field on a tab that
|
|
653
|
+
* is not open still counts — the tab is opened for it (see
|
|
654
|
+
* `showProblems`), where a field the form never draws has nowhere to be
|
|
655
|
+
* shown.
|
|
656
|
+
*/
|
|
657
|
+
const hasPlace = (key: string) =>
|
|
658
|
+
// A setting with no field of its own (the way the repository is had,
|
|
659
|
+
// which is chosen by its tab) has nowhere to hold a message. The
|
|
660
|
+
// repository on GitHub has one, drawn by that tab's panel.
|
|
661
|
+
(FIELDS[key] !== undefined || (key === 'githubRepository' && !!repository?.modes.includes('github-app'))) &&
|
|
662
|
+
editable.some((s) => s.key === key && sections.some((section) => section.id === s.section));
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Put a refused save's problems where the reader will see them. EVERY
|
|
666
|
+
* problem ends up on screen, which is the one property this function is
|
|
667
|
+
* for: one about a field the form draws goes beside that field, with the
|
|
668
|
+
* tab it lives on opened; one about a field the form does not draw goes
|
|
669
|
+
* to the message line. A save that failed must never look like a save
|
|
670
|
+
* that did nothing.
|
|
671
|
+
*/
|
|
672
|
+
function showProblems(found: Record<string, string>) {
|
|
673
|
+
setProblems(found);
|
|
674
|
+
const placed = Object.keys(found).filter(hasPlace);
|
|
675
|
+
if (signInOption && placed.some((key) => settings.find((s) => s.key === key)?.section === 'sign-in')) {
|
|
676
|
+
setSignInTab('own');
|
|
677
|
+
}
|
|
678
|
+
const owner = placed.map(tabOf).find((tab) => tab !== null);
|
|
679
|
+
if (owner) setGitTab(owner);
|
|
680
|
+
const unplaced = Object.entries(found).filter(([key]) => !hasPlace(key));
|
|
681
|
+
if (unplaced.length > 0) setError(unplaced.map(([, message]) => message).join(' '));
|
|
682
|
+
}
|
|
419
683
|
|
|
420
684
|
/**
|
|
421
685
|
* Whether saving now would actually change this connection field: something
|
|
@@ -467,6 +731,8 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
467
731
|
* blank form is the server's to complain about, field by field.
|
|
468
732
|
*/
|
|
469
733
|
const mustProveConnection =
|
|
734
|
+
// A repository the deployment keeps has no host to prove anything to.
|
|
735
|
+
byAddress &&
|
|
470
736
|
!!resolved('kbRepoUrl') &&
|
|
471
737
|
(variant === 'setup' || CONNECTION_KEYS.some((key) => connectionKeyChanged(key)));
|
|
472
738
|
|
|
@@ -816,6 +1082,16 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
816
1082
|
|
|
817
1083
|
async function submit(e: FormEvent) {
|
|
818
1084
|
e.preventDefault();
|
|
1085
|
+
await saveNow();
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Store the draft. Called by the form, and again by the repository-change
|
|
1090
|
+
* confirmation with the decision the admin made — the SAME path, so a
|
|
1091
|
+
* confirmed save proves the connection and fills in the branch fields
|
|
1092
|
+
* exactly as an ordinary one does.
|
|
1093
|
+
*/
|
|
1094
|
+
async function saveNow(confirmRepositoryChange?: RepositoryChangeChoice) {
|
|
819
1095
|
// A save during a sign-in check would clear the draft the check is about.
|
|
820
1096
|
if (saving || retrying || oidcTesting) return;
|
|
821
1097
|
setSaving(true);
|
|
@@ -825,8 +1101,9 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
825
1101
|
// attempt supersedes it — leaving it up put "Saved what you filled in, but
|
|
826
1102
|
// this deployment still needs…" directly above this attempt's "Not saved."
|
|
827
1103
|
setStillMissing([]);
|
|
1104
|
+
setRepositoryChanged(null);
|
|
828
1105
|
try {
|
|
829
|
-
let payload = draft;
|
|
1106
|
+
let payload = chosenRepository(draft);
|
|
830
1107
|
/** What the host said this time, or null when it could not be asked. */
|
|
831
1108
|
let proven: ConnectionTest | null = test;
|
|
832
1109
|
let probed = false;
|
|
@@ -857,13 +1134,18 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
857
1134
|
// Includes a probe the server REFUSED (a 4xx comes back as a
|
|
858
1135
|
// rejection, not a throw) — that is an answer about these values.
|
|
859
1136
|
if (proven && !proven.ok) {
|
|
860
|
-
|
|
1137
|
+
// THE SERVER'S OWN WORDS FIRST. The sentences below say that the
|
|
1138
|
+
// save did not happen; only the host knows WHY — "there is no
|
|
1139
|
+
// repository at that address", "the host rejected the credentials".
|
|
1140
|
+
// Replacing that with a generic sentence is how an admin is left
|
|
1141
|
+
// reading "fix the connection" with no idea what is wrong with it.
|
|
1142
|
+
const refusal =
|
|
861
1143
|
proven.outcome === 'read-only'
|
|
862
1144
|
? 'Not saved. The token can read the repository but cannot write to it — grant it write access and test again.'
|
|
863
1145
|
: variant === 'setup'
|
|
864
1146
|
? 'Not saved. Nothing behind this screen works until the repository answers, and it did not — fix the connection above and test it again.'
|
|
865
|
-
: 'Not saved. The repository did not answer with those details — fix the connection above and test it again.'
|
|
866
|
-
);
|
|
1147
|
+
: 'Not saved. The repository did not answer with those details — fix the connection above and test it again.';
|
|
1148
|
+
setError(proven.error ? `${refusal} The server said: ${proven.error}` : refusal);
|
|
867
1149
|
return;
|
|
868
1150
|
}
|
|
869
1151
|
}
|
|
@@ -875,17 +1157,27 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
875
1157
|
// above fills the same fields from the same answer.
|
|
876
1158
|
if (
|
|
877
1159
|
!probed &&
|
|
1160
|
+
// Only a repository reached by its address is asked this way.
|
|
1161
|
+
byAddress &&
|
|
878
1162
|
// No address, nothing to look a branch up in.
|
|
879
1163
|
!!resolvedIn(payload, 'kbRepoUrl') &&
|
|
880
1164
|
(!resolvedIn(payload, 'defaultBranch') || !resolvedIn(payload, 'protectedBranches'))
|
|
881
1165
|
) {
|
|
882
1166
|
await probe();
|
|
883
1167
|
}
|
|
884
|
-
|
|
1168
|
+
// An ordinary save is sent exactly as it always was — one argument, and
|
|
1169
|
+
// no `confirmRepositoryChange` in the body. Only the save that answers
|
|
1170
|
+
// the repository-change confirmation carries the answer.
|
|
1171
|
+
const result = confirmRepositoryChange
|
|
1172
|
+
? await saveSettings(payload, confirmRepositoryChange, moveAsked?.openChangeRequests)
|
|
1173
|
+
: await saveSettings(payload);
|
|
885
1174
|
// A save while a failure stands re-ran the initialization, and it held.
|
|
886
1175
|
setClearedFailure(initFailure);
|
|
887
1176
|
setInitFailure(null);
|
|
888
1177
|
setRestartRequired(result.restartRequired);
|
|
1178
|
+
// The confirmation was answered — and the answer went through.
|
|
1179
|
+
setRepositoryChange(null);
|
|
1180
|
+
setRepositoryChanged(result.repositoryChange ?? null);
|
|
889
1181
|
setDraft({});
|
|
890
1182
|
if (result.oidcVerification) setLatest(result.oidcVerification);
|
|
891
1183
|
// A save can succeed and STILL leave the deployment unusable: a blank
|
|
@@ -893,8 +1185,12 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
893
1185
|
// accepts a batch that answers only some of what it needs. Saying so is
|
|
894
1186
|
// the difference between a form that looks broken and one that tells you
|
|
895
1187
|
// what is left.
|
|
1188
|
+
// An address and a token are owed only by a deployment that reaches
|
|
1189
|
+
// its repository by them; the branch model by every one.
|
|
1190
|
+
const way = result.repository ? (result.repository.chosen ?? result.repository.mode) : 'token';
|
|
1191
|
+
const owed = (way ?? 'token') === 'token' ? REQUIRED_KEYS : BRANCH_MODEL_KEYS;
|
|
896
1192
|
const missing = result.settings
|
|
897
|
-
.filter((setting) =>
|
|
1193
|
+
.filter((setting) => owed.includes(setting.key) && !setting.configured)
|
|
898
1194
|
.map((setting) => FIELDS[setting.key]?.label ?? setting.key);
|
|
899
1195
|
setStillMissing(result.complete || result.awaitingRestart ? [] : missing);
|
|
900
1196
|
if (result.awaitingRestart) {
|
|
@@ -922,14 +1218,12 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
922
1218
|
onSaved();
|
|
923
1219
|
} catch (err) {
|
|
924
1220
|
if (err instanceof SettingsProblems) {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
//
|
|
928
|
-
//
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
);
|
|
932
|
-
if (unshown.length > 0) setError(unshown.map(([, message]) => message).join(' '));
|
|
1221
|
+
showProblems(err.problems);
|
|
1222
|
+
} else if (err instanceof RepositoryChangeNeedsConfirmation) {
|
|
1223
|
+
// NOT an error: nothing was saved and nothing was destroyed. The
|
|
1224
|
+
// draft stays exactly as typed — the confirmed save re-sends it.
|
|
1225
|
+
setRepositoryChange({ openChangeRequests: err.openChangeRequests, from: err.from, to: err.to, target: moveTarget });
|
|
1226
|
+
setChangeChoice('keep');
|
|
933
1227
|
} else if (err instanceof KbInitFailed) {
|
|
934
1228
|
// The values ARE stored — only the initialization failed. The form
|
|
935
1229
|
// shows what was saved, and the banner says what to fix and retries
|
|
@@ -937,6 +1231,14 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
937
1231
|
setClearedFailure(null);
|
|
938
1232
|
setInitFailure(err.kbInit);
|
|
939
1233
|
setDraft({});
|
|
1234
|
+
// The confirmation was ANSWERED — the address is stored; it is the
|
|
1235
|
+
// initialization that failed, and the banner above owns the retry.
|
|
1236
|
+
// Left standing, it would offer Replace for a change that already
|
|
1237
|
+
// happened, over a draft this line has just cleared: a second click
|
|
1238
|
+
// would re-send the stored address, change nothing, and swallow the
|
|
1239
|
+
// "requests closed" outcome for good.
|
|
1240
|
+
setRepositoryChange(null);
|
|
1241
|
+
setChangeChoice('keep');
|
|
940
1242
|
onSaved();
|
|
941
1243
|
} else setError(err instanceof Error ? err.message : 'Could not save these settings.');
|
|
942
1244
|
} finally {
|
|
@@ -1107,14 +1409,25 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1107
1409
|
<>
|
|
1108
1410
|
<h1 className="text-display font-semibold text-ink">Set up this deployment</h1>
|
|
1109
1411
|
<p className="mt-2 max-w-[62ch] text-lede text-ink-muted">
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1412
|
+
{repository
|
|
1413
|
+
? 'One thing is needed before anyone can use it: somewhere to keep your knowledge, skills and tools. Choose where below; this deployment can keep it for you. Single sign-on is optional and can wait.'
|
|
1414
|
+
: 'One thing is needed before anyone can use it: somewhere to keep your knowledge, skills and tools. Connect a repository below, test it, and the rest fills itself in. Single sign-on is optional and can wait.'}
|
|
1113
1415
|
</p>
|
|
1114
1416
|
</>
|
|
1115
1417
|
)}
|
|
1116
1418
|
|
|
1117
1419
|
<div ref={noticeRef}>
|
|
1420
|
+
{/* Back from GitHub, with a secret that was typed before the trip
|
|
1421
|
+
and not kept. Said, because an empty field that was full a
|
|
1422
|
+
minute ago otherwise reads as something that went wrong. It
|
|
1423
|
+
goes as each is entered again. */}
|
|
1424
|
+
{toEnterAgain.length > 0 && (
|
|
1425
|
+
<Banner tone="wait" role="status" className="mt-6" data-testid="enter-again">
|
|
1426
|
+
What you had entered is back, except{' '}
|
|
1427
|
+
{toEnterAgain.map((key) => FIELDS[key]?.label ?? key).join(', ')}. For safety, a secret is not kept while
|
|
1428
|
+
the browser is away: enter {toEnterAgain.length === 1 ? 'it' : 'them'} again.
|
|
1429
|
+
</Banner>
|
|
1430
|
+
)}
|
|
1118
1431
|
{/* Saved, but the knowledge base behind the gate was never set up.
|
|
1119
1432
|
The cause is the server's classified sentence — what to fix, not
|
|
1120
1433
|
what git said — and the retry needs nothing re-entered. */}
|
|
@@ -1140,6 +1453,23 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1140
1453
|
</Banner>
|
|
1141
1454
|
)}
|
|
1142
1455
|
|
|
1456
|
+
{/* What the save that moved the deployment actually did. */}
|
|
1457
|
+
{repositoryChanged && (
|
|
1458
|
+
<Banner tone="ok" role="status" className="mt-6" data-testid="repository-changed">
|
|
1459
|
+
<p>
|
|
1460
|
+
Saved. This deployment now works on the new repository.
|
|
1461
|
+
</p>
|
|
1462
|
+
{repositoryChanged.choice === 'close' && repositoryChanged.closedChangeRequests > 0 && (
|
|
1463
|
+
<p className="mt-1">
|
|
1464
|
+
{repositoryChanged.closedChangeRequests === 1
|
|
1465
|
+
? '1 change request was closed as “repository replaced”.'
|
|
1466
|
+
: `${repositoryChanged.closedChangeRequests} change requests were closed as “repository replaced”.`}{' '}
|
|
1467
|
+
Nothing was deleted.
|
|
1468
|
+
</p>
|
|
1469
|
+
)}
|
|
1470
|
+
</Banner>
|
|
1471
|
+
)}
|
|
1472
|
+
|
|
1143
1473
|
{error && (
|
|
1144
1474
|
<Banner tone="danger" role="alert" className="mt-6">
|
|
1145
1475
|
{error}
|
|
@@ -1180,12 +1510,32 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1180
1510
|
Marketplace section: the button is the last thing on the page, but
|
|
1181
1511
|
Marketplace is deliberately not part of this form (see below). */}
|
|
1182
1512
|
<form id="setup-settings-form" onSubmit={submit} className="mt-8 space-y-10">
|
|
1183
|
-
{
|
|
1184
|
-
const fields = editable.filter(
|
|
1513
|
+
{sections.map((section) => {
|
|
1514
|
+
const fields = editable.filter(
|
|
1515
|
+
(s) =>
|
|
1516
|
+
s.section === section.id &&
|
|
1517
|
+
// Chosen by its tab, not typed into a field.
|
|
1518
|
+
s.key !== 'gitMode' &&
|
|
1519
|
+
// Chosen from a list, by the panel of its tab.
|
|
1520
|
+
s.key !== 'githubRepository' &&
|
|
1521
|
+
// The address, the token and the name beside it belong to the
|
|
1522
|
+
// one way that reaches a repository by them.
|
|
1523
|
+
(byAddress || !CONNECTION_KEYS.includes(s.key)),
|
|
1524
|
+
);
|
|
1525
|
+
// The ways of having a repository, each on a tab of its own.
|
|
1526
|
+
const repositoryTabs = section.id === 'knowledge-base' ? repository : undefined;
|
|
1185
1527
|
// A section whose every field comes from the environment has
|
|
1186
1528
|
// nothing to offer — the locked list at the bottom already names
|
|
1187
1529
|
// them, and an empty heading would read as something missing.
|
|
1188
1530
|
if (fields.length === 0) return null;
|
|
1531
|
+
// Two ways of signing in, each on a tab of its own.
|
|
1532
|
+
const tabbed = section.id === 'sign-in' && signInOption !== undefined;
|
|
1533
|
+
const redirectUri = (
|
|
1534
|
+
<p className="mt-1.5 text-meta text-ink-faint">
|
|
1535
|
+
Redirect URI:{' '}
|
|
1536
|
+
<code className="font-mono">{`${window.location.origin}/api/auth/oidc/callback`}</code>
|
|
1537
|
+
</p>
|
|
1538
|
+
);
|
|
1189
1539
|
return (
|
|
1190
1540
|
<Surface
|
|
1191
1541
|
key={section.id}
|
|
@@ -1206,14 +1556,148 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1206
1556
|
<span className="text-meta text-ink-faint">Optional</span>
|
|
1207
1557
|
)}
|
|
1208
1558
|
</div>
|
|
1209
|
-
<p className="mt-1 max-w-[60ch] text-detail text-ink-muted">
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1559
|
+
<p className="mt-1 max-w-[60ch] text-detail text-ink-muted">
|
|
1560
|
+
{repositoryTabs
|
|
1561
|
+
? 'Where everything lives, together in one git repository: knowledge, skills and tools. Choose where that repository is.'
|
|
1562
|
+
: section.blurb}
|
|
1563
|
+
</p>
|
|
1564
|
+
{/* About the deployment's own provider: under the heading
|
|
1565
|
+
when that is all the section holds, inside its tab when
|
|
1566
|
+
the section has two. */}
|
|
1567
|
+
{section.id === 'sign-in' && !tabbed && redirectUri}
|
|
1216
1568
|
</div>
|
|
1569
|
+
{section.id === 'sign-in' && signInOption && (
|
|
1570
|
+
<>
|
|
1571
|
+
<div role="tablist" aria-label="How people sign in" className="flex gap-1 border-b border-line">
|
|
1572
|
+
{(
|
|
1573
|
+
[
|
|
1574
|
+
['managed', signInOption.label],
|
|
1575
|
+
['own', signInOption.ownProviderLabel ?? 'Your own provider'],
|
|
1576
|
+
] as const
|
|
1577
|
+
).map(([id, label]) => (
|
|
1578
|
+
<button
|
|
1579
|
+
key={id}
|
|
1580
|
+
type="button"
|
|
1581
|
+
role="tab"
|
|
1582
|
+
id={`sign-in-tab-${id}`}
|
|
1583
|
+
aria-selected={signInTab === id}
|
|
1584
|
+
aria-controls={`sign-in-panel-${id}`}
|
|
1585
|
+
onClick={() => setSignInTab(id)}
|
|
1586
|
+
className={`-mb-px border-b-2 px-3 py-2 text-detail font-medium ${
|
|
1587
|
+
signInTab === id
|
|
1588
|
+
? 'border-accent text-ink'
|
|
1589
|
+
: 'border-transparent text-ink-muted hover:text-ink'
|
|
1590
|
+
}`}
|
|
1591
|
+
>
|
|
1592
|
+
{label}
|
|
1593
|
+
</button>
|
|
1594
|
+
))}
|
|
1595
|
+
</div>
|
|
1596
|
+
{signInTab === 'managed' && (
|
|
1597
|
+
<div
|
|
1598
|
+
role="tabpanel"
|
|
1599
|
+
id="sign-in-panel-managed"
|
|
1600
|
+
aria-labelledby="sign-in-tab-managed"
|
|
1601
|
+
onKeyDown={keepEnterFromTheForm}
|
|
1602
|
+
>
|
|
1603
|
+
{/* The distribution's code: a throw in it costs this
|
|
1604
|
+
tab, not the form the repository is entered on. */}
|
|
1605
|
+
<SlotBoundary label="sign-in panel">
|
|
1606
|
+
<signInOption.Panel variant={variant} ownProviderConfigured={ownProviderConfigured} />
|
|
1607
|
+
</SlotBoundary>
|
|
1608
|
+
</div>
|
|
1609
|
+
)}
|
|
1610
|
+
</>
|
|
1611
|
+
)}
|
|
1612
|
+
|
|
1613
|
+
{/* The section's own fields: every field it has, in ONE
|
|
1614
|
+
place. With a distribution's tab beside them they are
|
|
1615
|
+
the second tab's panel, there while that tab is open;
|
|
1616
|
+
what was typed stays in the draft either way, so
|
|
1617
|
+
switching tabs loses nothing and saves what was entered. */}
|
|
1618
|
+
{(!tabbed || signInTab === 'own') && (
|
|
1619
|
+
<SectionFields panel={tabbed ? { group: 'sign-in', id: 'own' } : null}>
|
|
1620
|
+
{tabbed && redirectUri}
|
|
1621
|
+
{repositoryTabs && (
|
|
1622
|
+
<div role="tablist" aria-label="Where the repository is" className="flex gap-1 border-b border-line">
|
|
1623
|
+
{repositoryTabs.modes.map((mode) => (
|
|
1624
|
+
<button
|
|
1625
|
+
key={mode}
|
|
1626
|
+
type="button"
|
|
1627
|
+
role="tab"
|
|
1628
|
+
id={`repository-tab-${mode}`}
|
|
1629
|
+
aria-selected={gitTab === mode}
|
|
1630
|
+
aria-controls={`repository-panel-${mode}`}
|
|
1631
|
+
// Chosen by the environment, the choice is not the
|
|
1632
|
+
// screen's: the other ways are shown, as what they
|
|
1633
|
+
// are, and cannot be opened.
|
|
1634
|
+
disabled={repositoryTabs.pinned !== undefined && mode !== gitTab}
|
|
1635
|
+
onClick={() => setGitTab(mode)}
|
|
1636
|
+
className={`-mb-px border-b-2 px-3 py-2 text-detail font-medium disabled:cursor-not-allowed disabled:opacity-50 ${
|
|
1637
|
+
gitTab === mode
|
|
1638
|
+
? 'border-accent text-ink'
|
|
1639
|
+
: 'border-transparent text-ink-muted hover:text-ink'
|
|
1640
|
+
}`}
|
|
1641
|
+
>
|
|
1642
|
+
{GIT_MODE_LABEL[mode]}
|
|
1643
|
+
</button>
|
|
1644
|
+
))}
|
|
1645
|
+
</div>
|
|
1646
|
+
)}
|
|
1647
|
+
{repositoryTabs?.pinned && (
|
|
1648
|
+
<p className="text-meta text-ink-faint" data-testid="repository-pinned">
|
|
1649
|
+
Set by the <span className="font-mono">{repositoryTabs.pinned}</span> environment variable. Change it
|
|
1650
|
+
there.
|
|
1651
|
+
</p>
|
|
1652
|
+
)}
|
|
1653
|
+
{/* What the open tab asks: nothing, for a repository the
|
|
1654
|
+
deployment keeps; the address and the token, and the test
|
|
1655
|
+
that proves them, for one reached by them. */}
|
|
1656
|
+
<SectionFields panel={repositoryTabs ? { group: 'repository', id: gitTab } : null}>
|
|
1657
|
+
{repositoryTabs && movePending && gitTab === chosen && (
|
|
1658
|
+
<Banner tone="wait" role="status" data-testid="move-pending">
|
|
1659
|
+
A restart is pending. This deployment is still working on “{movingFrom}” and moves
|
|
1660
|
+
here when it is restarted. To stay where it is, open “{movingFrom}” and save.
|
|
1661
|
+
</Banner>
|
|
1662
|
+
)}
|
|
1663
|
+
{repositoryTabs && savingMoves && gitTab !== inEffect && (
|
|
1664
|
+
<Banner tone="wait" role="status" data-testid="moves-repository">
|
|
1665
|
+
Saving moves this deployment to another repository, which starts without what the
|
|
1666
|
+
current one holds. Nothing is deleted: the current repository is left as it is, and
|
|
1667
|
+
this deployment’s working copies of it are set aside. You are asked to confirm
|
|
1668
|
+
before anything moves.
|
|
1669
|
+
</Banner>
|
|
1670
|
+
)}
|
|
1671
|
+
{repositoryTabs && savingMoves && gitTab === inEffect && (
|
|
1672
|
+
<Banner tone="wait" role="status" data-testid="move-taken-back">
|
|
1673
|
+
Saving takes the move back: this deployment stays on the repository it is working on.
|
|
1674
|
+
</Banner>
|
|
1675
|
+
)}
|
|
1676
|
+
{repositoryTabs && gitTab === 'github-app' && (
|
|
1677
|
+
<GitHubRepositoryPanel
|
|
1678
|
+
repository={resolved('githubRepository')}
|
|
1679
|
+
onChoose={(name) => set('githubRepository', name)}
|
|
1680
|
+
problem={problems.githubRepository}
|
|
1681
|
+
disabled={saving}
|
|
1682
|
+
// The browser is about to leave for GitHub, and the page
|
|
1683
|
+
// that comes back is a new one.
|
|
1684
|
+
onLeaving={() => keepDraft(draft, isSecret)}
|
|
1685
|
+
/>
|
|
1686
|
+
)}
|
|
1687
|
+
{repositoryTabs && gitTab === 'managed' && (
|
|
1688
|
+
<div className="space-y-2" data-testid="managed-repository">
|
|
1689
|
+
<p className="max-w-[60ch] text-detail text-ink">
|
|
1690
|
+
This deployment keeps the repository itself. There is nothing to connect and
|
|
1691
|
+
nothing to enter.
|
|
1692
|
+
</p>
|
|
1693
|
+
<p className="max-w-[60ch] text-meta text-ink-muted">
|
|
1694
|
+
Everything is versioned as it is with any repository: every change is a commit,
|
|
1695
|
+
and changes are reviewed as change requests. The repository is stored with this
|
|
1696
|
+
deployment’s backups, so backing those up backs it up. You can move to a
|
|
1697
|
+
repository of your own later.
|
|
1698
|
+
</p>
|
|
1699
|
+
</div>
|
|
1700
|
+
)}
|
|
1217
1701
|
{fields
|
|
1218
1702
|
.filter(
|
|
1219
1703
|
(f) =>
|
|
@@ -1236,7 +1720,7 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1236
1720
|
section, so the answer to "did I type the token right?"
|
|
1237
1721
|
was below the identity-provider questions and, once the
|
|
1238
1722
|
page grew, below the fold entirely. */}
|
|
1239
|
-
{section.id === 'knowledge-base' && (
|
|
1723
|
+
{section.id === 'knowledge-base' && byAddress && (
|
|
1240
1724
|
<Surface tone="sunken" radius="md" className="p-4">
|
|
1241
1725
|
<div className="flex flex-wrap items-center gap-3">
|
|
1242
1726
|
<Button
|
|
@@ -1272,6 +1756,7 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1272
1756
|
)}
|
|
1273
1757
|
</Surface>
|
|
1274
1758
|
)}
|
|
1759
|
+
</SectionFields>
|
|
1275
1760
|
|
|
1276
1761
|
{/* The layout: the three root folders and the agent guide's
|
|
1277
1762
|
file name, in the main section, directly under the test
|
|
@@ -1320,6 +1805,8 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1320
1805
|
sync &&
|
|
1321
1806
|
!fields.some((f) => f.key === 'kbSyncSecret') &&
|
|
1322
1807
|
renderSyncPanel()}
|
|
1808
|
+
</SectionFields>
|
|
1809
|
+
)}
|
|
1323
1810
|
</Surface>
|
|
1324
1811
|
);
|
|
1325
1812
|
})}
|
|
@@ -1354,25 +1841,104 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1354
1841
|
)}
|
|
1355
1842
|
</form>
|
|
1356
1843
|
|
|
1357
|
-
{/* Outside the form: nothing in it is saved by "Save and continue"
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
<MarketplaceSection variant={variant} />
|
|
1844
|
+
{/* Outside the form: nothing in it is saved by "Save and continue".
|
|
1845
|
+
On the Deployment page only: the first run asks for the
|
|
1846
|
+
repository and for sign-in (see FIRST_RUN_SECTIONS). */}
|
|
1847
|
+
{variant === 'settings' && <MarketplaceSection variant={variant} />}
|
|
1362
1848
|
|
|
1363
1849
|
{/* The submit button lives HERE, after Marketplace, though it belongs
|
|
1364
1850
|
to the form above — `form=` is what lets those two facts hold at
|
|
1365
1851
|
once. It is the last thing on the page because a reader should
|
|
1366
|
-
meet every section, Marketplace included
|
|
1367
|
-
leaves the screen; when it sat above Marketplace,
|
|
1368
|
-
finished while a section was still below it.
|
|
1852
|
+
meet every section, Marketplace included where it is shown, before
|
|
1853
|
+
the control that leaves the screen; when it sat above Marketplace,
|
|
1854
|
+
the page looked finished while a section was still below it.
|
|
1369
1855
|
|
|
1370
1856
|
A rejected connection stops here rather than at the far side of
|
|
1371
1857
|
it. Saving these answers would finish setup — the server checks
|
|
1372
1858
|
that they are present, not that they work — and open the app onto
|
|
1373
1859
|
a repository it cannot reach, which reads as a broken product
|
|
1374
1860
|
rather than a wrong token. */}
|
|
1375
|
-
|
|
1861
|
+
{/* ASKED WHERE THE DECISION IS MADE, AND ASKED ONCE. The tab is the
|
|
1862
|
+
choice, and the tab is a screen above this button: an admin who
|
|
1863
|
+
opened another way to read about it, then changed something else
|
|
1864
|
+
and saved, would have moved the deployment to an empty
|
|
1865
|
+
repository. So the server refuses a save that moves until the
|
|
1866
|
+
admin has said yes, and the question is put here, naming what is
|
|
1867
|
+
left and what is moved to. Nothing is stored and nothing is set
|
|
1868
|
+
aside while it stands; the draft is still on screen, and
|
|
1869
|
+
answering re-sends it. */}
|
|
1870
|
+
{moveAsked && (
|
|
1871
|
+
<Banner tone="wait" role="alert" className="mt-10" data-testid="repository-change-confirm">
|
|
1872
|
+
<p className="font-semibold">
|
|
1873
|
+
{moveAsked.from && moveAsked.to && moveAsked.from !== moveAsked.to
|
|
1874
|
+
? `Move this deployment from “${GIT_MODE_LABEL[moveAsked.from]}” to “${GIT_MODE_LABEL[moveAsked.to]}”?`
|
|
1875
|
+
: 'Move this deployment to another repository?'}
|
|
1876
|
+
</p>
|
|
1877
|
+
<p className="mt-1">
|
|
1878
|
+
The move happens as soon as you confirm, with no restart. Unless the new repository holds the
|
|
1879
|
+
same history, every working copy on this server stops being used and is cloned fresh from the
|
|
1880
|
+
new repository. Anything committed here and not
|
|
1881
|
+
yet pushed from this server goes out of the app with it. Nothing is deleted, but it is only
|
|
1882
|
+
recoverable from the
|
|
1883
|
+
<code className="mx-1">replaced-working-copies</code>
|
|
1884
|
+
folder on the server, by hand.
|
|
1885
|
+
</p>
|
|
1886
|
+
{moveAsked.openChangeRequests > 0 && (
|
|
1887
|
+
<fieldset className="mt-3">
|
|
1888
|
+
<legend className="font-semibold">
|
|
1889
|
+
{moveAsked.openChangeRequests === 1
|
|
1890
|
+
? 'There is 1 open change request.'
|
|
1891
|
+
: `There are ${moveAsked.openChangeRequests} open change requests.`}
|
|
1892
|
+
</legend>
|
|
1893
|
+
<label className="mt-1 flex items-start gap-2">
|
|
1894
|
+
<input
|
|
1895
|
+
type="radio"
|
|
1896
|
+
name="repository-change-requests"
|
|
1897
|
+
className="mt-1"
|
|
1898
|
+
checked={changeChoice === 'keep'}
|
|
1899
|
+
onChange={() => setChangeChoice('keep')}
|
|
1900
|
+
/>
|
|
1901
|
+
<span>Keep them open: the same repository only moved.</span>
|
|
1902
|
+
</label>
|
|
1903
|
+
<label className="mt-1 flex items-start gap-2">
|
|
1904
|
+
<input
|
|
1905
|
+
type="radio"
|
|
1906
|
+
name="repository-change-requests"
|
|
1907
|
+
className="mt-1"
|
|
1908
|
+
checked={changeChoice === 'close'}
|
|
1909
|
+
onChange={() => setChangeChoice('close')}
|
|
1910
|
+
/>
|
|
1911
|
+
<span>
|
|
1912
|
+
Close them as “repository replaced”: this is a different repository and their
|
|
1913
|
+
branches are not in it. Nothing is deleted, and the file locks held on those
|
|
1914
|
+
branches are released.
|
|
1915
|
+
</span>
|
|
1916
|
+
</label>
|
|
1917
|
+
</fieldset>
|
|
1918
|
+
)}
|
|
1919
|
+
<div className="mt-3 flex gap-2">
|
|
1920
|
+
<Button
|
|
1921
|
+
type="button"
|
|
1922
|
+
size="sm"
|
|
1923
|
+
onClick={() => void saveNow(moveAsked.openChangeRequests > 0 ? changeChoice : 'keep')}
|
|
1924
|
+
// The same things that stop a save: a click must never do nothing.
|
|
1925
|
+
disabled={saving || testing || retrying || oidcTesting}
|
|
1926
|
+
>
|
|
1927
|
+
{saving ? 'Moving…' : 'Move the deployment'}
|
|
1928
|
+
</Button>
|
|
1929
|
+
<Button
|
|
1930
|
+
type="button"
|
|
1931
|
+
variant="outline"
|
|
1932
|
+
size="sm"
|
|
1933
|
+
onClick={() => setRepositoryChange(null)}
|
|
1934
|
+
disabled={saving || testing}
|
|
1935
|
+
>
|
|
1936
|
+
Cancel
|
|
1937
|
+
</Button>
|
|
1938
|
+
</div>
|
|
1939
|
+
</Banner>
|
|
1940
|
+
)}
|
|
1941
|
+
<div className={`${moveAsked ? 'mt-4' : 'mt-10'} flex flex-wrap items-center justify-end gap-3`}>
|
|
1376
1942
|
{connectionRejected && (
|
|
1377
1943
|
// Before the button in the DOM so the reason is read first, and
|
|
1378
1944
|
// so `justify-end` leaves the button itself at the right edge.
|
|
@@ -1389,7 +1955,8 @@ export function SetupScreen({ settings, onSaved, variant = 'setup', sync, kbInit
|
|
|
1389
1955
|
type="submit"
|
|
1390
1956
|
form="setup-settings-form"
|
|
1391
1957
|
variant="primary"
|
|
1392
|
-
|
|
1958
|
+
// While the question stands, its own buttons are the way on.
|
|
1959
|
+
disabled={saving || testing || retrying || oidcTesting || connectionRejected || moveAsked !== null}
|
|
1393
1960
|
// Described by the refusal, so a reader who lands on a button
|
|
1394
1961
|
// that will not move is told why rather than left guessing.
|
|
1395
1962
|
aria-describedby={connectionRejected ? 'connection-refusal' : undefined}
|