var L=Object.defineProperty;var $=(a,r,s)=>r in a?L(a,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[r]=s;var S=(a,r,s)=>$(a,typeof r!="symbol"?r+"":r,s);import{cC as B,cD as I,r as c,ae as J,cn as y,bf as N,w as R,u as W,bd as G,bg as Q,au as U,O as z,q as u,j as e,Q as M,d as t,aR as Y,aE as _,aF as K,p as X,aS as Z,d0 as ee,aa as re,ab as te,aV as O,y as k,am as v,b6 as x,T as C,i2 as se,ca as ae,o as oe,av as ie}from"./index-CK33qGU_.js";import{O as f,S as ne,a as ce}from"./SketchWorkflow-efiBjb4a.js";import{b as le}from"./FileUploaderButton-Bppadu35.js";import{B as pe}from"./ButtonWithRole-NHXEosto.js";import{V as de}from"./Project-j3KdDsvH.js";import"./utils-37_jnP5r.js";import"./index-CIxm3shV.js";import"./SingleSelect-CV8k2k_j.js";import"./sum-BGhUhn3y.js";import"./index-DPxTMw0E.js";import"./zoom-CRTJnDeN.js";import"./transform-C0Urpblx.js";import"./string-CFFdVFMV.js";import"./min-Esn8rYAn.js";import"./useDownload-hrjXceJg.js";import"./useProject-BzBQtp4J.js";import"./length-fOfC3W0h.js";import"./dumbPluralize-CcxDsNiu.js";import"./alertManagerConfig.selectors-BX2JGYEL.js";import"./__-BIxbRvwe.js";import"./complement-M2aUPqXA.js";import"./PrimaryIconButton-DQUEhx3G.js";import"./zipObj-DQ8OxaYj.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./git-C8OLuEaG.js";import"./NoData-CuLyR2Bg.js";import"./useCopyToClipboard-_4vnCVip.js";import"./Anchor-HBBcGDu5.js";class me extends B{constructor(){super(...arguments);S(this,"generateDag",async(s,i)=>{await this.request({url:`${s}/airflow/dag`,type:I.post,data:i})})}}const he=new me("/project"),ue=J().shape({name:y.label("Name"),schedule:y.label("Schedule")}),xe=()=>{const a=N(),[r,s]=c.useState(!1),[i,l]=c.useState([]),[T,D]=c.useState(f.HopsworksLaunchOperator),[P,j]=R(),{id:p}=W(),d=G(),g=Q(),{formState:{errors:E},register:A,control:V,handleSubmit:q,reset:w,setError:F}=U({defaultValues:{name:"",schedule:"@once"},shouldUnregister:!1,resolver:ie(ue),reValidateMode:"onChange",mode:"onChange"}),H=c.useCallback(async o=>{const n={name:o.name,scheduleInterval:o.schedule,operators:i};s(!0),await he.generateDag(+p,n).then(m=>{d.success({title:"Dag Creation",content:"Dag successfully created. You can view it in the Airflow dataset."}),l([]),w(),s(!1)}).catch(m=>{s(!1),d.error({title:"Dag Creation",content:"Failed to create dag."})}).finally(()=>{a(le.invalidateTags([{type:z.ProjectTags.FileExplorer,id:"Airflow"}])),g(u.airflow.overview)})},[a,d,i,p,g,w]),b=o=>{D(o),j()};return e.jsxs(e.Fragment,{children:[e.jsx(M,{title:"Create new workflow",children:e.jsx(t,{sx:{width:"100%"},children:e.jsxs(t,{flexDirection:"column",gap:"20px",children:[e.jsx(Y,{disabled:r,...A("name"),label:"Name",placeholder:"Workflow name",..._("name",E)}),e.jsx(K,{name:"schedule",control:V,render:({field:{value:o,onChange:n},formState:{errors:m}})=>e.jsxs(t,{flexDirection:"column",gap:"10px",children:[e.jsx(t,{alignItems:"center",children:e.jsx(X,{mr:"4px",children:"Frequency"})}),e.jsx(Z,{value:o==="@once"?"Once":"Scheduled",options:["Once","Scheduled"],onChange:h=>n(h==="Once"?"@once":"0 * * * *"),flexDirection:"row"}),o!=="@once"&&e.jsx(de,{value:o,onChange:n,onError:h=>F("schedule",{message:h}),error:m.schedule,withoutLabel:!0})]})})]})})}),e.jsxs(ee,{title:"Operators",mt:"-1px",children:[e.jsx(re,{type:te.neutral,content:e.jsxs(t,{flexDirection:"column",children:[e.jsxs(t,{children:[e.jsx(O,{children:"Launch Operator: "}),e.jsx(k,{children:"Operator to launch a Job in Hopsworks."})]}),e.jsxs(t,{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(t,{gap:"20px",children:[e.jsx(v,{mainText:"",children:e.jsx(x,{disabled:r,intent:"secondary",onClick:()=>{b(f.HopsworksLaunchOperator)},icon:C.plus,sx:{path:{fill:"primary"}},children:"Launch Operator"})}),e.jsx(v,{mainText:"",children:e.jsx(x,{disabled:r,intent:"secondary",onClick:()=>{b(f.HopsworksJobSuccessSensor)},icon:C.plus,sx:{path:{fill:"primary"}},children:"Job Success Sensor"})})]}),e.jsx(se,{children:e.jsx(ne,{operators:i,setOperators:l})}),e.jsx(ae,{}),e.jsx(t,{mt:"20px",justifyContent:"right",children:e.jsxs(t,{flexDirection:"row",children:[e.jsx(x,{intent:"alert",mr:"10px",href:oe(u.airflow.overview,u.project.value,{id:p}),children:"Back"}),e.jsx(pe,{disabled:i.length===0||r,onClick:q(H),isLoading:r,children:"Generate Dag"})]})}),e.jsx(ce,{isOpen:!!P,onClose:j,operatorType:T,operators:i,setOperators:l})]}),e.jsx(t,{minHeight:"20px"})]})},Qe=c.memo(xe);export{Qe as default,ue as schema};
