@bevel-software/platform-core-frontend 0.20.0 → 0.22.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/registry.ts +57 -0
- package/src/modules/access/__tests__/ManageAccessDialog.request.test.tsx +376 -0
- 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/hooks/useFileAccess.ts +2 -2
- package/src/modules/access/requests.api.ts +121 -0
- package/src/modules/auth/components/LoginScreen.tsx +6 -0
- 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/ChangeRequestDialog.tsx +155 -98
- 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__/SkillPage.test.tsx +15 -0
- package/src/modules/library/__tests__/ToolPage.test.tsx +34 -0
- package/src/modules/library/__tests__/name-with-badges.test.tsx +16 -3
- package/src/modules/library/__tests__/title-row-actions.ts +95 -0
- package/src/modules/library/components/PluginIndexRow.tsx +37 -20
- package/src/modules/library/components/PluginJoinRequests.tsx +2 -2
- package/src/modules/library/components/PluginPage.tsx +115 -3
- package/src/modules/library/components/skill-page/SkillPage.tsx +2 -2
- package/src/modules/library/components/tool-page/ToolPage.tsx +36 -18
- package/src/modules/library/hooks/useJoinRequests.ts +26 -101
- 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/pr/services/pr-merge.api.ts +10 -2
- package/src/modules/review/components/ReviewPanel.tsx +2 -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.test.tsx +373 -0
- package/src/modules/setup/__tests__/setup.test.tsx +8 -14
- 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 +464 -38
- package/src/modules/setup/services/setup.api.ts +93 -0
- package/src/modules/setup/utils/kept-draft.ts +86 -0
- 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/components/SlotBoundary.tsx +51 -0
- package/src/shared/theme/measure.ts +23 -2
|
@@ -146,23 +146,18 @@ describe('SetupScreen', () => {
|
|
|
146
146
|
});
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
* The first
|
|
150
|
-
*
|
|
151
|
-
* is fetched or saved on the way.
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* tied to the form by `form=`, this also proves that out-of-form submit
|
|
155
|
-
* still saves.
|
|
149
|
+
* The first run asks for the repository and for sign-in, and nothing else:
|
|
150
|
+
* Marketplace is a preference set on the Deployment page. Setup finishes
|
|
151
|
+
* without it, and nothing of it is fetched or saved on the way. Because
|
|
152
|
+
* "Save and continue" sits outside the form and is tied to it by `form=`,
|
|
153
|
+
* this also proves that out-of-form submit still saves.
|
|
156
154
|
*/
|
|
157
|
-
it('
|
|
155
|
+
it('leaves Marketplace to the Deployment page, and finishes setup without it', async () => {
|
|
158
156
|
facade.fetchGitHubFacade.mockClear();
|
|
159
157
|
facade.setMarketplaceRegistration.mockClear();
|
|
160
158
|
await renderScreen();
|
|
161
|
-
|
|
162
|
-
expect(
|
|
163
|
-
expect(screen.getByRole('heading', { name: 'Marketplace' })).toBeInTheDocument();
|
|
164
|
-
expect(screen.getByText('Register this deployment with your Claude organization')).toBeInTheDocument();
|
|
165
|
-
expect(screen.queryByRole('button', { name: 'Skip for now' })).toBeNull();
|
|
159
|
+
expect(screen.queryByTestId('marketplace-deployment-section')).toBeNull();
|
|
160
|
+
expect(screen.queryByRole('heading', { name: 'Marketplace' })).toBeNull();
|
|
166
161
|
|
|
167
162
|
api.saveSettings.mockResolvedValue({ restartRequired: false, complete: true, settings: SETTINGS });
|
|
168
163
|
await userEvent.type(screen.getByLabelText('Repository address'), 'https://example.com/kb.git');
|
|
@@ -804,7 +799,6 @@ describe('SetupScreen', () => {
|
|
|
804
799
|
/** Single sign-on is skippable, and the screen has to say so. */
|
|
805
800
|
it('marks the optional section optional', async () => {
|
|
806
801
|
await renderScreen();
|
|
807
|
-
// Scoped: the Marketplace section below the form is optional too.
|
|
808
802
|
const signIn = screen.getByRole('heading', { name: 'Single sign-on' }).closest('section')!;
|
|
809
803
|
expect(within(signIn).getByText('Optional')).toBeInTheDocument();
|
|
810
804
|
});
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Banner, Button, TextField, useLatestRef } from '../../../shared/components';
|
|
3
|
+
import {
|
|
4
|
+
fetchGitHubApp,
|
|
5
|
+
fetchGitHubRepositories,
|
|
6
|
+
startGitHubAppInstallation,
|
|
7
|
+
startGitHubAppRefresh,
|
|
8
|
+
startGitHubAppRegistration,
|
|
9
|
+
type GitHubAppStatus,
|
|
10
|
+
type GitHubRepository,
|
|
11
|
+
} from '../services/setup.api';
|
|
12
|
+
|
|
13
|
+
/** How a round trip to GitHub ended, as the address the browser came back on says. */
|
|
14
|
+
const OUTCOMES: Record<string, { tone: 'ok' | 'danger' | 'wait'; text: string }> = {
|
|
15
|
+
connected: { tone: 'ok', text: 'GitHub is connected. Choose the repository below.' },
|
|
16
|
+
refreshed: { tone: 'ok', text: 'The list of repositories is up to date.' },
|
|
17
|
+
'not-installed': {
|
|
18
|
+
tone: 'danger',
|
|
19
|
+
text: 'The app is not installed anywhere your GitHub account can reach. Install it from here.',
|
|
20
|
+
},
|
|
21
|
+
several: {
|
|
22
|
+
tone: 'wait',
|
|
23
|
+
text: 'The app is installed in more than one place you can reach. Install it from here and choose the one to connect.',
|
|
24
|
+
},
|
|
25
|
+
requested: {
|
|
26
|
+
tone: 'wait',
|
|
27
|
+
text: 'You asked an owner of the organisation to install the app. Come back here once they have.',
|
|
28
|
+
},
|
|
29
|
+
'not-yours': {
|
|
30
|
+
tone: 'danger',
|
|
31
|
+
text: 'That installation is not one your GitHub account can reach, so it was not connected. Install the app on an account or organisation you belong to.',
|
|
32
|
+
},
|
|
33
|
+
'nothing-to-write': {
|
|
34
|
+
tone: 'danger',
|
|
35
|
+
text: 'The app reaches no repository your own GitHub account can write to, so nothing was connected. Add a repository you can write to, or ask someone who can to connect it.',
|
|
36
|
+
},
|
|
37
|
+
state: { tone: 'danger', text: 'The round trip to GitHub could not be verified. Start it again from here.' },
|
|
38
|
+
refused: { tone: 'danger', text: 'GitHub did not complete the connection. Start it again from here.' },
|
|
39
|
+
unreachable: { tone: 'danger', text: 'GitHub could not be reached. Try again shortly.' },
|
|
40
|
+
'not-registered': { tone: 'danger', text: 'This deployment has no GitHub App yet. Create it first.' },
|
|
41
|
+
'already-registered': { tone: 'wait', text: 'This deployment already has its GitHub App. Install it to go on.' },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** The outcome on the address, read once and taken off it, so a reload does not say it again. */
|
|
45
|
+
function takeOutcome(): string | null {
|
|
46
|
+
const outcome = new URLSearchParams(window.location.search ?? '').get('github');
|
|
47
|
+
if (!outcome) return null;
|
|
48
|
+
try {
|
|
49
|
+
const url = new URL(window.location.href);
|
|
50
|
+
url.searchParams.delete('github');
|
|
51
|
+
window.history.replaceState({}, '', `${url.pathname}${url.search}${url.hash}`);
|
|
52
|
+
} catch {
|
|
53
|
+
// The address stays as it is: the outcome is said once more on a reload, which is all that is lost.
|
|
54
|
+
}
|
|
55
|
+
return outcome;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Send the browser to GitHub with the manifest: a form GitHub receives, not
|
|
60
|
+
* a request of ours, because the app is created in the person's own GitHub
|
|
61
|
+
* session. Built on the page and outside the settings form, which a form
|
|
62
|
+
* cannot sit inside.
|
|
63
|
+
*/
|
|
64
|
+
function postManifest(action: string, manifest: Record<string, unknown>): void {
|
|
65
|
+
const form = document.createElement('form');
|
|
66
|
+
form.method = 'post';
|
|
67
|
+
form.action = action;
|
|
68
|
+
const field = document.createElement('input');
|
|
69
|
+
field.type = 'hidden';
|
|
70
|
+
field.name = 'manifest';
|
|
71
|
+
field.value = JSON.stringify(manifest);
|
|
72
|
+
form.appendChild(field);
|
|
73
|
+
document.body.appendChild(form);
|
|
74
|
+
form.submit();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface Props {
|
|
78
|
+
/** The repository chosen: what was picked on this screen, else what is stored. */
|
|
79
|
+
repository: string;
|
|
80
|
+
onChoose(repository: string): void;
|
|
81
|
+
/** What a refused save said about the repository. */
|
|
82
|
+
problem?: string;
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Called just before the browser is sent to GitHub. The page that comes
|
|
86
|
+
* back is a new one, so whatever the form holds has to be kept now.
|
|
87
|
+
*/
|
|
88
|
+
onLeaving?(): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The GitHub tab of the repository section: connect a repository through a
|
|
93
|
+
* GitHub App, in the three steps that takes, each offered when the one
|
|
94
|
+
* before it is done.
|
|
95
|
+
*
|
|
96
|
+
* 1. The app. A deployment registers its own, in one press, unless whoever
|
|
97
|
+
* operates it supplied one.
|
|
98
|
+
* 2. The installation: the admin chooses, on GitHub, which repositories
|
|
99
|
+
* the app may reach.
|
|
100
|
+
* 3. The repository, chosen here among those.
|
|
101
|
+
*
|
|
102
|
+
* Nothing is typed and no token is created or stored: GitHub issues one for
|
|
103
|
+
* an hour at a time. It sits inside the settings form, so it has no form of
|
|
104
|
+
* its own and its buttons are buttons; the repository chosen is saved with
|
|
105
|
+
* everything else by "Save and continue".
|
|
106
|
+
*/
|
|
107
|
+
export function GitHubRepositoryPanel({ repository, onChoose, problem, disabled, onLeaving }: Props) {
|
|
108
|
+
const [status, setStatus] = useState<GitHubAppStatus | null>(null);
|
|
109
|
+
const [failed, setFailed] = useState<string | null>(null);
|
|
110
|
+
const [outcome] = useState(takeOutcome);
|
|
111
|
+
const [organization, setOrganization] = useState('');
|
|
112
|
+
const [starting, setStarting] = useState(false);
|
|
113
|
+
const [repositories, setRepositories] = useState<GitHubRepository[] | null>(null);
|
|
114
|
+
const [more, setMore] = useState(false);
|
|
115
|
+
const [listFailed, setListFailed] = useState<string | null>(null);
|
|
116
|
+
/** GitHub was opened in another tab: what was changed there is not in the list until it is refreshed. */
|
|
117
|
+
const [managed, setManaged] = useState(false);
|
|
118
|
+
// Asked for at the moment of leaving, not at the press that led to it:
|
|
119
|
+
// GitHub is asked for an address in between, and what the form holds when
|
|
120
|
+
// the browser goes is what has to be kept.
|
|
121
|
+
const leaving = useLatestRef(onLeaving);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
let mounted = true;
|
|
125
|
+
fetchGitHubApp()
|
|
126
|
+
.then((found) => mounted && setStatus(found))
|
|
127
|
+
.catch((err: unknown) => mounted && setFailed(err instanceof Error ? err.message : 'Could not read the GitHub connection.'));
|
|
128
|
+
return () => {
|
|
129
|
+
mounted = false;
|
|
130
|
+
};
|
|
131
|
+
}, []);
|
|
132
|
+
|
|
133
|
+
const installed = status?.installation ?? null;
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!installed) return;
|
|
136
|
+
let mounted = true;
|
|
137
|
+
fetchGitHubRepositories()
|
|
138
|
+
.then((found) => {
|
|
139
|
+
if (!mounted) return;
|
|
140
|
+
setRepositories(found.repositories);
|
|
141
|
+
setMore(found.more);
|
|
142
|
+
})
|
|
143
|
+
.catch((err: unknown) => mounted && setListFailed(err instanceof Error ? err.message : 'Could not list the repositories.'));
|
|
144
|
+
return () => {
|
|
145
|
+
mounted = false;
|
|
146
|
+
};
|
|
147
|
+
}, [installed?.id]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
148
|
+
|
|
149
|
+
async function register() {
|
|
150
|
+
setFailed(null);
|
|
151
|
+
setStarting(true);
|
|
152
|
+
try {
|
|
153
|
+
const { action, manifest } = await startGitHubAppRegistration(organization.trim());
|
|
154
|
+
leaving.current?.();
|
|
155
|
+
postManifest(action, manifest);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
setFailed(err instanceof Error ? err.message : 'Could not start creating the app.');
|
|
158
|
+
setStarting(false);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Ask where on GitHub the app is installed, and go there. Asking is what starts the round trip. */
|
|
163
|
+
async function install() {
|
|
164
|
+
setFailed(null);
|
|
165
|
+
setStarting(true);
|
|
166
|
+
try {
|
|
167
|
+
const address = await startGitHubAppInstallation();
|
|
168
|
+
leaving.current?.();
|
|
169
|
+
window.location.assign(address);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
setFailed(err instanceof Error ? err.message : 'Could not open GitHub.');
|
|
172
|
+
setStarting(false);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Open the installation's settings on GitHub IN ANOTHER TAB. Once the app
|
|
178
|
+
* is installed, the address that installs it leads there, and GitHub
|
|
179
|
+
* offers no way back from that page: in this tab the admin would be left
|
|
180
|
+
* on GitHub with the setup screen gone. The tab is opened at the press,
|
|
181
|
+
* before the address is known, because a tab opened after an answer has
|
|
182
|
+
* arrived is one browsers block.
|
|
183
|
+
*/
|
|
184
|
+
async function manage() {
|
|
185
|
+
setFailed(null);
|
|
186
|
+
const tab = window.open('', '_blank');
|
|
187
|
+
try {
|
|
188
|
+
const address = await startGitHubAppInstallation();
|
|
189
|
+
if (tab) {
|
|
190
|
+
// The page on GitHub gets no handle on this one.
|
|
191
|
+
tab.opener = null;
|
|
192
|
+
tab.location.href = address;
|
|
193
|
+
setManaged(true);
|
|
194
|
+
} else {
|
|
195
|
+
// No tab was allowed: this one goes, with what was typed kept.
|
|
196
|
+
leaving.current?.();
|
|
197
|
+
window.location.assign(address);
|
|
198
|
+
}
|
|
199
|
+
} catch (err) {
|
|
200
|
+
tab?.close();
|
|
201
|
+
setFailed(err instanceof Error ? err.message : 'Could not open GitHub.');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Sign in on GitHub and come straight back, so what may be connected is read again. */
|
|
206
|
+
async function refresh() {
|
|
207
|
+
setFailed(null);
|
|
208
|
+
setStarting(true);
|
|
209
|
+
try {
|
|
210
|
+
const address = await startGitHubAppRefresh();
|
|
211
|
+
leaving.current?.();
|
|
212
|
+
window.location.assign(address);
|
|
213
|
+
} catch (err) {
|
|
214
|
+
setFailed(err instanceof Error ? err.message : 'Could not open GitHub.');
|
|
215
|
+
setStarting(false);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const said = outcome ? (OUTCOMES[outcome] ?? OUTCOMES.refused!) : null;
|
|
220
|
+
// A repository that is stored but no longer reached is still shown, so it is not silently replaced.
|
|
221
|
+
const listed = repositories ?? [];
|
|
222
|
+
const options = repository && !listed.some((r) => r.fullName === repository) ? [repository, ...listed.map((r) => r.fullName)] : listed.map((r) => r.fullName);
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<div className="space-y-5" data-testid="github-repository">
|
|
226
|
+
{said && (
|
|
227
|
+
<Banner tone={said.tone} role="status">
|
|
228
|
+
{said.text}
|
|
229
|
+
</Banner>
|
|
230
|
+
)}
|
|
231
|
+
{failed && (
|
|
232
|
+
<Banner tone="danger" role="alert">
|
|
233
|
+
{failed}
|
|
234
|
+
</Banner>
|
|
235
|
+
)}
|
|
236
|
+
|
|
237
|
+
{status && !status.app && (
|
|
238
|
+
<div className="space-y-3">
|
|
239
|
+
<p className="max-w-[60ch] text-detail text-ink">
|
|
240
|
+
Connect a repository on GitHub without creating a token. This deployment gets a GitHub App of its own, which
|
|
241
|
+
you install on the repository.
|
|
242
|
+
</p>
|
|
243
|
+
<label className="block space-y-1">
|
|
244
|
+
<span className="text-detail font-medium text-ink">Organisation</span>
|
|
245
|
+
<TextField
|
|
246
|
+
value={organization}
|
|
247
|
+
onChange={(e) => setOrganization(e.target.value)}
|
|
248
|
+
// Enter here means "create the app", not "save the settings
|
|
249
|
+
// form" this field happens to sit inside.
|
|
250
|
+
onKeyDown={(e) => {
|
|
251
|
+
if (e.key !== 'Enter') return;
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
void register();
|
|
254
|
+
}}
|
|
255
|
+
placeholder="acme"
|
|
256
|
+
autoCapitalize="none"
|
|
257
|
+
autoCorrect="off"
|
|
258
|
+
spellCheck={false}
|
|
259
|
+
disabled={disabled || starting}
|
|
260
|
+
aria-describedby="github-organisation-help"
|
|
261
|
+
/>
|
|
262
|
+
<span id="github-organisation-help" className="block text-meta text-ink-muted">
|
|
263
|
+
The GitHub organisation that owns the repository, as it appears in its address. Leave blank if the
|
|
264
|
+
repository is under your own account.
|
|
265
|
+
</span>
|
|
266
|
+
</label>
|
|
267
|
+
<Button type="button" variant="primary" size="sm" onClick={() => void register()} disabled={disabled || starting}>
|
|
268
|
+
{starting ? 'Opening GitHub…' : 'Create the GitHub App'}
|
|
269
|
+
</Button>
|
|
270
|
+
<p className="max-w-[60ch] text-meta text-ink-muted">
|
|
271
|
+
GitHub asks you to confirm, then to choose which repositories the app may reach. It is given read and write
|
|
272
|
+
access to their contents, and nothing else.
|
|
273
|
+
</p>
|
|
274
|
+
</div>
|
|
275
|
+
)}
|
|
276
|
+
|
|
277
|
+
{status?.app && !installed && (
|
|
278
|
+
<div className="space-y-3">
|
|
279
|
+
<p className="max-w-[60ch] text-detail text-ink">
|
|
280
|
+
The GitHub App <span className="font-medium">{status.app.slug}</span> is ready. Install it on the account or
|
|
281
|
+
organisation that owns the repository, and choose which repositories it may reach.
|
|
282
|
+
</p>
|
|
283
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
284
|
+
<Button type="button" variant="primary" size="sm" onClick={() => void install()} disabled={disabled || starting}>
|
|
285
|
+
{starting ? 'Opening GitHub…' : 'Install the app on GitHub'}
|
|
286
|
+
</Button>
|
|
287
|
+
{/* Installed where this browser never came back from: by an
|
|
288
|
+
owner who approved it later, or in another browser. */}
|
|
289
|
+
<Button type="button" variant="outline" size="sm" onClick={() => void refresh()} disabled={disabled || starting}>
|
|
290
|
+
Already installed? Check again
|
|
291
|
+
</Button>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
)}
|
|
295
|
+
|
|
296
|
+
{status?.app && installed && (
|
|
297
|
+
<div className="space-y-3">
|
|
298
|
+
<p className="max-w-[60ch] text-detail text-ink-muted">
|
|
299
|
+
Connected to <span className="font-medium text-ink">{installed.account || 'GitHub'}</span> through the app{' '}
|
|
300
|
+
<span className="font-medium text-ink">{status.app.slug}</span>.
|
|
301
|
+
</p>
|
|
302
|
+
{/* The connection, ABOVE what is chosen through it: which
|
|
303
|
+
repositories the app reaches is decided first, on GitHub, and
|
|
304
|
+
the list under it is what came of that. */}
|
|
305
|
+
<div className="space-y-2" data-testid="github-connection">
|
|
306
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
307
|
+
<Button type="button" variant="outline" size="sm" onClick={() => void manage()} disabled={disabled || starting}>
|
|
308
|
+
Change repositories on GitHub
|
|
309
|
+
</Button>
|
|
310
|
+
<Button type="button" variant="outline" size="sm" onClick={() => void refresh()} disabled={disabled || starting}>
|
|
311
|
+
{starting ? 'Opening GitHub…' : 'Refresh the list'}
|
|
312
|
+
</Button>
|
|
313
|
+
</div>
|
|
314
|
+
{managed ? (
|
|
315
|
+
<Banner tone="wait" role="status" data-testid="github-managed">
|
|
316
|
+
GitHub is open in another tab. When you have saved your changes there, come back here and press
|
|
317
|
+
“Refresh the list”.
|
|
318
|
+
</Banner>
|
|
319
|
+
) : (
|
|
320
|
+
<p className="max-w-[60ch] text-meta text-ink-muted">
|
|
321
|
+
GitHub opens in another tab, where you choose which repositories the app reaches. Refresh the list
|
|
322
|
+
afterwards: it holds the ones your own GitHub account can write to, as they were when it was last
|
|
323
|
+
read.
|
|
324
|
+
</p>
|
|
325
|
+
)}
|
|
326
|
+
</div>
|
|
327
|
+
{listFailed && (
|
|
328
|
+
<Banner tone="danger" role="alert">
|
|
329
|
+
{listFailed}
|
|
330
|
+
</Banner>
|
|
331
|
+
)}
|
|
332
|
+
{/* Named by its label alone: wrapped in it, the picker would be
|
|
333
|
+
named by every repository it lists and the help under it. */}
|
|
334
|
+
<div className="space-y-1">
|
|
335
|
+
<label htmlFor="github-repository-picker" className="block text-detail font-medium text-ink">
|
|
336
|
+
Repository
|
|
337
|
+
</label>
|
|
338
|
+
<select
|
|
339
|
+
id="github-repository-picker"
|
|
340
|
+
value={repository}
|
|
341
|
+
onChange={(e) => onChoose(e.target.value)}
|
|
342
|
+
disabled={disabled || repositories === null}
|
|
343
|
+
aria-invalid={problem ? true : undefined}
|
|
344
|
+
aria-describedby={problem ? 'github-repository-problem' : 'github-repository-help'}
|
|
345
|
+
className="block w-full rounded-md border border-line-strong bg-surface px-2.5 py-2 text-ui text-ink"
|
|
346
|
+
>
|
|
347
|
+
<option value="">{repositories === null && !listFailed ? 'Loading…' : 'Choose a repository'}</option>
|
|
348
|
+
{options.map((name) => (
|
|
349
|
+
<option key={name} value={name}>
|
|
350
|
+
{name}
|
|
351
|
+
</option>
|
|
352
|
+
))}
|
|
353
|
+
</select>
|
|
354
|
+
{problem ? (
|
|
355
|
+
<span id="github-repository-problem" role="alert" className="block text-meta text-danger">
|
|
356
|
+
{problem}
|
|
357
|
+
</span>
|
|
358
|
+
) : (
|
|
359
|
+
<span id="github-repository-help" className="block text-meta text-ink-muted">
|
|
360
|
+
Where your knowledge, skills and tools are kept. An empty repository is fine: it is set up for you.
|
|
361
|
+
{more ? ' Only the first 500 repositories are listed.' : ''}
|
|
362
|
+
</span>
|
|
363
|
+
)}
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
)}
|
|
367
|
+
</div>
|
|
368
|
+
);
|
|
369
|
+
}
|