import{d as R,ez as h,ey as D,r as F,F as x,a as O,b as d,et as E,u as s,c as b,ev as w,f as p,w as f,bo as A,bF as M,cu as $}from"./outputWidgets.517466a4.js";import{e as B,u as S,K as T,F as U}from"./icons.18ac3d6d.js";import{a as V}from"./asyncComputed.4cc49353.js";import"./router.7372192a.js";import"./jwt-decode.esm.74bd4619.js";import"./index.93c4bd99.js";import{P as g}from"./project.d9b77799.js";import{O as L}from"./organization.9f4826a6.js";import{C as G}from"./CrudView.3319d010.js";import{a as J}from"./ant-design.6f3f0026.js";import{A as K}from"./FormItem.ebe02103.js";import{M as q}from"./Modal.c37f1dd1.js";import"./storage.a7faa4ce.js";import"./index.c09b1845.js";import"./index.cf4c23b9.js";import"./record.00f55d8c.js";import"./pubsub.1c68a664.js";import"./Title.50fff1e9.js";import"./Text.b4fa08c4.js";import"./Form.dedf0123.js";import"./hasIn.41d385a0.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.541da426.js";import"./url.f9726388.js";import"./index.1de61334.js";import"./index.79f0c9dc.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},c=new Error().stack;c&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[c]="1a1aab4e-922f-44af-b4a6-9c48d705f095",l._sentryDebugIdIdentifier="sentry-dbid-1a1aab4e-922f-44af-b4a6-9c48d705f095")}catch{}})();const we=R({__name:"Projects",setup(l){const c=[{key:"name",label:"Project Name"}],m=h().params.organizationId,k=D(),{loading:C,result:r,refetch:y}=V(()=>Promise.all([g.list(m),L.get(m)]).then(([t,e])=>({projects:t,organization:e}))),u=({key:t})=>k.push({name:"project",params:{projectId:t}}),P=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 J("Are you sure you want to delete this project?"))try{await((o=(a=r.value)==null?void 0:a.projects.find(i=>i.id===t))==null?void 0:o.delete())}catch(i){$.error({message:"Error deleting project",description:String(i)})}finally{await y()}},_=async({key:t})=>{var a;const e=(a=r.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 N(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 z=x(()=>{var t,e;return{columns:[{name:"Project Name",align:"left"},{name:"",align:"right"}],rows:(e=(t=r.value)==null?void 0:t.projects.map(a=>{var o,i;return{key:a.id,cells:[{type:"link",text:a.name,to:`/projects/${encodeURIComponent(a.id)}`},{type:"actions",actions:[{icon:B,label:"Go to project",onClick:u},{icon:S,label:"Rename project",onClick:()=>N(a)},...(i=(o=r.value)==null?void 0:o.organization)!=null&&i.featureFlags.DUPLICATE_PROJECTS?[{icon:T,label:"Duplicate",onClick:_}]:[],{icon:U,label:"Delete",onClick:I,dangerous:!0}]}]}}))!=null?e:[]}});return(t,e)=>{const a=O("ant-form");return d(),E(A,null,[s(r)?(d(),b(G,{key:0,"entity-name":"project",loading:s(C),title:`${s(r).organization.name}'s Projects`,description:"Organize your team's work into different Projects, each with it's own subdomain.","create-button-text":"Create Project","empty-title":"No projects here yet",table:z.value,fields:c,onCreate:P},null,8,["loading","title","table"])):w("",!0),p(s(q),{open:n.value.state==="renaming",title:"Rename organization",onCancel:e[1]||(e[1]=o=>j(!1)),onOk:e[2]||(e[2]=o=>j(!0))},{default:f(()=>[n.value.state==="renaming"?(d(),b(a,{key:0,layout:"vertical"},{default:f(()=>[p(s(K),{label:"New name"},{default:f(()=>[p(s(M),{value:n.value.newName,"onUpdate:value":e[0]||(e[0]=o=>n.value.newName=o)},null,8,["value"])]),_:1})]),_:1})):w("",!0)]),_:1},8,["open"])],64)}}});export{we as default};
//# sourceMappingURL=Projects.05a1c61b.js.map
