swarm-ui: edit a notification flow on a canvas
A custom flow opens at /notifications/<id>: its nodes drawn left to right (source, then matches, then todos), and a panel to edit the picked node: the source's events, a match's conditions, a todo's recipients, op, key and text. Add a match or todo below a node, move a branch under another match, or remove it; an edit the controller would refuse (a todo with children, a second parent, a cycle, over the node or depth cap) is turned away with the reason. Edits stay in a draft until save, which sends the whole document at the revision read. A stale revision is told apart from a refused document: the editor offers to reload or to keep the draft on top of the latest. The form choices come from the controller's schema when it sends one. The list page gains edit and duplicate on custom flows, duplicate on the built-ins, and a new-flow box; a new flow's id avoids the built-ins' too.
This commit is contained in:
parent
c00fd99112
commit
f28e1e9063
13 changed files with 1209 additions and 6 deletions
|
|
@ -5,7 +5,7 @@
|
|||
// these edits only refuse what could never be saved, so the canvas can
|
||||
// turn a bad drop away with a reason instead of drawing a flow the save
|
||||
// would reject. The tree rules mirror `Flow::validate` in swarm-wire.
|
||||
import type { Flow, FlowNode, FlowsView } from "./FlowTypes.js";
|
||||
import type { Flow, FlowNode, FlowSchema, FlowsView } from "./FlowTypes.js";
|
||||
|
||||
export interface Limits {
|
||||
maxNodes: number;
|
||||
|
|
@ -21,6 +21,14 @@ export const DEFAULT_LIMITS: Limits = {
|
|||
maxFlows: 100,
|
||||
};
|
||||
|
||||
// The caps the controller reports, or today's when it reports none.
|
||||
export function limitsOf(schema?: FlowSchema): Limits {
|
||||
const l = schema?.limits;
|
||||
return l
|
||||
? { maxNodes: l.max_nodes, maxDepth: l.max_depth, maxFlows: l.max_flows }
|
||||
: DEFAULT_LIMITS;
|
||||
}
|
||||
|
||||
export type Edit = { ok: true; flow: Flow } | { ok: false; reason: string };
|
||||
|
||||
const ID = /^[A-Za-z0-9_-]{1,64}$/;
|
||||
|
|
|
|||
Loading…
Reference in a new issue