swarm-wire, swarm-ui: the flow schema lists the values a field takes, and the editor picks them instead of asking for typed names
The schema's event fields gain values, a values_from marker (agents, repos) and a closed flag; a node field gains the marker and the flag. kind is now listed as issue and PR, what the router sends. The flow editor shows a dropdown where the list is complete, suggestions where it is only examples, and a plain box where there is none.
This commit is contained in:
parent
3d142feb6a
commit
b6da2bc9d0
1 changed files with 503 additions and 26 deletions
|
|
@ -48,6 +48,7 @@ import {
|
|||
} from "./FlowDraft.js";
|
||||
import { useLeaveGuard } from "./useLeaveGuard.js";
|
||||
import { NodeInspector } from "./NodeInspector.js";
|
||||
import { markersIn, SOURCE_URLS, type Sources } from "./FlowChoices.js";
|
||||
import { FALLBACK_SCHEMA, type Flow, type FlowsView } from "./FlowTypes.js";
|
||||
import { DRY_RUN_URL, hitsOf, type DryRun } from "./RouterLive.js";
|
||||
import "./NotificationsPage.css";
|
||||
|
|
@ -85,6 +86,7 @@ export function FlowEditorPage({
|
|||
dry: DryRun;
|
||||
} | null>(null);
|
||||
const [previewError, setPreviewError] = useState<ProblemDetails | null>(null);
|
||||
const [sources, setSources] = useState<Sources>({});
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [confirmDelete, setConfirmDelete] = useState(false);
|
||||
|
||||
|
|
@ -121,6 +123,19 @@ export function FlowEditorPage({
|
|||
void load(false);
|
||||
}, [load]);
|
||||
|
||||
// The lists the schema's values come from. One that cannot be fetched is
|
||||
// left out and its field falls back to a box that takes any text.
|
||||
const markers = view?.schema ? markersIn(view.schema).join(",") : "";
|
||||
useEffect(() => {
|
||||
const abort = new AbortController();
|
||||
for (const marker of markers === "" ? [] : markers.split(",")) {
|
||||
fetchJson<string[]>(SOURCE_URLS[marker], abort.signal)
|
||||
.then((names) => setSources((all) => ({ ...all, [marker]: names })))
|
||||
.catch(() => undefined);
|
||||
}
|
||||
return () => abort.abort();
|
||||
}, [markers]);
|
||||
|
||||
const dirty =
|
||||
view !== null &&
|
||||
draft !== null &&
|
||||
|
|
@ -377,6 +392,7 @@ export function FlowEditorPage({
|
|||
node={node}
|
||||
schema={schema}
|
||||
limits={limits}
|
||||
sources={sources}
|
||||
onEdit={onEdit}
|
||||
/>
|
||||
) : null}
|
||||
|
|
|
|||
Loading…
Reference in a new issue