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 P}from"./CrudView.30543074.js";import{a as A}from"./asyncComputed.c7982027.js";import{G as D}from"./PhPencil.vue.5fbcac5a.js";import{d as _,eC as E,q as G,J as U,o as k,eu as N,b as u,u as l,w as d,aD as B,eP as F,c as T,cj as S,cQ as q,ar as J,eG as K,co as O,ci as Q,ew as R,ct as z}from"./vue-router.6b399b0b.js";import{C as c}from"./gateway.34f2a318.js";import"./index.c3b84c4d.js";import"./router.ab3f179a.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.e21048fc.js";import"./BookOutlined.7993dbf1.js";import"./url.2f4a4260.js";import"./index.57cdc892.js";import"./index.2e72b67b.js";import"./popupNotifcation.17b9c327.js";import"./record.f5201a57.js";import"./string.79d7b0e1.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]="8041a9a5-b693-457a-91f9-9ef74e9a0542",s._sentryDebugIdIdentifier="sentry-dbid-8041a9a5-b693-457a-91f9-9ef74e9a0542")}catch{}})();class H{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 p=new H;class i{constructor(e,t){this.projectId=e,this.dto=t}static async list(e){return(await p.list(e)).map(a=>new i(e,a))}static async create(e,t,a){const y=await p.create({projectId:e,name:t,value:a});return new i(e,y)}static async get(e,t){const a=await p.get(t);return new i(e,a)}get key(){return this.dto.name}async delete(){await p.delete(this.projectId,this.key)}async update(e){await p.update(this.projectId,this.key,e)}}const ce=_({__name:"EnvVars",setup(s){const t=E().params.projectId,a=G({type:"idle"}),{loading:y,result:m,refetch:f}=A(()=>i.list(t)),g=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"multiline-text"}];async function h({key:o,value:n}){await i.create(t,o,n),f()}function $(o){a.value={type:"update-value",key:o.key,newValue:""}}async function v(o){var n;if(a.value.type==="update-value"&&o){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 o,n;return{columns:[{name:"Key"},{name:"",align:"right"}],rows:(n=(o=m.value)==null?void 0:o.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:D,label:"Update value",onClick(){$(r)}}]}]})))!=null?n:[]}});return(o,n)=>(k(),N(B,null,[u(P,{"entity-name":"Env var",loading:l(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(l(z),{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:d(()=>[a.value.type==="update-value"?(k(),T(l(Q),{key:0,layout:"vertical"},{default:d(()=>[u(l(S),null,{default:d(()=>[u(l(q),null,{default:d(()=>[J(K(a.value.key),1)]),_:1}),u(l(O),{value:a.value.newValue,"onUpdate:value":n[0]||(n[0]=r=>a.value.newValue=r)},null,8,["value"])]),_:1})]),_:1})):R("",!0)]),_:1},8,["open"])],64))}});export{ce as default};
//# sourceMappingURL=EnvVars.97f25df5.js.map
