var _=Object.defineProperty;var j=(o,e,t)=>e in o?_(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var k=(o,e,t)=>(j(o,typeof e!="symbol"?e+"":e,t),t);import{d as x,eB as D,r as A,H as P,a as E,b as g,ev as U,f as u,u as p,w as m,aD as B,c as N,ar as F,eD as H,bz as S,ex as T}from"./outputWidgets.66cb3323.js";import{C as c}from"./router.0bc1d0d5.js";import"./index.9d397e35.js";import{i as z,H as G}from"./icons.bf22aa40.js";import{a as K}from"./asyncComputed.e916adae.js";import{C as O}from"./CrudView.4fbaeb64.js";import{A as R}from"./Form.6c3a2d9f.js";import{A as q}from"./Text.86e9a2de.js";import{M as J}from"./Modal.7f50b274.js";import"./popupNotifcation.9d486082.js";import"./index.cf4c23b9.js";import"./record.b20b5768.js";import"./pubsub.19cef690.js";import"./Paragraph.de06c047.js";import"./Base.e0db6d09.js";import"./Typography.2ce150f4.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.f80c2df7.js";import"./url.50176a21.js";import"./index.c07575ec.js";import"./Title.dfc9c803.js";import"./index.c1ed2dcd.js";import"./hasIn.cda4df71.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[e]="af808ed5-12d3-47e0-86ff-2bff7abbcc15",o._sentryDebugIdIdentifier="sentry-dbid-af808ed5-12d3-47e0-86ff-2bff7abbcc15")}catch{}})();class L{constructor(){k(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 l{constructor(e,t){this.projectId=e,this.dto=t}static async list(e){return(await d.list(e)).map(a=>new l(e,a))}static async create(e,t,a){const y=await d.create({projectId:e,name:t,value:a});return new l(e,y)}static async get(e,t){const a=await d.get(t);return new l(e,a)}get key(){return this.dto.name}get value(){return this.dto.value}async delete(){await d.delete(this.projectId,this.key)}async update(e){await d.update(this.projectId,this.key,e)}}const be=x({__name:"EnvVars",setup(o){const t=D().params.projectId,a=A({type:"idle"}),{loading:y,result:f,refetch:v}=K(()=>l.list(t)),h=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function $({key:r,value:n}){await l.create(t,r,n),v()}function C(r){a.value={type:"update-value",key:r.key,newValue:""}}async function b(r){var n;if(a.value.type==="update-value"&&r){const{key:s,newValue:i}=a.value,w=(n=f.value)==null?void 0:n.find(V=>V.key===s);w&&await w.update(i)}a.value={type:"idle"}}const I=P(()=>{var r,n;return{columns:[{name:"Key"},{name:"",align:"right"}],rows:(n=(r=f.value)==null?void 0:r.map(s=>({key:s.key,cells:[{type:"text",text:s.key},{type:"actions",actions:[{icon:z,label:"Delete",async onClick(){await s.delete(),v()},dangerous:!0},{icon:G,label:"Update value",onClick(){C(s)}}]}]})))!=null?n:[]}});return(r,n)=>{const s=E("ant-form");return g(),U(B,null,[u(O,{"entity-name":"Env var",loading:p(y),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:I.value,"create-button-text":"Add Environment Variable",fields:h,onCreate:$},null,8,["loading","table"]),u(p(J),{open:a.value.type==="update-value",title:"Update value",onCancel:n[1]||(n[1]=i=>b(!1)),onOk:n[2]||(n[2]=i=>b(!0))},{default:m(()=>[a.value.type==="update-value"?(g(),N(s,{key:0,layout:"vertical"},{default:m(()=>[u(p(R),null,{default:m(()=>[u(p(q),null,{default:m(()=>[F(H(a.value.key),1)]),_:1}),u(p(S),{value:a.value.newValue,"onUpdate:value":n[0]||(n[0]=i=>a.value.newValue=i)},null,8,["value"])]),_:1})]),_:1})):T("",!0)]),_:1},8,["open"])],64)}}});export{be as default};
//# sourceMappingURL=EnvVars.96a36f0d.js.map
