var x=Object.defineProperty;var j=(r,e,t)=>e in r?x(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var b=(r,e,t)=>(j(r,typeof e!="symbol"?e+"":e,t),t);import{C as A}from"./CrudView.20a6abd6.js";import{a as E}from"./asyncComputed.d7d35a9b.js";import{G as P}from"./PhPencil.vue.c44f0344.js";import{d as _,eE as D,r as U,J as F,b as k,ew as G,f as u,u as l,w as c,aE as N,eS as B,c as S,as as T,eH as H,cr as J,ey as K}from"./outputWidgets.eb68177a.js";import{C as d}from"./router.317efb7d.js";import"./index.2a154e70.js";import{A as O,F as R}from"./Form.80a7df3d.js";import{A as q}from"./Text.accbe772.js";import{M as z}from"./Modal.92968fec.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.f91735c0.js";import"./BookOutlined.297648c9.js";import"./url.1bbc2ec6.js";import"./Paragraph.fd20e99e.js";import"./Base.20dd2a14.js";import"./index.c8945831.js";import"./Title.59fcdfbb.js";import"./index.1753b1f8.js";import"./popupNotifcation.24fa7567.js";import"./record.0fb02764.js";import"./pubsub.bf42621d.js";import"./hasIn.5508971f.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="30b277f8-dd49-42f9-9e65-5c9d71ad5392",r._sentryDebugIdIdentifier="sentry-dbid-30b277f8-dd49-42f9-9e65-5c9d71ad5392")}catch{}})();class L{constructor(){b(this,"urlPath","env-vars")}async create(e){return d.post(`projects/${e.projectId}/${this.urlPath}`,{name:e.name,value:e.value})}async delete(e,t){await d.delete(`projects/${e}/${this.urlPath}/${t}`)}async update(e,t,a){await d.patch(`projects/${e}/${this.urlPath}/${t}`,{value:a})}async list(e){return d.get(`projects/${e}/${this.urlPath}`)}async get(e){return d.get(`${this.urlPath}/${e}`)}}const p=new L;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 m=await p.create({projectId:e,name:t,value:a});return new i(e,m)}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 ve=_({__name:"EnvVars",setup(r){const t=D().params.projectId,a=U({type:"idle"}),{loading:m,result:y,refetch:f}=E(()=>i.list(t)),g=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"multiline-text"}];async function h({key:s,value:n}){await i.create(t,s,n),f()}function $(s){a.value={type:"update-value",key:s.key,newValue:""}}async function v(s){var n;if(a.value.type==="update-value"&&s){const{key:o,newValue:V}=a.value,w=(n=y.value)==null?void 0:n.find(I=>I.key===o);w&&await w.update(V)}a.value={type:"idle"}}const C=F(()=>{var s,n;return{columns:[{name:"Key"},{name:"",align:"right"}],rows:(n=(s=y.value)==null?void 0:s.map(o=>({key:o.key,cells:[{type:"text",text:o.key},{type:"actions",actions:[{icon:B,label:"Delete",async onClick(){await o.delete(),f()},dangerous:!0},{icon:P,label:"Update value",onClick(){$(o)}}]}]})))!=null?n:[]}});return(s,n)=>(k(),G(N,null,[u(A,{"entity-name":"Env var",loading:l(m),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]=o=>v(!1)),onOk:n[2]||(n[2]=o=>v(!0))},{default:c(()=>[a.value.type==="update-value"?(k(),S(l(R),{key:0,layout:"vertical"},{default:c(()=>[u(l(O),null,{default:c(()=>[u(l(q),null,{default:c(()=>[T(H(a.value.key),1)]),_:1}),u(l(J),{value:a.value.newValue,"onUpdate:value":n[0]||(n[0]=o=>a.value.newValue=o)},null,8,["value"])]),_:1})]),_:1})):K("",!0)]),_:1},8,["open"])],64))}});export{ve as default};
//# sourceMappingURL=EnvVars.5e86692e.js.map
