import{bI as E,u as L,bJ as M,jl as I,hb as O,jA as U,jm as K,jk as R,r,bx as _,by as $,w as z,c8 as G,bu as Q,a0 as W,d7 as H,jB as V,s as n,j as e,bA as q,aK as D,y as X,B as Y,aL as Z,b5 as J,dz as C,bs as ee}from"./index-C1DmWO_C.js";import{A as te,a as m}from"./Anchor-DFXOcnPw.js";import{K as se,F as ie}from"./Project-CpwJZ-CK.js";import{S as oe}from"./ServiceAlertList-CzBjm52H.js";import{u as ae}from"./CronSchedule-DcbtrNRK.js";import{u as ne,S as re}from"./JobOverviewContent-DjYXCveA.js";import{N as le}from"./NotebookJobArgsCallout-7tIiXwQk.js";import{K as ce}from"./KubernetesProjectEdit-O522bxXP.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"./index-BnHp_Wzf.js";import"./LabelValue-BcFtbPW0.js";import"./Panel-Z-sMb6LN.js";import"./Deprecated-BQWZLUTP.js";import"./index-GabIfpNZ.js";import"./DateValue-CuEyJqPS.js";import"./RunJobButtons-DDz4XNL0.js";import"./KubernetesProjectView-Bel69CN9.js";const Ue=()=>{const u=E(),{id:t,jobName:l}=L(),a=M(),[o,{isLoading:b}]=I(),[h,{isLoading:P}]=O(),[j]=U(),[x]=K(),{data:c}=ae(),A=b||P,{currentData:s,isFetching:g}=R({pId:t,jobName:l}),{handleDeleteJob:S,isDeleting:f}=ne(),N=r.useMemo(()=>s?[s.config]:[],[s]);_(`${$.editJob} ${s==null?void 0:s.name}`);const[w,d]=z(),k=r.useCallback(async(i,pe,me,p)=>{const v=G(Q(W))(i),T={...i[i.type],...v},{name:y}=await o({pId:t,data:H(s==null?void 0:s.config,T),name:i.appName}).unwrap();c&&p&&await h({pId:t,data:{...c,...p},jobName:i.appName}).unwrap(),c&&!p&&(await j({pId:t,jobName:i.appName}),u(V.updateQueryData("getJobSchedule",{pId:t,jobName:l},B=>{Object.assign(B,{deleted:!0})}))),!c&&p&&await x({pId:t,data:p,jobName:i.appName}),y&&a(n.jobs.overview,{jobName:y})},[x,j,u,s==null?void 0:s.config,l,a,c,t,o,h]),F=r.useCallback(async()=>{s&&(await S(s.name),d(),a(n.jobs.list))},[s,S,d,a]);return e.jsxs(e.Fragment,{children:[s&&N.length>0&&e.jsx(se,{isLoading:g,isDisabled:A||f,initialData:N,submitHandler:k,isSubmiting:A,disabledJobTypeChange:!0,checkedAdvancedConfig:!0,children:i=>e.jsx(de,{...i,jobData:s,handleToggle:d})}),e.jsx(q,{title:`Delete ${s==null?void 0:s.name}`,secondaryText:"Once you delete a job, there is no going back. Please be certain.",isOpen:w,onClose:d,mainButtonProps:{"data-test":"delete-job",children:"Delete job",onClick:F,disabled:g,isLoading:f},secondaryButtonProps:{children:"Back",onClick:d,disabled:f||g}})]})},de=({advanceConfig:u,jobData:t,handleToggle:l})=>{const{register:a,setValue:o}=D();r.useEffect(()=>{o("appName",t.config.appName),setTimeout(()=>o("appPath",t.config.appPath)),o("defaultArgs",t.config.defaultArgs??""),setTimeout(()=>o("python.schedulingConfig",t.config.schedulingConfig??{}))},[t,t.appName,t.appPath,t.defaultArgs,t.config.schedulingConfig,o]);const b=r.useMemo(()=>[t.jobType.toLowerCase()],[t]),h=r.useMemo(()=>!1,[]);return e.jsxs(te,{children:[e.jsx(m,{name:n.jobAnchors.jobDetails,children:e.jsx(X,{title:"Edit job",children:e.jsxs(Y,{flexDirection:"column",sx:{gap:"20px"},children:[e.jsx(ie,{name:"appPath",label:"File",fileExplorerMode:Z.oneFile,filePathPrefix:"hdfs://",disabled:!0}),e.jsx(J,{...a("appName"),placeholder:"name",label:"Name",labelProps:{width:"320px"},readOnly:!0}),(t.config.appPath??"").endsWith(".ipynb")&&e.jsx(le,{}),e.jsx(J,{optional:!0,...a("defaultArgs"),placeholder:"args",label:"Default arguments",labelProps:{width:"100%"}})]})})}),e.jsx(m,{name:n.jobAnchors.schedule,children:e.jsx(re,{withoutSave:!0})}),e.jsx(m,{name:n.jobAnchors.kubernetesScheduler,children:e.jsx(ce,{prefix:b,init:h})}),e.jsx(m,{name:n.jobAnchors.config,children:e.jsx(C,{width:"100%",title:"Advanced configuration",children:u})}),e.jsx(m,{name:n.jobAnchors.alerts,children:e.jsx(oe,{type:"job",job:t,mb:"0"})}),e.jsx(C,{title:"Danger zone",children:e.jsx(ee,{intent:"alert",onClick:l,children:"Delete job"})})]})};export{Ue as default};
