import{d as R,eB as h,eA as x,r as D,H as O,a as A,b as d,ev as E,u as s,c as w,ex as b,f as p,w as f,a$ as $,bO as B,cz as F}from"./outputWidgets.fe662b4f.js";import{a as M}from"./asyncComputed.60882aa5.js";import{a as S}from"./ant-design.f876da58.js";import"./router.359674ae.js";import"./index.dc77b07b.js";import{P as g}from"./project.c86572f1.js";import{O as T}from"./organization.11aff731.js";import{C as U}from"./CrudView.51a3daa0.js";import{e as V,H,P as L,K as G}from"./icons.06e79e54.js";import{A as J}from"./Form.240adf1b.js";import{M as K}from"./Modal.c3452f91.js";import"./index.fb6346ff.js";import"./index.cf4c23b9.js";import"./record.b07c9a4f.js";import"./pubsub.d5a444ac.js";import"./Paragraph.4acd5c9c.js";import"./Base.752e5f84.js";import"./Typography.a9c97257.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.069b2a70.js";import"./url.e299df37.js";import"./index.96fe91d4.js";import"./Title.694e574f.js";import"./Text.79714a42.js";import"./index.6c541f9d.js";import"./hasIn.36cbd9d8.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]="06476606-cb0e-47a7-9754-31c43f16765f",l._sentryDebugIdIdentifier="sentry-dbid-06476606-cb0e-47a7-9754-31c43f16765f")}catch{}})();const be=R({__name:"Projects",setup(l){const c=[{key:"name",label:"Project Name"}],m=h().params.organizationId,k=x(),{loading:P,result:r,refetch:y}=M(()=>Promise.all([g.list(m),T.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 o,a;if(await S("Are you sure you want to delete this project?"))try{await((a=(o=r.value)==null?void 0:o.projects.find(i=>i.id===t))==null?void 0:a.delete())}catch(i){F.error({message:"Error deleting project",description:String(i)})}finally{await y()}},_=async({key:t})=>{var o;const e=(o=r.value)==null?void 0:o.projects.find(a=>a.id===t);if(e){const a=await e.duplicate();u({key:a.id})}},n=D({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:o}=n.value;await g.rename(e,o),y()}n.value={state:"idle"}}const z=O(()=>{var t,e;return{columns:[{name:"Project Name",align:"left"},{name:"",align:"right"}],rows:(e=(t=r.value)==null?void 0:t.projects.map(o=>{var a,i;return{key:o.id,cells:[{type:"link",text:o.name,to:`/projects/${encodeURIComponent(o.id)}`},{type:"actions",actions:[{icon:V,label:"Go to project",onClick:u},{icon:H,label:"Rename project",onClick:()=>N(o)},...(i=(a=r.value)==null?void 0:a.organization)!=null&&i.featureFlags.DUPLICATE_PROJECTS?[{icon:L,label:"Duplicate",onClick:_}]:[],{icon:G,label:"Delete",onClick:I,dangerous:!0}]}]}}))!=null?e:[]}});return(t,e)=>{const o=A("ant-form");return d(),E($,null,[s(r)?(d(),w(U,{key:0,"entity-name":"project",loading:s(P),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:C},null,8,["loading","title","table"])):b("",!0),p(s(K),{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(o,{key:0,layout:"vertical"},{default:f(()=>[p(s(J),{label:"New name"},{default:f(()=>[p(s(B),{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{be as default};
//# sourceMappingURL=Projects.3babebb1.js.map
