@uipath/apollo-wind 2.95.2 → 2.96.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/dist/components/forms/aria-ids.cjs +24 -2
- package/dist/components/forms/aria-ids.d.ts +15 -0
- package/dist/components/forms/aria-ids.js +14 -1
- package/dist/components/forms/field-control.cjs +18 -16
- package/dist/components/forms/field-control.d.ts +6 -5
- package/dist/components/forms/field-control.js +19 -17
- package/dist/components/forms/field-renderer.cjs +14 -10
- package/dist/components/forms/field-renderer.js +15 -11
- package/dist/components/forms/form-schema.d.ts +6 -1
- package/dist/components/forms/metadata-form.cjs +8 -3
- package/dist/components/forms/metadata-form.js +9 -4
- package/dist/components/forms/mode-aware-field.cjs +11 -9
- package/dist/components/forms/mode-aware-field.js +12 -10
- package/dist/components/forms/string-list-field.cjs +10 -6
- package/dist/components/forms/string-list-field.d.ts +1 -1
- package/dist/components/forms/string-list-field.js +10 -6
- package/dist/components/ui/byo-model-dialog/byo-model-dialog.cjs +340 -212
- package/dist/components/ui/byo-model-dialog/byo-model-dialog.js +342 -214
- package/dist/components/ui/byo-model-dialog/index.d.ts +1 -1
- package/dist/components/ui/byo-model-dialog/labels.cjs +22 -10
- package/dist/components/ui/byo-model-dialog/labels.d.ts +19 -5
- package/dist/components/ui/byo-model-dialog/labels.js +22 -10
- package/dist/components/ui/byo-model-dialog/model-alias-picker.cjs +293 -0
- package/dist/components/ui/byo-model-dialog/model-alias-picker.d.ts +24 -0
- package/dist/components/ui/byo-model-dialog/model-alias-picker.js +259 -0
- package/dist/components/ui/byo-model-dialog/types.d.ts +19 -0
- package/dist/components/ui/index.cjs +22 -22
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AlertCircle, Building2, Check, ChevronDown, ChevronRight, CircleCheck, KeyRound } from "lucide-react";
|
|
3
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { AlertCircle, Building2, Check, ChevronDown, ChevronRight, CircleCheck, KeyRound, TriangleAlert, X } from "lucide-react";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { Alert, AlertDescription, AlertTitle } from "../alert.js";
|
|
5
5
|
import { Button } from "../button.js";
|
|
6
|
+
import { Checkbox } from "../checkbox.js";
|
|
6
7
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../collapsible.js";
|
|
7
8
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "../command.js";
|
|
8
9
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "../dialog.js";
|
|
9
10
|
import { Input } from "../input.js";
|
|
10
11
|
import { Label } from "../label.js";
|
|
11
12
|
import { Popover, PopoverContent, PopoverTrigger } from "../popover.js";
|
|
12
|
-
import { RadioGroup, RadioGroupItem } from "../radio-group.js";
|
|
13
13
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../select.js";
|
|
14
14
|
import { Spinner } from "../spinner.js";
|
|
15
15
|
import { cn } from "../../../lib/index.js";
|
|
16
16
|
import { resolveByoModelDialogLabels } from "./labels.js";
|
|
17
|
+
import { ModelAliasPicker } from "./model-alias-picker.js";
|
|
17
18
|
function ByoModelDialog({ open, onOpenChange, ...rest }) {
|
|
18
19
|
return /*#__PURE__*/ jsx(Dialog, {
|
|
19
20
|
open: open,
|
|
@@ -41,7 +42,7 @@ const NO_MODELS = {
|
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
function defaultConnectionName(providerName, connections) {
|
|
44
|
-
const base =
|
|
45
|
+
const base = providerName;
|
|
45
46
|
const taken = new Set(connections.map((c)=>c.name.toLowerCase()));
|
|
46
47
|
if (!taken.has(base.toLowerCase())) return base;
|
|
47
48
|
let n = 2;
|
|
@@ -59,6 +60,8 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
59
60
|
const [editTarget] = useState(editing);
|
|
60
61
|
const generation = useRef(0);
|
|
61
62
|
const formLoad = useRef(0);
|
|
63
|
+
const stoppedEdits = useRef(new WeakSet());
|
|
64
|
+
const formFolder = useRef('');
|
|
62
65
|
useEffect(()=>()=>{
|
|
63
66
|
generation.current += 1;
|
|
64
67
|
formLoad.current += 1;
|
|
@@ -83,12 +86,14 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
83
86
|
status: 'idle'
|
|
84
87
|
});
|
|
85
88
|
const [modelsState, setModelsState] = useState(NO_MODELS);
|
|
89
|
+
const [changeAgreed, setChangeAgreed] = useState(false);
|
|
90
|
+
const [applyingChange, setApplyingChange] = useState(false);
|
|
86
91
|
const [modelId, setModelId] = useState('');
|
|
87
92
|
const [modelQuery, setModelQuery] = useState('');
|
|
88
93
|
const [modelListOpen, setModelListOpen] = useState(false);
|
|
89
94
|
const [name, setName] = useState('');
|
|
90
|
-
const [
|
|
91
|
-
const [
|
|
95
|
+
const [useAs, setUseAs] = useState('replacement');
|
|
96
|
+
const [dismissedFailures, setDismissedFailures] = useState([]);
|
|
92
97
|
const [replaces, setReplaces] = useState('');
|
|
93
98
|
const [apiType, setApiType] = useState('');
|
|
94
99
|
const [test, setTest] = useState({
|
|
@@ -108,11 +113,35 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
108
113
|
const connected = Boolean(connection) && !editingConnection;
|
|
109
114
|
const loadModels = async (pid, conn, gen)=>{
|
|
110
115
|
if (!conn) return void setModelsState(NO_MODELS);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
status: 'loading'
|
|
114
|
-
});
|
|
116
|
+
setChangeAgreed(false);
|
|
117
|
+
let cleared = !api.checkConnection;
|
|
115
118
|
try {
|
|
119
|
+
if (api.checkConnection) {
|
|
120
|
+
setModelsState({
|
|
121
|
+
...NO_MODELS,
|
|
122
|
+
status: 'checking'
|
|
123
|
+
});
|
|
124
|
+
const checked = await api.checkConnection(pid, conn);
|
|
125
|
+
if (gen !== generation.current) return;
|
|
126
|
+
if (!checked.ok) return void setModelsState({
|
|
127
|
+
...NO_MODELS,
|
|
128
|
+
status: 'error',
|
|
129
|
+
failure: {
|
|
130
|
+
...checked.failure
|
|
131
|
+
},
|
|
132
|
+
unchecked: true
|
|
133
|
+
});
|
|
134
|
+
if (checked.value) return void setModelsState({
|
|
135
|
+
...NO_MODELS,
|
|
136
|
+
status: 'change',
|
|
137
|
+
change: checked.value
|
|
138
|
+
});
|
|
139
|
+
cleared = true;
|
|
140
|
+
}
|
|
141
|
+
setModelsState({
|
|
142
|
+
...NO_MODELS,
|
|
143
|
+
status: 'loading'
|
|
144
|
+
});
|
|
116
145
|
const result = await api.listModels(pid, conn);
|
|
117
146
|
if (gen !== generation.current) return;
|
|
118
147
|
result.ok ? setModelsState({
|
|
@@ -121,17 +150,23 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
121
150
|
}) : setModelsState({
|
|
122
151
|
...NO_MODELS,
|
|
123
152
|
status: 'error',
|
|
124
|
-
failure:
|
|
153
|
+
failure: {
|
|
154
|
+
...result.failure
|
|
155
|
+
}
|
|
125
156
|
});
|
|
126
157
|
} catch (err) {
|
|
127
158
|
if (gen === generation.current) setModelsState({
|
|
128
159
|
...NO_MODELS,
|
|
129
160
|
status: 'error',
|
|
130
|
-
failure: unexpected(err)
|
|
161
|
+
failure: unexpected(err),
|
|
162
|
+
...cleared ? {} : {
|
|
163
|
+
unchecked: true
|
|
164
|
+
}
|
|
131
165
|
});
|
|
132
166
|
}
|
|
133
167
|
};
|
|
134
168
|
const loadForm = async (pid, folder)=>{
|
|
169
|
+
formFolder.current = folder;
|
|
135
170
|
formLoad.current += 1;
|
|
136
171
|
const load = formLoad.current;
|
|
137
172
|
setFormState({
|
|
@@ -167,23 +202,27 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
167
202
|
};
|
|
168
203
|
const startFromSavedModel = (model, loaded, defaultFolder)=>{
|
|
169
204
|
const gen = generation.current;
|
|
170
|
-
const
|
|
205
|
+
const ownConnection = loaded.connections.find((c)=>c.id === model.connectionId) ?? null;
|
|
206
|
+
const savedConnection = ownConnection ?? loaded.connections.find((c)=>c.providerId === model.providerId) ?? null;
|
|
171
207
|
const savedProvider = loaded.providers.find((p)=>p.id === model.providerId);
|
|
172
208
|
setModelToEdit(model);
|
|
173
209
|
setProviderId(model.providerId);
|
|
174
210
|
setConnectionChoice(savedConnection ? savedConnection.id : NEW);
|
|
175
211
|
setConnName(defaultConnectionName(savedProvider?.name ?? model.providerId, loaded.connections));
|
|
176
|
-
setModelId(model.modelId);
|
|
212
|
+
setModelId(ownConnection ? model.modelId : '');
|
|
177
213
|
setName(model.replaces ? '' : model.name);
|
|
178
|
-
setNameTouched(true);
|
|
179
214
|
setUseAs(model.replaces ? 'replacement' : 'own');
|
|
180
215
|
setReplaces(model.replaces ?? '');
|
|
181
216
|
setApiType(model.apiType ?? '');
|
|
182
217
|
loadModels(model.providerId, savedConnection, gen);
|
|
183
218
|
loadForm(model.providerId, savedConnection?.folderId ?? defaultFolder);
|
|
184
219
|
};
|
|
220
|
+
const [contextAttempt, setContextAttempt] = useState(0);
|
|
185
221
|
useEffect(()=>{
|
|
186
222
|
const gen = generation.current;
|
|
223
|
+
setContext({
|
|
224
|
+
status: 'running'
|
|
225
|
+
});
|
|
187
226
|
const load = async ()=>{
|
|
188
227
|
const contextResult = await api.loadContext();
|
|
189
228
|
if (gen !== generation.current) return;
|
|
@@ -209,7 +248,6 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
209
248
|
});
|
|
210
249
|
setConnections(loaded.connections);
|
|
211
250
|
setFolderId(defaultFolder);
|
|
212
|
-
if (!loaded.allowsNewNames) setUseAs('replacement');
|
|
213
251
|
if (savedModel) startFromSavedModel(savedModel, loaded, defaultFolder);
|
|
214
252
|
};
|
|
215
253
|
load().catch((err)=>{
|
|
@@ -220,14 +258,13 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
220
258
|
});
|
|
221
259
|
}, [
|
|
222
260
|
api,
|
|
223
|
-
editTarget
|
|
261
|
+
editTarget,
|
|
262
|
+
contextAttempt
|
|
224
263
|
]);
|
|
225
264
|
const resetDownstream = ()=>{
|
|
226
265
|
setModelQuery('');
|
|
227
266
|
setModelListOpen(false);
|
|
228
267
|
setModelId('');
|
|
229
|
-
setName('');
|
|
230
|
-
setNameTouched(false);
|
|
231
268
|
setTest({
|
|
232
269
|
status: 'idle'
|
|
233
270
|
});
|
|
@@ -247,12 +284,25 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
247
284
|
status: 'idle'
|
|
248
285
|
});
|
|
249
286
|
resetDownstream();
|
|
250
|
-
setUseAs(ctx?.allowsNewNames === false ? 'replacement' : 'own');
|
|
251
|
-
setReplaces('');
|
|
252
287
|
setApiType('');
|
|
253
288
|
loadModels(id, existing[0] ?? null, gen);
|
|
254
289
|
loadForm(id, folderId);
|
|
255
290
|
};
|
|
291
|
+
const clearProvider = ()=>{
|
|
292
|
+
generation.current += 1;
|
|
293
|
+
formLoad.current += 1;
|
|
294
|
+
setProviderId('');
|
|
295
|
+
setConnectionChoice(NEW);
|
|
296
|
+
setMoreOpen(false);
|
|
297
|
+
setEditingConnection(false);
|
|
298
|
+
setConnect({
|
|
299
|
+
status: 'idle'
|
|
300
|
+
});
|
|
301
|
+
resetDownstream();
|
|
302
|
+
setApiType('');
|
|
303
|
+
setModelsState(NO_MODELS);
|
|
304
|
+
setFormState(NO_FORM);
|
|
305
|
+
};
|
|
256
306
|
const chooseConnection = (id)=>{
|
|
257
307
|
generation.current += 1;
|
|
258
308
|
setConnectionChoice(id);
|
|
@@ -268,9 +318,13 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
268
318
|
const failConnectionEdit = (failure)=>{
|
|
269
319
|
setEditingConnection(false);
|
|
270
320
|
resetFormValues();
|
|
321
|
+
const stopped = {
|
|
322
|
+
...failure
|
|
323
|
+
};
|
|
324
|
+
stoppedEdits.current.add(stopped);
|
|
271
325
|
setConnect({
|
|
272
326
|
status: 'error',
|
|
273
|
-
failure
|
|
327
|
+
failure: stopped
|
|
274
328
|
});
|
|
275
329
|
loadModels(providerId, connection, generation.current);
|
|
276
330
|
};
|
|
@@ -306,6 +360,46 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
306
360
|
if (gen === generation.current) setLoadingConnectionValues(false);
|
|
307
361
|
}
|
|
308
362
|
};
|
|
363
|
+
const applyChange = async ()=>{
|
|
364
|
+
if (!connection || !api.applyConnectionChange || 'change' !== modelsState.status) return;
|
|
365
|
+
const gen = generation.current;
|
|
366
|
+
const pending = modelsState;
|
|
367
|
+
setApplyingChange(true);
|
|
368
|
+
try {
|
|
369
|
+
const result = await api.applyConnectionChange(providerId, connection);
|
|
370
|
+
if (gen !== generation.current) return;
|
|
371
|
+
if (!result.ok) {
|
|
372
|
+
setChangeAgreed(false);
|
|
373
|
+
setModelsState(result.failure.final ? {
|
|
374
|
+
...NO_MODELS,
|
|
375
|
+
status: 'error',
|
|
376
|
+
failure: {
|
|
377
|
+
...result.failure
|
|
378
|
+
},
|
|
379
|
+
unchecked: true
|
|
380
|
+
} : {
|
|
381
|
+
...pending,
|
|
382
|
+
failure: {
|
|
383
|
+
...result.failure
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const switched = result.value;
|
|
389
|
+
setConnections((prev)=>prev.map((c)=>c.id === switched.id ? switched : c));
|
|
390
|
+
loadModels(providerId, switched, gen);
|
|
391
|
+
} catch (err) {
|
|
392
|
+
if (gen === generation.current) {
|
|
393
|
+
setChangeAgreed(false);
|
|
394
|
+
setModelsState({
|
|
395
|
+
...pending,
|
|
396
|
+
failure: unexpected(err)
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
} finally{
|
|
400
|
+
setApplyingChange(false);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
309
403
|
const cancelConnectionEdit = ()=>{
|
|
310
404
|
generation.current += 1;
|
|
311
405
|
setEditingConnection(false);
|
|
@@ -364,7 +458,9 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
364
458
|
if (gen !== generation.current) return;
|
|
365
459
|
if (!result.ok) return void setConnect({
|
|
366
460
|
status: 'error',
|
|
367
|
-
failure:
|
|
461
|
+
failure: {
|
|
462
|
+
...result.failure
|
|
463
|
+
}
|
|
368
464
|
});
|
|
369
465
|
const saved = result.value;
|
|
370
466
|
existing ? setConnections((prev)=>prev.map((c)=>c.id === saved.id ? saved : c)) : setConnections((prev)=>[
|
|
@@ -385,7 +481,6 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
385
481
|
};
|
|
386
482
|
const pickModel = (id)=>{
|
|
387
483
|
setModelId(id);
|
|
388
|
-
if (!nameTouched) setName(id);
|
|
389
484
|
setTest({
|
|
390
485
|
status: 'idle'
|
|
391
486
|
});
|
|
@@ -397,27 +492,56 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
397
492
|
let nameProblem = null;
|
|
398
493
|
if (ownName && takenNames.has(ownName.toLowerCase())) nameProblem = labels.nameTaken(ownName);
|
|
399
494
|
else if (ownName && reservedNames.has(ownName.toLowerCase())) nameProblem = labels.nameReserved(ownName);
|
|
400
|
-
const replacementOptions = (ctx?.replaceableModels ?? []).filter((m)=>(!m.replaced || m.name === modelToEdit?.replaces) &&
|
|
495
|
+
const replacementOptions = (ctx?.replaceableModels ?? []).filter((m)=>(!m.replaced || m.name === modelToEdit?.replaces) && providers.some((p)=>api.apiTypes(p.id, m.name).length > 0));
|
|
401
496
|
const canUseOwnName = ctx?.allowsNewNames ?? false;
|
|
402
497
|
const replacing = 'replacement' === useAs;
|
|
403
498
|
const replacement = replacementOptions.find((m)=>m.name === replaces) ?? null;
|
|
404
499
|
const chosenName = replacing ? replacement?.name ?? '' : ownName;
|
|
405
500
|
const nameReady = replacing ? Boolean(replacement) : Boolean(ownName) && !nameProblem;
|
|
406
|
-
|
|
501
|
+
let alias = null;
|
|
502
|
+
if (replacing && replacement) alias = {
|
|
503
|
+
kind: 'replacement',
|
|
504
|
+
name: replacement.name
|
|
505
|
+
};
|
|
506
|
+
else if (!replacing && ownName) alias = {
|
|
507
|
+
kind: 'custom',
|
|
508
|
+
name: ownName
|
|
509
|
+
};
|
|
510
|
+
const apiTypesFor = (pid, a)=>api.apiTypes(pid, a?.kind === 'replacement' ? a.name : null);
|
|
511
|
+
const providerOptions = providers.filter((p)=>apiTypesFor(p.id, alias).length > 0);
|
|
512
|
+
const chooseAlias = (next)=>{
|
|
513
|
+
if ('replacement' === next.kind) {
|
|
514
|
+
setUseAs('replacement');
|
|
515
|
+
setReplaces(next.name);
|
|
516
|
+
} else {
|
|
517
|
+
setUseAs('own');
|
|
518
|
+
setName(next.name);
|
|
519
|
+
}
|
|
520
|
+
setTest({
|
|
521
|
+
status: 'idle'
|
|
522
|
+
});
|
|
523
|
+
if (providerId && 0 === apiTypesFor(providerId, next).length) clearProvider();
|
|
524
|
+
};
|
|
525
|
+
const apiTypeOptions = provider && alias ? apiTypesFor(providerId, alias) : [];
|
|
407
526
|
const apiTypeKey = apiTypeOptions.map((t)=>t.value).join('|');
|
|
408
527
|
useEffect(()=>{
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
|
|
528
|
+
const saved = modelToEdit?.apiType;
|
|
529
|
+
const next = saved && apiTypeOptions.some((o)=>o.value === saved) ? saved : apiTypeOptions[0]?.value ?? '';
|
|
530
|
+
if (apiType !== next) setApiType(next);
|
|
412
531
|
}, [
|
|
413
532
|
apiTypeKey,
|
|
414
|
-
|
|
415
|
-
|
|
533
|
+
apiType,
|
|
534
|
+
modelToEdit
|
|
416
535
|
]);
|
|
417
536
|
const apiTypeReady = apiTypeOptions.some((t)=>t.value === apiType);
|
|
418
537
|
const busy = keyLocked || 'running' === test.status || 'ok' === test.status;
|
|
419
538
|
const hasModel = Boolean(modelId.trim());
|
|
420
|
-
const
|
|
539
|
+
const connectionCleared = 'checking' !== modelsState.status && 'change' !== modelsState.status && !modelsState.unchecked;
|
|
540
|
+
const providerOpen = nameReady;
|
|
541
|
+
const providerDone = providerOpen && Boolean(provider);
|
|
542
|
+
const connectionDone = providerDone && connected && connectionCleared;
|
|
543
|
+
const modelDone = connectionDone && hasModel;
|
|
544
|
+
const readyToSave = modelDone && apiTypeReady;
|
|
421
545
|
const runTest = async ()=>{
|
|
422
546
|
if (!connection || !readyToSave || busy) return;
|
|
423
547
|
const gen = generation.current;
|
|
@@ -445,7 +569,9 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
445
569
|
if (!result.ok) {
|
|
446
570
|
if (stillOpen) setTest({
|
|
447
571
|
status: 'error',
|
|
448
|
-
failure:
|
|
572
|
+
failure: {
|
|
573
|
+
...result.failure
|
|
574
|
+
}
|
|
449
575
|
});
|
|
450
576
|
return;
|
|
451
577
|
}
|
|
@@ -475,7 +601,7 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
475
601
|
hint: keepsCurrentValue(f) ? labels.secretKeepHint : f.hint,
|
|
476
602
|
required: isRequired(f),
|
|
477
603
|
children: f.options?.length ? /*#__PURE__*/ jsxs(Select, {
|
|
478
|
-
value: values[f.key]
|
|
604
|
+
value: values[f.key] ?? '',
|
|
479
605
|
onValueChange: (v)=>setValue(f.key, v),
|
|
480
606
|
disabled: keyLocked,
|
|
481
607
|
children: [
|
|
@@ -513,6 +639,8 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
513
639
|
}, f.key);
|
|
514
640
|
const modelTriggerText = (()=>{
|
|
515
641
|
if (!connected) return labels.modelNeedsConnection(providerName);
|
|
642
|
+
if ('checking' === modelsState.status) return labels.checkingConnection;
|
|
643
|
+
if ('change' === modelsState.status) return labels.modelNeedsConnection(providerName);
|
|
516
644
|
if ('loading' === modelsState.status) return labels.modelsLoading(providerName);
|
|
517
645
|
if ('error' === modelsState.status) return labels.modelsFailed(providerName);
|
|
518
646
|
return labels.modelSelect(models.compatible.length);
|
|
@@ -523,10 +651,37 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
523
651
|
if (connectOutcome.updated) return labels.connectionUpdated;
|
|
524
652
|
return labels.connectedIn(folderLabel(connectOutcome.connection.folderId));
|
|
525
653
|
})();
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
654
|
+
const modelsFailure = 'error' === modelsState.status ? modelsState.failure ?? null : null;
|
|
655
|
+
const failureHint = (f)=>{
|
|
656
|
+
if (f.final) return;
|
|
657
|
+
if ('error' === connect.status && f === connect.failure) {
|
|
658
|
+
if (stoppedEdits.current.has(f)) return;
|
|
659
|
+
return labels.retryConnect(editingConnection ? labels.saveConnection : labels.connect);
|
|
660
|
+
}
|
|
661
|
+
if ('error' === test.status && f === test.failure) return labels.retryTest(saveLabel);
|
|
662
|
+
if ('change' === modelsState.status && f === modelsState.failure) return labels.retrySwitch;
|
|
663
|
+
};
|
|
664
|
+
const failure = [
|
|
665
|
+
'error' === connect.status ? connect.failure : null,
|
|
666
|
+
'error' === test.status ? test.failure : null,
|
|
667
|
+
'error' === modelsState.status || 'change' === modelsState.status ? modelsState.failure ?? null : null
|
|
668
|
+
].find((f)=>f && !dismissedFailures.includes(f)) ?? null;
|
|
669
|
+
let aliasHint = {
|
|
670
|
+
text: labels.nameHint,
|
|
671
|
+
tone: 'text-foreground-muted'
|
|
672
|
+
};
|
|
673
|
+
if (replacing && replacement?.retiresOn) aliasHint = {
|
|
674
|
+
text: labels.retiresOn(replacement.retiresOn),
|
|
675
|
+
tone: 'text-warning'
|
|
676
|
+
};
|
|
677
|
+
else if (replacing && replacement) aliasHint = {
|
|
678
|
+
text: labels.replacementHint,
|
|
679
|
+
tone: 'text-foreground-muted'
|
|
680
|
+
};
|
|
681
|
+
else if (!replacing && nameProblem) aliasHint = {
|
|
682
|
+
text: nameProblem,
|
|
683
|
+
tone: 'text-error'
|
|
684
|
+
};
|
|
530
685
|
const title = editTarget ? labels.editTitle : labels.title;
|
|
531
686
|
const description = editTarget ? labels.editDescription : labels.description;
|
|
532
687
|
const saveLabel = editTarget ? labels.testAndSave : labels.testAndAdd;
|
|
@@ -564,16 +719,42 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
564
719
|
}),
|
|
565
720
|
'error' === context.status && /*#__PURE__*/ jsx(FailureAlert, {
|
|
566
721
|
failure: context.failure,
|
|
567
|
-
labels: labels
|
|
722
|
+
labels: labels,
|
|
723
|
+
onRetry: ()=>setContextAttempt((n)=>n + 1)
|
|
568
724
|
}),
|
|
569
725
|
ctx && /*#__PURE__*/ jsxs(Fragment, {
|
|
570
726
|
children: [
|
|
571
727
|
/*#__PURE__*/ jsx(Step, {
|
|
572
728
|
n: 1,
|
|
729
|
+
title: labels.nameStep,
|
|
730
|
+
done: nameReady,
|
|
731
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
732
|
+
className: "flex flex-col gap-1.5",
|
|
733
|
+
children: [
|
|
734
|
+
/*#__PURE__*/ jsx(ModelAliasPicker, {
|
|
735
|
+
replaceable: replacementOptions,
|
|
736
|
+
allowsCustom: canUseOwnName,
|
|
737
|
+
value: alias,
|
|
738
|
+
onChange: chooseAlias,
|
|
739
|
+
disabled: busy,
|
|
740
|
+
invalid: Boolean(nameProblem) && !replacing,
|
|
741
|
+
container: container,
|
|
742
|
+
labels: labels
|
|
743
|
+
}),
|
|
744
|
+
/*#__PURE__*/ jsx("p", {
|
|
745
|
+
className: cn('text-xs', aliasHint.tone),
|
|
746
|
+
children: aliasHint.text
|
|
747
|
+
})
|
|
748
|
+
]
|
|
749
|
+
})
|
|
750
|
+
}),
|
|
751
|
+
/*#__PURE__*/ jsx(Step, {
|
|
752
|
+
n: 2,
|
|
573
753
|
title: labels.providerStep,
|
|
574
|
-
done:
|
|
754
|
+
done: providerDone,
|
|
755
|
+
disabled: !providerOpen,
|
|
575
756
|
children: /*#__PURE__*/ jsxs(Select, {
|
|
576
|
-
value: providerId
|
|
757
|
+
value: providerId,
|
|
577
758
|
onValueChange: chooseProvider,
|
|
578
759
|
disabled: busy,
|
|
579
760
|
children: [
|
|
@@ -586,7 +767,7 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
586
767
|
}),
|
|
587
768
|
/*#__PURE__*/ jsx(SelectContent, {
|
|
588
769
|
container: container,
|
|
589
|
-
children:
|
|
770
|
+
children: providerOptions.map((p)=>/*#__PURE__*/ jsx(SelectItem, {
|
|
590
771
|
value: p.id,
|
|
591
772
|
children: p.name
|
|
592
773
|
}, p.id))
|
|
@@ -595,10 +776,10 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
595
776
|
})
|
|
596
777
|
}),
|
|
597
778
|
/*#__PURE__*/ jsx(Step, {
|
|
598
|
-
n:
|
|
779
|
+
n: 3,
|
|
599
780
|
title: labels.connectionStep,
|
|
600
|
-
done:
|
|
601
|
-
disabled: !
|
|
781
|
+
done: connectionDone,
|
|
782
|
+
disabled: !providerDone,
|
|
602
783
|
children: /*#__PURE__*/ jsxs("div", {
|
|
603
784
|
className: "flex flex-col gap-3",
|
|
604
785
|
children: [
|
|
@@ -642,7 +823,17 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
642
823
|
connectMessage
|
|
643
824
|
]
|
|
644
825
|
}),
|
|
645
|
-
connection && !editingConnection && /*#__PURE__*/ jsx(
|
|
826
|
+
connection && !editingConnection && 'change' === modelsState.status && /*#__PURE__*/ jsx(ConnectionChangeNotice, {
|
|
827
|
+
change: modelsState.change,
|
|
828
|
+
agreed: changeAgreed,
|
|
829
|
+
applying: applyingChange,
|
|
830
|
+
disabled: busy,
|
|
831
|
+
labels: labels,
|
|
832
|
+
onAgreedChange: setChangeAgreed,
|
|
833
|
+
onApply: applyChange,
|
|
834
|
+
onSeparate: ()=>chooseConnection(NEW)
|
|
835
|
+
}),
|
|
836
|
+
connection && !editingConnection && connectionCleared && /*#__PURE__*/ jsx("div", {
|
|
646
837
|
children: /*#__PURE__*/ jsx(Button, {
|
|
647
838
|
variant: "link",
|
|
648
839
|
size: "2xs",
|
|
@@ -652,6 +843,11 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
652
843
|
children: labels.editConnection
|
|
653
844
|
})
|
|
654
845
|
}),
|
|
846
|
+
connection && !showConnectionForm && 'error' === formState.status && /*#__PURE__*/ jsx(FailureAlert, {
|
|
847
|
+
failure: formState.failure,
|
|
848
|
+
labels: labels,
|
|
849
|
+
onRetry: ()=>loadForm(providerId, formFolder.current)
|
|
850
|
+
}),
|
|
655
851
|
showConnectionForm && /*#__PURE__*/ jsxs(Fragment, {
|
|
656
852
|
children: [
|
|
657
853
|
/*#__PURE__*/ jsxs(Group, {
|
|
@@ -671,7 +867,8 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
671
867
|
}),
|
|
672
868
|
'error' === formState.status && /*#__PURE__*/ jsx(FailureAlert, {
|
|
673
869
|
failure: formState.failure,
|
|
674
|
-
labels: labels
|
|
870
|
+
labels: labels,
|
|
871
|
+
onRetry: ()=>loadForm(providerId, formFolder.current)
|
|
675
872
|
}),
|
|
676
873
|
loadingConnectionValues && /*#__PURE__*/ jsxs("div", {
|
|
677
874
|
className: "flex items-center gap-2 text-xs text-foreground-muted",
|
|
@@ -759,7 +956,7 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
759
956
|
id: "byo-folder",
|
|
760
957
|
label: labels.folder,
|
|
761
958
|
children: /*#__PURE__*/ jsxs(Select, {
|
|
762
|
-
value: formFolderId
|
|
959
|
+
value: formFolderId,
|
|
763
960
|
onValueChange: setFolderId,
|
|
764
961
|
disabled: keyLocked || editingConnection,
|
|
765
962
|
children: [
|
|
@@ -815,10 +1012,10 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
815
1012
|
})
|
|
816
1013
|
}),
|
|
817
1014
|
/*#__PURE__*/ jsx(Step, {
|
|
818
|
-
n:
|
|
1015
|
+
n: 4,
|
|
819
1016
|
title: labels.modelStep,
|
|
820
|
-
done:
|
|
821
|
-
disabled: !
|
|
1017
|
+
done: modelDone,
|
|
1018
|
+
disabled: !connectionDone,
|
|
822
1019
|
children: freeTextModel ? /*#__PURE__*/ jsx(Input, {
|
|
823
1020
|
ref: modelTriggerRef,
|
|
824
1021
|
"aria-label": labels.modelIdLabel,
|
|
@@ -883,7 +1080,7 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
883
1080
|
children: labels.modelNoMatch(modelQuery)
|
|
884
1081
|
}),
|
|
885
1082
|
shownCompatible.length > 0 && /*#__PURE__*/ jsx(CommandGroup, {
|
|
886
|
-
heading: labels.compatibleGroup(shownCompatible.length),
|
|
1083
|
+
heading: models.incompatible.length > 0 ? labels.compatibleGroup(shownCompatible.length) : void 0,
|
|
887
1084
|
children: shownCompatible.map((m)=>/*#__PURE__*/ jsx(ModelRow, {
|
|
888
1085
|
model: m,
|
|
889
1086
|
selected: m.id === modelId,
|
|
@@ -908,165 +1105,6 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
908
1105
|
})
|
|
909
1106
|
]
|
|
910
1107
|
})
|
|
911
|
-
}),
|
|
912
|
-
/*#__PURE__*/ jsx(Step, {
|
|
913
|
-
n: 4,
|
|
914
|
-
title: labels.nameStep,
|
|
915
|
-
done: hasModel && nameReady,
|
|
916
|
-
disabled: !hasModel,
|
|
917
|
-
children: /*#__PURE__*/ jsxs("div", {
|
|
918
|
-
className: "flex flex-col gap-3",
|
|
919
|
-
children: [
|
|
920
|
-
canUseOwnName && replacementOptions.length > 0 && /*#__PURE__*/ jsxs(RadioGroup, {
|
|
921
|
-
value: useAs,
|
|
922
|
-
onValueChange: (v)=>{
|
|
923
|
-
setUseAs(v);
|
|
924
|
-
setTest({
|
|
925
|
-
status: 'idle'
|
|
926
|
-
});
|
|
927
|
-
},
|
|
928
|
-
disabled: busy,
|
|
929
|
-
"aria-label": labels.nameStep,
|
|
930
|
-
className: "flex flex-wrap gap-4",
|
|
931
|
-
children: [
|
|
932
|
-
/*#__PURE__*/ jsxs("div", {
|
|
933
|
-
className: "flex items-center gap-2",
|
|
934
|
-
children: [
|
|
935
|
-
/*#__PURE__*/ jsx(RadioGroupItem, {
|
|
936
|
-
value: "own",
|
|
937
|
-
id: "byo-use-own"
|
|
938
|
-
}),
|
|
939
|
-
/*#__PURE__*/ jsx(Label, {
|
|
940
|
-
htmlFor: "byo-use-own",
|
|
941
|
-
className: "text-xs font-normal",
|
|
942
|
-
children: labels.useOwnName
|
|
943
|
-
})
|
|
944
|
-
]
|
|
945
|
-
}),
|
|
946
|
-
/*#__PURE__*/ jsxs("div", {
|
|
947
|
-
className: "flex items-center gap-2",
|
|
948
|
-
children: [
|
|
949
|
-
/*#__PURE__*/ jsx(RadioGroupItem, {
|
|
950
|
-
value: "replacement",
|
|
951
|
-
id: "byo-use-replacement"
|
|
952
|
-
}),
|
|
953
|
-
/*#__PURE__*/ jsx(Label, {
|
|
954
|
-
htmlFor: "byo-use-replacement",
|
|
955
|
-
className: "text-xs font-normal",
|
|
956
|
-
children: labels.useReplacement
|
|
957
|
-
})
|
|
958
|
-
]
|
|
959
|
-
})
|
|
960
|
-
]
|
|
961
|
-
}),
|
|
962
|
-
replacing ? /*#__PURE__*/ jsxs("div", {
|
|
963
|
-
className: "flex flex-col gap-1.5",
|
|
964
|
-
children: [
|
|
965
|
-
/*#__PURE__*/ jsxs(Select, {
|
|
966
|
-
value: replacement?.name,
|
|
967
|
-
onValueChange: (v)=>{
|
|
968
|
-
setReplaces(v);
|
|
969
|
-
setTest({
|
|
970
|
-
status: 'idle'
|
|
971
|
-
});
|
|
972
|
-
},
|
|
973
|
-
disabled: busy,
|
|
974
|
-
children: [
|
|
975
|
-
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
976
|
-
className: "w-full",
|
|
977
|
-
"aria-label": labels.useReplacement,
|
|
978
|
-
children: /*#__PURE__*/ jsx(SelectValue, {
|
|
979
|
-
placeholder: labels.replacementPlaceholder
|
|
980
|
-
})
|
|
981
|
-
}),
|
|
982
|
-
/*#__PURE__*/ jsx(SelectContent, {
|
|
983
|
-
container: container,
|
|
984
|
-
children: replacementOptions.map((m)=>/*#__PURE__*/ jsxs(SelectItem, {
|
|
985
|
-
value: m.name,
|
|
986
|
-
children: [
|
|
987
|
-
/*#__PURE__*/ jsx("span", {
|
|
988
|
-
className: "font-mono text-xs",
|
|
989
|
-
children: m.name
|
|
990
|
-
}),
|
|
991
|
-
m.retiresOn && /*#__PURE__*/ jsx("span", {
|
|
992
|
-
className: "ml-2 text-xs text-foreground-muted",
|
|
993
|
-
children: labels.deprecated
|
|
994
|
-
})
|
|
995
|
-
]
|
|
996
|
-
}, m.name))
|
|
997
|
-
})
|
|
998
|
-
]
|
|
999
|
-
}),
|
|
1000
|
-
/*#__PURE__*/ jsx("p", {
|
|
1001
|
-
className: cn('text-xs', replacement?.retiresOn ? 'text-warning' : 'text-foreground-muted'),
|
|
1002
|
-
children: replacement?.retiresOn ? labels.retiresOn(replacement.retiresOn) : labels.replacementHint
|
|
1003
|
-
})
|
|
1004
|
-
]
|
|
1005
|
-
}) : /*#__PURE__*/ jsxs("div", {
|
|
1006
|
-
className: "flex flex-col gap-1.5",
|
|
1007
|
-
children: [
|
|
1008
|
-
/*#__PURE__*/ jsx(Input, {
|
|
1009
|
-
"aria-label": labels.nameStep,
|
|
1010
|
-
value: name,
|
|
1011
|
-
disabled: busy,
|
|
1012
|
-
onChange: (e)=>{
|
|
1013
|
-
setName(e.target.value);
|
|
1014
|
-
setNameTouched(true);
|
|
1015
|
-
setTest({
|
|
1016
|
-
status: 'idle'
|
|
1017
|
-
});
|
|
1018
|
-
},
|
|
1019
|
-
"aria-invalid": Boolean(nameProblem)
|
|
1020
|
-
}),
|
|
1021
|
-
/*#__PURE__*/ jsx("p", {
|
|
1022
|
-
className: cn('text-xs', nameProblem ? 'text-error' : 'text-foreground-muted'),
|
|
1023
|
-
children: nameProblem ?? labels.nameHint
|
|
1024
|
-
})
|
|
1025
|
-
]
|
|
1026
|
-
})
|
|
1027
|
-
]
|
|
1028
|
-
})
|
|
1029
|
-
}),
|
|
1030
|
-
/*#__PURE__*/ jsx(Step, {
|
|
1031
|
-
n: 5,
|
|
1032
|
-
title: labels.apiTypeStep,
|
|
1033
|
-
done: readyToSave,
|
|
1034
|
-
disabled: !hasModel || !nameReady,
|
|
1035
|
-
children: /*#__PURE__*/ jsxs("div", {
|
|
1036
|
-
className: "flex flex-col gap-1.5",
|
|
1037
|
-
children: [
|
|
1038
|
-
/*#__PURE__*/ jsxs(Select, {
|
|
1039
|
-
value: apiTypeReady ? apiType : void 0,
|
|
1040
|
-
onValueChange: (v)=>{
|
|
1041
|
-
setApiType(v);
|
|
1042
|
-
setTest({
|
|
1043
|
-
status: 'idle'
|
|
1044
|
-
});
|
|
1045
|
-
},
|
|
1046
|
-
disabled: busy || 0 === apiTypeOptions.length,
|
|
1047
|
-
children: [
|
|
1048
|
-
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
1049
|
-
className: "w-full",
|
|
1050
|
-
"aria-label": labels.apiTypeStep,
|
|
1051
|
-
children: /*#__PURE__*/ jsx(SelectValue, {
|
|
1052
|
-
placeholder: labels.apiTypePlaceholder
|
|
1053
|
-
})
|
|
1054
|
-
}),
|
|
1055
|
-
/*#__PURE__*/ jsx(SelectContent, {
|
|
1056
|
-
container: container,
|
|
1057
|
-
children: apiTypeOptions.map((t)=>/*#__PURE__*/ jsx(SelectItem, {
|
|
1058
|
-
value: t.value,
|
|
1059
|
-
children: t.label
|
|
1060
|
-
}, t.value))
|
|
1061
|
-
})
|
|
1062
|
-
]
|
|
1063
|
-
}),
|
|
1064
|
-
/*#__PURE__*/ jsx("p", {
|
|
1065
|
-
className: "text-xs text-foreground-muted",
|
|
1066
|
-
children: hasModel && nameReady && 0 === apiTypeOptions.length ? labels.apiTypeNone(providerName) : labels.apiTypeHint
|
|
1067
|
-
})
|
|
1068
|
-
]
|
|
1069
|
-
})
|
|
1070
1108
|
})
|
|
1071
1109
|
]
|
|
1072
1110
|
})
|
|
@@ -1076,7 +1114,13 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
|
|
|
1076
1114
|
className: "max-h-[40%] shrink-0 overflow-y-auto border-t border-border-subtle px-6 py-3",
|
|
1077
1115
|
children: /*#__PURE__*/ jsx(FailureAlert, {
|
|
1078
1116
|
failure: failure,
|
|
1079
|
-
labels: labels
|
|
1117
|
+
labels: labels,
|
|
1118
|
+
onDismiss: ()=>setDismissedFailures((prev)=>[
|
|
1119
|
+
...prev,
|
|
1120
|
+
failure
|
|
1121
|
+
]),
|
|
1122
|
+
onRetry: failure === modelsFailure && connection && !busy ? ()=>loadModels(providerId, connection, generation.current) : void 0,
|
|
1123
|
+
hint: failureHint(failure)
|
|
1080
1124
|
})
|
|
1081
1125
|
}),
|
|
1082
1126
|
/*#__PURE__*/ jsxs(DialogFooter, {
|
|
@@ -1204,12 +1248,83 @@ function Field({ id, label, hint, required, children }) {
|
|
|
1204
1248
|
]
|
|
1205
1249
|
});
|
|
1206
1250
|
}
|
|
1207
|
-
function
|
|
1251
|
+
function ConnectionChangeNotice({ change, agreed, applying, disabled, labels, onAgreedChange, onApply, onSeparate }) {
|
|
1252
|
+
const id = useId();
|
|
1253
|
+
return /*#__PURE__*/ jsxs(Alert, {
|
|
1254
|
+
variant: "warning",
|
|
1255
|
+
className: "min-w-0",
|
|
1256
|
+
children: [
|
|
1257
|
+
/*#__PURE__*/ jsx(TriangleAlert, {}),
|
|
1258
|
+
/*#__PURE__*/ jsx(AlertTitle, {
|
|
1259
|
+
children: change.title
|
|
1260
|
+
}),
|
|
1261
|
+
/*#__PURE__*/ jsxs(AlertDescription, {
|
|
1262
|
+
className: "flex flex-col gap-3 break-words",
|
|
1263
|
+
children: [
|
|
1264
|
+
/*#__PURE__*/ jsx("span", {
|
|
1265
|
+
children: change.message
|
|
1266
|
+
}),
|
|
1267
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1268
|
+
className: "flex items-start gap-2",
|
|
1269
|
+
children: [
|
|
1270
|
+
/*#__PURE__*/ jsx(Checkbox, {
|
|
1271
|
+
id: id,
|
|
1272
|
+
checked: agreed,
|
|
1273
|
+
disabled: disabled || applying,
|
|
1274
|
+
onCheckedChange: (v)=>onAgreedChange(true === v),
|
|
1275
|
+
className: "mt-0.5"
|
|
1276
|
+
}),
|
|
1277
|
+
/*#__PURE__*/ jsx(Label, {
|
|
1278
|
+
htmlFor: id,
|
|
1279
|
+
className: "text-xs font-normal leading-4",
|
|
1280
|
+
children: change.agreement
|
|
1281
|
+
})
|
|
1282
|
+
]
|
|
1283
|
+
}),
|
|
1284
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1285
|
+
className: "flex flex-wrap items-center gap-3",
|
|
1286
|
+
children: [
|
|
1287
|
+
/*#__PURE__*/ jsxs(Button, {
|
|
1288
|
+
size: "2xs",
|
|
1289
|
+
disabled: !agreed || disabled || applying,
|
|
1290
|
+
onClick: onApply,
|
|
1291
|
+
children: [
|
|
1292
|
+
applying && /*#__PURE__*/ jsx(Spinner, {
|
|
1293
|
+
size: "sm"
|
|
1294
|
+
}),
|
|
1295
|
+
applying ? labels.applyingChange : labels.applyChange
|
|
1296
|
+
]
|
|
1297
|
+
}),
|
|
1298
|
+
/*#__PURE__*/ jsx(Button, {
|
|
1299
|
+
variant: "link",
|
|
1300
|
+
size: "2xs",
|
|
1301
|
+
className: "h-auto p-0 text-xs",
|
|
1302
|
+
disabled: disabled || applying,
|
|
1303
|
+
onClick: onSeparate,
|
|
1304
|
+
children: labels.separateConnection
|
|
1305
|
+
})
|
|
1306
|
+
]
|
|
1307
|
+
})
|
|
1308
|
+
]
|
|
1309
|
+
})
|
|
1310
|
+
]
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
function FailureAlert({ failure, labels, onDismiss, onRetry, hint }) {
|
|
1208
1314
|
const [showRaw, setShowRaw] = useState(false);
|
|
1209
1315
|
return /*#__PURE__*/ jsxs(Alert, {
|
|
1210
1316
|
variant: "destructive",
|
|
1211
|
-
className:
|
|
1317
|
+
className: cn('min-w-0', onDismiss && 'pr-9'),
|
|
1212
1318
|
children: [
|
|
1319
|
+
onDismiss && /*#__PURE__*/ jsx(Button, {
|
|
1320
|
+
variant: "ghost",
|
|
1321
|
+
size: "3xs",
|
|
1322
|
+
icon: true,
|
|
1323
|
+
className: "absolute top-2 right-2",
|
|
1324
|
+
"aria-label": labels.dismiss,
|
|
1325
|
+
onClick: onDismiss,
|
|
1326
|
+
children: /*#__PURE__*/ jsx(X, {})
|
|
1327
|
+
}),
|
|
1213
1328
|
/*#__PURE__*/ jsx(AlertCircle, {}),
|
|
1214
1329
|
/*#__PURE__*/ jsx(AlertTitle, {
|
|
1215
1330
|
children: failure.title
|
|
@@ -1233,6 +1348,19 @@ function FailureAlert({ failure, labels }) {
|
|
|
1233
1348
|
!failure.detail && failure.message && /*#__PURE__*/ jsx(AlertDescription, {
|
|
1234
1349
|
className: "break-words",
|
|
1235
1350
|
children: failure.message
|
|
1351
|
+
}),
|
|
1352
|
+
hint && /*#__PURE__*/ jsx(AlertDescription, {
|
|
1353
|
+
className: "text-foreground-muted",
|
|
1354
|
+
children: hint
|
|
1355
|
+
}),
|
|
1356
|
+
onRetry && !failure.final && /*#__PURE__*/ jsx(AlertDescription, {
|
|
1357
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
1358
|
+
variant: "link",
|
|
1359
|
+
size: "2xs",
|
|
1360
|
+
className: "mt-1 h-auto p-0 text-xs",
|
|
1361
|
+
onClick: onRetry,
|
|
1362
|
+
children: labels.tryAgain
|
|
1363
|
+
})
|
|
1236
1364
|
})
|
|
1237
1365
|
]
|
|
1238
1366
|
});
|