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,eE as A,r as E,J as P,a as D,b as g,ew as U,f as u,u as c,w as m,aE as G,eS as N,c as B,as as S,eH as F,bz as T,ey as z}from"./outputWidgets.eb498848.js";import{C as p}from"./router.dc5374c0.js";import"./index.38387dc8.js";import{G as H}from"./PhPencil.vue.3ad2fce1.js";import{a as J}from"./asyncComputed.6b2a5298.js";import{C as K}from"./CrudView.c7c3d33a.js";import{A as O}from"./Form.bd9a7b94.js";import{A as R}from"./Text.c3630863.js";import{M as q}from"./Modal.19adabd3.js";import"./popupNotifcation.1234df84.js";import"./record.7cc6fca0.js";import"./pubsub.1ca1fb40.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.083d7014.js";import"./BookOutlined.d5ff4087.js";import"./url.1d686ce1.js";import"./Paragraph.82d8120c.js";import"./Base.60455d70.js";import"./index.60acdd5f.js";import"./Title.ef0a0830.js";import"./index.98ba73a6.js";import"./hasIn.ceb11556.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]="bc27bb72-fcb7-47d8-921c-a39c2b21df48",o._sentryDebugIdIdentifier="sentry-dbid-bc27bb72-fcb7-47d8-921c-a39c2b21df48")}catch{}})();class L{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 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 ve=x({__name:"EnvVars",setup(o){const t=A().params.projectId,a=E({type:"idle"}),{loading:y,result:f,refetch:v}=J(()=>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: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=D("ant-form");return g(),U(G,null,[u(K,{"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(q),{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(c(O),null,{default:m(()=>[u(c(R),null,{default:m(()=>[S(F(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})):z("",!0)]),_:1},8,["open"])],64)}}});export{ve as default};
//# sourceMappingURL=EnvVars.47615e6f.js.map
