var _=Object.defineProperty;var j=(r,e,t)=>e in r?_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var k=(r,e,t)=>(j(r,typeof e!="symbol"?e+"":e,t),t);import{d as x,eD as D,r as A,I as P,a as E,b as g,ev as G,f as u,u as p,w as m,aD as U,eR as N,c as B,ar as F,eG as R,by as S,ex as T}from"./outputWidgets.be3472c2.js";import{C as c}from"./router.87bf43b6.js";import"./index.86288308.js";import{G as K}from"./PhPencil.vue.6be3e07b.js";import{a as O}from"./asyncComputed.a619212b.js";import{C as q}from"./CrudView.08af3b90.js";import{A as z}from"./Form.254a7379.js";import{A as H}from"./Text.c9febe27.js";import{M as J}from"./Modal.304207b8.js";import"./popupNotifcation.9025cc7b.js";import"./record.820df198.js";import"./pubsub.1063a0da.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.f9aebc41.js";import"./BookOutlined.53049b66.js";import"./url.7fe1be7b.js";import"./Paragraph.7601abde.js";import"./index.ba676107.js";import"./Title.65752aa0.js";import"./index.6773e8c7.js";import"./hasIn.bddd0a1a.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]="bf6e7e70-4a26-4ec5-92be-ed9fe05e2eb8",r._sentryDebugIdIdentifier="sentry-dbid-bf6e7e70-4a26-4ec5-92be-ed9fe05e2eb8")}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 fe=x({__name:"EnvVars",setup(r){const t=D().params.projectId,a=A({type:"idle"}),{loading:y,result:f,refetch:v}=O(()=>l.list(t)),h=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function $({key:o,value:n}){await l.create(t,o,n),v()}function C(o){a.value={type:"update-value",key:o.key,newValue:""}}async function b(o){var n;if(a.value.type==="update-value"&&o){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 o,n;return{columns:[{name:"Key"},{name:"",align:"right"}],rows:(n=(o=f.value)==null?void 0:o.map(s=>({key:s.key,cells:[{type:"text",text:s.key},{type:"actions",actions:[{icon:N,label:"Delete",async onClick(){await s.delete(),v()},dangerous:!0},{icon:K,label:"Update value",onClick(){C(s)}}]}]})))!=null?n:[]}});return(o,n)=>{const s=E("ant-form");return g(),G(U,null,[u(q,{"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(),B(s,{key:0,layout:"vertical"},{default:m(()=>[u(p(z),null,{default:m(()=>[u(p(H),null,{default:m(()=>[F(R(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{fe as default};
//# sourceMappingURL=EnvVars.de4400da.js.map
