import{d as h,ed as z,eq as D,e as F,f as x,X as E,u as r,c as w,R as v,b as d,w as p,aR as O,o as f,cv as $,bH as A,cu as B,cH as G,er as M,cI as S}from"./vue-router.c5124aea.js";import{a as T}from"./asyncComputed.492220e2.js";import{a as U}from"./ant-design.8d54eea4.js";import"./gateway.f0a8a4c2.js";import{O as V}from"./organization.41019896.js";import{P as g}from"./project.0a5e591f.js";import"./tables.e3d4a0cb.js";import{C as H}from"./CrudView.c3cfdbe0.js";import{F as q}from"./PhArrowSquareOut.vue.cc3b352f.js";import{I as J}from"./PhCopy.vue.322ff3da.js";import{G as L}from"./PhPencil.vue.2e11b63b.js";import"./popupNotifcation.13f7057e.js";import"./record.3c40de6b.js";import"./string.243c4431.js";import"./router.09f8c7fd.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.ee60e4e5.js";import"./BookOutlined.4a8c6e69.js";import"./url.a882d197.js";import"./PhDotsThreeVertical.vue.db7af6ac.js";import"./Badge.2abe7f2d.js";import"./index.31f5d814.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]="e5c0571a-2ca5-4632-9775-f3f79017c4ef",c._sentryDebugIdIdentifier="sentry-dbid-e5c0571a-2ca5-4632-9775-f3f79017c4ef")}catch{}})();const ge=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 R(t){n.value={state:"renaming",projectId:t.id,newName:t.name}}async function j(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 _=x(()=>{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:q,label:"Go to project",onClick:u},{icon:L,label:"Rename project",onClick:()=>R(a)},...(s=(o=i.value)==null?void 0:o.organization)!=null&&s.featureFlags.DUPLICATE_PROJECTS?[{icon:J,label:"Duplicate",onClick:N}]:[],{icon:M,label:"Delete",onClick:I,dangerous:!0}]}]}}))!=null?e:[]}});return(t,e)=>(f(),E(O,null,[r(i)?(f(),w(H,{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:_.value,fields:l,create:C},null,8,["loading","title","table"])):v("",!0),d(r(G),{open:n.value.state==="renaming",title:"Rename organization",onCancel:e[1]||(e[1]=a=>j(!1)),onOk:e[2]||(e[2]=a=>j(!0))},{default:p(()=>[n.value.state==="renaming"?(f(),w(r(B),{key:0,layout:"vertical"},{default:p(()=>[d(r($),{label:"New name"},{default:p(()=>[d(r(A),{value:n.value.newName,"onUpdate:value":e[0]||(e[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):v("",!0)]),_:1},8,["open"])],64))}});export{ge as default};
//# sourceMappingURL=Projects.2ef68e9d.js.map
