import{bf as T,u as B,bg as L,hw as O,gh as U,hM as D,hx as Q,hv as R,r as u,bb as _,bc as $,w as z,bE as G,b8 as I,Y as V,cy as W,hN as q,q as r,j as e,be as H,ay as Y,Q as K,d as X,az as Z,aR as w,d0 as J}from"./index-CK33qGU_.js";import{A as ee,a as d}from"./Anchor-HBBcGDu5.js";import{P as te,F as oe}from"./Project-j3KdDsvH.js";import{B as ie}from"./ButtonWithRole-NHXEosto.js";import{S as ae}from"./ServiceAlertList-BdM6y14f.js";import{u as se}from"./CronSchedule-BIoMWGFs.js";import{u as re,S as ne}from"./JobOverviewContent-CbBWZ5M5.js";import{N as le}from"./NotebookJobArgsCallout-BePPd6f1.js";import"./alertManagerConfig.selectors-BX2JGYEL.js";import"./__-BIxbRvwe.js";import"./useDownload-hrjXceJg.js";import"./useProject-BzBQtp4J.js";import"./length-fOfC3W0h.js";import"./complement-M2aUPqXA.js";import"./FileUploaderButton-Bppadu35.js";import"./dumbPluralize-CcxDsNiu.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"./index-CKCOe8Wi.js";import"./LabelValue-j2PGK56O.js";import"./PopupWithTitle-CR47heoT.js";import"./Panel-q_vviXAK.js";import"./Deprecated-D5xZ0QMJ.js";import"./CardActionButton-DcsFpjJz.js";import"./index-Cwe0XbXT.js";import"./DateValue-BXA-t-WJ.js";import"./FileContent-BRNHLExA.js";import"./clamp-Cn_DLqOJ.js";import"./jupyter.selectors-B8a5Dlnv.js";import"./utils-CP84q1kA.js";import"./SvgContent-DBU37Fnv.js";import"./mergeDeepWith-BpZXvEs5.js";import"./index-CIxm3shV.js";import"./Table-BN1CB6vu.js";import"./useKeyPress-fCwPtiTw.js";import"./utils-37_jnP5r.js";import"./index-B550xy2H.js";import"./pathSatisfies-CSrP04yE.js";import"./JobsExecutionsPopup-BCMHDb4N.js";import"./RunJobButtons-DnPapolJ.js";const ot=()=>{const c=T(),{id:o,jobName:n}=B(),a=L(),[s,{isLoading:P}]=O(),[g,{isLoading:y}]=U(),[f]=D(),[x]=Q(),{data:l}=se(),j=P||y,{currentData:t,isFetching:h}=R({pId:o,jobName:n}),{handleDeleteJob:N,isDeleting:b}=re(),S=u.useMemo(()=>t?[t.config]:[],[t]);_(`${$.editJob} ${t==null?void 0:t.name}`);const[C,p]=z(),v=u.useCallback(async(i,me,ce,m)=>{const k=G(I(V))(i),E={...i[i.type],...k},{name:A}=await s({pId:o,data:W(t==null?void 0:t.config,E),name:i.appName}).unwrap();l&&m&&await g({pId:o,data:{...l,...m},jobName:i.appName}).unwrap(),l&&!m&&(await f({pId:o,jobName:i.appName}),c(q.updateQueryData("getJobSchedule",{pId:o,jobName:n},M=>{Object.assign(M,{deleted:!0})}))),!l&&m&&await x({pId:o,data:m,jobName:i.appName}),A&&a(r.jobs.overview,{jobName:A})},[x,f,c,t==null?void 0:t.config,n,a,l,o,s,g]),F=u.useCallback(async()=>{t&&(await N(t.name),p(),a(r.jobs.list))},[t,N,p,a]);return e.jsxs(e.Fragment,{children:[t&&S.length>0&&e.jsx(te,{isLoading:h,isDisabled:j||b,initialData:S,submitHandler:v,isSubmiting:j,disabledJobTypeChange:!0,checkedAdvancedConfig:!0,children:i=>e.jsx(pe,{...i,jobData:t,handleToggle:p})}),e.jsx(H,{title:`Delete ${t==null?void 0:t.name}`,secondaryText:"Once you delete a job, there is no going back. Please be certain.",isOpen:C,onClose:p,mainButtonProps:{"data-test":"delete-job",children:"Delete job",onClick:F,disabled:h,isLoading:b},secondaryButtonProps:{children:"Back",onClick:p,disabled:b||h}})]})},pe=({advanceConfig:c,jobData:o,handleToggle:n})=>{const{register:a,setValue:s}=Y();return u.useEffect(()=>{s("appName",o.config.appName),setTimeout(()=>s("appPath",o.config.appPath)),s("defaultArgs",o.config.defaultArgs??"")},[o,o.appName,o.appPath,o.defaultArgs,s]),e.jsxs(ee,{children:[e.jsx(d,{name:r.jobAnchors.jobDetails,children:e.jsx(K,{title:"Edit job",children:e.jsxs(X,{flexDirection:"column",sx:{gap:"20px"},children:[e.jsx(oe,{name:"appPath",label:"File",fileExplorerMode:Z.oneFile,filePathPrefix:"hdfs://",disabled:!0}),e.jsx(w,{...a("appName"),placeholder:"name",label:"Name",labelProps:{width:"320px"},readOnly:!0}),(o.config.appPath??"").endsWith(".ipynb")&&e.jsx(le,{}),e.jsx(w,{optional:!0,...a("defaultArgs"),placeholder:"args",label:"Default arguments",labelProps:{width:"100%"}})]})})}),e.jsx(d,{name:r.jobAnchors.schedule,children:e.jsx(ne,{withoutSave:!0})}),e.jsx(d,{name:r.jobAnchors.config,children:e.jsx(J,{width:"100%",title:"Advanced configuration",children:c})}),e.jsx(d,{name:r.jobAnchors.alerts,children:e.jsx(ae,{type:"job",job:o,mb:"0"})}),e.jsx(J,{title:"Danger zone",children:e.jsx(ie,{intent:"alert",onClick:n,children:"Delete job"})})]})};export{ot as default};
