import{aO as l,cM as a,j as t,y as h,fR as j,L as I,bs as d,a as c,ap as m,d as g,bA as v,fS as D,aw as y,du as b,eN as f,r as u,dx as _,dv as k,dw as A}from"./index-_eM6l4Nf.js";import{u as x}from"./useProjectId-BzgWWAl7.js";const P=e=>{const{deployment:{status:s}}=e;return l(s,[a.RUNNING,a.IDLE,a.FAILED,a.STARTING,a.UPDATING])?t.jsx(L,{...e}):t.jsx(T,{...e})},L=({deployment:e})=>{const[s,n]=h(),[i,{isLoading:o}]=j(),r=x();return t.jsxs(I,{children:[t.jsx(d,{variant:"secondary",color:"labels.red",disabled:l(e.status,S),onClick:n,height:"32px",minWidth:"88px",children:t.jsxs(c,{alignItems:"center",children:[t.jsx(c,{mr:"10px",children:t.jsx(m,{icon:g.stop,color:"labels.red",size:"sm"})}),t.jsx("span",{children:"Stop"})]})}),t.jsx(v,{title:`Stop the deployment ${e.name}`,secondaryText:`You are about to stop the deployment ${e.name}. Please be certain.`,isOpen:s,onClose:n,mainButtonProps:{children:"Stop deployment",isLoading:o,onClick:async()=>{await i({projectId:r,servingId:e.id}),n()}},secondaryButtonProps:{children:"Back",onClick:n}})]})},T=({title:e,deployment:s})=>{const[n,{isLoading:i}]=D(),o=x();return t.jsx(d,{variant:"secondary",color:"labels.green",disabled:l(s.status,S),onClick:()=>n({projectId:o,servingId:s.id}),height:"32px",minWidth:"88px",children:t.jsxs(c,{alignItems:"center",children:[t.jsx(c,{mr:"10px",children:t.jsx(m,{icon:g.play,color:"primary",size:"sm"})}),t.jsx("span",{children:e??"Run"})]})})},S=[a.STOPPING],$=({projectName:e,deploymentName:s})=>`/grafana/d/kserve/kserve?${f.stringify({orgId:1,refresh:"10s","var-namespace":e.toLowerCase().replaceAll("_","-"),"var-configuration":`${s}-.*`,"var-revision":"All"})}`,E=()=>{const{project:e}=y();return s=>`${b}${$({projectName:(e==null?void 0:e.projectName)??"",deploymentName:s})}`},C=({projectName:e,deploymentName:s})=>`/?_g=()&_a=(columns:!(serving_name,log_message,'@timestamp'),index:'${e.toLowerCase()}_serving-*',interval:auto,query:(language:lucene,query:'serving_name:${s}'),sort:!('@timestamp',desc))`,R=()=>{const{id:e,project:s}=y(),[n,i]=u.useState(),o=async r=>{const{data:p}=await new k().request({url:`/elastic/jwt/${r} `,type:A.get});p&&i(p.kibanaUrl)};return u.useEffect(()=>{o(e)},[e]),r=>`${_}${n}security_tenant=private#${C({projectName:(s==null?void 0:s.projectName)??"",deploymentName:r})}`};export{P as D,E as a,R as u};
