Prune files not in the deploy set (stale build context)
Browse files
web/src/automation/AutomationSteps.tsx
DELETED
|
@@ -1,201 +0,0 @@
|
|
| 1 |
-
// ---------------------------------------------------------------------------
|
| 2 |
-
// automation/AutomationSteps.tsx — one automation as NUMBERED STEPS (owner ruling R9).
|
| 3 |
-
//
|
| 4 |
-
// WHAT THIS REPLACES, AND WHY. It replaces the pan/zoom canvas as the work
|
| 5 |
-
// surface. The owner asked for "trigger-first Steps": a job you read top to
|
| 6 |
-
// bottom, starting with what makes it happen. A canvas answers "what shape is
|
| 7 |
-
// this flow"; a numbered list answers "what does it do, in what order, and what
|
| 8 |
-
// is step 3" — and the engine EXECUTES a list, not a graph. `capture_paid` and
|
| 9 |
-
// `capture_anon` render as a fork and are walked linearly (DEBT D-7), so a list
|
| 10 |
-
// that shows them as ALTERNATIVES AT ONE NUMBER is closer to what happens than
|
| 11 |
-
// two boxes with an arrow between them ever was.
|
| 12 |
-
//
|
| 13 |
-
// ⚠ EVERY STEP COMES FROM THE SERVER (contract C6). The nodes, their order,
|
| 14 |
-
// their titles, their switches and their dots are `engine.graph()`'s — this file
|
| 15 |
-
// numbers them (`steps.ts`) and paints them. It may not add a step, hide a step,
|
| 16 |
-
// or rename one: a client-side second idea of the steps is drift that is
|
| 17 |
-
// invisible until an automation stops doing what the picture says.
|
| 18 |
-
//
|
| 19 |
-
// ONE CONTROL PER FACT, and R9 moved one. The trigger's on/off used to be the
|
| 20 |
-
// canvas node's switch while the cron string lived in the panel. Step 1 now owns
|
| 21 |
-
// BOTH — the picker IS the on/off — and the panel's schedule face is gone, so
|
| 22 |
-
// there is exactly one place that decides when this runs.
|
| 23 |
-
// ---------------------------------------------------------------------------
|
| 24 |
-
import type { ReactNode } from "react";
|
| 25 |
-
|
| 26 |
-
import type { AutomationGraph, GraphNode } from "./automationApi";
|
| 27 |
-
import { numberSteps } from "./steps";
|
| 28 |
-
|
| 29 |
-
interface Props {
|
| 30 |
-
graph: AutomationGraph;
|
| 31 |
-
selected: string;
|
| 32 |
-
onSelect: (nodeId: string) => void;
|
| 33 |
-
onToggle: (nodeId: string) => void;
|
| 34 |
-
busyNode: string;
|
| 35 |
-
/**
|
| 36 |
-
* The trigger face (contract C3), composed by `AutomationDetail`.
|
| 37 |
-
*
|
| 38 |
-
* ⭐ PASSED IN RATHER THAN BUILT HERE, and that is wave 22's change to this file.
|
| 39 |
-
* The board frame needs the same picker, the same cron round-trip and the same
|
| 40 |
-
* tick honesty note; writing them twice would be two copies of three things that
|
| 41 |
-
* go wrong invisibly. `AutomationTrigger` owns all of it and both frames render
|
| 42 |
-
* the same element.
|
| 43 |
-
*/
|
| 44 |
-
triggerFace: ReactNode;
|
| 45 |
-
/** Dim Step 1 when nothing automatic starts this automation. */
|
| 46 |
-
triggerOff: boolean;
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
/** Step 1's icon vocabulary, drawn (owner constant: no emojis). */
|
| 50 |
-
function KindMark({ kind }: { kind: GraphNode["kind"] }) {
|
| 51 |
-
const common = {
|
| 52 |
-
width: 15,
|
| 53 |
-
height: 15,
|
| 54 |
-
viewBox: "0 0 16 16",
|
| 55 |
-
fill: "none",
|
| 56 |
-
stroke: "currentColor",
|
| 57 |
-
strokeWidth: 1.4,
|
| 58 |
-
strokeLinecap: "round" as const,
|
| 59 |
-
strokeLinejoin: "round" as const,
|
| 60 |
-
"aria-hidden": true,
|
| 61 |
-
};
|
| 62 |
-
if (kind === "trigger")
|
| 63 |
-
return (
|
| 64 |
-
<svg {...common}>
|
| 65 |
-
<circle cx="8" cy="8" r="5.6" />
|
| 66 |
-
<path d="M8 5.2V8l2 1.4" />
|
| 67 |
-
</svg>
|
| 68 |
-
);
|
| 69 |
-
if (kind === "source")
|
| 70 |
-
return (
|
| 71 |
-
<svg {...common}>
|
| 72 |
-
<circle cx="8" cy="8" r="5.6" />
|
| 73 |
-
<path d="M2.6 8h10.8M8 2.4c1.5 1.7 2.2 3.6 2.2 5.6S9.5 12.3 8 13.6C6.5 12.3 5.8 10 5.8 8s.7-3.9 2.2-5.6z" />
|
| 74 |
-
</svg>
|
| 75 |
-
);
|
| 76 |
-
if (kind === "branch")
|
| 77 |
-
return (
|
| 78 |
-
<svg {...common}>
|
| 79 |
-
<path d="M2.6 8h3.2l2.6-3.6h5M8.4 11.6H5.8m2.6 0h5" />
|
| 80 |
-
<path d="M11.6 2.6 13.4 4.4 11.6 6.2M11.6 9.8l1.8 1.8-1.8 1.8" />
|
| 81 |
-
</svg>
|
| 82 |
-
);
|
| 83 |
-
if (kind === "write")
|
| 84 |
-
return (
|
| 85 |
-
<svg {...common}>
|
| 86 |
-
<ellipse cx="8" cy="4.2" rx="4.8" ry="1.9" />
|
| 87 |
-
<path d="M3.2 4.2v7.6c0 1 2.1 1.9 4.8 1.9s4.8-.9 4.8-1.9V4.2M3.2 8c0 1 2.1 1.9 4.8 1.9s4.8-.9 4.8-1.9" />
|
| 88 |
-
</svg>
|
| 89 |
-
);
|
| 90 |
-
return (
|
| 91 |
-
<svg {...common}>
|
| 92 |
-
<path d="M8 2.6v7.2M5.2 7l2.8 2.8L10.8 7M3 12.4h10" />
|
| 93 |
-
</svg>
|
| 94 |
-
);
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
export default function AutomationSteps({
|
| 98 |
-
graph,
|
| 99 |
-
selected,
|
| 100 |
-
onSelect,
|
| 101 |
-
onToggle,
|
| 102 |
-
busyNode,
|
| 103 |
-
triggerFace,
|
| 104 |
-
triggerOff,
|
| 105 |
-
}: Props) {
|
| 106 |
-
const steps = numberSteps(graph?.nodes || []);
|
| 107 |
-
const trigger = steps.length && steps[0].node.kind === "trigger" ? steps[0] : null;
|
| 108 |
-
const rest = trigger ? steps.slice(1) : steps;
|
| 109 |
-
|
| 110 |
-
return (
|
| 111 |
-
<div className="auto-steps-wrap">
|
| 112 |
-
<ol className="auto-steps">
|
| 113 |
-
{trigger ? (
|
| 114 |
-
<li className={"auto-step is-trigger" + (triggerOff ? " is-off" : "")}>
|
| 115 |
-
<div className="auto-step-rail">
|
| 116 |
-
<span className="auto-step-n">{trigger.n}</span>
|
| 117 |
-
</div>
|
| 118 |
-
<div className="auto-step-card">
|
| 119 |
-
<div className="auto-step-head">
|
| 120 |
-
<span className="auto-step-mark">
|
| 121 |
-
<KindMark kind={trigger.node.kind} />
|
| 122 |
-
</span>
|
| 123 |
-
<span className="auto-step-title">{trigger.node.title}</span>
|
| 124 |
-
<span className="auto-step-tag">Trigger</span>
|
| 125 |
-
</div>
|
| 126 |
-
{triggerFace}
|
| 127 |
-
</div>
|
| 128 |
-
</li>
|
| 129 |
-
) : null}
|
| 130 |
-
|
| 131 |
-
{rest.map((s) => (
|
| 132 |
-
<li
|
| 133 |
-
key={s.node.id}
|
| 134 |
-
className={
|
| 135 |
-
"auto-step" +
|
| 136 |
-
(s.node.id === selected ? " is-selected" : "") +
|
| 137 |
-
(s.node.enabled ? "" : " is-off") +
|
| 138 |
-
(s.alt ? " is-alt" : "") +
|
| 139 |
-
` is-${s.node.kind}`
|
| 140 |
-
}
|
| 141 |
-
>
|
| 142 |
-
<div className="auto-step-rail">
|
| 143 |
-
{/* An alternative shares the number of the step it is an alternative TO — the
|
| 144 |
-
fork is a choice at one position, not two things that both happen. */}
|
| 145 |
-
<span className={"auto-step-n" + (s.alt ? " is-alt" : "")}>{s.n}</span>
|
| 146 |
-
{s.alt ? <span className="auto-step-or">or</span> : null}
|
| 147 |
-
</div>
|
| 148 |
-
<div className="auto-step-card">
|
| 149 |
-
<button
|
| 150 |
-
type="button"
|
| 151 |
-
className="auto-step-hit"
|
| 152 |
-
aria-pressed={s.node.id === selected}
|
| 153 |
-
title={`${s.node.title} — ${s.node.subtitle}`}
|
| 154 |
-
onClick={() => onSelect(s.node.id)}
|
| 155 |
-
>
|
| 156 |
-
<span className="auto-step-head">
|
| 157 |
-
<span className="auto-step-mark">
|
| 158 |
-
<KindMark kind={s.node.kind} />
|
| 159 |
-
</span>
|
| 160 |
-
<span className="auto-step-title">{s.node.title}</span>
|
| 161 |
-
<span
|
| 162 |
-
className={`auto-dot is-${s.node.status}`}
|
| 163 |
-
title={`Last run: ${s.node.status}`}
|
| 164 |
-
aria-label={`Last run: ${s.node.status}`}
|
| 165 |
-
/>
|
| 166 |
-
</span>
|
| 167 |
-
<span className="auto-step-sub">{s.node.subtitle}</span>
|
| 168 |
-
{s.node.detail ? (
|
| 169 |
-
<span className="auto-step-detail">{s.node.detail}</span>
|
| 170 |
-
) : null}
|
| 171 |
-
</button>
|
| 172 |
-
{s.node.toggle ? (
|
| 173 |
-
<button
|
| 174 |
-
type="button"
|
| 175 |
-
className={"auto-step-switch" + (s.node.enabled ? " is-on" : "")}
|
| 176 |
-
disabled={busyNode === s.node.id}
|
| 177 |
-
aria-pressed={s.node.enabled}
|
| 178 |
-
aria-label={`${s.node.enabled ? "Turn off" : "Turn on"} ${s.node.title}`}
|
| 179 |
-
title={`${s.node.enabled ? "Turn off" : "Turn on"} ${s.node.title}`}
|
| 180 |
-
onClick={(e) => {
|
| 181 |
-
e.stopPropagation();
|
| 182 |
-
onToggle(s.node.id);
|
| 183 |
-
}}
|
| 184 |
-
>
|
| 185 |
-
<span className="auto-step-switch-knob" />
|
| 186 |
-
</button>
|
| 187 |
-
) : (
|
| 188 |
-
// A step with no honest switch says so rather than carrying a control that
|
| 189 |
-
// would do nothing — "every step toggleable" ends where a real behaviour
|
| 190 |
-
// change ends.
|
| 191 |
-
<span className="auto-step-always" title="This step is what the automation is">
|
| 192 |
-
Always
|
| 193 |
-
</span>
|
| 194 |
-
)}
|
| 195 |
-
</div>
|
| 196 |
-
</li>
|
| 197 |
-
))}
|
| 198 |
-
</ol>
|
| 199 |
-
</div>
|
| 200 |
-
);
|
| 201 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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