var j=Object.defineProperty;var x=(s,e,t)=>e in s?j(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var b=(s,e,t)=>(x(s,typeof e!="symbol"?e+"":e,t),t);import{C as A}from"./CrudView.f360b43c.js";import{a as P}from"./asyncComputed.7b5c3427.js";import{G as _}from"./PhPencil.vue.184a28bf.js";import{d as D,eB as E,e as N,f as U,o as k,eu as B,b as u,u as o,w as p,aE as G,eN as F,c as T,ck as R,cR as S,as as K,eA as O,cp as q,cj as z,ew as H,cu as J}from"./vue-router.74c693f1.js";import{C as c}from"./gateway.707771fc.js";import"./index.0791082e.js";import"./router.77dea3d2.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.97a16843.js";import"./BookOutlined.7a96a9c1.js";import"./url.8b7ee03b.js";import"./index.ad2af8a3.js";import"./index.33768c38.js";import"./popupNotifcation.d39bbf9b.js";import"./record.0d85e3b6.js";import"./string.b1ebfabb.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="e5eb94bd-8d4c-45f9-96d4-a2605c421a19",s._sentryDebugIdIdentifier="sentry-dbid-e5eb94bd-8d4c-45f9-96d4-a2605c421a19")}catch{}})();class L{constructor(){b(this,"urlPath","env-vars")}async create(e){return c.post(`projects/${e.projectId}/${this.urlPath}`,{name:e.name,value:e.value})}async delete(e,t){await c.delete(`projects/${e}/${this.urlPath}/${t}`)}async update(e,t,a){await c.patch(`projects/${e}/${this.urlPath}/${t}`,{value:a})}async list(e){return c.get(`projects/${e}/${this.urlPath}`)}async get(e){return c.get(`${this.urlPath}/${e}`)}}const d=new L;class i{constructor(e,t){this.projectId=e,this.dto=t}static async list(e){return(await d.list(e)).map(a=>new i(e,a))}static async create(e,t,a){const y=await d.create({projectId:e,name:t,value:a});return new i(e,y)}static async get(e,t){const a=await d.get(t);return new i(e,a)}get key(){return this.dto.name}async delete(){await d.delete(this.projectId,this.key)}async update(e){await d.update(this.projectId,this.key,e)}}const ce=D({__name:"EnvVars",setup(s){const t=E().params.projectId,a=N({type:"idle"}),{loading:y,result:m,refetch:f}=P(()=>i.list(t)),g=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"multiline-text"}];async function h({key:l,value:n}){await i.create(t,l,n),f()}function $(l){a.value={type:"update-value",key:l.key,newValue:""}}async function v(l){var n;if(a.value.type==="update-value"&&l){const{key:r,newValue:V}=a.value,w=(n=m.value)==null?void 0:n.find(I=>I.key===r);w&&await w.update(V)}a.value={type:"idle"}}const C=U(()=>{var l,n;return{columns:[{name:"Key"},{name:"",align:"right"}],rows:(n=(l=m.value)==null?void 0:l.map(r=>({key:r.key,cells:[{type:"text",text:r.key},{type:"actions",actions:[{icon:F,label:"Delete",async onClick(){await r.delete(),f()},dangerous:!0},{icon:_,label:"Update value",onClick(){$(r)}}]}]})))!=null?n:[]}});return(l,n)=>(k(),B(G,null,[u(A,{"entity-name":"Env var",loading:o(y),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:C.value,"create-button-text":"Add Environment Variable",fields:g,onCreate:h},null,8,["loading","table"]),u(o(J),{open:a.value.type==="update-value",title:"Update value",onCancel:n[1]||(n[1]=r=>v(!1)),onOk:n[2]||(n[2]=r=>v(!0))},{default:p(()=>[a.value.type==="update-value"?(k(),T(o(z),{key:0,layout:"vertical"},{default:p(()=>[u(o(R),null,{default:p(()=>[u(o(S),null,{default:p(()=>[K(O(a.value.key),1)]),_:1}),u(o(q),{value:a.value.newValue,"onUpdate:value":n[0]||(n[0]=r=>a.value.newValue=r)},null,8,["value"])]),_:1})]),_:1})):H("",!0)]),_:1},8,["open"])],64))}});export{ce as default};
//# sourceMappingURL=EnvVars.80fdea16.js.map
