1import{H as g,j as e,U as $,o as ae,s as ne,N as M}from"./vendors-GjAHfUur.js";import{aL as oe,b3 as I,bE as ie,aa as N,aG as E,bF as re,ab as ce,x as P,bk as le,bG as de,bH as B,z as u,P as me,bI as q,bJ as ue,bK as pe,b9 as Q,y as p,u as xe,a4 as he,b5 as L,w as je,bL as O,bM as ge,D as W,e as H,l as K,at as G,b as A,m as J,n as F,h as z,o as k,p as U,f as fe,C as Y,T as b,s as X,aw as be,ba as ve,ad as T,I as C,as as ye,bN as Ie,aJ as Ne,a7 as V,bd as Se,W as we,bb as Te,bO as Ce,bP as Ve,aM as De,bQ as Ee,bR as Pe,b2 as Ae,ak as Fe}from"./index-DPgctgMV.js";import{r as D}from"./analytics-BDaDZ9f1.js";import{N as ze}from"./no-resource-DnlOqBDc.js";import{R as ke}from"./region-flag-Bh_Fka_D.js";import{R as Re}from"./region-name-DiCd0ou7.js";import{S as Z}from"./service-type-icon-DVXo5w9r.js";import{V as _e}from"./status-badges-ljRpPhmj.js";import{a as Me}from"./formatted-3wtevW2y.js";import{I as $e}from"./input-end-spinner-DsxQFAFx.js";import{N as Be}from"./no-items-BeBHVTSd.js";import{P as qe}from"./pen-C_hyv_wp.js";import{T as Qe}from"./trash-COOlBJ4O.js";import"./package-DsSCz-7L.js";import"./square-code-BV2m0esR.js";import"./cpu-BpiHuYJX.js";import"./moon-Pcfnffyt.js";import"./circle-check-CUujM7rL.js";import"./timers-PgkQhLJK.js";import"./date-Ctz5HfUF.js";import"./differenceInSeconds-BkiuOB6c.js";import"./toDate-REVqqrxt.js";import"./addMonths-ndSlExaS.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"f3c35768d03cf7cbdb16c05b8e4bf996578a057c"};var a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="d82b8408-ed22-42e0-a1a1-96cb0c66993d",t._sentryDebugIdIdentifier="sentry-dbid-d82b8408-ed22-42e0-a1a1-96cb0c66993d")}catch{}})();const f=p("pages.volumes.list.attach"),ee=10;function Le({volume:t}){const a=f.useTranslate(),s=oe(),[n]=I(),o=t.region,c=ie(o),[r,d]=D.useState(""),x=Oe(o,r),se=N({...E("get /v1/services",{query:{project_id:n,limit:"1",regions:[o]}}),select:({count:i})=>i}),m=g({items:x.data?.services??[],itemToString:i=>i?.name??"",inputValue:r,onInputValueChange({inputValue:i}){d(i)},onSelectedItemChange({selectedItem:i}){i&&s({to:`/services/${i.id}/settings`,search:{"attach-volume":t.id}})},stateReducer:(i,{type:j,changes:w})=>{switch(j){case g.stateChangeTypes.InputClick:return{...w,isOpen:i.isOpen};case g.stateChangeTypes.ItemClick:case g.stateChangeTypes.InputKeyDownEnter:return{...w,inputValue:i.inputValue};default:return w}}}),R=re({floating:{open:m.isOpen,placement:"bottom-end"},offset:4,flip:!0}),{apps:te,services:S}=x.data??{},_=se.data;return e.jsxs(e.Fragment,{children:[e.jsx(ce,{forceDesktop:!0,content:x.error?.message??(t.serviceId&&e.jsx(f,{id:"alreadyMounted"})),trigger:i=>e.jsx("div",{...i,children:e.jsxs(P,{...m.getToggleButtonProps({ref:R.refs.setReference}),disabled:t.serviceId!==void 0||x.isError,size:1,color:"gray",children:[e.jsx(f,{id:"label"}),e.jsx(le,{className:"size-em"})]})})}),e.jsxs(de,{dropdown:R,onClosed:()=>d(""),className:"w-full max-w-sm",children:[e.jsx(B,{...m.getInputProps(),type:"search",start:e.jsx(me,{background:!1,children:e.jsx(q,{className:"size-4 text-dim"})}),end:e.jsx($e,{show:x.isPending}),placeholder:a("placeholder"),className:u({hidden:_===void 0||_<=ee}),root:{className:"rounded-b-none border-x-0 border-t-0 outline-none"}}),S?.length===0&&e.jsx(Be,{message:e.jsx(f,{id:"noServices",values:{region:c?.name}})}),e.jsx(ue,{...m.getMenuProps(),className:u({hidden:S?.length===0}),children:S?.map((i,j)=>D.createElement(pe,{...m.getItemProps({item:i,index:j}),key:i.id,highlighted:j===m.highlightedIndex,className:"py-1.5"},e.jsx(Ge,{app:te?.find(Q("id",i.appId)),service:i})))})]})]})}function Oe(t,a){const s=xe(),[n]=I();return N({queryKey:["searchServices",{api:s,projectId:n,region:t,search:a}],queryFn:async({signal:o})=>{await je(200,o);const[c,r]=await Promise.all([We(s,n,o),Ke(s,n,t,a,o)]);return await Promise.all(r.map(async d=>{c.find(Q("id",d.appId))||c.push(await He(s,d.appId,o))})),{apps:c,services:r}},placeholderData:L})}async function We(t,a,s){return t("get /v1/apps",{query:{project_id:a,limit:"100"}},{signal:s}).then(({apps:n})=>n.map(O))}async function He(t,a,s){return t("get /v1/apps/{id}",{path:{id:a}},{signal:s}).then(({app:n})=>O(n))}async function Ke(t,a,s,n,o){return t("get /v1/services",{query:{project_id:a,name:n,regions:[s],limit:String(ee),types:["WEB","WORKER"]}},{signal:o}).then(({services:c})=>c.map(ge))}function Ge({app:t,service:a}){return e.jsxs("div",{className:"row items-center gap-2",children:[e.jsx(Z,{type:a.type}),e.jsxs("div",{className:"col gap-0.5",children:[`${t?.name}/${a.name}`,e.jsx("div",{className:"text-xs text-dim",children:e.jsx(he,{enum:"serviceType",value:a.type})})]})]})}const v=p("pages.volumes.createSnapshot"),Je=ae({name:ne().min(2).max(63)});function Ue(){return e.jsx(W,{id:"CreateSnapshotFromVolume",className:"col w-full max-w-xl gap-4",children:t=>e.jsxs(e.Fragment,{children:[e.jsx(H,{title:e.jsx(v,{id:"title"})}),e.jsx("div",{className:"text-dim",children:e.jsx(v,{id:"description"})}),e.jsx(Ye,{volume:t})]})})}function Ye({volume:t}){const a=v.useTranslate(),s=K(),[n]=I(),o=$({defaultValues:{name:""},resolver:G(Je)}),c=A({...k("post /v1/snapshots",({name:r})=>({body:{project_id:n,parent_volume_id:t.id,name:r}})),async onSuccess({snapshot:r}){await Promise.all([s("get /v1/volumes"),s("get /v1/snapshots")]),F.success(a("success",{name:r.name})),z()},onError:J(o)});return e.jsxs("form",{onSubmit:X(o,c.mutateAsync),className:"col gap-4",children:[e.jsx(U,{control:o.control,name:"name",label:e.jsx(v,{id:"nameLabel"}),placeholder:a("namePlaceholder")}),e.jsxs(fe,{children:[e.jsx(Y,{children:e.jsx(b,{id:"common.cancel"})}),e.jsx(P,{type:"submit",loading:o.formState.isSubmitting,autoFocus:!0,children:e.jsx(b,{id:"common.create"})})]})]})}const y=p("pages.volumes.edit");function Xe(){return e.jsx(W,{id:"EditVolume",className:"col w-full max-w-xl gap-4",children:t=>e.jsxs(e.Fragment,{children:[e.jsx(H,{title:e.jsx(y,{id:"title"})}),e.jsx("p",{className:"text-dim",children:e.jsx(y,{id:"description"})}),e.jsx(es,{volume:t})]})})}const Ze=M.object({name:M.string().min(2).max(63)});function es({volume:t}){const a=y.useTranslate(),s=$({defaultValues:{name:t.name},resolver:G(Ze)}),n=A({...k("post /v1/volumes/{id}",({name:o})=>({path:{id:t.id},body:{name:o}})),onError:J(s),onSuccess(o){F.success(a("updated",{name:o.volume?.name})),z()}});return e.jsxs("form",{className:"col gap-4",onSubmit:X(s,n.mutateAsync),children:[e.jsx(U,{control:s.control,name:"name",label:e.jsx(y,{id:"name.label"}),placeholder:a("name.placeholder")}),e.jsxs(be,{children:[e.jsx(Y,{children:e.jsx(b,{id:"common.cancel"})}),e.jsx(P,{type:"submit",loading:s.formState.isSubmitting,autoFocus:!0,children:e.jsx(b,{id:"common.save"})})]})]})}
1const h=p("pages.volumes");function ss({volume:t}){const a=h.useTranslate(),s=ts(),n=()=>{C("Confirmation",{title:a("delete.title"),description:a("delete.description",{name:t.name}),destructiveAction:!0,destructiveActionMessage:a("delete.destructiveActionWarning"),confirmationText:t.name,submitText:a("delete.confirm"),onConfirm:()=>s.mutateAsync(t)})};return e.jsxs(ve,{children:[e.jsxs(T,{onClick:()=>C("EditVolume",t),children:[e.jsx(qe,{className:"size-4"}),e.jsx(h,{id:"list.actions.edit"})]}),e.jsxs(T,{onClick:()=>C("CreateSnapshotFromVolume",t),children:[e.jsx(ye,{className:"size-4"}),e.jsx(h,{id:"list.actions.createSnapshot"})]}),e.jsxs(T,{onClick:n,children:[e.jsx(Qe,{className:"size-4"}),e.jsx(h,{id:"list.actions.delete"})]})]})}function ts(){const t=h.useTranslate(),a=K();return A({...k("delete /v1/volumes/{id}",s=>({path:{id:s.id}})),async onSuccess(s,n){await a("get /v1/volumes"),F.info(t("delete.success",{name:n.name})),z()}})}const l=p("pages.volumes.list");function as(){const t=l.useTranslate(),[a]=I(),s=Ie(),[n,o]=D.useState(""),c=N({...E("get /v1/volumes",{query:{...s.query,project_id:a,name:n||void 0}}),placeholderData:L,select:({volumes:r,has_next:d})=>({volumes:r.map(Ee),hasNext:!!d})});return s.useSync(c.data),e.jsx(Ne,{query:c,children:({volumes:r})=>e.jsxs("section",{className:"col gap-4",children:[e.jsxs("div",{className:"row items-center justify-between gap-4",children:[e.jsx(B,{placeholder:t("header.search"),value:n,onChange:d=>o(d.target.value),start:e.jsx("span",{className:"row items-center self-stretch pl-1",children:e.jsx(q,{className:"size-4 text-dim"})})}),r.length>0&&e.jsx(V,{to:"/volumes/new",children:e.jsx(l,{id:"header.createVolume"})})]}),r.length===0&&e.jsx(ze,{title:e.jsx(l,{id:"noVolumes.title"}),description:e.jsx(l,{id:"noVolumes.description"}),cta:e.jsx(V,{to:"/volumes/new",children:e.jsx(l,{id:"noVolumes.cta"})})}),r.length>0&&e.jsx(ns,{volumes:r}),s.hasPages&&e.jsx(Se,{pagination:s})]})})}function ns({volumes:t}){const a=!we("lg");return e.jsxs(e.Fragment,{children:[e.jsx(Te,{items:t,columns:{name:{header:e.jsx(l,{id:"name"}),render:s=>e.jsx(os,{volume:s})},status:{header:e.jsx(l,{id:"status"}),render:s=>e.jsx(_e,{status:s.status})},region:{hidden:a,header:e.jsx(l,{id:"region"}),render:s=>e.jsxs("div",{className:"row items-center gap-2",children:[e.jsx(ke,{regionId:s.region,className:"size-4"}),e.jsx(Re,{regionId:s.region})]})},size:{header:e.jsx(l,{id:"size"}),className:u("w-26"),render:s=>Ce(s.size,{decimal:!0})},created:{hidden:a,header:e.jsx(l,{id:"created"}),className:u("w-34"),render:s=>e.jsx(Me,{value:s.createdAt})},service:{hidden:a,header:e.jsx(l,{id:"attachedTo"}),className:u("w-26"),render:s=>e.jsx(is,{volume:s,serviceId:s.serviceId})},actions:{className:u("w-[1%]"),render:s=>e.jsx(ss,{volume:s})}}}),e.jsx(Xe,{}),e.jsx(Ue,{})]})}function os({volume:t}){const a=N({...E("get /v1/snapshots/{id}",{path:{id:t.snapshotId}}),enabled:t.snapshotId!==void 0,refetchInterval:Ae(),select:({snapshot:s})=>Pe(s)});return e.jsxs("div",{className:"row items-center gap-2",children:[e.jsx("div",{className:"max-w-xs truncate",children:t.name}),a.isSuccess&&e.jsx(De,{content:e.jsx(l,{id:"parentSnapshot",values:{name:a.data.name}})})]})}function is({volume:t,serviceId:a}){const s=Ve(a);return a===void 0?e.jsx(Le,{volume:t}):s?e.jsxs(V,{to:"/services/$serviceId",params:{serviceId:a},variant:"outline",color:"gray",size:1,children:[e.jsx(Z,{type:s.type,size:2}),s.name]}):null}const rs=p("pages.volumes"),Ps=function(){const a=rs.useTranslate();return e.jsxs("div",{className:"col gap-8",children:[e.jsx(Fe,{title:a("documentTitle")}),e.jsx(as,{})]})};export{Ps as component}; 2//# sourceMappingURL=index-DHIervBb.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.