import{d as h,ea as z,eo as D,e as F,f as x,o as d,X as E,u as r,c as w,R as b,b as p,w as f,aR as O,cv as $,bH as A,cu as B,cH as G,ep as M,cI as S}from"./vue-router.e3ef87f0.js";import{a as T}from"./asyncComputed.e840076d.js";import{a as U}from"./ant-design.ab86670b.js";import"./gateway.e3730daa.js";import{O as V}from"./organization.365449ea.js";import{P as g}from"./project.1af02886.js";import"./tables.8b5b16f2.js";import{C as H}from"./CrudView.6dee12dd.js";import{F as J}from"./PhArrowSquareOut.vue.a3cf64eb.js";import{I as L}from"./PhCopy.vue.0da0c2a4.js";import{G as X}from"./PhPencil.vue.c5b74fb4.js";import"./popupNotifcation.bf248d47.js";import"./record.9f354c97.js";import"./string.5524ff61.js";import"./router.7553e78c.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.7e26700d.js";import"./BookOutlined.2206ef88.js";import"./url.d7fc9f74.js";import"./PhDotsThreeVertical.vue.4a059a70.js";import"./Badge.e09547ac.js";import"./index.45410f8d.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]="06c7a555-dc0e-46da-b915-1bf409ce22e5",c._sentryDebugIdIdentifier="sentry-dbid-06c7a555-dc0e-46da-b915-1bf409ce22e5")}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:J,label:"Go to project",onClick:u},{icon:X,label:"Rename project",onClick:()=>R(a)},...(s=(o=i.value)==null?void 0:o.organization)!=null&&s.featureFlags.DUPLICATE_PROJECTS?[{icon:L,label:"Duplicate",onClick:N}]:[],{icon:M,label:"Delete",onClick:I,dangerous:!0}]}]}}))!=null?e:[]}});return(t,e)=>(d(),E(O,null,[r(i)?(d(),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"])):b("",!0),p(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:f(()=>[n.value.state==="renaming"?(d(),w(r(B),{key:0,layout:"vertical"},{default:f(()=>[p(r($),{label:"New name"},{default:f(()=>[p(r(A),{value:n.value.newName,"onUpdate:value":e[0]||(e[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):b("",!0)]),_:1},8,["open"])],64))}});export{ge as default};
//# sourceMappingURL=Projects.48132015.js.map
