easy_flow 0.41.0 → 0.43.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.
- checksums.yaml +4 -4
- data/app/assets/builds/easy_flow/canvas.js +1 -1
- data/app/controllers/concerns/easy_flow/manage/draws_canvas.rb +1 -0
- data/app/helpers/easy_flow/run_view_helper.rb +12 -0
- data/app/javascript/easy_flow/canvas/Canvas.jsx +97 -70
- data/app/javascript/easy_flow/canvas/GroupHeader.jsx +6 -2
- data/app/javascript/easy_flow/canvas/Joint.jsx +25 -0
- data/app/javascript/easy_flow/canvas/LeftToRight.jsx +36 -0
- data/app/javascript/easy_flow/canvas/Placeholder.jsx +6 -2
- data/app/javascript/easy_flow/canvas/RunCard.jsx +35 -0
- data/app/javascript/easy_flow/canvas/RunView.jsx +15 -0
- data/app/javascript/easy_flow/canvas/StepCard.jsx +14 -6
- data/app/javascript/easy_flow/canvas/reading.js +37 -0
- data/app/javascript/easy_flow/canvas.jsx +2 -0
- data/app/models/easy_flow/run_view.rb +56 -0
- data/lib/easy_flow/engine.rb +4 -0
- data/lib/easy_flow/host.rb +5 -1
- data/lib/easy_flow/version.rb +1 -1
- data/the_local/agents/easy_flow-develop.md +31 -1
- data/the_local/agents/easy_flow-info.md +2 -0
- data/the_local/agents/easy_flow-install.md +3 -0
- metadata +8 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 903a5d34c101287d43a0152f92ae6e4cf582b6c06e3597feae978cc993ff2ee6
|
|
4
|
+
data.tar.gz: e1adcecbe09283626afd2146e46c89fde75584f9c23943bbb3290479c67fbdbf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7eed3b85ed030cf3078d369b02f8a0bf284ccfe892777c65ee81becaab605a2224eb124d56a52ef322cfbcf550fb4014cc984d2b665d17056fb2cc1cd2ba2748
|
|
7
|
+
data.tar.gz: 1924e948c03d18afa05055947053caf60304d72ad61e27dd6d5907fa10e99ab80653fce36aa74512ae3ab9046aa40ae32bb38fbbbad83c6aa32f8c81217a0f6d
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var Rt=globalThis.ReactDOM;var{createPortal:oo,createRoot:rt,flushSync:ro,hydrateRoot:no,preconnect:so,prefetchDNS:ao,preinit:io,preinitModule:lo,preload:co,preloadModule:po,requestFormReset:uo,unstable_batchedUpdates:mo,useFormState:fo,useFormStatus:go,version:ho}=Rt;var nt=globalThis.React,e=nt,{Children:xo,Component:bo,Fragment:vo,PureComponent:ko,StrictMode:wo,Suspense:Co,cloneElement:No,createContext:So,createElement:Bo,createRef:zo,forwardRef:_o,isValidElement:Eo,lazy:To,memo:Do,startTransition:Ao,useCallback:Oo,useContext:Po,useDebugValue:$o,useDeferredValue:Mo,useEffect:P,useId:Lo,useImperativeHandle:Io,useLayoutEffect:st,useMemo:$,useReducer:Ho,useRef:J,useState:w,useSyncExternalStore:jo,useTransition:Wo}=nt;var at=new Map,j=new Map,it=(t,o)=>at.set(t,o),lt=()=>{j.forEach(t=>t.unmount()),j.clear()},dt=(t,o)=>t.querySelectorAll("[data-react-ui]").forEach(n=>{if(j.has(n))return;let r=at.get(n.dataset.reactUi),a=o(n);j.set(n,a),a.render(e.createElement(r,JSON.parse(n.dataset.props)))});var ct=(t,o)=>{let n=()=>dt(t,o);t.addEventListener("turbo:load",n),t.addEventListener("turbo:frame-load",n),t.addEventListener("turbo:before-cache",lt),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",n):n()};var _=(...t)=>t.filter(Boolean).join(" ");var te={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},ee={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},oe=({variant:t="primary",size:o="md",className:n,children:r,...a})=>{let d=a.href?"a":"button";return e.createElement(d,{...a,className:_("ks-button",te[t],ee[o],n)},r)},k=oe;var re="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",ne="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",se="border border-accent-600 bg-accent-600 text-white",ae=({name:t,connected:o,armed:n,onArm:r,connecting:a})=>e.createElement("button",{onClick:d=>{a||(d.stopPropagation(),r(d))},title:n?"Now choose a step to connect to":"Connect this branch",className:n?se:o?ne:re,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),pt=ae;var ie={width:240,boxSizing:"border-box",borderRadius:8},le={padding:"8px 14px",textAlign:"center",fontWeight:600},de={fontWeight:600,lineHeight:1.3},ce=(t,o,n)=>{let r=n?"ring-4 ring-accent-600/15":"shadow-sm";return t||n&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},pe=(t,o)=>o&&t.label===t.id&&t.type_name||t.label,ue=(t,o,n)=>n?o===t.type_name?null:t.type_name:t.type,me=({node:t,selected:o,armed:n,connecting:r,onSelect:a,onOpen:d,onArm:u,onDragEnd:i,onDragStart:p,hideStepTypeCodes:x})=>{let b=t.begins_here||t.ends_here,m=t.begins_here,g=t.ends_here?[]:t.ports,h=r&&!m,l=pe(t,x),v=ue(t,l,x);return e.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!m,onDragStart:f=>{f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",t.id),p()},onDragEnd:i,onClick:t.opens&&!r?()=>d(t.opens):a,className:`bg-white border-2 dark:bg-zinc-900 ${ce(h,t.violations.length>0,o)}`,style:{...ie,padding:b?0:"12px 14px",cursor:m?"default":r?"crosshair":"grab"}},b&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:le},l),!b&&e.createElement("div",{style:de},l),!b&&v&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},v),t.picture_url&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&e.createElement(k,{variant:"secondary",size:"sm",className:"mt-2",onClick:f=>{f.stopPropagation(),a()}},"Settings"),t.violations.map(f=>e.createElement("div",{key:f.problem+f.detail,className:"text-red-600 dark:text-red-400",style:{fontSize:11,padding:"0 14px 6px"}},f.sentence)),g.length>0&&e.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},g.map(f=>e.createElement(pt,{key:f,name:f,connected:t.connected.includes(f),connecting:r,armed:n===f,onArm:C=>u(f,C)}))))},K=me;var fe=({node:t,header:o,onSelect:n})=>e.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:n,className:"font-mono text-gray-500 dark:text-gray-400",style:{position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"}},o),ut=fe;var ge=({id:t,bounds:o,onDrop:n})=>e.createElement("div",{"data-group-box":t,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),n()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...o}}),mt=ge;var he=t=>t!=null&&t!==""&&typeof t!="object",ye=["integer","float"],xe=(t,o,n)=>n&&o.labels?.[t]||t,ft=(t,o,n)=>{let r=Object.keys(o?.fields||{}).filter(a=>he(t.config[a])).map(a=>`${xe(a,o,n)}${ye.includes(o.fields[a])?"":":"} ${t.config[a]}`);return[n&&t.type_name||t.type,...r].join(" \xB7 ")};var gt=(t,o,n)=>{let r=Math.min(...t.map(i=>i.left))-o.left+n.scrollLeft-12,a=Math.min(...t.map(i=>i.top))-o.top+n.scrollTop-10,d=Math.max(...t.map(i=>i.left+i.width))-o.left+n.scrollLeft+12,u=Math.max(...t.map(i=>i.top+i.height))-o.top+n.scrollTop+10;return{left:r,top:a,width:d-r,height:u-a}},be=({left:t,top:o,width:n,height:r},a)=>a.x>=t&&a.x<=t+n&&a.y>=o&&a.y<=o+r,ht=(t,o)=>t.find(n=>be(n.bounds,o))?.id||null,yt=(t,o)=>t.filter(n=>!o.some(r=>r.id===n.source&&r.holds?.includes(n.target))),xt=(t,o)=>o.some(n=>n.holds?.includes(t.id)&&!n.loose&&n.row===t.row-1);var Z=(t,o)=>t.includes(o)?t.filter(n=>n!==o):[...t,o],bt=(t,o)=>({...o?.choices||{},...t?.choices||{}});var ve=({as:t="input",disabled:o,className:n,...r})=>e.createElement(t,{...r,disabled:o,className:_("ks-input",o&&"ks-input-disabled",n)}),A=ve;var ke=t=>e.createElement(A,{...t,as:"select"}),vt=ke;var we=({className:t,...o})=>e.createElement("input",{type:"checkbox",...o,className:_("ks-checkbox",t)}),W=we;var kt=t=>(t||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),Ce=({type:t,value:o,choices:n,onChange:r,onSettle:a,onPick:d,pictureUrl:u})=>{if(t==="picture")return e.createElement("div",{className:"mb-3"},o&&u&&e.createElement("img",{src:u,alt:"The step's picture",style:{maxWidth:"100%"}}),o&&e.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>a("")},"Remove picture"),e.createElement("input",{type:"file",accept:"image/*",onChange:i=>i.target.files[0]&&d(i.target.files[0])}));if(t==="boolean")return e.createElement(W,{checked:!!o,onChange:i=>a(i.target.checked)});if(t==="select"||t==="previous_step"||t==="from_step"||t==="flow")return e.createElement(vt,{className:"mb-3",value:o??"",onChange:i=>a(i.target.value)},e.createElement("option",{value:""}),kt(n).map(i=>e.createElement("option",{key:i.value,value:i.value},i.label)));if(t==="multi_select"){let i=Array.isArray(o)?o:[],p=x=>a(Z(i,x));return e.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(n||[]).map(x=>e.createElement("label",{key:x,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(W,{checked:i.includes(x),onChange:()=>p(x)}),e.createElement("span",null,x))))}if(t==="flows"){let i=Array.isArray(o)?o:[];return e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},kt(n).map(p=>e.createElement("label",{key:p.value,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(W,{checked:i.includes(p.value),onChange:()=>a(Z(i,p.value))}),e.createElement("span",null,p.label))))}return t==="integer"||t==="float"?e.createElement(A,{className:"mb-3",type:"number",step:t==="integer"?"1":"any",value:o??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)}):e.createElement(A,{className:"mb-3",type:"text",value:o??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)})},F=Ce;var wt=(t,o,n,r)=>t.map((a,d)=>d===o?{...a,[n]:r}:a);var Ne=({text:t})=>e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),V=Ne;var Se=(t,o,n,r)=>{let a=(t||{})[n],d=(o||{})[n];return d?(a||{})[r[d]]:a},Be=({holds:t,labels:o,explanations:n,rows:r,choices:a,outputsOf:d,onChange:u,onSettle:i})=>{let p=Array.isArray(r)?r:[],x=(b,m,g,h)=>{let l=wt(p,b,m,g);h?i(l):u(l)};return e.createElement("div",{style:{marginBottom:12}},p.map((b,m)=>e.createElement("div",{key:m,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([g,h])=>e.createElement("label",{key:g,style:{display:"block"}},e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[g]||g),e.createElement(F,{type:h,value:b[g],choices:Se(a,d,g,b),onChange:l=>x(m,g,l,!1),onSettle:l=>x(m,g,l,!0)}),(n||{})[g]&&e.createElement(V,{text:n[g]}))),e.createElement(k,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>i(p.filter((g,h)=>h!==m))},"Remove"))),e.createElement(k,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>i([...p,{}])},"Add"))},Ct=Be;var ze=({as:t="div",className:o,children:n,...r})=>e.createElement(t,{...r,className:_("ks-panel",o)},n),M=ze;var U=(t,o)=>({className:n,children:r,...a})=>e.createElement(t,{...a,className:_(o,n)},r),H=U("label","ks-label"),Wr=U("p","ks-hint"),Fr=U("p","ks-error"),Vr=U("span","ks-required");var _e={width:280,padding:20,overflowY:"auto"},Ee=({node:t,fields:o,holds:n,labels:r,explanations:a,recordLabels:d,recordExplanations:u,recordChoices:i,recordOutputsOf:p,choices:x,onSave:b,onDelete:m,onClose:g,onPickPicture:h,refusal:l})=>{let[v,f]=w(t.config),[C,E]=w(t.picture_url);P(()=>E(t.picture_url),[t.id,t.picture_url]),P(()=>f(t.config),[t.id,t.config]);let N=y=>{f(y),JSON.stringify(y)!==JSON.stringify(t.config)&&b(y)};return e.createElement(M,{as:"aside",style:_e,"data-inspector":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},e.createElement("h2",{style:{fontWeight:600,marginBottom:2}},t.label),e.createElement("button",{title:"Close",onClick:g,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:16}},t.id," \xB7 ",t.type),l&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},l),Object.entries(o).map(([y,S])=>e.createElement(H,{key:y},e.createElement("span",{style:{display:"block",marginBottom:3}},r[y]||y),S==="list"?e.createElement(Ct,{holds:n[y]||{},labels:d[y]||{},explanations:(u||{})[y],rows:v[y],choices:{...(i||{})[y],...(t.record_choices||{})[y]},outputsOf:(p||{})[y],onChange:z=>f({...v,[y]:z}),onSettle:z=>N({...v,[y]:z})}):e.createElement(F,{type:S,value:v[y],choices:x[y],pictureUrl:C,onChange:z=>f({...v,[y]:z}),onSettle:z=>N({...v,[y]:z}),onPick:async z=>{let L=await h(z);L&&(E(L.url),N({...v,[y]:L.reference}))}}),(a||{})[y]&&e.createElement(V,{text:a[y]}))),e.createElement(k,{variant:"danger",size:"sm",className:"w-full",onClick:m},"Delete step"))},Nt=Ee;var Te={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},De="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",Ae="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Oe=({node:t,dragging:o,onFill:n,onDrop:r})=>e.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:n,onDragOver:a=>{o&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDrop:a=>{a.preventDefault(),r()},className:o?Ae:De,style:Te},e.createElement("div",{style:{fontWeight:600}},t.label),e.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),St=Oe;var Pe=({entries:t,at:o,onPick:n,onConnect:r,onDismiss:a,hideStepTypeCodes:d})=>e.createElement(M,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(u=>e.createElement(k,{key:u.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>n(u)},u.label,!d&&e.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},u.type))),r&&e.createElement(k,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),e.createElement(k,{variant:"secondary",size:"sm",className:"w-full",onClick:a},"Cancel")),Bt=Pe;var $e={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},zt=({label:t,title:o,idle:n,enabled:r,onUse:a})=>e.createElement(k,{variant:"secondary",size:"sm",title:r?o:n,disabled:!r,onClick:a,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),Me=({undoable:t,redoable:o,onAdd:n,onUndo:r,onRedo:a})=>e.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},e.createElement(k,{variant:"secondary",className:"rounded-full",style:$e,title:"Add a step",onClick:n},"+"),e.createElement(zt,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),e.createElement(zt,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:a})),_t=Me;var Le=({type:t="info",title:o,message:n,onDismiss:r,className:a})=>e.createElement("div",{className:_("ks-alert",`ks-alert-${t}`,a),role:"alert"},e.createElement("div",{className:"ks-alert-body"},e.createElement("div",{className:"ks-alert-content"},o&&e.createElement("p",{className:"ks-alert-title"},o),e.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},n)),r&&e.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),Et=Le;var Tt=t=>{let o=t.map(n=>`\u201C${n.name}\u201D`).join(", ");return t.length===1?`${o} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${o} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Dt=({version:t,published:o})=>t?o?o===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${o}`:`Version ${t} \xB7 never published`:"No version yet";var Ie={width:280,padding:20,overflowY:"auto"},Q={fontWeight:600,marginBottom:6,marginTop:14},Y={fontSize:12,marginBottom:4,lineHeight:1.4},At={display:"block",marginBottom:3},Ot=(t,o,n)=>r=>{r.target.value!==(t[o]??"")&&n({[o]:r.target.value})},He=({flow:t,changes:o,problems:n,refusal:r,notice:a,publishNote:d,warning:u,onCreate:i,onPublish:p,onAccept:x,onDecline:b,onSaveDetails:m,onClose:g})=>e.createElement(M,{as:"aside",style:Ie,"data-builder-panel":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},e.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),e.createElement("button",{title:"Close",onClick:g,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),e.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},Dt(t)),u?e.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},e.createElement(Et,{type:"warning",className:"mb-1.5",message:Tt(u.steps)}),e.createElement(k,{size:"sm",className:"w-full mb-1.5",onClick:x,"data-accept-removal":!0},u.path==="/publish"?"Remove and publish":"Remove and create version"),e.createElement(k,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:b,"data-decline-removal":!0},"Cancel")):e.createElement("div",{style:{marginTop:14}},e.createElement(k,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:i,"data-create-version":!0},"Create version"),e.createElement(k,{size:"sm",className:"w-full mb-1.5",onClick:p,"data-publish":!0},"Publish"),d&&e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},d)),e.createElement("h2",{style:Q},"Problems"),r&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...Y,fontWeight:600},"data-refusal":!0},r),a&&!r&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...Y,fontWeight:600},"data-notice":!0},a),n.length===0&&!r?e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing wrong with this flow."):n.map(h=>e.createElement("p",{key:`${h.node}-${h.problem}`,className:"text-amber-700 dark:text-amber-400",style:Y,"data-problem":!0},"\u26A0 ",h.sentence)),e.createElement("h2",{style:Q},"Changes since the last version"),o.length===0?e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((h,l)=>e.createElement("p",{key:l,style:Y,"data-change":!0},h)),e.createElement("h2",{style:Q},"Details"),e.createElement(H,null,e.createElement("span",{style:At},"Title"),e.createElement(A,{className:"mb-3",defaultValue:t.title??"",onBlur:Ot(t,"title",m),"data-flow-title":!0})),e.createElement(H,null,e.createElement("span",{style:At},"Start label"),e.createElement(A,{className:"mb-3",defaultValue:t.start_label??"",onBlur:Ot(t,"start_label",m),"data-flow-start-label":!0})),e.createElement("div",{style:{marginTop:16}},e.createElement(k,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),e.createElement(k,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),Pt=He;var $t={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Mt=t=>({opacity:t?1:0,transition:"opacity .12s"}),je=({link:t,onInsert:o,onRemove:n,onDrop:r,dragging:a,alwaysShowInsertButtons:d})=>{let[u,i]=w(!1),p=u||a;return e.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},onDrop:x=>{x.preventDefault(),i(!1),r()}},e.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},e.createElement(k,{variant:"secondary",title:a?"Move the step here":"Insert a step here",onClick:o,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(a&&u),style:{...$t,...Mt(p||d)}},"+"),!a&&e.createElement(k,{variant:"danger",title:"Remove this connection",onClick:n,className:"rounded-full",style:{...$t,...Mt(p)}},"\xD7")))},Lt=je;var We=({links:t,extent:o,dragging:n,onInsert:r,onRemove:a,onDrop:d,alwaysShowInsertButtons:u})=>e.createElement(e.Fragment,null,e.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(i=>e.createElement("path",{key:i.id,"data-link":i.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:i.path}))),t.filter(i=>i.label).map(i=>e.createElement("div",{key:`${i.id}-label`,"data-link-label":i.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:i.midX+(u?2:-10),top:i.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},i.label)),t.filter(i=>!i.placeholder).map(i=>e.createElement(Lt,{key:i.id,link:i,dragging:!!n,alwaysShowInsertButtons:u,onInsert:()=>r(i),onRemove:()=>a(i),onDrop:()=>d(i)}))),It=We;var Ht="Your change was not saved because the server could not be reached.",jt=({base:t,token:o,fetch:n,onFlow:r,onError:a,onNotice:d,onWarning:u=()=>{}})=>async(i,p,x)=>{let b=await n(t+i,{method:p,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:x&&JSON.stringify(x)}).catch(()=>null);if(!b)return d(null),a(Ht);let m=await b.json().catch(()=>({}));if(m.unconnected)return d(null),a(null),u({path:i,steps:m.unconnected}),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json());if(u(null),!b.ok)return d(null),a(m.error||"That change was refused");a(null),d(m.notice||null),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json())},Wt=({base:t,token:o,fetch:n,onError:r})=>async a=>{let d=new FormData;d.append("picture",a);let u=await n(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:d}).catch(()=>null);if(!u)return r(Ht),null;let i=await u.json().catch(()=>({}));return u.ok?(r(null),i):(r(i.error||"That picture was refused"),null)};var Fe=(t,o,n)=>{let[r,a]=w(n),[d,u]=w(null),[i,p]=w(null),[x,b]=w(null),m=$(()=>jt({base:t,token:o,fetch:(...h)=>window.fetch(...h),onFlow:a,onError:u,onNotice:p,onWarning:b}),[t,o]),g=$(()=>Wt({base:t,token:o,fetch:(...h)=>window.fetch(...h),onError:u}),[t,o]);return{flow:r,error:d,notice:i,warning:x,setWarning:b,send:m,pickPicture:g}},Ft=Fe;var G=(t,o,n,r)=>{let a=t.left-n.left+r.scrollLeft,d=t.top-n.top+r.scrollTop;return o==="left"?{x:a,y:d+t.height/2}:o==="right"?{x:a+t.width,y:d+t.height/2}:o==="top"?{x:a+t.width/2,y:d}:{x:a+t.width/2,y:d+t.height}},Ve=(t,o,n)=>n&&o==="top"?{x:t.x,y:n.top}:t,Ue=(t,o)=>o==="top"?{x:t.x,y:t.y-3}:o==="left"?{x:t.x-3,y:t.y}:o==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},Ye=(t,o,n,r,a)=>{let d={straight:`M ${o.x} ${o.y} L ${n.x} ${n.y}`,turn:`M ${o.x} ${o.y} H ${n.x} V ${n.y}`,lane:`M ${o.x} ${o.y} V ${r} H ${n.x} V ${n.y}`,detour:`M ${o.x} ${o.y} H ${a} V ${n.y} H ${n.x}`}[t.route];return{...t,path:d,midX:t.route==="detour"?a:(o.x+n.x)/2,midY:t.route==="lane"?r:(o.y+n.y)/2}},Ge=(t,o,n,r)=>{let[a,d]=w([]),[u,i]=w({width:"100%",height:"100%"}),[p,x]=w([]);return st(()=>{let b=()=>{let g=o.current?.getBoundingClientRect();if(!g)return;i({width:o.current.scrollWidth,height:o.current.scrollHeight});let h=t.nodes.filter(l=>l.holds&&!l.loose&&n.current[l.id]).map(l=>{let v=n.current[l.id],f=v.getBoundingClientRect(),C=l.holds.flatMap(N=>n.current[N]?[n.current[N].getBoundingClientRect()]:[]),E=[{left:f.left,top:f.top,width:Math.max(f.width,v.scrollWidth),height:f.height},...C];return{id:l.id,bounds:gt(E,g,o.current)}});x(h),d(t.edges.flatMap(l=>{let v=n.current[l.source]?.getBoundingClientRect(),f=n.current[l.target]?.getBoundingClientRect();if(!v||!f)return[];let C=G(v,l.leaves,g,o.current),E=h.find(z=>z.id===l.target)?.bounds,N=Ue(Ve(G(f,l.enters,g,o.current),l.enters,E),l.enters),y=(G(v,"bottom",g,o.current).y+G(f,"top",g,o.current).y)/2,S=l.leaves==="left"?Math.min(C.x,N.x)-28:Math.max(C.x,N.x)+28;return[Ye(l,C,N,y,S)]}))};b(),window.addEventListener("resize",b);let m=new ResizeObserver(b);return o.current&&m.observe(o.current),()=>{window.removeEventListener("resize",b),m.disconnect()}},r),{links:a,extent:u,boxes:p}},Vt=Ge;var Ut=(t,o)=>{let n=new Set(o),r=t,a=2;for(;n.has(r);)r=`${t}_${a++}`;return r};var qe=8,Je={display:"flex",height:"100%",minHeight:0,fontSize:13},Ke={flex:1,overflow:"auto",position:"relative"},Ze={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Qe={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Re={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},to=({port:t,onCancel:o})=>e.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Re},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",e.createElement("button",{onClick:o,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),eo=({base:t,token:o,initial:n})=>{let{flow:r,error:a,notice:d,warning:u,setWarning:i,send:p,pickPicture:x}=Ft(t,o,n),[b,m]=w(null),[g,h]=w(null),[l,v]=w(null),[f,C]=w(null),[E,N]=w(!1),y=J({}),S=J(null);P(()=>{let s=()=>{m(null),N(!0)};return document.addEventListener("easy_flow:open-flow",s),()=>document.removeEventListener("easy_flow:open-flow",s)},[]),P(()=>{if(!E){i(null);return}let s=c=>{c.target.isConnected&&!c.target.closest("[data-builder-panel], [data-open-panel]")&&N(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[E]),P(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]);let z=$(()=>Object.fromEntries(r.nodes.map(s=>[s.id,s])),[r.nodes]),{links:L,extent:Xt,boxes:R}=Vt(r,S,y,[r,b,z]),tt=$(()=>{let s={};return r.violations.forEach(c=>{var B;return(s[B=c.node]||(s[B]=[])).push(c)}),s},[r.violations]),X=r.nodes.filter(s=>!s.loose),et=r.nodes.filter(s=>s.loose),qt=Math.max(0,...X.map(s=>s.row))+1,Jt=Math.max(0,...X.map(s=>s.column))+1,q=s=>{if(!l)return;let[c,B]=l;v(null),c!==s&&p("/edges","POST",{from:c,to:s,on:B||null})},Kt=s=>{if(s.isDefaultPrevented()||!f)return;s.preventDefault();let c=f;C(null);let B=S.current.getBoundingClientRect(),I=ht(R,{x:s.clientX-B.left+S.current.scrollLeft,y:s.clientY-B.top+S.current.scrollTop}),Zt=r.nodes.find(Qt=>Qt.holds?.includes(c))?.id||null;I!==Zt&&p(`/steps/${c}/group`,"PATCH",{group:I})},ot=s=>[...r.palette,...r.unoffered||[]].find(c=>c.type===s?.type),O=r.nodes.find(s=>s.id===b),T=ot(O);return e.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Je,onMouseUp:()=>C(null),onKeyDown:s=>{s.key==="Escape"&&(m(null),v(null),h(null))},tabIndex:-1},e.createElement("div",{ref:S,className:"bg-surface-50 dark:bg-surface-950",style:Ke,onClick:s=>{s.target===S.current&&(m(null),v(null),N(!1))},onDragOver:s=>{f&&s.preventDefault()},onDrop:Kt},l&&e.createElement(to,{port:l[1],onCancel:()=>v(null)}),e.createElement(_t,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>h({at:{x:16,y:52}}),onUndo:()=>{m(null),p("/undo","POST")},onRedo:()=>{m(null),p("/redo","POST")}}),R.map(s=>e.createElement(mt,{key:s.id,id:s.id,bounds:s.bounds,onDrop:()=>{let c=f;C(null),c&&p(`/steps/${c}/group`,"PATCH",{group:s.id})}})),e.createElement(It,{links:yt(L,r.nodes),extent:Xt,dragging:f,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:s=>h({from:s.source,to:s.target,at:{x:s.midX+30,y:s.midY}}),onRemove:s=>{m(null),p("/edges","DELETE",{from:s.source,to:s.target})},onDrop:s=>{let c=f;C(null),p("/steps/"+c+"/move","PATCH",{from:s.source,to:s.target})}}),et.length>0&&e.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:Ze},e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),et.map(s=>e.createElement("div",{key:s.id,style:{marginBottom:8}},e.createElement(K,{node:{...s,ref:c=>{y.current[s.id]=c},violations:tt[s.id]||[],connected:[]},selected:b===s.id,armed:l&&l[0]===s.id?l[1]:null,connecting:!!l,onSelect:()=>l?q(s.id):m(s.id),onOpen:c=>window.location.assign(c),onArm:(c,B)=>{B.stopPropagation(),v([s.id,c])},onDragStart:()=>C(s.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes})))),e.createElement("div",{style:{...Qe,gridTemplateColumns:`repeat(${Jt+1}, ${280/2}px)`,gridTemplateRows:`repeat(${qt}, auto)`}},X.map(s=>e.createElement("div",{key:s.id,style:{gridRow:s.row+1,gridColumn:`${s.column+1} / span 2`,zIndex:2,marginTop:xt(s,r.nodes)?qe-64:0}},s.placeholder&&e.createElement(St,{node:{...s,ref:c=>{y.current[s.id]=c}},dragging:!!f,onFill:()=>h({from:s.from,on:s.on,at:{x:16,y:52}}),onDrop:()=>{let c=f;C(null),c&&p("/edges","POST",{from:s.from,to:c,on:s.on})}}),s.holds&&e.createElement(ut,{node:{...s,ref:c=>{y.current[s.id]=c}},header:ft(s,ot(s),r.hide_step_type_codes),onSelect:()=>l?q(s.id):m(s.id)}),!s.placeholder&&!s.holds&&e.createElement(K,{node:{...s,ref:c=>{y.current[s.id]=c},violations:tt[s.id]||[],connected:r.edges.filter(c=>c.source===s.id).map(c=>c.label||null)},selected:s.id===b,armed:l&&l[0]===s.id?l[1]:null,connecting:!!l&&l[0]!==s.id,onSelect:()=>l?q(s.id):m(s.id),onOpen:c=>window.location.assign(c),onArm:(c,B)=>{let I=S.current.getBoundingClientRect();h({from:s.id,on:c,at:{x:B.clientX-I.left+S.current.scrollLeft+8,y:B.clientY-I.top+S.current.scrollTop+8}})},onDragEnd:()=>C(null),onDragStart:()=>C(s.id),hideStepTypeCodes:r.hide_step_type_codes})))),g&&e.createElement(Bt,{entries:r.palette,at:g.at,onDismiss:()=>h(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:g.on!==void 0?()=>{v([g.from,g.on]),h(null)}:null,onPick:s=>{let c=g;h(null),p("/steps","POST",{id:Ut(s.type,r.nodes.map(B=>B.id)),type:s.type,from:c.from,to:c.to,on:c.on})}})),E&&!O&&e.createElement(Pt,{flow:r.flow||{},changes:r.changes||[],problems:r.violations,refusal:a,notice:d,publishNote:r.publish_note,warning:u,onClose:()=>N(!1),onCreate:()=>p("/versions","POST"),onPublish:()=>p("/publish","POST"),onAccept:()=>p(u.path,"POST",{remove_unconnected:u.steps.map(s=>s.id)}),onDecline:()=>i(null),onSaveDetails:s=>p("/details","PATCH",{flow:s})}),O&&e.createElement(Nt,{node:O,fields:T?.fields||{},holds:T?.records||{},labels:T?.labels||{},explanations:T?.explanations||{},recordLabels:T?.record_labels||{},recordExplanations:T?.record_explanations||{},recordChoices:T?.record_choices||{},recordOutputsOf:T?.record_outputs_of||{},choices:bt(O,T),onClose:()=>m(null),onSave:s=>p(`/steps/${O.id}`,"PATCH",{config:s}),onPickPicture:x,refusal:a,onDelete:()=>{m(null),p(`/steps/${O.id}`,"DELETE")}}))},Gt=eo;it("easy_flow/flow-editor",Gt);document.addEventListener("easy_flow:flow-named",t=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=t.detail)});ct(document,rt);})();
|
|
1
|
+
(()=>{var be=globalThis.ReactDOM;var{createPortal:Wo,createRoot:ct,flushSync:Vo,hydrateRoot:Fo,preconnect:Uo,prefetchDNS:Yo,preinit:Go,preinitModule:Xo,preload:Jo,preloadModule:qo,requestFormReset:Ko,unstable_batchedUpdates:Zo,useFormState:Qo,useFormStatus:Ro,version:tr}=be;var pt=globalThis.React,o=pt,{Children:or,Component:rr,Fragment:nr,PureComponent:sr,StrictMode:ar,Suspense:ir,cloneElement:lr,createContext:dr,createElement:cr,createRef:pr,forwardRef:ur,isValidElement:mr,lazy:fr,memo:gr,startTransition:hr,useCallback:yr,useContext:xr,useDebugValue:br,useDeferredValue:vr,useEffect:P,useId:wr,useImperativeHandle:kr,useLayoutEffect:ut,useMemo:L,useReducer:Cr,useRef:R,useState:S,useSyncExternalStore:Sr,useTransition:Nr}=pt;var mt=new Map,V=new Map,tt=(t,e)=>mt.set(t,e),ft=()=>{V.forEach(t=>t.unmount()),V.clear()},gt=(t,e)=>t.querySelectorAll("[data-react-ui]").forEach(n=>{if(V.has(n))return;let r=mt.get(n.dataset.reactUi),a=e(n);V.set(n,a),a.render(o.createElement(r,JSON.parse(n.dataset.props)))});var ht=(t,e)=>{let n=()=>gt(t,e);t.addEventListener("turbo:load",n),t.addEventListener("turbo:frame-load",n),t.addEventListener("turbo:before-cache",ft),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",n):n()};var _=(...t)=>t.filter(Boolean).join(" ");var ve={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},we={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},ke=({variant:t="primary",size:e="md",className:n,children:r,...a})=>{let l=a.href?"a":"button";return o.createElement(l,{...a,className:_("ks-button",ve[t],we[e],n)},r)},w=ke;var Ce="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Se="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Ne="border border-accent-600 bg-accent-600 text-white",ze=({name:t,connected:e,armed:n,onArm:r,connecting:a})=>o.createElement("button",{onClick:l=>{a||(l.stopPropagation(),r(l))},title:n?"Now choose a step to connect to":"Connect this branch",className:n?Ne:e?Se:Ce,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),yt=ze;var Be={width:240,boxSizing:"border-box",borderRadius:8},Te={minWidth:120,boxSizing:"border-box",borderRadius:6},_e={padding:"8px 14px",textAlign:"center",fontWeight:600},Ee={fontWeight:600,lineHeight:1.3},De={fontSize:12,fontWeight:500,lineHeight:1.3},Ae=(t,e,n)=>{let r=n?"ring-4 ring-accent-600/15":"shadow-sm";return t||n&&!e?`border-accent-600 ${r}`:e?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},Oe=(t,e)=>e&&t.label===t.id&&t.type_name||t.label,$e=(t,e,n)=>n?e===t.type_name?null:t.type_name:t.type,Pe=({node:t,selected:e,armed:n,connecting:r,onSelect:a,onOpen:l,onArm:c,onDragEnd:i,onDragStart:u,hideStepTypeCodes:y,branches:b=[],compact:m=!1})=>{let f=t.begins_here||t.ends_here,g=t.begins_here,p=t.ends_here?[]:t.ports,k=r&&!g,v=Oe(t,y),C=$e(t,v,y);return o.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!g,onDragStart:x=>{x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",t.id),u()},onDragEnd:i,onClick:t.opens&&!r?()=>l(t.opens):a,className:`bg-white ${m&&!e?"border":"border-2"} dark:bg-zinc-900 ${Ae(k,t.violations.length>0,e)}`,style:{...m?Te:Be,padding:f?0:m?"8px 10px":"12px 14px",cursor:g?"default":r?"crosshair":"grab"}},!f&&m&&C&&o.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},C),f&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:_e},v),!f&&o.createElement("div",{style:m?De:Ee},v),!f&&!m&&C&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},C),t.picture_url&&o.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&o.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&o.createElement(w,{variant:"secondary",size:"sm",className:"mt-2",onClick:x=>{x.stopPropagation(),a()}},"Settings"),b.map(x=>o.createElement("div",{key:x,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},x)),t.violations.map(x=>o.createElement("div",{key:x.problem+x.detail,className:"text-red-600 dark:text-red-400",style:{fontSize:11,padding:"0 14px 6px"}},x.sentence)),p.length>0&&o.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},p.map(x=>o.createElement(yt,{key:x,name:x,connected:t.connected.includes(x),connecting:r,armed:n===x,onArm:N=>c(x,N)}))))},et=Pe;var xt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},Le={...xt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},Ie=({node:t,header:e,onSelect:n,compact:r=!1})=>o.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:n,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?Le:xt,...n?{}:{cursor:"default"}}},e),F=Ie;var Me=({id:t,bounds:e,onDrop:n})=>o.createElement("div",{"data-group-box":t,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),n()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...e}}),bt=Me;var He=t=>t!=null&&t!==""&&typeof t!="object",je=["integer","float"],We=(t,e,n)=>n&&e.labels?.[t]||t,U=(t,e,n)=>{let r=Object.keys(e?.fields||{}).filter(a=>He(t.config[a])).map(a=>`${We(a,e,n)}${je.includes(e.fields[a])?"":":"} ${t.config[a]}`);return[n&&t.type_name||t.type,...r].join(" \xB7 ")};var vt=(t,e,n)=>{let r=Math.min(...t.map(i=>i.left))-e.left+n.scrollLeft-12,a=Math.min(...t.map(i=>i.top))-e.top+n.scrollTop-10,l=Math.max(...t.map(i=>i.left+i.width))-e.left+n.scrollLeft+12,c=Math.max(...t.map(i=>i.top+i.height))-e.top+n.scrollTop+10;return{left:r,top:a,width:l-r,height:c-a}},Ve=({left:t,top:e,width:n,height:r},a)=>a.x>=t&&a.x<=t+n&&a.y>=e&&a.y<=e+r,wt=(t,e)=>t.find(n=>Ve(n.bounds,e))?.id||null,kt=(t,e)=>t.filter(n=>!e.some(r=>r.id===n.source&&r.holds?.includes(n.target))),Ct=(t,e)=>e.some(n=>n.holds?.includes(t.id)&&!n.loose&&n.row===t.row-1);var ot=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],St=(t,e)=>({...e?.choices||{},...t?.choices||{}});var Fe=({as:t="input",disabled:e,className:n,...r})=>o.createElement(t,{...r,disabled:e,className:_("ks-input",e&&"ks-input-disabled",n)}),O=Fe;var Ue=t=>o.createElement(O,{...t,as:"select"}),Nt=Ue;var Ye=({className:t,...e})=>o.createElement("input",{type:"checkbox",...e,className:_("ks-checkbox",t)}),Y=Ye;var zt=t=>(t||[]).map(e=>typeof e=="object"?e:{value:e,label:e}),Ge=({type:t,value:e,choices:n,onChange:r,onSettle:a,onPick:l,pictureUrl:c})=>{if(t==="picture")return o.createElement("div",{className:"mb-3"},e&&c&&o.createElement("img",{src:c,alt:"The step's picture",style:{maxWidth:"100%"}}),e&&o.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>a("")},"Remove picture"),o.createElement("input",{type:"file",accept:"image/*",onChange:i=>i.target.files[0]&&l(i.target.files[0])}));if(t==="boolean")return o.createElement(Y,{checked:!!e,onChange:i=>a(i.target.checked)});if(t==="select"||t==="previous_step"||t==="from_step"||t==="flow")return o.createElement(Nt,{className:"mb-3",value:e??"",onChange:i=>a(i.target.value)},o.createElement("option",{value:""}),zt(n).map(i=>o.createElement("option",{key:i.value,value:i.value},i.label)));if(t==="multi_select"){let i=Array.isArray(e)?e:[],u=y=>a(ot(i,y));return o.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(n||[]).map(y=>o.createElement("label",{key:y,style:{display:"inline-flex",alignItems:"center",gap:4}},o.createElement(Y,{checked:i.includes(y),onChange:()=>u(y)}),o.createElement("span",null,y))))}if(t==="flows"){let i=Array.isArray(e)?e:[];return o.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},zt(n).map(u=>o.createElement("label",{key:u.value,style:{display:"inline-flex",alignItems:"center",gap:4}},o.createElement(Y,{checked:i.includes(u.value),onChange:()=>a(ot(i,u.value))}),o.createElement("span",null,u.label))))}return t==="integer"||t==="float"?o.createElement(O,{className:"mb-3",type:"number",step:t==="integer"?"1":"any",value:e??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)}):o.createElement(O,{className:"mb-3",type:"text",value:e??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)})},G=Ge;var Bt=(t,e,n,r)=>t.map((a,l)=>l===e?{...a,[n]:r}:a);var Xe=({text:t})=>o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),X=Xe;var Je=(t,e,n,r)=>{let a=(t||{})[n],l=(e||{})[n];return l?(a||{})[r[l]]:a},qe=({holds:t,labels:e,explanations:n,rows:r,choices:a,outputsOf:l,onChange:c,onSettle:i})=>{let u=Array.isArray(r)?r:[],y=(b,m,f,g)=>{let p=Bt(u,b,m,f);g?i(p):c(p)};return o.createElement("div",{style:{marginBottom:12}},u.map((b,m)=>o.createElement("div",{key:m,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([f,g])=>o.createElement("label",{key:f,style:{display:"block"}},o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(e||{})[f]||f),o.createElement(G,{type:g,value:b[f],choices:Je(a,l,f,b),onChange:p=>y(m,f,p,!1),onSettle:p=>y(m,f,p,!0)}),(n||{})[f]&&o.createElement(X,{text:n[f]}))),o.createElement(w,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>i(u.filter((f,g)=>g!==m))},"Remove"))),o.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>i([...u,{}])},"Add"))},Tt=qe;var Ke=({as:t="div",className:e,children:n,...r})=>o.createElement(t,{...r,className:_("ks-panel",e)},n),I=Ke;var J=(t,e)=>({className:n,children:r,...a})=>o.createElement(t,{...a,className:_(e,n)},r),W=J("label","ks-label"),zn=J("p","ks-hint"),Bn=J("p","ks-error"),Tn=J("span","ks-required");var Ze={width:280,padding:20,overflowY:"auto"},Qe=({node:t,fields:e,holds:n,labels:r,explanations:a,recordLabels:l,recordExplanations:c,recordChoices:i,recordOutputsOf:u,choices:y,onSave:b,onDelete:m,onClose:f,onPickPicture:g,refusal:p})=>{let[k,v]=S(t.config),[C,x]=S(t.picture_url);P(()=>x(t.picture_url),[t.id,t.picture_url]),P(()=>v(t.config),[t.id,t.config]);let N=h=>{v(h),JSON.stringify(h)!==JSON.stringify(t.config)&&b(h)};return o.createElement(I,{as:"aside",style:Ze,"data-inspector":!0},o.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},o.createElement("h2",{style:{fontWeight:600,marginBottom:2}},t.label),o.createElement("button",{title:"Close",onClick:f,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:16}},t.id," \xB7 ",t.type),p&&o.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},p),Object.entries(e).map(([h,z])=>o.createElement(W,{key:h},o.createElement("span",{style:{display:"block",marginBottom:3}},r[h]||h),z==="list"?o.createElement(Tt,{holds:n[h]||{},labels:l[h]||{},explanations:(c||{})[h],rows:k[h],choices:{...(i||{})[h],...(t.record_choices||{})[h]},outputsOf:(u||{})[h],onChange:T=>v({...k,[h]:T}),onSettle:T=>N({...k,[h]:T})}):o.createElement(G,{type:z,value:k[h],choices:y[h],pictureUrl:C,onChange:T=>v({...k,[h]:T}),onSettle:T=>N({...k,[h]:T}),onPick:async T=>{let M=await g(T);M&&(x(M.url),N({...k,[h]:M.reference}))}}),(a||{})[h]&&o.createElement(X,{text:a[h]}))),o.createElement(w,{variant:"danger",size:"sm",className:"w-full",onClick:m},"Delete step"))},_t=Qe;var Re={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},to={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},eo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",oo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",ro=({node:t,dragging:e,onFill:n,onDrop:r,compact:a=!1})=>o.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:n,onDragOver:l=>{e&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{l.preventDefault(),r()},className:e?oo:eo,style:a?to:Re},o.createElement("div",{style:{fontWeight:600}},t.label),o.createElement("div",{style:{fontSize:11}},e?"drop a step here":"leads nowhere yet \u2014 click to choose")),Et=ro;var no=({entries:t,at:e,onPick:n,onConnect:r,onDismiss:a,hideStepTypeCodes:l})=>o.createElement(I,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:e.y,left:e.x,width:210,padding:8,borderRadius:8}},o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(c=>o.createElement(w,{key:c.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>n(c)},c.label,!l&&o.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},c.type))),r&&o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),o.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:a},"Cancel")),Dt=no;var so={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},At=({label:t,title:e,idle:n,enabled:r,onUse:a})=>o.createElement(w,{variant:"secondary",size:"sm",title:r?e:n,disabled:!r,onClick:a,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),ao=({undoable:t,redoable:e,onAdd:n,onUndo:r,onRedo:a})=>o.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},o.createElement(w,{variant:"secondary",className:"rounded-full",style:so,title:"Add a step",onClick:n},"+"),o.createElement(At,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),o.createElement(At,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:e,onUse:a})),Ot=ao;var io=({type:t="info",title:e,message:n,onDismiss:r,className:a})=>o.createElement("div",{className:_("ks-alert",`ks-alert-${t}`,a),role:"alert"},o.createElement("div",{className:"ks-alert-body"},o.createElement("div",{className:"ks-alert-content"},e&&o.createElement("p",{className:"ks-alert-title"},e),o.createElement("p",{className:e?"ks-alert-message-titled":"ks-alert-message"},n)),r&&o.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),$t=io;var Pt=t=>{let e=t.map(n=>`\u201C${n.name}\u201D`).join(", ");return t.length===1?`${e} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${e} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Lt=({version:t,published:e})=>t?e?e===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${e}`:`Version ${t} \xB7 never published`:"No version yet";var lo={width:280,padding:20,overflowY:"auto"},rt={fontWeight:600,marginBottom:6,marginTop:14},q={fontSize:12,marginBottom:4,lineHeight:1.4},It={display:"block",marginBottom:3},Mt=(t,e,n)=>r=>{r.target.value!==(t[e]??"")&&n({[e]:r.target.value})},co=({flow:t,changes:e,problems:n,refusal:r,notice:a,publishNote:l,warning:c,onCreate:i,onPublish:u,onAccept:y,onDecline:b,onSaveDetails:m,onClose:f})=>o.createElement(I,{as:"aside",style:lo,"data-builder-panel":!0},o.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},o.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),o.createElement("button",{title:"Close",onClick:f,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),o.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},Lt(t)),c?o.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},o.createElement($t,{type:"warning",className:"mb-1.5",message:Pt(c.steps)}),o.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:y,"data-accept-removal":!0},c.path==="/publish"?"Remove and publish":"Remove and create version"),o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:b,"data-decline-removal":!0},"Cancel")):o.createElement("div",{style:{marginTop:14}},o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:i,"data-create-version":!0},"Create version"),o.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:u,"data-publish":!0},"Publish"),l&&o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},l)),o.createElement("h2",{style:rt},"Problems"),r&&o.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...q,fontWeight:600},"data-refusal":!0},r),a&&!r&&o.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...q,fontWeight:600},"data-notice":!0},a),n.length===0&&!r?o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing wrong with this flow."):n.map(g=>o.createElement("p",{key:`${g.node}-${g.problem}`,className:"text-amber-700 dark:text-amber-400",style:q,"data-problem":!0},"\u26A0 ",g.sentence)),o.createElement("h2",{style:rt},"Changes since the last version"),e.length===0?o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):e.map((g,p)=>o.createElement("p",{key:p,style:q,"data-change":!0},g)),o.createElement("h2",{style:rt},"Details"),o.createElement(W,null,o.createElement("span",{style:It},"Title"),o.createElement(O,{className:"mb-3",defaultValue:t.title??"",onBlur:Mt(t,"title",m),"data-flow-title":!0})),o.createElement(W,null,o.createElement("span",{style:It},"Start label"),o.createElement(O,{className:"mb-3",defaultValue:t.start_label??"",onBlur:Mt(t,"start_label",m),"data-flow-start-label":!0})),o.createElement("div",{style:{marginTop:16}},o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),Ht=co;var jt={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Wt=t=>({opacity:t?1:0,transition:"opacity .12s"}),po=({link:t,onInsert:e,onRemove:n,onDrop:r,dragging:a,alwaysShowInsertButtons:l})=>{let[c,i]=S(!1),u=c||a;return o.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDragOver:y=>{y.preventDefault(),y.dataTransfer.dropEffect="move"},onDrop:y=>{y.preventDefault(),i(!1),r()}},o.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},o.createElement(w,{variant:"secondary",title:a?"Move the step here":"Insert a step here",onClick:e,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(a&&c),style:{...jt,...Wt(u||l)}},"+"),!a&&o.createElement(w,{variant:"danger",title:"Remove this connection",onClick:n,className:"rounded-full",style:{...jt,...Wt(u)}},"\xD7")))},Vt=po;var uo=({links:t,extent:e,dragging:n,onInsert:r,onRemove:a,onDrop:l,alwaysShowInsertButtons:c})=>o.createElement(o.Fragment,null,o.createElement("svg",{width:e.width,height:e.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},o.createElement("defs",null,o.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},o.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(i=>o.createElement("path",{key:i.id,"data-link":i.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:i.path}))),t.filter(i=>i.label).map(i=>o.createElement("div",{key:`${i.id}-label`,"data-link-label":i.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:i.midX+(c?2:-10),top:i.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},i.label)),t.filter(i=>!i.placeholder).map(i=>o.createElement(Vt,{key:i.id,link:i,dragging:!!n,alwaysShowInsertButtons:c,onInsert:()=>r(i),onRemove:()=>a(i),onDrop:()=>l(i)}))),Ft=uo;var Ut={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Yt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",mo=({link:t,onInsert:e,onRemove:n,onDrop:r,alwaysShowInsertButtons:a})=>o.createElement("div",{"data-joint":t?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:l=>{l.currentTarget.dataset.over="true"},onMouseLeave:l=>{delete l.currentTarget.dataset.over},onDragOver:l=>{t&&r&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{t&&(l.preventDefault(),r(t))}},t&&o.createElement("div",{className:"absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500"}),t&&e&&o.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},o.createElement(w,{variant:"secondary",title:"Insert a step here",onClick:l=>e(t,l),className:`rounded-full ${a?"opacity-100":Yt}`,style:Ut},"+"),o.createElement(w,{variant:"danger",title:"Remove this connection",onClick:()=>n(t),className:`rounded-full ${Yt}`,style:Ut},"\xD7"))),Gt=mo;var fo=(t,e)=>t.row-e.row||t.column-e.column,Xt=t=>{let e=[...t].sort(fo),n=e.filter(r=>t.some(a=>a.holds?.includes(r.id)));return e.filter(r=>!n.includes(r)).flatMap(r=>[r,...n.filter(a=>r.holds?.includes(a.id))])},Jt=t=>{let e=Xt(t),n=r=>e.some(a=>a.holds?.includes(r.id));return e.filter(r=>!n(r)).reduce((r,a)=>{if(a.holds)return[...r,{group:a,steps:e.filter(c=>a.holds.includes(c.id))}];let l=r[r.length-1];return l&&!l.group?[...r.slice(0,-1),{steps:[...l.steps,a]}]:[...r,{steps:[a]}]},[])},go=(t,e)=>t[t.findIndex(n=>n.id===e.id)+1]?.id,qt=(t,e,n)=>{let r=go(Xt(n),t);return e.filter(a=>a.source===t.id&&(a.label||a.target!==r))},ho=t=>t?.placeholder?"nowhere yet":t?.label,Kt=(t,e)=>[t.label,"\u2192",ho(e.find(n=>n.id===t.target))].filter(Boolean).join(" "),Zt=(t,e,n)=>t.find(r=>r.source===e.id&&r.target===n.id);var yo={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},Qt=({steps:t,edges:e,draw:n,joints:r})=>o.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},t.map((a,l)=>o.createElement("div",{key:a.id,className:"flex flex-col sm:flex-row sm:items-center"},l>0&&o.createElement(Gt,{link:Zt(e,t[l-1],a),...r}),n(a)))),xo={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},bo=({group:t,steps:e,edges:n,draw:r,joints:a})=>o.createElement("div",{"data-group-box":t.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:xo},r(t),o.createElement(Qt,{steps:e,edges:n,draw:r,joints:a})),vo=({nodes:t,edges:e,draw:n,joints:r,children:a,style:l})=>o.createElement("div",{"data-flow-rows":!0,style:{...yo,...l}},a,Jt(t).map(c=>c.group?o.createElement(bo,{key:c.group.id,group:c.group,steps:c.steps,edges:e,draw:n,joints:r}):o.createElement(Qt,{key:c.steps[0].id,steps:c.steps,edges:e,draw:n,joints:r}))),K=vo;var Rt="Your change was not saved because the server could not be reached.",te=({base:t,token:e,fetch:n,onFlow:r,onError:a,onNotice:l,onWarning:c=()=>{}})=>async(i,u,y)=>{let b=await n(t+i,{method:u,headers:{"Content-Type":"application/json","X-CSRF-Token":e},body:y&&JSON.stringify(y)}).catch(()=>null);if(!b)return l(null),a(Rt);let m=await b.json().catch(()=>({}));if(m.unconnected)return l(null),a(null),c({path:i,steps:m.unconnected}),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json());if(c(null),!b.ok)return l(null),a(m.error||"That change was refused");a(null),l(m.notice||null),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json())},ee=({base:t,token:e,fetch:n,onError:r})=>async a=>{let l=new FormData;l.append("picture",a);let c=await n(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":e},body:l}).catch(()=>null);if(!c)return r(Rt),null;let i=await c.json().catch(()=>({}));return c.ok?(r(null),i):(r(i.error||"That picture was refused"),null)};var wo=(t,e,n)=>{let[r,a]=S(n),[l,c]=S(null),[i,u]=S(null),[y,b]=S(null),m=L(()=>te({base:t,token:e,fetch:(...g)=>window.fetch(...g),onFlow:a,onError:c,onNotice:u,onWarning:b}),[t,e]),f=L(()=>ee({base:t,token:e,fetch:(...g)=>window.fetch(...g),onError:c}),[t,e]);return{flow:r,error:l,notice:i,warning:y,setWarning:b,send:m,pickPicture:f}},oe=wo;var Z=(t,e,n,r)=>{let a=t.left-n.left+r.scrollLeft,l=t.top-n.top+r.scrollTop;return e==="left"?{x:a,y:l+t.height/2}:e==="right"?{x:a+t.width,y:l+t.height/2}:e==="top"?{x:a+t.width/2,y:l}:{x:a+t.width/2,y:l+t.height}},ko=(t,e,n)=>n&&e==="top"?{x:t.x,y:n.top}:t,Co=(t,e)=>e==="top"?{x:t.x,y:t.y-3}:e==="left"?{x:t.x-3,y:t.y}:e==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},So=(t,e,n,r,a)=>{let l={straight:`M ${e.x} ${e.y} L ${n.x} ${n.y}`,turn:`M ${e.x} ${e.y} H ${n.x} V ${n.y}`,lane:`M ${e.x} ${e.y} V ${r} H ${n.x} V ${n.y}`,detour:`M ${e.x} ${e.y} H ${a} V ${n.y} H ${n.x}`}[t.route];return{...t,path:l,midX:t.route==="detour"?a:(e.x+n.x)/2,midY:t.route==="lane"?r:(e.y+n.y)/2}},No=(t,e,n,r)=>{let[a,l]=S([]),[c,i]=S({width:"100%",height:"100%"}),[u,y]=S([]);return ut(()=>{let b=()=>{let f=e.current?.getBoundingClientRect();if(!f)return;i({width:e.current.scrollWidth,height:e.current.scrollHeight});let g=t.nodes.filter(p=>p.holds&&!p.loose&&n.current[p.id]).map(p=>{let k=n.current[p.id],v=k.getBoundingClientRect(),C=p.holds.flatMap(N=>n.current[N]?[n.current[N].getBoundingClientRect()]:[]),x=[{left:v.left,top:v.top,width:Math.max(v.width,k.scrollWidth),height:v.height},...C];return{id:p.id,bounds:vt(x,f,e.current)}});y(g),l(t.edges.flatMap(p=>{let k=n.current[p.source]?.getBoundingClientRect(),v=n.current[p.target]?.getBoundingClientRect();if(!k||!v)return[];let C=Z(k,p.leaves,f,e.current),x=g.find(T=>T.id===p.target)?.bounds,N=Co(ko(Z(v,p.enters,f,e.current),p.enters,x),p.enters),h=(Z(k,"bottom",f,e.current).y+Z(v,"top",f,e.current).y)/2,z=p.leaves==="left"?Math.min(C.x,N.x)-28:Math.max(C.x,N.x)+28;return[So(p,C,N,h,z)]}))};b(),window.addEventListener("resize",b);let m=new ResizeObserver(b);return e.current&&m.observe(e.current),()=>{window.removeEventListener("resize",b),m.disconnect()}},r),{links:a,extent:c,boxes:u}},re=No;var ne=(t,e)=>{let n=new Set(e),r=t,a=2;for(;n.has(r);)r=`${t}_${a++}`;return r};var Bo=8,To={display:"flex",height:"100%",minHeight:0,fontSize:13},_o={flex:1,overflow:"auto",position:"relative"},ae={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Eo={...ae,position:"static",alignSelf:"flex-start"},Do={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Ao={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Oo=({port:t,onCancel:e})=>o.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Ao},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",o.createElement("button",{onClick:e,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),$o=({base:t,token:e,initial:n})=>{let{flow:r,error:a,notice:l,warning:c,setWarning:i,send:u,pickPicture:y}=oe(t,e,n),[b,m]=S(null),[f,g]=S(null),[p,k]=S(null),[v,C]=S(null),[x,N]=S(!1),h=R({}),z=R(null);P(()=>{let s=()=>{m(null),N(!0)};return document.addEventListener("easy_flow:open-flow",s),()=>document.removeEventListener("easy_flow:open-flow",s)},[]),P(()=>{if(!x){i(null);return}let s=d=>{d.target.isConnected&&!d.target.closest("[data-builder-panel], [data-open-panel]")&&N(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[x]),P(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]);let T=L(()=>Object.fromEntries(r.nodes.map(s=>[s.id,s])),[r.nodes]),{links:M,extent:ue,boxes:nt}=re(r,z,h,[r,b,T]),st=L(()=>{let s={};return r.violations.forEach(d=>{var B;return(s[B=d.node]||(s[B]=[])).push(d)}),s},[r.violations]),E=r.direction==="left_to_right",H=r.nodes.filter(s=>!s.loose),at=r.nodes.filter(s=>s.loose),me=Math.max(0,...H.map(s=>s.row))+1,fe=Math.max(0,...H.map(s=>s.column))+1,Q=s=>{if(!p)return;let[d,B]=p;k(null),d!==s&&u("/edges","POST",{from:d,to:s,on:B||null})},ge=s=>{if(s.isDefaultPrevented()||!v)return;s.preventDefault();let d=v;C(null);let B=z.current.getBoundingClientRect(),j=wt(nt,{x:s.clientX-B.left+z.current.scrollLeft,y:s.clientY-B.top+z.current.scrollTop}),ye=r.nodes.find(xe=>xe.holds?.includes(d))?.id||null;j!==ye&&u(`/steps/${d}/group`,"PATCH",{group:j})},it=s=>[...r.palette,...r.unoffered||[]].find(d=>d.type===s?.type),$=r.nodes.find(s=>s.id===b),D=it($),he=s=>{let d=z.current.getBoundingClientRect();return{x:s.clientX-d.left+z.current.scrollLeft+8,y:s.clientY-d.top+z.current.scrollTop+8}},lt=s=>o.createElement(o.Fragment,null,s.placeholder&&o.createElement(Et,{node:{...s,ref:d=>{h.current[s.id]=d}},dragging:!!v,compact:E,onFill:()=>g({from:s.from,on:s.on,at:{x:16,y:52}}),onDrop:()=>{let d=v;C(null),d&&u("/edges","POST",{from:s.from,to:d,on:s.on})}}),s.holds&&o.createElement(F,{node:{...s,ref:d=>{h.current[s.id]=d}},header:U(s,it(s),r.hide_step_type_codes),compact:E,onSelect:()=>p?Q(s.id):m(s.id)}),!s.placeholder&&!s.holds&&o.createElement(et,{node:{...s,ref:d=>{h.current[s.id]=d},violations:st[s.id]||[],connected:r.edges.filter(d=>d.source===s.id).map(d=>d.label||null)},selected:s.id===b,armed:p&&p[0]===s.id?p[1]:null,connecting:!!p&&p[0]!==s.id,onSelect:()=>p?Q(s.id):m(s.id),onOpen:d=>window.location.assign(d),onArm:(d,B)=>{let j=z.current.getBoundingClientRect();g({from:s.id,on:d,at:{x:B.clientX-j.left+z.current.scrollLeft+8,y:B.clientY-j.top+z.current.scrollTop+8}})},onDragEnd:()=>C(null),onDragStart:()=>C(s.id),hideStepTypeCodes:r.hide_step_type_codes,compact:E,branches:E?qt(s,r.edges,H).map(d=>Kt(d,r.nodes)):[]})),dt=at.length>0&&o.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:E?Eo:ae},o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),at.map(s=>o.createElement("div",{key:s.id,style:{marginBottom:8}},o.createElement(et,{node:{...s,ref:d=>{h.current[s.id]=d},violations:st[s.id]||[],connected:[]},selected:b===s.id,armed:p&&p[0]===s.id?p[1]:null,connecting:!!p,onSelect:()=>p?Q(s.id):m(s.id),onOpen:d=>window.location.assign(d),onArm:(d,B)=>{B.stopPropagation(),k([s.id,d])},onDragStart:()=>C(s.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes}))));return o.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:To,onMouseUp:()=>C(null),onKeyDown:s=>{s.key==="Escape"&&(m(null),k(null),g(null))},tabIndex:-1},o.createElement("div",{ref:z,className:"bg-surface-50 dark:bg-surface-950",style:_o,onClick:s=>{s.target===z.current&&(m(null),k(null),N(!1))},onDragOver:s=>{v&&s.preventDefault()},onDrop:ge},p&&o.createElement(Oo,{port:p[1],onCancel:()=>k(null)}),o.createElement(Ot,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>g({at:{x:16,y:52}}),onUndo:()=>{m(null),u("/undo","POST")},onRedo:()=>{m(null),u("/redo","POST")}}),!E&&nt.map(s=>o.createElement(bt,{key:s.id,id:s.id,bounds:s.bounds,onDrop:()=>{let d=v;C(null),d&&u(`/steps/${d}/group`,"PATCH",{group:s.id})}})),!E&&o.createElement(Ft,{links:kt(M,r.nodes),extent:ue,dragging:v,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:s=>g({from:s.source,to:s.target,at:{x:s.midX+30,y:s.midY}}),onRemove:s=>{m(null),u("/edges","DELETE",{from:s.source,to:s.target})},onDrop:s=>{let d=v;C(null),u("/steps/"+d+"/move","PATCH",{from:s.source,to:s.target})}}),!E&&dt,E&&o.createElement(K,{nodes:H,edges:r.edges,draw:lt,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:(s,d)=>g({from:s.source,to:s.target,at:he(d)}),onRemove:s=>{m(null),u("/edges","DELETE",{from:s.source,to:s.target})},onDrop:s=>{let d=v;C(null),d&&u("/steps/"+d+"/move","PATCH",{from:s.source,to:s.target})}}},dt),!E&&o.createElement("div",{style:{...Do,gridTemplateColumns:`repeat(${fe+1}, ${280/2}px)`,gridTemplateRows:`repeat(${me}, auto)`}},H.map(s=>o.createElement("div",{key:s.id,style:{gridRow:s.row+1,gridColumn:`${s.column+1} / span 2`,zIndex:2,marginTop:Ct(s,r.nodes)?Bo-64:0}},lt(s)))),f&&o.createElement(Dt,{entries:r.palette,at:f.at,onDismiss:()=>g(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:f.on!==void 0?()=>{k([f.from,f.on]),g(null)}:null,onPick:s=>{let d=f;g(null),u("/steps","POST",{id:ne(s.type,r.nodes.map(B=>B.id)),type:s.type,from:d.from,to:d.to,on:d.on})}})),x&&!$&&o.createElement(Ht,{flow:r.flow||{},changes:r.changes||[],problems:r.violations,refusal:a,notice:l,publishNote:r.publish_note,warning:c,onClose:()=>N(!1),onCreate:()=>u("/versions","POST"),onPublish:()=>u("/publish","POST"),onAccept:()=>u(c.path,"POST",{remove_unconnected:c.steps.map(s=>s.id)}),onDecline:()=>i(null),onSaveDetails:s=>u("/details","PATCH",{flow:s})}),$&&o.createElement(_t,{node:$,fields:D?.fields||{},holds:D?.records||{},labels:D?.labels||{},explanations:D?.explanations||{},recordLabels:D?.record_labels||{},recordExplanations:D?.record_explanations||{},recordChoices:D?.record_choices||{},recordOutputsOf:D?.record_outputs_of||{},choices:St($,D),onClose:()=>m(null),onSave:s=>u(`/steps/${$.id}`,"PATCH",{config:s}),onPickPicture:y,refusal:a,onDelete:()=>{m(null),u(`/steps/${$.id}`,"DELETE")}}))},ie=$o;var Po={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Lo={fontSize:12,fontWeight:500,lineHeight:1.3},le={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},de={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},Io="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Mo=({node:t,selected:e=!1})=>{let n=t.address?"a":"div";return o.createElement(n,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${le[t.state]||le.pending}${e?` ${Io}`:""}`,style:Po},o.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),o.createElement("div",{style:Lo},t.label,t.version&&o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&o.createElement("div",{className:de[t.state]||de.pending,style:{fontSize:11}},t.status))},ce=Mo;var Ho={gap:12,padding:0},jo=({nodes:t,edges:e,selected:n})=>o.createElement(K,{nodes:t,edges:e,joints:{},style:Ho,draw:r=>r.holds?o.createElement(F,{node:r,header:U(r,r,!1),compact:!0}):o.createElement(ce,{node:r,selected:r.id===n})}),pe=jo;tt("easy_flow/flow-editor",ie);tt("easy_flow/run-view",pe);document.addEventListener("easy_flow:flow-named",t=>{let e=document.querySelector("[data-flow-heading]");e&&(e.textContent=t.detail)});ht(document,ct);})();
|
|
@@ -11,6 +11,7 @@ module EasyFlow
|
|
|
11
11
|
"changes" => listed_changes(flow), "flow" => flow_details(flow),
|
|
12
12
|
"always_show_insert_buttons" => flow_host.always_show_insert_buttons?,
|
|
13
13
|
"hide_step_type_codes" => flow_host.hide_step_type_codes?,
|
|
14
|
+
"direction" => flow_host.canvas_direction.to_s,
|
|
14
15
|
"publish_note" => flow_host.publish_note)
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require "keystone_ui/react/mount_helper"
|
|
2
|
+
|
|
3
|
+
module EasyFlow
|
|
4
|
+
module RunViewHelper
|
|
5
|
+
include KeystoneUi::React::MountHelper
|
|
6
|
+
|
|
7
|
+
def easy_flow_run_view(version, steps:, selected: nil, **attributes)
|
|
8
|
+
react_ui("easy_flow/run-view", RunView.new(version, steps: steps, selected: selected).to_h,
|
|
9
|
+
data: { flow_run_view: true }, **attributes)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -10,10 +10,12 @@ import TypePicker from "./TypePicker"
|
|
|
10
10
|
import Toolbar from "./Toolbar"
|
|
11
11
|
import Panel from "./Panel"
|
|
12
12
|
import ConnectorLayer from "./ConnectorLayer"
|
|
13
|
+
import LeftToRight from "./LeftToRight"
|
|
13
14
|
import useFlow from "./useFlow"
|
|
14
15
|
import useConnectors from "./useConnectors"
|
|
15
16
|
import { CARD, GAP_X, GAP_Y } from "./styles"
|
|
16
17
|
import { nextId } from "./ids"
|
|
18
|
+
import { branchLine, branchesOf } from "./reading"
|
|
17
19
|
|
|
18
20
|
const HEADER_GAP = 8
|
|
19
21
|
|
|
@@ -21,6 +23,8 @@ const page = { display: "flex", height: "100%", minHeight: 0, fontSize: 13 }
|
|
|
21
23
|
const scroll = { flex: 1, overflow: "auto", position: "relative" }
|
|
22
24
|
const waiting = { position: "absolute", top: 56, left: 16, zIndex: 5, width: CARD + 24, padding: 12, borderRadius: 8 }
|
|
23
25
|
|
|
26
|
+
const waitingInRows = { ...waiting, position: "static", alignSelf: "flex-start" }
|
|
27
|
+
|
|
24
28
|
const grid = { display: "grid", rowGap: GAP_Y, columnGap: 0, padding: 40, justifyContent: "center", position: "relative" }
|
|
25
29
|
const notice = { position: "sticky", zIndex: 8, top: 8, margin: "8px auto 0", width: "fit-content", padding: "6px 12px", borderRadius: 6, fontSize: 12 }
|
|
26
30
|
|
|
@@ -72,6 +76,7 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
72
76
|
return grouped
|
|
73
77
|
}, [ flow.violations ])
|
|
74
78
|
|
|
79
|
+
const leftToRight = flow.direction === "left_to_right"
|
|
75
80
|
const attached = flow.nodes.filter((node) => !node.loose)
|
|
76
81
|
const loose = flow.nodes.filter((node) => node.loose)
|
|
77
82
|
const rows = Math.max(0, ...attached.map((node) => node.row)) + 1
|
|
@@ -100,6 +105,83 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
100
105
|
const selectedNode = flow.nodes.find((node) => node.id === selected)
|
|
101
106
|
const entryFor = entryOf(selectedNode)
|
|
102
107
|
|
|
108
|
+
const pointed = (event) => {
|
|
109
|
+
const frame = surface.current.getBoundingClientRect()
|
|
110
|
+
return { x: event.clientX - frame.left + surface.current.scrollLeft + 8, y: event.clientY - frame.top + surface.current.scrollTop + 8 }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const draw = (node) => (
|
|
114
|
+
<>
|
|
115
|
+
{node.placeholder && (
|
|
116
|
+
<Placeholder node={{ ...node, ref: (element) => { cards.current[node.id] = element } }}
|
|
117
|
+
dragging={Boolean(dragging)} compact={leftToRight}
|
|
118
|
+
onFill={() => setAdding({ from: node.from, on: node.on, at: { x: 16, y: 52 } })}
|
|
119
|
+
onDrop={() => {
|
|
120
|
+
const held = dragging
|
|
121
|
+
setDragging(null)
|
|
122
|
+
if (held) send("/edges", "POST", { from: node.from, to: held, on: node.on })
|
|
123
|
+
}} />
|
|
124
|
+
)}
|
|
125
|
+
{node.holds && (
|
|
126
|
+
<GroupHeader node={{ ...node, ref: (element) => { cards.current[node.id] = element } }}
|
|
127
|
+
header={headerOf(node, entryOf(node), flow.hide_step_type_codes)} compact={leftToRight}
|
|
128
|
+
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))} />
|
|
129
|
+
)}
|
|
130
|
+
{!node.placeholder && !node.holds && <StepCard
|
|
131
|
+
node={{
|
|
132
|
+
...node,
|
|
133
|
+
ref: (element) => { cards.current[node.id] = element },
|
|
134
|
+
violations: violationsFor[node.id] || [],
|
|
135
|
+
connected: flow.edges.filter((edge) => edge.source === node.id).map((edge) => edge.label || null)
|
|
136
|
+
}}
|
|
137
|
+
selected={node.id === selected}
|
|
138
|
+
armed={armed && armed[0] === node.id ? armed[1] : null}
|
|
139
|
+
connecting={Boolean(armed) && armed[0] !== node.id}
|
|
140
|
+
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))}
|
|
141
|
+
onOpen={(path) => window.location.assign(path)}
|
|
142
|
+
onArm={(port, event) => {
|
|
143
|
+
const frame = surface.current.getBoundingClientRect()
|
|
144
|
+
setAdding({
|
|
145
|
+
from: node.id, on: port,
|
|
146
|
+
at: { x: event.clientX - frame.left + surface.current.scrollLeft + 8,
|
|
147
|
+
y: event.clientY - frame.top + surface.current.scrollTop + 8 }
|
|
148
|
+
})
|
|
149
|
+
}}
|
|
150
|
+
onDragEnd={() => setDragging(null)}
|
|
151
|
+
onDragStart={() => setDragging(node.id)}
|
|
152
|
+
hideStepTypeCodes={flow.hide_step_type_codes}
|
|
153
|
+
compact={leftToRight}
|
|
154
|
+
branches={leftToRight ? branchesOf(node, flow.edges, attached).map((edge) => branchLine(edge, flow.nodes)) : []}
|
|
155
|
+
/>}
|
|
156
|
+
</>
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
const waitingSteps = loose.length > 0 && (
|
|
160
|
+
<div data-loose className="border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900" style={leftToRight ? waitingInRows : waiting}>
|
|
161
|
+
<div className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginBottom: 6 }}>Not in the flow yet — drag one onto a connection</div>
|
|
162
|
+
{loose.map((node) => (
|
|
163
|
+
<div key={node.id} style={{ marginBottom: 8 }}>
|
|
164
|
+
<StepCard
|
|
165
|
+
node={{
|
|
166
|
+
...node,
|
|
167
|
+
ref: (element) => { cards.current[node.id] = element },
|
|
168
|
+
violations: violationsFor[node.id] || [],
|
|
169
|
+
connected: []
|
|
170
|
+
}}
|
|
171
|
+
selected={selected === node.id}
|
|
172
|
+
armed={armed && armed[0] === node.id ? armed[1] : null}
|
|
173
|
+
connecting={Boolean(armed)}
|
|
174
|
+
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))}
|
|
175
|
+
onOpen={(path) => window.location.assign(path)}
|
|
176
|
+
onArm={(port, event) => { event.stopPropagation(); setArmed([ node.id, port ]) }}
|
|
177
|
+
onDragStart={() => setDragging(node.id)}
|
|
178
|
+
onDragEnd={() => setDragging(null)}
|
|
179
|
+
hideStepTypeCodes={flow.hide_step_type_codes} />
|
|
180
|
+
</div>
|
|
181
|
+
))}
|
|
182
|
+
</div>
|
|
183
|
+
)
|
|
184
|
+
|
|
103
185
|
return (
|
|
104
186
|
<div className="text-gray-900 dark:text-gray-100" style={page} onMouseUp={() => setDragging(null)}
|
|
105
187
|
onKeyDown={(event) => { if (event.key === "Escape") { setSelected(null); setArmed(null); setAdding(null) } }}
|
|
@@ -116,87 +198,32 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
116
198
|
onUndo={() => { setSelected(null); send("/undo", "POST") }}
|
|
117
199
|
onRedo={() => { setSelected(null); send("/redo", "POST") }} />
|
|
118
200
|
|
|
119
|
-
{boxes.map((box) => (
|
|
201
|
+
{!leftToRight && boxes.map((box) => (
|
|
120
202
|
<GroupBox key={box.id} id={box.id} bounds={box.bounds}
|
|
121
203
|
onDrop={() => { const held = dragging; setDragging(null); if (held) send(`/steps/${held}/group`, "PATCH", { group: box.id }) }} />
|
|
122
204
|
))}
|
|
123
205
|
|
|
124
|
-
<ConnectorLayer links={linksOutside(links, flow.nodes)} extent={extent} dragging={dragging} alwaysShowInsertButtons={flow.always_show_insert_buttons}
|
|
206
|
+
{!leftToRight && <ConnectorLayer links={linksOutside(links, flow.nodes)} extent={extent} dragging={dragging} alwaysShowInsertButtons={flow.always_show_insert_buttons}
|
|
125
207
|
onInsert={(link) => setAdding({ from: link.source, to: link.target, at: { x: link.midX + 30, y: link.midY } })}
|
|
126
208
|
onRemove={(link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) }}
|
|
127
|
-
onDrop={(link) => { const held = dragging; setDragging(null); send("/steps/" + held + "/move", "PATCH", { from: link.source, to: link.target }) }} />
|
|
128
|
-
|
|
129
|
-
{
|
|
130
|
-
<div data-loose className="border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900" style={waiting}>
|
|
131
|
-
<div className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginBottom: 6 }}>Not in the flow yet — drag one onto a connection</div>
|
|
132
|
-
{loose.map((node) => (
|
|
133
|
-
<div key={node.id} style={{ marginBottom: 8 }}>
|
|
134
|
-
<StepCard
|
|
135
|
-
node={{
|
|
136
|
-
...node,
|
|
137
|
-
ref: (element) => { cards.current[node.id] = element },
|
|
138
|
-
violations: violationsFor[node.id] || [],
|
|
139
|
-
connected: []
|
|
140
|
-
}}
|
|
141
|
-
selected={selected === node.id}
|
|
142
|
-
armed={armed && armed[0] === node.id ? armed[1] : null}
|
|
143
|
-
connecting={Boolean(armed)}
|
|
144
|
-
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))}
|
|
145
|
-
onOpen={(path) => window.location.assign(path)}
|
|
146
|
-
onArm={(port, event) => { event.stopPropagation(); setArmed([ node.id, port ]) }}
|
|
147
|
-
onDragStart={() => setDragging(node.id)}
|
|
148
|
-
onDragEnd={() => setDragging(null)}
|
|
149
|
-
hideStepTypeCodes={flow.hide_step_type_codes} />
|
|
150
|
-
</div>
|
|
151
|
-
))}
|
|
152
|
-
</div>
|
|
153
|
-
)}
|
|
209
|
+
onDrop={(link) => { const held = dragging; setDragging(null); send("/steps/" + held + "/move", "PATCH", { from: link.source, to: link.target }) }} />}
|
|
210
|
+
|
|
211
|
+
{!leftToRight && waitingSteps}
|
|
154
212
|
|
|
155
|
-
|
|
213
|
+
{leftToRight && <LeftToRight nodes={attached} edges={flow.edges} draw={draw} joints={{
|
|
214
|
+
alwaysShowInsertButtons: flow.always_show_insert_buttons,
|
|
215
|
+
onInsert: (link, event) => setAdding({ from: link.source, to: link.target, at: pointed(event) }),
|
|
216
|
+
onRemove: (link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) },
|
|
217
|
+
onDrop: (link) => { const held = dragging; setDragging(null); if (held) send("/steps/" + held + "/move", "PATCH", { from: link.source, to: link.target }) }
|
|
218
|
+
}}>{waitingSteps}</LeftToRight>}
|
|
219
|
+
|
|
220
|
+
{!leftToRight && <div style={{ ...grid, gridTemplateColumns: `repeat(${columns + 1}, ${(CARD + GAP_X) / 2}px)`, gridTemplateRows: `repeat(${rows}, auto)` }}>
|
|
156
221
|
{attached.map((node) => (
|
|
157
222
|
<div key={node.id} style={{ gridRow: node.row + 1, gridColumn: `${node.column + 1} / span 2`, zIndex: 2, marginTop: underHeader(node, flow.nodes) ? HEADER_GAP - GAP_Y : 0 }}>
|
|
158
|
-
{node
|
|
159
|
-
<Placeholder node={{ ...node, ref: (element) => { cards.current[node.id] = element } }}
|
|
160
|
-
dragging={Boolean(dragging)}
|
|
161
|
-
onFill={() => setAdding({ from: node.from, on: node.on, at: { x: 16, y: 52 } })}
|
|
162
|
-
onDrop={() => {
|
|
163
|
-
const held = dragging
|
|
164
|
-
setDragging(null)
|
|
165
|
-
if (held) send("/edges", "POST", { from: node.from, to: held, on: node.on })
|
|
166
|
-
}} />
|
|
167
|
-
)}
|
|
168
|
-
{node.holds && (
|
|
169
|
-
<GroupHeader node={{ ...node, ref: (element) => { cards.current[node.id] = element } }}
|
|
170
|
-
header={headerOf(node, entryOf(node), flow.hide_step_type_codes)}
|
|
171
|
-
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))} />
|
|
172
|
-
)}
|
|
173
|
-
{!node.placeholder && !node.holds && <StepCard
|
|
174
|
-
node={{
|
|
175
|
-
...node,
|
|
176
|
-
ref: (element) => { cards.current[node.id] = element },
|
|
177
|
-
violations: violationsFor[node.id] || [],
|
|
178
|
-
connected: flow.edges.filter((edge) => edge.source === node.id).map((edge) => edge.label || null)
|
|
179
|
-
}}
|
|
180
|
-
selected={node.id === selected}
|
|
181
|
-
armed={armed && armed[0] === node.id ? armed[1] : null}
|
|
182
|
-
connecting={Boolean(armed) && armed[0] !== node.id}
|
|
183
|
-
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))}
|
|
184
|
-
onOpen={(path) => window.location.assign(path)}
|
|
185
|
-
onArm={(port, event) => {
|
|
186
|
-
const frame = surface.current.getBoundingClientRect()
|
|
187
|
-
setAdding({
|
|
188
|
-
from: node.id, on: port,
|
|
189
|
-
at: { x: event.clientX - frame.left + surface.current.scrollLeft + 8,
|
|
190
|
-
y: event.clientY - frame.top + surface.current.scrollTop + 8 }
|
|
191
|
-
})
|
|
192
|
-
}}
|
|
193
|
-
onDragEnd={() => setDragging(null)}
|
|
194
|
-
onDragStart={() => setDragging(node.id)}
|
|
195
|
-
hideStepTypeCodes={flow.hide_step_type_codes}
|
|
196
|
-
/>}
|
|
223
|
+
{draw(node)}
|
|
197
224
|
</div>
|
|
198
225
|
))}
|
|
199
|
-
</div>
|
|
226
|
+
</div>}
|
|
200
227
|
|
|
201
228
|
{adding && (
|
|
202
229
|
<TypePicker entries={flow.palette} at={adding.at} onDismiss={() => setAdding(null)} hideStepTypeCodes={flow.hide_step_type_codes}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { CARD } from "./styles"
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const line = { position: "relative", zIndex: 2, width: CARD, fontSize: 11, whiteSpace: "nowrap", cursor: "pointer" }
|
|
5
|
+
|
|
6
|
+
const compactLine = { ...line, width: "auto", whiteSpace: "normal", overflowWrap: "anywhere" }
|
|
7
|
+
|
|
8
|
+
const GroupHeader = ({ node, header, onSelect, compact = false }) => (
|
|
5
9
|
<div ref={node.ref} data-group-header={node.id} onClick={onSelect}
|
|
6
10
|
className="font-mono text-gray-500 dark:text-gray-400"
|
|
7
|
-
style={{
|
|
11
|
+
style={{ ...(compact ? compactLine : line), ...(onSelect ? {} : { cursor: "default" }) }}>{header}</div>
|
|
8
12
|
)
|
|
9
13
|
|
|
10
14
|
export default GroupHeader
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import Button from "keystone_ui-react/src/Button.jsx"
|
|
3
|
+
|
|
4
|
+
const round = { width: 24, height: 24, padding: 0, fontSize: 15, lineHeight: "15px" }
|
|
5
|
+
|
|
6
|
+
const shownOnHover = "opacity-0 transition-opacity group-data-[over=true]:opacity-100"
|
|
7
|
+
|
|
8
|
+
const Joint = ({ link, onInsert, onRemove, onDrop, alwaysShowInsertButtons }) => (
|
|
9
|
+
<div data-joint={link?.id} className="group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch"
|
|
10
|
+
onMouseEnter={(event) => { event.currentTarget.dataset.over = "true" }}
|
|
11
|
+
onMouseLeave={(event) => { delete event.currentTarget.dataset.over }}
|
|
12
|
+
onDragOver={(event) => { if (link && onDrop) { event.preventDefault(); event.dataTransfer.dropEffect = "move" } }}
|
|
13
|
+
onDrop={(event) => { if (!link) return; event.preventDefault(); onDrop(link) }}>
|
|
14
|
+
{link && <div className="absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500" />}
|
|
15
|
+
{link && onInsert && (
|
|
16
|
+
<div className="absolute inset-0 flex items-center justify-center gap-1 sm:flex-col" style={{ zIndex: 4 }}>
|
|
17
|
+
<Button variant="secondary" title="Insert a step here" onClick={(event) => onInsert(link, event)}
|
|
18
|
+
className={`rounded-full ${alwaysShowInsertButtons ? "opacity-100" : shownOnHover}`} style={round}>+</Button>
|
|
19
|
+
<Button variant="danger" title="Remove this connection" onClick={() => onRemove(link)} className={`rounded-full ${shownOnHover}`} style={round}>×</Button>
|
|
20
|
+
</div>
|
|
21
|
+
)}
|
|
22
|
+
</div>
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export default Joint
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import Joint from "./Joint"
|
|
3
|
+
import { blocksOf, joining } from "./reading"
|
|
4
|
+
|
|
5
|
+
const stack = { display: "flex", flexDirection: "column", gap: 14, padding: "64px 24px 24px" }
|
|
6
|
+
|
|
7
|
+
const Steps = ({ steps, edges, draw, joints }) => (
|
|
8
|
+
<div data-flow-row className="flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5">
|
|
9
|
+
{steps.map((step, at) => (
|
|
10
|
+
<div key={step.id} className="flex flex-col sm:flex-row sm:items-center">
|
|
11
|
+
{at > 0 && <Joint link={joining(edges, steps[at - 1], step)} {...joints} />}
|
|
12
|
+
{draw(step)}
|
|
13
|
+
</div>
|
|
14
|
+
))}
|
|
15
|
+
</div>
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const box = { display: "flex", flexDirection: "column", gap: 8, padding: "10px 12px", borderRadius: 8 }
|
|
19
|
+
|
|
20
|
+
const Box = ({ group, steps, edges, draw, joints }) => (
|
|
21
|
+
<div data-group-box={group.id} className="border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60" style={box}>
|
|
22
|
+
{draw(group)}
|
|
23
|
+
<Steps steps={steps} edges={edges} draw={draw} joints={joints} />
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const LeftToRight = ({ nodes, edges, draw, joints, children, style }) => (
|
|
28
|
+
<div data-flow-rows style={{ ...stack, ...style }}>
|
|
29
|
+
{children}
|
|
30
|
+
{blocksOf(nodes).map((block) => (block.group
|
|
31
|
+
? <Box key={block.group.id} group={block.group} steps={block.steps} edges={edges} draw={draw} joints={joints} />
|
|
32
|
+
: <Steps key={block.steps[0].id} steps={block.steps} edges={edges} draw={draw} joints={joints} />))}
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
export default LeftToRight
|
|
@@ -5,17 +5,21 @@ const waiting = {
|
|
|
5
5
|
width: CARD, boxSizing: "border-box", padding: "10px 14px", borderRadius: 8, textAlign: "center", fontSize: 12, cursor: "pointer"
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
const compactWaiting = {
|
|
9
|
+
minWidth: 120, boxSizing: "border-box", padding: "8px 10px", borderRadius: 6, textAlign: "center", fontSize: 12, cursor: "pointer"
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
const open = "border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300"
|
|
9
13
|
const receiving = "border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200"
|
|
10
14
|
|
|
11
|
-
const Placeholder = ({ node, dragging, onFill, onDrop }) => (
|
|
15
|
+
const Placeholder = ({ node, dragging, onFill, onDrop, compact = false }) => (
|
|
12
16
|
<div ref={node.ref} data-placeholder={node.id}
|
|
13
17
|
title={`Choose the step “${node.label}” should lead to`}
|
|
14
18
|
onClick={onFill}
|
|
15
19
|
onDragOver={(event) => { if (dragging) { event.preventDefault(); event.dataTransfer.dropEffect = "move" } }}
|
|
16
20
|
onDrop={(event) => { event.preventDefault(); onDrop() }}
|
|
17
21
|
className={dragging ? receiving : open}
|
|
18
|
-
style={waiting}>
|
|
22
|
+
style={compact ? compactWaiting : waiting}>
|
|
19
23
|
<div style={{ fontWeight: 600 }}>{node.label}</div>
|
|
20
24
|
<div style={{ fontSize: 11 }}>{dragging ? "drop a step here" : "leads nowhere yet — click to choose"}</div>
|
|
21
25
|
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
|
|
3
|
+
const card = { display: "block", minWidth: 118, boxSizing: "border-box", borderRadius: 6, padding: "8px 10px", textDecoration: "none" }
|
|
4
|
+
|
|
5
|
+
const named = { fontSize: 12, fontWeight: 500, lineHeight: 1.3 }
|
|
6
|
+
|
|
7
|
+
const STATES = {
|
|
8
|
+
done: "border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",
|
|
9
|
+
paused: "border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",
|
|
10
|
+
pending: "border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",
|
|
11
|
+
failed: "border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const STATUS_LINES = {
|
|
15
|
+
done: "text-green-700 dark:text-green-400",
|
|
16
|
+
paused: "text-amber-800 dark:text-amber-300",
|
|
17
|
+
pending: "text-gray-500 dark:text-gray-400",
|
|
18
|
+
failed: "text-red-700 dark:text-red-400"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const marked = "ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950"
|
|
22
|
+
|
|
23
|
+
const RunCard = ({ node, selected = false }) => {
|
|
24
|
+
const Card = node.address ? "a" : "div"
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Card data-step={node.id} href={node.address || undefined} className={`${node.state === "paused" ? "border-2" : "border"} ${STATES[node.state] || STATES.pending}${selected ? ` ${marked}` : ""}`} style={card}>
|
|
28
|
+
<div className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{node.type}</div>
|
|
29
|
+
<div style={named}>{node.label}{node.version && <span className="text-gray-500 dark:text-gray-400" style={{ fontWeight: 400, marginLeft: 4 }}>{node.version}</span>}</div>
|
|
30
|
+
{node.status && <div className={STATUS_LINES[node.state] || STATUS_LINES.pending} style={{ fontSize: 11 }}>{node.status}</div>}
|
|
31
|
+
</Card>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default RunCard
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import LeftToRight from "./LeftToRight"
|
|
3
|
+
import GroupHeader from "./GroupHeader"
|
|
4
|
+
import RunCard from "./RunCard"
|
|
5
|
+
import { headerOf } from "./group"
|
|
6
|
+
|
|
7
|
+
const rows = { gap: 12, padding: 0 }
|
|
8
|
+
|
|
9
|
+
const RunView = ({ nodes, edges, selected }) => (
|
|
10
|
+
<LeftToRight nodes={nodes} edges={edges} joints={{}} style={rows} draw={(node) => (node.holds
|
|
11
|
+
? <GroupHeader node={node} header={headerOf(node, node, false)} compact />
|
|
12
|
+
: <RunCard node={node} selected={node.id === selected} />)} />
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export default RunView
|
|
@@ -5,10 +5,14 @@ import { CARD } from "./styles"
|
|
|
5
5
|
|
|
6
6
|
const card = { width: CARD, boxSizing: "border-box", borderRadius: 8 }
|
|
7
7
|
|
|
8
|
+
const compactCard = { minWidth: 120, boxSizing: "border-box", borderRadius: 6 }
|
|
9
|
+
|
|
8
10
|
const bookendCard = { padding: "8px 14px", textAlign: "center", fontWeight: 600 }
|
|
9
11
|
|
|
10
12
|
const named = { fontWeight: 600, lineHeight: 1.3 }
|
|
11
13
|
|
|
14
|
+
const compactName = { fontSize: 12, fontWeight: 500, lineHeight: 1.3 }
|
|
15
|
+
|
|
12
16
|
const edge = (target, troubled, selected) => {
|
|
13
17
|
const lift = selected ? "ring-4 ring-accent-600/15" : "shadow-sm"
|
|
14
18
|
if (target || (selected && !troubled)) return `border-accent-600 ${lift}`
|
|
@@ -24,7 +28,7 @@ const typeLineOf = (node, heading, hideStepTypeCodes) => {
|
|
|
24
28
|
return heading === node.type_name ? null : node.type_name
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm, onDragEnd, onDragStart, hideStepTypeCodes }) => {
|
|
31
|
+
const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm, onDragEnd, onDragStart, hideStepTypeCodes, branches = [], compact = false }) => {
|
|
28
32
|
const bookend = node.begins_here || node.ends_here
|
|
29
33
|
const pinned = node.begins_here
|
|
30
34
|
const ports = node.ends_here ? [] : node.ports
|
|
@@ -39,18 +43,22 @@ const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm,
|
|
|
39
43
|
onDragStart={(event) => { event.dataTransfer.effectAllowed = "move"; event.dataTransfer.setData("text/plain", node.id); onDragStart() }}
|
|
40
44
|
onDragEnd={onDragEnd}
|
|
41
45
|
onClick={node.opens && !connecting ? () => onOpen(node.opens) : onSelect}
|
|
42
|
-
className={`bg-white border-2 dark:bg-zinc-900 ${edge(target, node.violations.length > 0, selected)}`}
|
|
46
|
+
className={`bg-white ${compact && !selected ? "border" : "border-2"} dark:bg-zinc-900 ${edge(target, node.violations.length > 0, selected)}`}
|
|
43
47
|
style={{
|
|
44
|
-
...card,
|
|
45
|
-
padding: bookend ? 0 : "12px 14px",
|
|
48
|
+
...(compact ? compactCard : card),
|
|
49
|
+
padding: bookend ? 0 : compact ? "8px 10px" : "12px 14px",
|
|
46
50
|
cursor: pinned ? "default" : connecting ? "crosshair" : "grab"
|
|
47
51
|
}}>
|
|
52
|
+
{!bookend && compact && typeLine && <div className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{typeLine}</div>}
|
|
48
53
|
{bookend && <div className="text-gray-500 dark:text-gray-400" style={bookendCard}>{heading}</div>}
|
|
49
|
-
{!bookend && <div style={named}>{heading}</div>}
|
|
50
|
-
{!bookend && typeLine && <div className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginTop: 2 }}>{typeLine}</div>}
|
|
54
|
+
{!bookend && <div style={compact ? compactName : named}>{heading}</div>}
|
|
55
|
+
{!bookend && !compact && typeLine && <div className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginTop: 2 }}>{typeLine}</div>}
|
|
51
56
|
{node.picture_url && <div className="text-accent-600 dark:text-accent-400" style={{ fontSize: 11, marginTop: 2 }}>Has a picture</div>}
|
|
52
57
|
{node.starts_a_flow && <div className="text-accent-600 dark:text-accent-400" style={{ fontSize: 11, marginTop: 2 }}>Runs a flow</div>}
|
|
53
58
|
{node.opens && <Button variant="secondary" size="sm" className="mt-2" onClick={(event) => { event.stopPropagation(); onSelect() }}>Settings</Button>}
|
|
59
|
+
{branches.map((branch) => (
|
|
60
|
+
<div key={branch} className="text-gray-500 dark:text-gray-400" style={{ fontSize: 10 }}>{branch}</div>
|
|
61
|
+
))}
|
|
54
62
|
{node.violations.map((violation) => (
|
|
55
63
|
<div key={violation.problem + violation.detail} className="text-red-600 dark:text-red-400" style={{ fontSize: 11, padding: "0 14px 6px" }}>
|
|
56
64
|
{violation.sentence}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const byPlace = (a, b) => a.row - b.row || a.column - b.column
|
|
2
|
+
|
|
3
|
+
export const readingOrder = (nodes) => {
|
|
4
|
+
const placed = [ ...nodes ].sort(byPlace)
|
|
5
|
+
const held = placed.filter((node) => nodes.some((group) => group.holds?.includes(node.id)))
|
|
6
|
+
|
|
7
|
+
return placed.filter((node) => !held.includes(node))
|
|
8
|
+
.flatMap((node) => [ node, ...held.filter((step) => node.holds?.includes(step.id)) ])
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const blocksOf = (nodes) => {
|
|
12
|
+
const ordered = readingOrder(nodes)
|
|
13
|
+
const held = (step) => ordered.some((group) => group.holds?.includes(step.id))
|
|
14
|
+
|
|
15
|
+
return ordered.filter((node) => !held(node)).reduce((blocks, node) => {
|
|
16
|
+
if (node.holds) return [ ...blocks, { group: node, steps: ordered.filter((step) => node.holds.includes(step.id)) } ]
|
|
17
|
+
|
|
18
|
+
const last = blocks[blocks.length - 1]
|
|
19
|
+
if (last && !last.group) return [ ...blocks.slice(0, -1), { steps: [ ...last.steps, node ] } ]
|
|
20
|
+
return [ ...blocks, { steps: [ node ] } ]
|
|
21
|
+
}, [])
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const nextAfter = (ordered, node) => ordered[ordered.findIndex((step) => step.id === node.id) + 1]?.id
|
|
25
|
+
|
|
26
|
+
export const branchesOf = (node, edges, nodes) => {
|
|
27
|
+
const next = nextAfter(readingOrder(nodes), node)
|
|
28
|
+
|
|
29
|
+
return edges.filter((edge) => edge.source === node.id && (edge.label || edge.target !== next))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const nameOf = (step) => (step?.placeholder ? "nowhere yet" : step?.label)
|
|
33
|
+
|
|
34
|
+
export const branchLine = (edge, nodes) =>
|
|
35
|
+
[ edge.label, "→", nameOf(nodes.find((node) => node.id === edge.target)) ].filter(Boolean).join(" ")
|
|
36
|
+
|
|
37
|
+
export const joining = (edges, before, after) => edges.find((edge) => edge.source === before.id && edge.target === after.id)
|
|
@@ -2,8 +2,10 @@ import { createRoot } from "react-dom/client"
|
|
|
2
2
|
import { register } from "keystone_ui-react/src/registry.js"
|
|
3
3
|
import { startMounting } from "keystone_ui-react/src/mounting.js"
|
|
4
4
|
import Canvas from "./canvas/Canvas"
|
|
5
|
+
import RunView from "./canvas/RunView"
|
|
5
6
|
|
|
6
7
|
register("easy_flow/flow-editor", Canvas)
|
|
8
|
+
register("easy_flow/run-view", RunView)
|
|
7
9
|
|
|
8
10
|
document.addEventListener("easy_flow:flow-named", (event) => {
|
|
9
11
|
const heading = document.querySelector("[data-flow-heading]")
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module EasyFlow
|
|
2
|
+
class RunView
|
|
3
|
+
def initialize(version, steps: {}, selected: nil, registry: EasyFlow.registry)
|
|
4
|
+
@document = Document.new(version.definition || {}, registry: registry)
|
|
5
|
+
@steps = steps.to_h.transform_keys(&:to_s)
|
|
6
|
+
@selected = selected
|
|
7
|
+
@registry = registry
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def to_h
|
|
11
|
+
{ "nodes" => nodes, "edges" => edges, "selected" => @selected&.to_s }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def nodes
|
|
17
|
+
@document.nodes.reject { |node| bookend?(node) }.map { |node| drawn_step(node) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def edges
|
|
21
|
+
@document.edges.each_with_index.map do |edge, index|
|
|
22
|
+
{ "id" => "#{edge.from}-#{edge.to}-#{index}", "source" => edge.from, "target" => edge.to, "label" => edge.on&.to_s }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def placed
|
|
27
|
+
@placed ||= Layout.new(@document).positions
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def bookend?(node)
|
|
31
|
+
step_type = step_type_for(node)
|
|
32
|
+
step_type.present? && (step_type.begins_here? || step_type.ends_here?)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def holds(node)
|
|
36
|
+
Array(node.config["holds"]) if step_type_for(node)&.holds_steps?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def step_type_for(node)
|
|
40
|
+
@registry.fetch(node.type) if @registry.registered?(node.type)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def drawn_step(node)
|
|
44
|
+
shown = @steps.fetch(node.id, {}).to_h.symbolize_keys
|
|
45
|
+
|
|
46
|
+
{ "id" => node.id, "type" => node.type, "label" => Name.of(node, @registry), "state" => shown[:state]&.to_s, "status" => shown[:status], "address" => shown[:address], "version" => shown[:version],
|
|
47
|
+
"holds" => holds(node), **header_of(node), **placed.fetch(node.id, {}) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def header_of(node)
|
|
51
|
+
return {} unless step_type_for(node)&.holds_steps?
|
|
52
|
+
|
|
53
|
+
{ "config" => node.config, "fields" => step_type_for(node).settings.fields.transform_keys(&:to_s).transform_values(&:to_s) }
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/lib/easy_flow/engine.rb
CHANGED
|
@@ -13,6 +13,10 @@ module EasyFlow
|
|
|
13
13
|
KeystoneUi.configuration.tailwind_sources << root.join("app/assets/builds/easy_flow/*.js").to_s
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
initializer "easy_flow.run_view_helper" do
|
|
17
|
+
ActiveSupport.on_load(:action_view) { include EasyFlow::RunViewHelper }
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
initializer "easy_flow.step_types" do |app|
|
|
17
21
|
app.config.to_prepare do
|
|
18
22
|
EasyFlow::Start.register
|
data/lib/easy_flow/host.rb
CHANGED
|
@@ -3,7 +3,7 @@ module EasyFlow
|
|
|
3
3
|
BackLink = Data.define(:label, :address)
|
|
4
4
|
|
|
5
5
|
attr_reader :name, :back_link
|
|
6
|
-
attr_writer :layout, :admin_layout, :offers, :allowed_answers, :always_show_insert_buttons, :hide_step_type_codes, :marks_ends, :on_publish
|
|
6
|
+
attr_writer :layout, :admin_layout, :offers, :allowed_answers, :always_show_insert_buttons, :hide_step_type_codes, :marks_ends, :on_publish, :canvas_direction
|
|
7
7
|
attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method, :finds_flows_across_owners, :publish_note
|
|
8
8
|
|
|
9
9
|
def initialize(name)
|
|
@@ -49,6 +49,10 @@ module EasyFlow
|
|
|
49
49
|
@always_show_insert_buttons.present?
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
def canvas_direction
|
|
53
|
+
@canvas_direction || :top_to_bottom
|
|
54
|
+
end
|
|
55
|
+
|
|
52
56
|
def marks_ends?
|
|
53
57
|
@marks_ends.present?
|
|
54
58
|
end
|
data/lib/easy_flow/version.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: easy_flow-develop
|
|
3
|
-
description: Use PROACTIVELY for adding a step type to easy_flow flows (a step that asks the visitor something, takes several answers at once, computes a value from earlier answers, records several values under names an admin enters in the step's settings, counts how many times an earlier step was answered so a loop can give up after a number of tries, picks the next branch, or holds the visitor until something outside the flow has happened), adding a step type an admin draws as a box that holds other steps on the canvas, such as a "for each" step, branching on whether all or any of several comparisons of earlier answers hold, holding a run until a number of minutes after an earlier answer, the next time of day after it, or a date, branching on the hour, weekday or time an earlier step was completed or on the minutes between two completed steps, reading when each step was completed and when a waiting run will move on, showing a step differently depending on the visitor's stored run, branching on what a visitor ticked on a checklist, moving a paused run on once what it waits for has happened, refusing a blank or invalid answer to a step with a message, offering an admin a step setting whose options are read from the app's own records, letting an admin pick another flow of the same host in a step's settings, adding a step type that starts another flow and works out which flow and version to run from its own settings, adding a step type that starts another flow chosen from the visitor's run, such as its owner or its answers, offering a visitor only the answers to a step that their earlier answers allow, filling in a step that has only one possible answer without asking it, skipping a step that does not apply to a visitor, letting an admin edit a value stored on one of the app's own records from a step's settings on the canvas, serving a host's flows from the app's own controller and routes, starting a visitor's run on a published version of a flow other than the live one, acting when a visitor finishes a flow, acting on the output a visitor's flow ended with, telling whether a run ended at an End step or was stopped by a loop that came back with nothing new answered and at which step, keeping a flow from being published while a step that starts another flow names a flow or version that cannot run or leads back to the flow it sits in, finding the run of another flow that a Flow step started, the run a waiting run is waiting on, and the run that started it, sending a visitor back to the run that started a flow once that flow ends, handling a run whose starting run was removed with its flow, handling a Flow step that cannot start its flow, whose flow ended with no output, or whose flow was stopped by a loop, taking one file or several from a visitor at a step, showing a step's recorded answer by a label the step type works out, and reading a run's recorded answers and question labels, including every answer ticked on a checklist and every visit's answer when a flow loops back to a question already asked — MUST BE USED instead of hand-rolling questionnaire steps, checkbox lists, file upload steps, branching logic, answer lists filtered by earlier answers, skipped questions, number comparisons, comparisons of two earlier answers, and/or conditions over several comparisons, hard-coded setting options, copying a record's value into a flow and back, answer validation, retry counters, timers or scheduled delays, step completion timestamps, polling or "come back later" pages, flow controllers or
|
|
3
|
+
description: Use PROACTIVELY for adding a step type to easy_flow flows (a step that asks the visitor something, takes several answers at once, computes a value from earlier answers, records several values under names an admin enters in the step's settings, counts how many times an earlier step was answered so a loop can give up after a number of tries, picks the next branch, or holds the visitor until something outside the flow has happened), adding a step type an admin draws as a box that holds other steps on the canvas, such as a "for each" step, branching on whether all or any of several comparisons of earlier answers hold, holding a run until a number of minutes after an earlier answer, the next time of day after it, or a date, branching on the hour, weekday or time an earlier step was completed or on the minutes between two completed steps, reading when each step was completed and when a waiting run will move on, showing a step differently depending on the visitor's stored run, branching on what a visitor ticked on a checklist, moving a paused run on once what it waits for has happened, refusing a blank or invalid answer to a step with a message, offering an admin a step setting whose options are read from the app's own records, letting an admin pick another flow of the same host in a step's settings, adding a step type that starts another flow and works out which flow and version to run from its own settings, adding a step type that starts another flow chosen from the visitor's run, such as its owner or its answers, offering a visitor only the answers to a step that their earlier answers allow, filling in a step that has only one possible answer without asking it, skipping a step that does not apply to a visitor, letting an admin edit a value stored on one of the app's own records from a step's settings on the canvas, serving a host's flows from the app's own controller and routes, starting a visitor's run on a published version of a flow other than the live one, acting when a visitor finishes a flow, acting on the output a visitor's flow ended with, telling whether a run ended at an End step or was stopped by a loop that came back with nothing new answered and at which step, keeping a flow from being published while a step that starts another flow names a flow or version that cannot run or leads back to the flow it sits in, finding the run of another flow that a Flow step started, the run a waiting run is waiting on, and the run that started it, sending a visitor back to the run that started a flow once that flow ends, handling a run whose starting run was removed with its flow, handling a Flow step that cannot start its flow, whose flow ended with no output, or whose flow was stopped by a loop, taking one file or several from a visitor at a step, showing a step's recorded answer by a label the step type works out, and reading a run's recorded answers and question labels, including every answer ticked on a checklist and every visit's answer when a flow loops back to a question already asked, and showing on the app's own page where a run stands, with each step's state, status line and link — MUST BE USED instead of hand-rolling questionnaire steps, checkbox lists, file upload steps, branching logic, answer lists filtered by earlier answers, skipped questions, number comparisons, comparisons of two earlier answers, and/or conditions over several comparisons, hard-coded setting options, copying a record's value into a flow and back, answer validation, retry counters, timers or scheduled delays, step completion timestamps, polling or "come back later" pages, flow controllers, answer lookups or hand-drawn run diagrams.
|
|
4
4
|
tools: Read, Write, Edit, Grep
|
|
5
5
|
scope: guided flows — versioned documents of steps and the connections between them, drawn on a canvas by an admin and run by a visitor one step at a time, with step types the host registers
|
|
6
6
|
---
|
|
@@ -25,6 +25,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
25
25
|
- `run_address` — private method a `FlowsController` subclass overrides to give the value put in a run's address in place of its id.
|
|
26
26
|
- `find_run` — private method a `FlowsController` subclass overrides to find a run, among the host's own runs, from the value in its address.
|
|
27
27
|
- `EasyFlow::Run` — the stored record of one visitor's pass through a flow, started with `EasyFlow::Run.start` on the live version or a chosen published one and pinned to that version, moved on past a waiting step with `advance`, read for the output its flow ended with by `output`, for the mark of the End it reached by `end_mark`, for whether it ended at an End step by `ended_at_end?`, for the step a loop stopped it at by `stopped_on_loop`, for when each step visit was completed by `completed_at` and for the time a Wait step holds it until by `held_until`, and linked to the runs its Flow steps started by `inner_runs`, to the one it is waiting on by `waiting_on`, and to the run that started it by `parent_run`.
|
|
28
|
+
- `easy_flow_run_view(version, steps:, selected: nil)` — a view helper every view in the app can call, drawing a read-only view of one flow version's steps with the state, status line, version and address the app supplies for each step.
|
|
28
29
|
- `EasyFlow::QuestionRunner` — reads a flow document: its steps, the next step for a set of answers and the times their steps were completed, the answers on the path taken, and a question's text and an answer's label.
|
|
29
30
|
|
|
30
31
|
## How to use it
|
|
@@ -548,6 +549,35 @@ Use this when a visitor's run should stop until a set time has passed, such as a
|
|
|
548
549
|
- In a flow set to save on finish or to save nothing, the waiting page also shows a `Check again` button, which loads the page again with the answers and the times their steps were completed, so the Wait moves on once its time has passed. Reloading the page in the browser instead takes the completion time of the step just submitted again, so a Wait counting minutes or a time of day from that step does not move on by reloading. Ask the developer whether such a flow needs to be set to save each step.
|
|
549
550
|
4. Publish a flow set to save each step with a Wait step counting a few minutes from a question, walk it to the Wait step, check the page shows `Waiting for <minutes> minutes after <question id>.` and `run.held_until` is that many minutes after the answer, and check `run.advance` after that time moves the run on. In a flow set to save nothing, walk to the same Wait step, wait past the time, press `Check again`, and check the next step is shown.
|
|
550
551
|
|
|
552
|
+
### Show where a run stands on the app's own page
|
|
553
|
+
|
|
554
|
+
1. Put the two scripts the view needs in the page's head, the same ones the canvas uses:
|
|
555
|
+
|
|
556
|
+
```erb
|
|
557
|
+
<% content_for :head do %>
|
|
558
|
+
<%= javascript_include_tag "keystone_ui/react", defer: true %>
|
|
559
|
+
<%= javascript_include_tag "easy_flow/canvas", defer: true %>
|
|
560
|
+
<% end %>
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
2. Call the helper with the flow version the run is on and one entry per step id:
|
|
564
|
+
|
|
565
|
+
```erb
|
|
566
|
+
<%= easy_flow_run_view(run.definition_version,
|
|
567
|
+
steps: { "outline" => { state: :done, status: "8.2s · $0.04", version: "v9", address: run_step_path(run, "outline") },
|
|
568
|
+
"human_approve" => { state: :paused, status: "waiting · expires 46h", address: run_step_path(run, "human_approve") } },
|
|
569
|
+
selected: "outline") %>
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
- `state` — `:done`, `:paused`, `:pending` or `:failed`, shown on the card's edge. A paused step's edge is thicker than the others. A step with no state or an unknown one is drawn as pending.
|
|
573
|
+
- `status` — one line of text under the step's name, written in the colour of its state. The app works it out; easy_flow does not.
|
|
574
|
+
- `version` — optional text written after the step's name, such as `v9`.
|
|
575
|
+
- `address` — optional. A card with one is a link to it, and a card without one is not a link.
|
|
576
|
+
- `selected` — the id of one step whose card is ringed in the accent colour, such as the step whose details the page shows.
|
|
577
|
+
- Any other keyword is passed to the wrapping element, such as `class:`.
|
|
578
|
+
3. The view lays the steps out left to right whatever the host's `canvas_direction`, as compact cards in rows joined by short lines. A group step's box takes a row of its own with its header line and the steps it holds. On a screen narrower than 640 pixels each step sits on a row of its own. The Start and End steps are left out. It has no buttons and nothing on it changes the flow.
|
|
579
|
+
4. Ask the developer what each step's status line says and where each card links. Do not pick.
|
|
580
|
+
|
|
551
581
|
### Read a run and its answers
|
|
552
582
|
|
|
553
583
|
1. Find runs scoped to one host so one host never sees another's: `EasyFlow::Run.joins(:flow).where(easy_flow_definitions: { host: "intake" })`.
|
|
@@ -103,6 +103,8 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
103
103
|
- **Allowed answers** — a rule a host may carry that looks at a step and the answers given so far in a run and names the answer values that step allows. When it names nothing for a step, the step offers every answer. When it names several, a question or checklist offers only those. When it names exactly one, the step records that answer without being shown, and when it names none, the step is passed over and records a blank answer. This holds in a stored run, a run moved on outside a visitor's request, a flow that carries its answers in the page, and an admin's preview. Going back skips the steps the host filled in and returns to the last step the visitor was shown.
|
|
104
104
|
- **Always-visible insert buttons** — a setting a host may turn on, `always_show_insert_buttons`, that shows each connection's button for inserting a step on its canvas without the pointer over the connection, with the connection's label moved to the right of the line. It is off by default, and with it off the button shows only with the pointer over the connection.
|
|
105
105
|
- **Hidden step type codes** — a setting a host may turn on, `hide_step_type_codes`, that hides step type code names on its canvas. The add menu lists each step type by its name alone, and a step's box shows its step type's name in place of the code name, with a step that has no name of its own headed by its step type's name. It is off by default, and with it off the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
|
|
106
|
+
- **Canvas direction** — a setting a host may set, `canvas_direction`, to `:left_to_right` to lay its canvas out left to right in place of top to bottom. Steps sit as compact cards in rows joined by short lines, a row that reaches the edge of the canvas goes on in a new row, each branch or loop that leads anywhere but the step beside it is written on its step's card with the step it leads to, a group step's box takes a row of its own, and a phone-width screen shows one step per row. Top to bottom is the default.
|
|
107
|
+
- **Run view** — a read-only view of one flow version that an app draws on its own page with `easy_flow_run_view`, showing each step as a compact card with its type code, name, the version and status line the app supplies, and an edge coloured by the state the app supplies, done, paused, pending or failed. A paused step's edge is thicker, the step the app names as selected is ringed, a card the app gives an address is a link to it, and steps sit left to right as on a left-to-right canvas, with a group step's box holding its steps and one card per row on a phone. It has no editing controls.
|
|
106
108
|
- **Publish note** — a setting a host may set, `publish_note`, whose sentence is shown directly under the Publish button in its flow panel. With none set, the panel shows no note.
|
|
107
109
|
- **Back link** — a setting a host may set, `back_link`, holding a label and an address, or a callable that takes the flow being shown and returns them, that shows a button with that label and address in its builder header in place of `All flows`. With a callable, each flow's canvas shows the back link worked out for that flow. With none set, the header shows `All flows`.
|
|
108
110
|
- **On publish** — a setting a host may set, `on_publish`, holding a callable that takes a flow. easy_flow calls it each time a new version of one of that host's flows goes live, from the canvas's Publish button or from the app calling publish. Publishing a version that is already live does not call it. With none set, nothing is called.
|
|
@@ -60,6 +60,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
60
60
|
- `offers` — the step types this host's admins can add from the canvas palette, as a list of step type names. With none set, every registered step type is offered. The engine's own names are `question`, `checklist`, `multiple_select`, `fill_in_the_blank`, `file_upload`, `condition`, `switch`, `compare`, `compare_two_values`, `all_or_any`, `count`, `wait`, `flow_step` and `play_flows`, `file_upload` being the File upload step, which needs the file store from step 10, `compare_two_values` being the Compare two values step, which compares the outputs of two earlier steps, `all_or_any` being the All of or Any of step, which decides whether all or any of several such comparisons hold, `count` being the Count step, which counts how often an earlier step was answered, `wait` being the Wait step, which holds a run until a time counted from an earlier answer or until a date, `flow_step` being the Flow step, which names one of the same host's flows, and `play_flows` being the Play flows step, which lists several of the same host's flows for a visitor to play in the order they choose. A step type the app declares is named by the id it was declared with, or after its class when it is a step class, so `Steps::Notify` is `notify`. The End step is offered whether it is listed or not, and the Start step is never offered. Ask the developer which step types each host should offer.
|
|
61
61
|
- `always_show_insert_buttons` — set to `true` to show each connection's button for inserting a step on this host's canvas without the pointer over the connection. A connection's label then sits to the right of the line so the button does not cover it. With none set, the button shows only with the pointer over the connection.
|
|
62
62
|
- `hide_step_type_codes` — set to `true` to hide step type code names on this host's canvas. The add menu then lists each step type by its name alone, and a step's box shows its step type's name in place of the code name. With none set, the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
|
|
63
|
+
- `canvas_direction` — set to `:left_to_right` to lay this host's canvas out left to right. Steps then sit as compact cards in rows joined by short lines, and a row that reaches the edge of the canvas goes on in a new row below it. A step whose branch or loop leads anywhere other than the step beside it, or whose branch carries an answer, writes each such branch on its card as the answer, an arrow and the step it leads to. A group step's box takes a row of its own, with its steps in a row inside it under its header line. On a screen narrower than 640 pixels, each step sits on a row of its own. With none set, or with `:top_to_bottom`, the canvas is laid out top to bottom as before.
|
|
63
64
|
- `marks_ends` — set to `true` to have this host's admins mark each End step as success or failure. The End step's settings then show a Mark with those two choices, and publishing one of this host's flows with an End left unmarked is refused, the refusal shown on that End's card. With none set, End steps show no mark and publish as they do. Ask the developer whether this host's runs need to say if they ended well.
|
|
64
65
|
- `publish_note` — a sentence shown directly under the Publish button in this host's flow panel. It is shown as plain text. With none set, the panel shows no note.
|
|
65
66
|
- `back_link` — a hash with a `label` and an `address`, such as `{ label: "Games", address: "/admin/games" }`, that shows a button with that label and address in this host's builder header in place of `All flows`. The header then has no `All flows` button. A hash missing either key raises `ArgumentError` when the host is declared, and a blank value is not refused. The address is used as written and is not checked, so it comes from the app's own configuration and never from a request. It may instead be a callable that takes the flow being shown and returns that hash, such as `->(flow) { { label: "Funnel", address: "/funnels/#{flow.owner_id}" } }`, so each flow's canvas links to a page of its own, such as its owner record's page. A returned hash missing either key raises `ArgumentError` when that flow's canvas is opened. With none set, the header shows `All flows`.
|
|
@@ -162,6 +163,8 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
162
163
|
- A step type of the app's own that holds other steps, such as a "for each" step, is drawn on the canvas as a dashed box with a header line at the top and the steps it holds inside. It needs no migration and no setting in the initializer beyond being listed in a host's `offers` when that host sets `offers`. Flows with no such step load and run as before.
|
|
163
164
|
- After adding a step type that holds other steps to a flow, check that its header line shows the step type's code followed by each filled-in setting, or the type's name and the settings' labels on a host with `hide_step_type_codes` set, and that clicking the header opens the step's settings.
|
|
164
165
|
- After adding a step type that holds other steps to a flow, check that dragging another step onto its box puts the step inside the box, that dragging it onto the canvas outside the box takes it out, and that both leave the step's connections as they were.
|
|
166
|
+
- After setting `canvas_direction` to `:left_to_right` on a host, check that its canvas shows the steps in rows joined by short lines, that a branch or loop to a step not beside it is written on its step's card, and that a phone-width screen shows one step per row.
|
|
167
|
+
- A page of the app that calls `easy_flow_run_view` needs the `keystone_ui/react` and `easy_flow/canvas` scripts in its head, the same two the canvas page loads. The helper needs no setting in the initializer, and it is available in every view of the app. After adding one, check that the page shows each step's card with the state and status line the app supplied, and that a phone-width screen shows one card per row.
|
|
165
168
|
- Every stored run keeps each step's value together with the time the step was completed. An app upgrading from a version that kept values alone runs `bin/rails easy_flow:install:migrations` and `bin/rails db:migrate` before any stored run takes an answer. The migration wraps each value its existing runs already hold, and those values carry no completion time. Running the migration back drops every completion time.
|
|
166
169
|
- After install, check that a Compare step, a Compare two values step, or a comparison of an All of or Any of step, once its earlier step is picked, offers "Hour completed", "Weekday completed" and "Minutes since 1970 when completed" beside that step's own outputs. They need no setting in the initializer.
|
|
167
170
|
- After install, check that a Wait step placed on the canvas asks for the earlier step it counts from, minutes after it, a time of day as HH:MM and a date as YYYY-MM-DD. It needs no migration beyond the one that keeps each step's completion time with its value and no setting in the initializer beyond being listed in a host's `offers` when that host sets `offers`.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: easy_flow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.43.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -76,6 +76,7 @@ files:
|
|
|
76
76
|
- app/controllers/easy_flow/manage/previews_controller.rb
|
|
77
77
|
- app/controllers/easy_flow/manage/versions_controller.rb
|
|
78
78
|
- app/helpers/easy_flow/app_routes_helper.rb
|
|
79
|
+
- app/helpers/easy_flow/run_view_helper.rb
|
|
79
80
|
- app/javascript/easy_flow/canvas.jsx
|
|
80
81
|
- app/javascript/easy_flow/canvas/Canvas.jsx
|
|
81
82
|
- app/javascript/easy_flow/canvas/Connector.jsx
|
|
@@ -85,10 +86,14 @@ files:
|
|
|
85
86
|
- app/javascript/easy_flow/canvas/GroupBox.jsx
|
|
86
87
|
- app/javascript/easy_flow/canvas/GroupHeader.jsx
|
|
87
88
|
- app/javascript/easy_flow/canvas/Inspector.jsx
|
|
89
|
+
- app/javascript/easy_flow/canvas/Joint.jsx
|
|
90
|
+
- app/javascript/easy_flow/canvas/LeftToRight.jsx
|
|
88
91
|
- app/javascript/easy_flow/canvas/Panel.jsx
|
|
89
92
|
- app/javascript/easy_flow/canvas/Placeholder.jsx
|
|
90
93
|
- app/javascript/easy_flow/canvas/Port.jsx
|
|
91
94
|
- app/javascript/easy_flow/canvas/Records.jsx
|
|
95
|
+
- app/javascript/easy_flow/canvas/RunCard.jsx
|
|
96
|
+
- app/javascript/easy_flow/canvas/RunView.jsx
|
|
92
97
|
- app/javascript/easy_flow/canvas/StepCard.jsx
|
|
93
98
|
- app/javascript/easy_flow/canvas/Toolbar.jsx
|
|
94
99
|
- app/javascript/easy_flow/canvas/TypePicker.jsx
|
|
@@ -98,6 +103,7 @@ files:
|
|
|
98
103
|
- app/javascript/easy_flow/canvas/flowSender.js
|
|
99
104
|
- app/javascript/easy_flow/canvas/group.js
|
|
100
105
|
- app/javascript/easy_flow/canvas/ids.js
|
|
106
|
+
- app/javascript/easy_flow/canvas/reading.js
|
|
101
107
|
- app/javascript/easy_flow/canvas/rows.js
|
|
102
108
|
- app/javascript/easy_flow/canvas/styles.js
|
|
103
109
|
- app/javascript/easy_flow/canvas/useConnectors.js
|
|
@@ -137,6 +143,7 @@ files:
|
|
|
137
143
|
- app/models/easy_flow/read_data.rb
|
|
138
144
|
- app/models/easy_flow/registry.rb
|
|
139
145
|
- app/models/easy_flow/run.rb
|
|
146
|
+
- app/models/easy_flow/run_view.rb
|
|
140
147
|
- app/models/easy_flow/runner.rb
|
|
141
148
|
- app/models/easy_flow/settings.rb
|
|
142
149
|
- app/models/easy_flow/start.rb
|