import{d as h,e7 as z,ek as D,e as F,f as E,W as x,u as r,c as j,R as w,b as d,w as p,aJ as O,el as $,o as f,cs as A,bD as B,cr as G,cE as M,cF as S}from"./vue-router.97d0d8a6.js";import{a as T}from"./asyncComputed.72143f3b.js";import{a as U}from"./ant-design.c0f2ec4c.js";import"./gateway.91a35dd3.js";import{O as V}from"./organization.c9b277ba.js";import{P as g}from"./project.52eb4019.js";import"./tables.8944c1e2.js";import{C as J}from"./CrudView.797f086e.js";import{F as L}from"./PhArrowSquareOut.vue.93a854fa.js";import{I as W}from"./PhCopy.vue.98def612.js";import{G as q}from"./PhPencil.vue.bb6c5a6a.js";import"./popupNotifcation.80047f06.js";import"./record.a84b6d90.js";import"./string.4a3650cc.js";import"./router.bf9d2a86.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.05d4ef76.js";import"./BookOutlined.868baafb.js";import"./url.6a6403b0.js";import"./PhDotsThree.vue.3d83613d.js";import"./index.557e8025.js";(function(){try{var c=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(c._sentryDebugIds=c._sentryDebugIds||{},c._sentryDebugIds[l]="f023dbc2-72ce-4b86-b572-68c8b0cabe3a",c._sentryDebugIdIdentifier="sentry-dbid-f023dbc2-72ce-4b86-b572-68c8b0cabe3a")}catch{}})();const fe=h({__name:"Projects",setup(c){const l=[{key:"name",label:"Project Name"}],m=z().params.organizationId,k=D(),{loading:P,result:i,refetch:y}=T(()=>Promise.all([g.list(m),V.get(m)]).then(([t,e])=>({projects:t,organization:e}))),u=({key:t})=>k.push({name:"project",params:{projectId:t}}),C=async t=>{const e=await g.create({organizationId:m,name:t.name});u({key:e.id})},I=async({key:t})=>{var a,o;if(await U("Are you sure you want to delete this project?"))try{await((o=(a=i.value)==null?void 0:a.projects.find(s=>s.id===t))==null?void 0:o.delete())}catch(s){S.error({message:"Error deleting project",description:String(s)})}finally{await y()}},N=async({key:t})=>{var a;const e=(a=i.value)==null?void 0:a.projects.find(o=>o.id===t);if(e){const o=await e.duplicate();u({key:o.id})}},n=F({state:"idle"});function _(t){n.value={state:"renaming",projectId:t.id,newName:t.name}}async function b(t){if(n.value.state==="renaming"&&t){const{projectId:e,newName:a}=n.value;await g.rename(e,a),y()}n.value={state:"idle"}}const R=E(()=>{var t,e;return{columns:[{name:"Project Name",align:"left"},{name:"",align:"right"}],rows:(e=(t=i.value)==null?void 0:t.projects.map(a=>{var o,s;return{key:a.id,cells:[{type:"link",text:a.name,to:`/projects/${encodeURIComponent(a.id)}`},{type:"actions",actions:[{icon:L,label:"Go to project",onClick:u},{icon:q,label:"Rename project",onClick:()=>_(a)},...(s=(o=i.value)==null?void 0:o.organization)!=null&&s.featureFlags.DUPLICATE_PROJECTS?[{icon:W,label:"Duplicate",onClick:N}]:[],{icon:$,label:"Delete",onClick:I,dangerous:!0}]}]}}))!=null?e:[]}});return(t,e)=>(f(),x(O,null,[r(i)?(f(),j(J,{key:0,"entity-name":"project",loading:r(P),title:`${r(i).organization.name}'s Projects`,description:"Organize your team\u2019s work into different Projects, each with it\u2019s own environment settings and authorized users.","create-button-text":"Create Project","empty-title":"No projects here yet",table:R.value,fields:l,onCreate:C},null,8,["loading","title","table"])):w("",!0),d(r(M),{open:n.value.state==="renaming",title:"Rename organization",onCancel:e[1]||(e[1]=a=>b(!1)),onOk:e[2]||(e[2]=a=>b(!0))},{default:p(()=>[n.value.state==="renaming"?(f(),j(r(G),{key:0,layout:"vertical"},{default:p(()=>[d(r(A),{label:"New name"},{default:p(()=>[d(r(B),{value:n.value.newName,"onUpdate:value":e[0]||(e[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):w("",!0)]),_:1},8,["open"])],64))}});export{fe as default};
//# sourceMappingURL=Projects.bf0de856.js.map
