import{d as x,eB as h,eA as z,r as R,G as A,a as D,b as u,ev as O,u as r,c as b,ex as j,f as d,w as p,bq as B,bH as M,cw as $}from"./outputWidgets.fdae7e91.js";import{z as E,o as F,C as V}from"./icons.59384d21.js";import{a as G}from"./asyncComputed.43537aae.js";import"./authorManager.adc33c37.js";import"./index.30fe2a77.js";import{P as f}from"./project.1bad15ea.js";import{O as S}from"./organization.241846c8.js";import{C as U}from"./CrudView.e3fe23cf.js";import{a as q}from"./ant-design.f2f7cc3b.js";import{A as H}from"./FormItem.45b6065e.js";import{M as L}from"./Title.e4079793.js";import"./index.cf4c23b9.js";import"./record.f963a373.js";import"./pubsub.61789656.js";import"./gateway.8c35b4b8.js";import"./Form.d4070d32.js";import"./hasIn.e6601643.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.ed9adb70.js";import"./router.ae435e74.js";import"./index.6f560850.js";import"./url.f60fbe92.js";import"./index.42add8ec.js";import"./index.9026b0b4.js";import"./Text.2d7466b9.js";import"./index.a700463c.js";import"./index.dedb9dc3.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[s]="c4922486-b55f-4862-a6f6-99feee1aff63",i._sentryDebugIdIdentifier="sentry-dbid-c4922486-b55f-4862-a6f6-99feee1aff63")}catch{}})();const be=x({__name:"Projects",setup(i){const s=[{key:"name",label:"Project Name"}],l=h().params.organizationId,k=z(),{loading:C,result:m,refetch:g}=G(()=>Promise.all([f.list(l),S.get(l)]).then(([e,t])=>({projects:e,organization:t}))),y=({key:e})=>k.push({name:"project",params:{projectId:e}}),P=async e=>{const t=await f.create({organizationId:l,name:e.name});y({key:t.id})},I=async({key:e})=>{var o,n;if(await q("Are you sure you want to delete this project?"))try{await((n=(o=m.value)==null?void 0:o.projects.find(c=>c.id===e))==null?void 0:n.delete())}catch(c){$.error({message:"Error deleting project",description:String(c)})}finally{await g()}},a=R({state:"idle"});function _(e){a.value={state:"renaming",projectId:e.id,newName:e.name}}async function w(e){if(a.value.state==="renaming"&&e){const{projectId:t,newName:o}=a.value;await f.rename(t,o),g()}a.value={state:"idle"}}const N=A(()=>{var e,t;return{columns:[{name:"Project Name",align:"left"},{name:"Actions",align:"right"}],rows:(t=(e=m.value)==null?void 0:e.projects.map(o=>({key:o.id,cells:[{text:o.name,link:`/projects/${encodeURIComponent(o.id)}`},{text:"",actions:[{icon:E,label:"Go to project",onClick:y},{icon:F,label:"Rename project",onClick:()=>_(o)},{icon:V,label:"Delete",onClick:I,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>{const o=D("ant-form");return u(),O(B,null,[r(m)?(u(),b(U,{key:0,"entity-name":"project",loading:r(C),title:`${r(m).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:N.value,fields:s,onCreate:P},null,8,["loading","title","table"])):j("",!0),d(r(L),{open:a.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=n=>w(!1)),onOk:t[2]||(t[2]=n=>w(!0))},{default:p(()=>[a.value.state==="renaming"?(u(),b(o,{key:0,layout:"vertical"},{default:p(()=>[d(r(H),{label:"New name"},{default:p(()=>[d(r(M),{value:a.value.newName,"onUpdate:value":t[0]||(t[0]=n=>a.value.newName=n)},null,8,["value"])]),_:1})]),_:1})):j("",!0)]),_:1},8,["open"])],64)}}});export{be as default};
//# sourceMappingURL=Projects.f5d029dd.js.map
