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,eA as A,r as D,H as P,a as E,b as g,eu as U,f as u,u as c,w as m,aC as G,eQ as N,c as B,aq as F,eD as S,bx as T,ew as q}from"./outputWidgets.260a3c99.js";import{C as p}from"./router.c6bba0da.js";import"./index.16d63baf.js";import{G as H}from"./PhPencil.vue.78f87dc9.js";import{a as K}from"./asyncComputed.61df0e0c.js";import{C as O}from"./CrudView.9c881ed3.js";import{A as Q}from"./Form.46e378f9.js";import{A as R}from"./Text.3b774738.js";import{M as z}from"./Modal.6a26a016.js";import"./popupNotifcation.87bdba7f.js";import"./index.cf4c23b9.js";import"./record.608c7c8c.js";import"./pubsub.ab27f2c0.js";import"./Paragraph.482f5128.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.e08dd3ee.js";import"./BookOutlined.9a33e452.js";import"./url.13938513.js";import"./index.34fd2dd9.js";import"./Title.9673e08a.js";import"./index.a74fba23.js";import"./hasIn.8ab3cbf4.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]="adc09155-8893-4136-a43f-06c440949ca5",o._sentryDebugIdIdentifier="sentry-dbid-adc09155-8893-4136-a43f-06c440949ca5")}catch{}})();class J{constructor(){k(this,"urlPath","env-vars")}async create(e){return p.post(`projects/${e.projectId}/${this.urlPath}`,{name:e.name,value:e.value})}async delete(e,t){await p.delete(`projects/${e}/${this.urlPath}/${t}`)}async update(e,t,a){await p.patch(`projects/${e}/${this.urlPath}/${t}`,{value:a})}async list(e){return p.get(`projects/${e}/${this.urlPath}`)}async get(e){return p.get(`${this.urlPath}/${e}`)}}const d=new J;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 ve=x({__name:"EnvVars",setup(o){const t=A().params.projectId,a=D({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 w(r){var n;if(a.value.type==="update-value"&&r){const{key:s,newValue:i}=a.value,b=(n=f.value)==null?void 0:n.find(V=>V.key===s);b&&await b.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:N,label:"Delete",async onClick(){await s.delete(),v()},dangerous:!0},{icon:H,label:"Update value",onClick(){C(s)}}]}]})))!=null?n:[]}});return(r,n)=>{const s=E("ant-form");return g(),U(G,null,[u(O,{"entity-name":"Env var",loading:c(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(c(z),{open:a.value.type==="update-value",title:"Update value",onCancel:n[1]||(n[1]=i=>w(!1)),onOk:n[2]||(n[2]=i=>w(!0))},{default:m(()=>[a.value.type==="update-value"?(g(),B(s,{key:0,layout:"vertical"},{default:m(()=>[u(c(Q),null,{default:m(()=>[u(c(R),null,{default:m(()=>[F(S(a.value.key),1)]),_:1}),u(c(T),{value:a.value.newValue,"onUpdate:value":n[0]||(n[0]=i=>a.value.newValue=i)},null,8,["value"])]),_:1})]),_:1})):q("",!0)]),_:1},8,["open"])],64)}}});export{ve as default};
//# sourceMappingURL=EnvVars.08f5e667.js.map
