var L=Object.defineProperty;var $=(a,r,t)=>r in a?L(a,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[r]=t;var S=(a,r,t)=>$(a,typeof r!="symbol"?r+"":r,t);import{db as q,dc as F,r as c,al as N,cT as y,bI as R,w as W,u as G,bz as V,bJ as _,aD as z,b_ as U,T as M,s as u,j as e,y as Y,B as s,b5 as K,aR as Q,aS as X,b as Z,bf as ee,dz as re,ah as se,ai as te,bG as O,c as k,at as C,b4 as x,C as v,kk as ae,cG as oe,q as ie,bs as ne,aE as ce}from"./index-C1DmWO_C.js";import{O as f,S as le,a as pe}from"./SketchWorkflow-CaP1su2O.js";import{V as de}from"./Project-CpwJZ-CK.js";import"./SingleSelect-DvF8BLvQ.js";import"./sum-DlRFNH4j.js";import"./index-DMvrjxdW.js";import"./zoom-CRTJnDeN.js";import"./transform-C0Urpblx.js";import"./string-CFFdVFMV.js";import"./min-BJfYLHXY.js";import"./alertManagerConfig.selectors-B9ELaxCY.js";import"./index-Dub34MAX.js";import"./FileUploaderButton-BtxUzlTS.js";import"./zipObj-D8EtfWld.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./symmetricDifference-B3GPGppJ.js";import"./git-C8OLuEaG.js";import"./NoData-Y_e6mfNf.js";import"./useCopyToClipboard-v9FBn9Nz.js";import"./Anchor-DFXOcnPw.js";class he extends q{constructor(){super(...arguments);S(this,"generateDag",async(t,i)=>{await this.request({url:`${t}/airflow/dag`,type:F.post,data:i})})}}const me=new he("/project"),ue=N().shape({name:y.label("Name"),schedule:y.label("Schedule")}),xe=()=>{const a=R(),[r,t]=c.useState(!1),[i,l]=c.useState([]),[D,T]=c.useState(f.HopsworksLaunchOperator),[P,j]=W(),{id:p}=G(),d=V(),w=_(),{formState:{errors:E},register:A,control:I,handleSubmit:B,reset:g,setError:H}=z({defaultValues:{name:"",schedule:"@once"},shouldUnregister:!1,resolver:ce(ue),reValidateMode:"onChange",mode:"onChange"}),J=c.useCallback(async o=>{const n={name:o.name,scheduleInterval:o.schedule,operators:i};t(!0),await me.generateDag(+p,n).then(h=>{d.success({title:"Dag Creation",content:"Dag successfully created. You can view it in the Airflow dataset."}),l([]),g(),t(!1)}).catch(h=>{t(!1),d.error({title:"Dag Creation",content:"Failed to create dag."})}).finally(()=>{a(U.invalidateTags([{type:M.ProjectTags.FileExplorer,id:"Airflow"}])),w(u.airflow.overview)})},[a,d,i,p,w,g]),b=o=>{T(o),j()};return e.jsxs(e.Fragment,{children:[e.jsx(Y,{title:"Create new workflow",children:e.jsx(s,{sx:{width:"100%"},children:e.jsxs(s,{flexDirection:"column",gap:"20px",children:[e.jsx(K,{disabled:r,...A("name"),label:"Name",placeholder:"Workflow name",...Q("name",E)}),e.jsx(X,{name:"schedule",control:I,render:({field:{value:o,onChange:n},formState:{errors:h}})=>e.jsxs(s,{flexDirection:"column",gap:"10px",children:[e.jsx(s,{alignItems:"center",children:e.jsx(Z,{mr:"4px",children:"Frequency"})}),e.jsx(ee,{value:o==="@once"?"Once":"Scheduled",options:["Once","Scheduled"],onChange:m=>n(m==="Once"?"@once":"0 * * * *"),flexDirection:"row"}),o!=="@once"&&e.jsx(de,{value:o,onChange:n,onError:m=>H("schedule",{message:m}),error:h.schedule,withoutLabel:!0})]})})]})})}),e.jsxs(re,{title:"Operators",mt:"-1px",children:[e.jsx(se,{type:te.neutral,content:e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{children:[e.jsx(O,{children:"Launch Operator: "}),e.jsx(k,{children:"Operator to launch a Job in Hopsworks."})]}),e.jsxs(s,{children:[e.jsx(O,{children:"Job Success Sensor: "}),e.jsx(k,{children:"Operator which waits for the completion of a specific job. The task will fail too if the job which is waiting for fails."})]})]}),mb:"20px"}),e.jsxs(s,{gap:"20px",children:[e.jsx(C,{mainText:"",children:e.jsx(x,{disabled:r,intent:"secondary",onClick:()=>{b(f.HopsworksLaunchOperator)},icon:v.plus,sx:{path:{fill:"primary"}},children:"Launch Operator"})}),e.jsx(C,{mainText:"",children:e.jsx(x,{disabled:r,intent:"secondary",onClick:()=>{b(f.HopsworksJobSuccessSensor)},icon:v.plus,sx:{path:{fill:"primary"}},children:"Job Success Sensor"})})]}),e.jsx(ae,{children:e.jsx(le,{operators:i,setOperators:l})}),e.jsx(oe,{}),e.jsx(s,{mt:"20px",justifyContent:"right",children:e.jsxs(s,{flexDirection:"row",children:[e.jsx(x,{intent:"alert",mr:"10px",href:ie(u.airflow.overview,u.project.value,{id:p}),children:"Back"}),e.jsx(ne,{disabled:i.length===0||r,onClick:B(J),isLoading:r,children:"Generate Dag"})]})}),e.jsx(pe,{isOpen:!!P,onClose:j,operatorType:D,operators:i,setOperators:l})]}),e.jsx(s,{minHeight:"20px"})]})},$e=c.memo(xe);export{$e as default,ue as schema};
