@startsimpli/integrations 0.2.133 → 0.2.135
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 +1 -1
- package/src/__tests__/corpus-planning.test.tsx +13 -3
- package/src/__tests__/corpus-tracker.test.tsx +53 -69
- package/src/__tests__/focus-standings.test.tsx +3 -1
- package/src/__tests__/home-brief.test.tsx +84 -0
- package/src/__tests__/project-surfaces.test.tsx +1 -1
- package/src/__tests__/work-groups.test.ts +181 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/ConnectionsPage.tsx +7 -1402
- package/src/components/pages/PlanningPage.tsx +129 -67
- package/src/components/pages/TrackerPage.tsx +174 -149
- package/src/components/pages/connections/CapabilityPicker.tsx +75 -0
- package/src/components/pages/connections/CatalogCard.tsx +300 -0
- package/src/components/pages/connections/ConnectionCard.tsx +489 -0
- package/src/components/pages/connections/ConnectionForms.tsx +215 -0
- package/src/components/pages/connections/MemberPolicyToggle.tsx +106 -0
- package/src/components/pages/connections/bound-api.ts +175 -0
- package/src/components/pages/connections/copy.ts +74 -0
- package/src/components/pages/home/BriefCard.tsx +84 -0
- package/src/components/pages/home/CompactItemRow.tsx +61 -0
- package/src/components/pages/home/DueAcrossProjects.tsx +74 -0
- package/src/components/pages/home/HomeBriefPage.tsx +112 -0
- package/src/components/pages/home/RecentNotes.tsx +69 -0
- package/src/components/pages/home/index.ts +10 -0
- package/src/components/pages/home/useProjectNames.ts +23 -0
- package/src/components/pages/work-items.tsx +15 -9
- package/src/corpus/due-groups.ts +81 -0
- package/src/corpus/focus-overview.ts +54 -0
- package/src/corpus/index.ts +10 -0
- package/src/corpus/note-actions.ts +44 -0
- package/src/corpus/tracker-groups.ts +84 -0
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A connected account: discover, wire, confirm, fire, and its runs. Split out of ConnectionsPage (bd startsim-ovq7f) with no behaviour change.
|
|
3
|
+
*/
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { isTaskTracker } from '../../../task-tracker/sync-config';
|
|
7
|
+
import { schemaFields } from '../../CredentialSchemaForm';
|
|
8
|
+
import { TaskTrackerSettings } from '../task-tracker/TaskTrackerSettings';
|
|
9
|
+
import type { Connection, ConnectionChoice, ConnectionRun, ConnectionTarget, ConnectorAction, ConnectorCatalogEntry } from '../types';
|
|
10
|
+
import { CapabilityPicker, orderCapabilities } from './CapabilityPicker';
|
|
11
|
+
import { ConnectionSettingsForm, ReplaceKeyForm } from './ConnectionForms';
|
|
12
|
+
import type { BoundApi } from './bound-api';
|
|
13
|
+
import { DEFAULTS, RUN_KIND_COPY } from './copy';
|
|
14
|
+
|
|
15
|
+
export function ConnectionCard({
|
|
16
|
+
api, personal, connection, entry, canManage, classNames: cn, onChanged,
|
|
17
|
+
}: {
|
|
18
|
+
api: BoundApi;
|
|
19
|
+
personal: boolean;
|
|
20
|
+
connection: Connection;
|
|
21
|
+
/** This connector's catalog row: its capabilities AND its field schema. */
|
|
22
|
+
entry?: ConnectorCatalogEntry;
|
|
23
|
+
canManage: boolean;
|
|
24
|
+
classNames: typeof DEFAULTS;
|
|
25
|
+
onChanged: () => void;
|
|
26
|
+
}) {
|
|
27
|
+
const [choices, setChoices] = React.useState<ConnectionChoice[] | null>(null);
|
|
28
|
+
const [target, setTarget] = React.useState<ConnectionTarget | null>(null);
|
|
29
|
+
const [actions, setActions] = React.useState<ConnectorAction[]>([]);
|
|
30
|
+
const [busy, setBusy] = React.useState('');
|
|
31
|
+
const [error, setError] = React.useState('');
|
|
32
|
+
const [notice, setNotice] = React.useState('');
|
|
33
|
+
/** Sentences the SERVER wrote about the last settings save. Never composed here. */
|
|
34
|
+
const [notices, setNotices] = React.useState<string[]>([]);
|
|
35
|
+
const [replacing, setReplacing] = React.useState(false);
|
|
36
|
+
const [settingsOpen, setSettingsOpen] = React.useState(false);
|
|
37
|
+
const [confirmingDisconnect, setConfirmingDisconnect] = React.useState(false);
|
|
38
|
+
const [activityOpen, setActivityOpen] = React.useState(false);
|
|
39
|
+
/** `null` is NOT LOADED YET, which reads differently from a connection that
|
|
40
|
+
has never run — the distinction the empty state below turns on. */
|
|
41
|
+
const [runs, setRuns] = React.useState<ConnectionRun[] | null>(null);
|
|
42
|
+
|
|
43
|
+
const declared = entry?.capabilities;
|
|
44
|
+
const enabled = React.useMemo(
|
|
45
|
+
() => connection.capabilities_enabled ?? [], [connection.capabilities_enabled]);
|
|
46
|
+
// The catalog's declaration first, then anything this connection holds that
|
|
47
|
+
// the catalog no longer offers. A capability an admin cannot SEE is one they
|
|
48
|
+
// cannot turn off, and a catalog row that will not load must not blank the
|
|
49
|
+
// card's own state.
|
|
50
|
+
const offered = React.useMemo(() => {
|
|
51
|
+
const seen = new Set<string>();
|
|
52
|
+
return [...(declared ?? []), ...enabled].filter((capability) => {
|
|
53
|
+
if (seen.has(capability)) return false;
|
|
54
|
+
seen.add(capability);
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
}, [declared, enabled]);
|
|
58
|
+
const [selected, setSelected] = React.useState<string[]>(enabled);
|
|
59
|
+
React.useEffect(() => { setSelected(enabled); }, [enabled]);
|
|
60
|
+
|
|
61
|
+
const pending = orderCapabilities(offered, selected);
|
|
62
|
+
const dirty = pending.join(',') !== orderCapabilities(offered, enabled).join(',');
|
|
63
|
+
|
|
64
|
+
async function guard(label: string, run: () => Promise<void>) {
|
|
65
|
+
setBusy(label);
|
|
66
|
+
setError('');
|
|
67
|
+
try {
|
|
68
|
+
await run();
|
|
69
|
+
} catch (err) {
|
|
70
|
+
setError((err as { message?: string })?.message || 'That did not work.');
|
|
71
|
+
} finally {
|
|
72
|
+
setBusy('');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const configFields = schemaFields(entry?.config_schema);
|
|
77
|
+
// A TASK TRACKER (the catalog says `kind: task_tracker`; no vendor is named here)
|
|
78
|
+
// also gets its sync settings: team, project, personal destination, state mapping.
|
|
79
|
+
const trackerApi = isTaskTracker(entry) && api.connectionChoices && api.updateConnectionConfig
|
|
80
|
+
? { connectionChoices: api.connectionChoices, updateConnectionConfig: api.updateConnectionConfig,
|
|
81
|
+
...(api.syncConnectionNow ? { syncConnectionNow: api.syncConnectionNow } : {}) }
|
|
82
|
+
: null;
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className={cn.card} data-connection={connection.id}>
|
|
86
|
+
<div className="flex items-start justify-between gap-4">
|
|
87
|
+
<div>
|
|
88
|
+
<p className="font-medium text-gray-900">{connection.name}</p>
|
|
89
|
+
<p className={cn.muted}>
|
|
90
|
+
{connection.connector_name}
|
|
91
|
+
{connection.account_label ? ` · ${connection.account_label}` : ''}
|
|
92
|
+
</p>
|
|
93
|
+
<p className="mt-1 text-xs text-gray-400">{connection.status}</p>
|
|
94
|
+
{connection.check_error ? (
|
|
95
|
+
<p className={cn.error}>{connection.check_error}</p>
|
|
96
|
+
) : null}
|
|
97
|
+
</div>
|
|
98
|
+
<div className="flex flex-wrap justify-end gap-2">
|
|
99
|
+
{/* ACTIVITY IS OUTSIDE THE MANAGE GATE, and deliberately. Reading the
|
|
100
|
+
run ledger needs `view_connections` server-side, which is what put
|
|
101
|
+
this card on the screen at all — and the person who most needs to
|
|
102
|
+
know WHY a connection is failing is often the one who cannot fix
|
|
103
|
+
it themselves. Gating the answer behind the permission to act
|
|
104
|
+
would leave them with the word "Failing" and nothing else, which
|
|
105
|
+
is the sixteen days this bead is about. */}
|
|
106
|
+
{api.connectionRuns ? (
|
|
107
|
+
<button
|
|
108
|
+
type="button"
|
|
109
|
+
className={cn.button}
|
|
110
|
+
disabled={Boolean(busy)}
|
|
111
|
+
onClick={() => {
|
|
112
|
+
const opening = !activityOpen;
|
|
113
|
+
setActivityOpen(opening);
|
|
114
|
+
if (!opening) return;
|
|
115
|
+
void guard('activity', async () => {
|
|
116
|
+
const page = await api.connectionRuns!(connection.id);
|
|
117
|
+
setRuns(page.results ?? []);
|
|
118
|
+
});
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
{activityOpen ? 'Hide activity' : 'Activity'}
|
|
122
|
+
</button>
|
|
123
|
+
) : null}
|
|
124
|
+
{canManage ? (
|
|
125
|
+
<>
|
|
126
|
+
<button
|
|
127
|
+
type="button"
|
|
128
|
+
className={cn.button}
|
|
129
|
+
disabled={Boolean(busy)}
|
|
130
|
+
onClick={() => void guard('check', async () => {
|
|
131
|
+
const res = await api.checkConnection(connection.id);
|
|
132
|
+
setNotice(res.detail || (res.ok ? 'Connection is healthy.' : ''));
|
|
133
|
+
onChanged();
|
|
134
|
+
})}
|
|
135
|
+
>
|
|
136
|
+
Test
|
|
137
|
+
</button>
|
|
138
|
+
{/* THE CONTROL THIS PAGE WAS MISSING. A vendor key gets rotated —
|
|
139
|
+
that is normal operations, not an exception — and the only place
|
|
140
|
+
to put the new one was a form that creates a second account. */}
|
|
141
|
+
<button
|
|
142
|
+
type="button"
|
|
143
|
+
className={cn.button}
|
|
144
|
+
disabled={Boolean(busy)}
|
|
145
|
+
onClick={() => {
|
|
146
|
+
setConfirmingDisconnect(false);
|
|
147
|
+
setError('');
|
|
148
|
+
setReplacing((v) => !v);
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{replacing ? 'Cancel' : 'Replace key'}
|
|
152
|
+
</button>
|
|
153
|
+
{/* DISCOVER -> WIRE -> FIRE is foundry-level and stays there. The
|
|
154
|
+
member router serves no choices, targets or actions at all, so
|
|
155
|
+
the control is gated on the verb EXISTING rather than on a mode
|
|
156
|
+
flag — there is no way to render a button here whose handler is
|
|
157
|
+
undefined. */}
|
|
158
|
+
{api.connectionChoices && api.connectionActions ? (
|
|
159
|
+
<button
|
|
160
|
+
type="button"
|
|
161
|
+
className={cn.button}
|
|
162
|
+
disabled={Boolean(busy)}
|
|
163
|
+
onClick={() => void guard('discover', async () => {
|
|
164
|
+
const page = await api.connectionChoices!(connection.id);
|
|
165
|
+
setChoices(page.results ?? []);
|
|
166
|
+
const available = await api.connectionActions!(connection.id);
|
|
167
|
+
setActions(available.results ?? []);
|
|
168
|
+
})}
|
|
169
|
+
>
|
|
170
|
+
{busy === 'discover' ? 'Loading…' : 'Workflows'}
|
|
171
|
+
</button>
|
|
172
|
+
) : null}
|
|
173
|
+
{/* SETTINGS, which this card has never had. A connector's
|
|
174
|
+
`config_schema` ships on every catalog row and was rendered
|
|
175
|
+
exactly once — on the connect form, before the account existed.
|
|
176
|
+
After that a setting could not be changed from the product at
|
|
177
|
+
all, which for Granola means the switch deciding whether verbatim
|
|
178
|
+
recordings of people's conversations are stored was reachable
|
|
179
|
+
only by editing the database. `ReplaceKeyForm` already pointed at
|
|
180
|
+
"the connection's own settings" as if this existed.
|
|
181
|
+
|
|
182
|
+
GATED ON THE SETTINGS VERB, not on the general one (bd
|
|
183
|
+
startsim-sfms2). The member surface has `updateConnectionConfig`
|
|
184
|
+
and deliberately not `updateConnection`, because a personal
|
|
185
|
+
connection's config is the MEMBER's privacy boundary while its
|
|
186
|
+
name and what it may do stay the foundry's. One gate for both
|
|
187
|
+
would have made opening this control open the capability Save
|
|
188
|
+
beside it, which is a decision this change did not make. */}
|
|
189
|
+
{(configFields.length || trackerApi) && api.updateConnectionConfig ? (
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
className={cn.button}
|
|
193
|
+
disabled={Boolean(busy) || confirmingDisconnect}
|
|
194
|
+
onClick={() => {
|
|
195
|
+
setReplacing(false);
|
|
196
|
+
setError('');
|
|
197
|
+
setSettingsOpen((v) => !v);
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
{settingsOpen ? 'Close settings' : 'Settings'}
|
|
201
|
+
</button>
|
|
202
|
+
) : null}
|
|
203
|
+
<button
|
|
204
|
+
type="button"
|
|
205
|
+
className={cn.button}
|
|
206
|
+
disabled={Boolean(busy) || confirmingDisconnect}
|
|
207
|
+
onClick={() => {
|
|
208
|
+
setReplacing(false);
|
|
209
|
+
setSettingsOpen(false);
|
|
210
|
+
setError('');
|
|
211
|
+
setConfirmingDisconnect(true);
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
Disconnect
|
|
215
|
+
</button>
|
|
216
|
+
</>
|
|
217
|
+
) : null}
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
{activityOpen ? (
|
|
222
|
+
<div className="mt-3 space-y-2 border-t pt-3" role="group"
|
|
223
|
+
aria-label="Recent activity">
|
|
224
|
+
{/* THE FIELD NOTHING HAS EVER READ. `ConnectionRun.error_message` has
|
|
225
|
+
been declared in this package's types since the endpoint existed;
|
|
226
|
+
until #375 the server answered `""` for every source run ever
|
|
227
|
+
recorded, and even after it did not, no component asked. A failed
|
|
228
|
+
run rendered as a status word, which is a fact the reader already
|
|
229
|
+
had from the card above it.
|
|
230
|
+
|
|
231
|
+
RENDERED AS THE SERVER WROTE IT. The text is scrubbed against this
|
|
232
|
+
connection's stored credential and the platform app_secret before
|
|
233
|
+
it leaves Django (`surface.py::_reason_reader`), and a reason that
|
|
234
|
+
could not be scrubbed arrives as a sentence saying so. There is
|
|
235
|
+
one redaction path in this estate and it is not in the browser —
|
|
236
|
+
which does not hold the secrets to run it. */}
|
|
237
|
+
{busy === 'activity' && runs === null ? (
|
|
238
|
+
<p className={cn.muted}>Loading recent activity…</p>
|
|
239
|
+
) : null}
|
|
240
|
+
{runs !== null && runs.length === 0 ? (
|
|
241
|
+
<p className={cn.muted}>No runs yet for this connection.</p>
|
|
242
|
+
) : null}
|
|
243
|
+
{(runs ?? []).map((run) => (
|
|
244
|
+
<div key={run.id} data-run={run.id}>
|
|
245
|
+
<p className={cn.muted}>
|
|
246
|
+
<span className="font-medium text-gray-900">
|
|
247
|
+
{RUN_KIND_COPY[run.kind] ?? run.kind}
|
|
248
|
+
</span>
|
|
249
|
+
{run.name ? ` · ${run.name}` : ''}
|
|
250
|
+
{` · ${run.status}`}
|
|
251
|
+
{run.occurred_at ? ` · ${new Date(run.occurred_at).toLocaleString()}` : ''}
|
|
252
|
+
</p>
|
|
253
|
+
{run.error_message ? (
|
|
254
|
+
<p className={cn.error}>{run.error_message}</p>
|
|
255
|
+
) : null}
|
|
256
|
+
</div>
|
|
257
|
+
))}
|
|
258
|
+
</div>
|
|
259
|
+
) : null}
|
|
260
|
+
|
|
261
|
+
{settingsOpen && trackerApi ? (
|
|
262
|
+
<TaskTrackerSettings
|
|
263
|
+
api={trackerApi}
|
|
264
|
+
connection={connection}
|
|
265
|
+
classNames={cn}
|
|
266
|
+
onSaved={() => { setNotice('Sync settings saved.'); onChanged(); }}
|
|
267
|
+
/>
|
|
268
|
+
) : null}
|
|
269
|
+
|
|
270
|
+
{settingsOpen && configFields.length ? (
|
|
271
|
+
<ConnectionSettingsForm
|
|
272
|
+
api={api}
|
|
273
|
+
connection={connection}
|
|
274
|
+
fields={configFields}
|
|
275
|
+
classNames={cn}
|
|
276
|
+
onDone={(said) => {
|
|
277
|
+
setSettingsOpen(false);
|
|
278
|
+
setNotice('Settings saved.');
|
|
279
|
+
setNotices(said);
|
|
280
|
+
onChanged();
|
|
281
|
+
}}
|
|
282
|
+
/>
|
|
283
|
+
) : null}
|
|
284
|
+
|
|
285
|
+
{replacing ? (
|
|
286
|
+
<ReplaceKeyForm
|
|
287
|
+
api={api}
|
|
288
|
+
connection={connection}
|
|
289
|
+
entry={entry}
|
|
290
|
+
classNames={cn}
|
|
291
|
+
onDone={() => { setReplacing(false); setNotice('New key installed.'); onChanged(); }}
|
|
292
|
+
/>
|
|
293
|
+
) : null}
|
|
294
|
+
|
|
295
|
+
{confirmingDisconnect ? (
|
|
296
|
+
<div className="mt-3 space-y-2 border-t pt-3" role="group"
|
|
297
|
+
aria-label="Confirm disconnect">
|
|
298
|
+
{/* Disconnect is one sentence to an admin and four writes to the
|
|
299
|
+
server, three of which cannot be undone by reconnecting: the
|
|
300
|
+
tokens this vendor holds against us are revoked and the stored
|
|
301
|
+
credential is deleted. Naming them is the difference between a
|
|
302
|
+
control someone uses deliberately and one they regret. */}
|
|
303
|
+
<p className={cn.muted}>
|
|
304
|
+
Disconnecting <strong className="text-gray-900">{connection.name}</strong>{' '}
|
|
305
|
+
will stop its scheduled fetches, stop anything it sends out, revoke
|
|
306
|
+
every token issued for it and delete the stored key. The card stays
|
|
307
|
+
here, marked disabled, and you can connect it again later with a new
|
|
308
|
+
key.
|
|
309
|
+
</p>
|
|
310
|
+
{trackerApi ? (
|
|
311
|
+
<p className={cn.muted}>
|
|
312
|
+
{`Your to-dos stay in Tandem. Nothing is deleted in ${connection.connector_name}; they simply stop syncing.`}
|
|
313
|
+
</p>
|
|
314
|
+
) : null}
|
|
315
|
+
<div className="flex gap-2">
|
|
316
|
+
<button
|
|
317
|
+
type="button"
|
|
318
|
+
className={cn.button}
|
|
319
|
+
disabled={Boolean(busy)}
|
|
320
|
+
onClick={() => void guard('disconnect', async () => {
|
|
321
|
+
await api.disconnect(connection.id);
|
|
322
|
+
setConfirmingDisconnect(false);
|
|
323
|
+
setNotice('Disconnected.');
|
|
324
|
+
onChanged();
|
|
325
|
+
})}
|
|
326
|
+
>
|
|
327
|
+
{busy === 'disconnect' ? 'Disconnecting…' : 'Yes, disconnect'}
|
|
328
|
+
</button>
|
|
329
|
+
<button
|
|
330
|
+
type="button"
|
|
331
|
+
className={cn.button}
|
|
332
|
+
disabled={Boolean(busy)}
|
|
333
|
+
onClick={() => setConfirmingDisconnect(false)}
|
|
334
|
+
>
|
|
335
|
+
Cancel
|
|
336
|
+
</button>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
) : null}
|
|
340
|
+
|
|
341
|
+
{/* THE FIX FOR THE CARDS THAT ALREADY EXIST. A connection written before
|
|
342
|
+
the connect form asked holds an empty list and can do nothing; the
|
|
343
|
+
connect form can never reach it. Turning `poll` on here is what makes
|
|
344
|
+
the server create the scheduled ingest leg. */}
|
|
345
|
+
<CapabilityPicker
|
|
346
|
+
scope="connection"
|
|
347
|
+
declared={offered}
|
|
348
|
+
selected={selected}
|
|
349
|
+
// On the member surface there is no PATCH, so the picker is
|
|
350
|
+
// INFORMATIONAL rather than absent. A member chose these at connect time
|
|
351
|
+
// and `POST` accepted them; hiding the list afterwards would make that
|
|
352
|
+
// choice look like it never happened, and leave them unable to see what
|
|
353
|
+
// their own account is doing.
|
|
354
|
+
disabled={!canManage || !api.updateConnection || Boolean(busy)}
|
|
355
|
+
idPrefix={`connection-${connection.id}`}
|
|
356
|
+
onToggle={(capability, on) => setSelected((prev) => (
|
|
357
|
+
on ? [...prev, capability] : prev.filter((c) => c !== capability)
|
|
358
|
+
))}
|
|
359
|
+
classNames={cn}
|
|
360
|
+
>
|
|
361
|
+
{canManage && api.updateConnection ? (
|
|
362
|
+
<div className="mt-2 flex items-center gap-3">
|
|
363
|
+
<button
|
|
364
|
+
type="button"
|
|
365
|
+
className={cn.button}
|
|
366
|
+
disabled={!dirty || pending.length === 0 || Boolean(busy)}
|
|
367
|
+
onClick={() => void guard('capabilities', async () => {
|
|
368
|
+
await api.updateConnection!(connection.id, {
|
|
369
|
+
capabilities_enabled: pending,
|
|
370
|
+
});
|
|
371
|
+
setNotice('Saved.');
|
|
372
|
+
onChanged();
|
|
373
|
+
})}
|
|
374
|
+
>
|
|
375
|
+
{busy === 'capabilities' ? 'Saving…' : 'Save'}
|
|
376
|
+
</button>
|
|
377
|
+
{pending.length === 0 ? (
|
|
378
|
+
<span className={cn.error}>
|
|
379
|
+
Enable at least one, or disconnect the account.
|
|
380
|
+
</span>
|
|
381
|
+
) : null}
|
|
382
|
+
</div>
|
|
383
|
+
) : personal ? (
|
|
384
|
+
<p className={cn.muted}>
|
|
385
|
+
Chosen when you connected. Ask an admin to change what this account
|
|
386
|
+
may do, or disconnect it and connect again.
|
|
387
|
+
</p>
|
|
388
|
+
) : null}
|
|
389
|
+
</CapabilityPicker>
|
|
390
|
+
|
|
391
|
+
{notice ? <p className={cn.muted}>{notice}</p> : null}
|
|
392
|
+
{/* WHAT THE CHANGE COSTS, in the server's words. Rendered verbatim: this
|
|
393
|
+
file names no vendor and cannot know which settings restart a walk. */}
|
|
394
|
+
{notices.map((said) => (
|
|
395
|
+
<p key={said} className={cn.muted}>{said}</p>
|
|
396
|
+
))}
|
|
397
|
+
{error ? <p className={cn.error} role="alert">{error}</p> : null}
|
|
398
|
+
|
|
399
|
+
{choices ? (
|
|
400
|
+
<div className="mt-4 space-y-2">
|
|
401
|
+
<p className="text-sm font-medium text-gray-900">What this account can reach</p>
|
|
402
|
+
{choices.length === 0 ? <p className={cn.muted}>Nothing to wire yet.</p> : null}
|
|
403
|
+
{choices.map((choice) => (
|
|
404
|
+
<div key={choice.id} className="flex items-start justify-between gap-3 border-t pt-2">
|
|
405
|
+
<div>
|
|
406
|
+
<p className={choice.selectable ? 'text-sm text-gray-900' : 'text-sm text-gray-400'}>
|
|
407
|
+
{choice.label}
|
|
408
|
+
</p>
|
|
409
|
+
{/* An unpickable row is GREYED and says why — never dropped. A
|
|
410
|
+
picker that hides them looks broken with no way to tell. */}
|
|
411
|
+
{!choice.selectable ? (
|
|
412
|
+
<p className="text-xs text-gray-500">
|
|
413
|
+
{choice.reason}
|
|
414
|
+
{choice.remediation ? ` — ${choice.remediation}` : ''}
|
|
415
|
+
</p>
|
|
416
|
+
) : null}
|
|
417
|
+
</div>
|
|
418
|
+
{choice.selectable ? (
|
|
419
|
+
<button
|
|
420
|
+
type="button"
|
|
421
|
+
className={cn.button}
|
|
422
|
+
disabled={Boolean(busy)}
|
|
423
|
+
onClick={() => void guard('wire', async () => {
|
|
424
|
+
setTarget(await api.wireTarget!(connection.id, {
|
|
425
|
+
choice_id: choice.id,
|
|
426
|
+
}));
|
|
427
|
+
})}
|
|
428
|
+
>
|
|
429
|
+
Wire
|
|
430
|
+
</button>
|
|
431
|
+
) : null}
|
|
432
|
+
</div>
|
|
433
|
+
))}
|
|
434
|
+
</div>
|
|
435
|
+
) : null}
|
|
436
|
+
|
|
437
|
+
{target ? (
|
|
438
|
+
<div className="mt-4 space-y-2 border-t pt-3">
|
|
439
|
+
<p className="text-sm font-medium text-gray-900">{target.name}</p>
|
|
440
|
+
{/* The admin CONFIRMS what discovery proposed. Showing the derived
|
|
441
|
+
config is not a detail — nobody can confirm a URL they were never
|
|
442
|
+
shown, and a confidently wrong one only fails at 3am. */}
|
|
443
|
+
<pre className="overflow-x-auto rounded bg-gray-50 p-2 text-xs text-gray-700">
|
|
444
|
+
{JSON.stringify(target.destination_config, null, 2)}
|
|
445
|
+
</pre>
|
|
446
|
+
{!target.verified ? (
|
|
447
|
+
<button
|
|
448
|
+
type="button"
|
|
449
|
+
className={cn.button}
|
|
450
|
+
disabled={Boolean(busy)}
|
|
451
|
+
onClick={() => void guard('confirm', async () => {
|
|
452
|
+
setTarget(await api.confirmTarget!(connection.id, target.id));
|
|
453
|
+
})}
|
|
454
|
+
>
|
|
455
|
+
Confirm this target
|
|
456
|
+
</button>
|
|
457
|
+
) : (
|
|
458
|
+
<div className="flex flex-wrap gap-2">
|
|
459
|
+
<p className={cn.muted}>Confirmed.</p>
|
|
460
|
+
{actions.map((available) => (
|
|
461
|
+
<button
|
|
462
|
+
key={available.name}
|
|
463
|
+
type="button"
|
|
464
|
+
className={cn.button}
|
|
465
|
+
disabled={Boolean(busy)}
|
|
466
|
+
onClick={() => void guard('invoke', async () => {
|
|
467
|
+
const result = await api.invokeConnectionAction!(
|
|
468
|
+
connection.id, available.name,
|
|
469
|
+
{ destination_id: target.id, records: [] },
|
|
470
|
+
);
|
|
471
|
+
// `accepted` is not `completed`. Saying "done" here would
|
|
472
|
+
// render a success the vendor never reported.
|
|
473
|
+
setNotice(
|
|
474
|
+
result.run_status === 'completed'
|
|
475
|
+
? 'Finished.'
|
|
476
|
+
: `Accepted — run is ${result.run_status}.`,
|
|
477
|
+
);
|
|
478
|
+
})}
|
|
479
|
+
>
|
|
480
|
+
{available.label}
|
|
481
|
+
</button>
|
|
482
|
+
))}
|
|
483
|
+
</div>
|
|
484
|
+
)}
|
|
485
|
+
</div>
|
|
486
|
+
) : null}
|
|
487
|
+
</div>
|
|
488
|
+
);
|
|
489
|
+
}
|