import{d as x,eB as h,eA as R,r as z,G as A,a as B,b as d,ev as D,u as r,c as w,ex as j,f as u,w as p,bq as O,bH as E,cw as M}from"./outputWidgets.c7c3593b.js";import{B as $,q as F,E as V}from"./icons.e912a40c.js";import{a as q}from"./asyncComputed.87d89e82.js";import"./authorManager.33208873.js";import"./index.640c3418.js";import{P as f}from"./project.95833ddb.js";import{O as G}from"./organization.1981f198.js";import{C as S}from"./CrudView.b146ef3d.js";import{a as U}from"./ant-design.41fde510.js";import{A as H}from"./FormItem.9941e947.js";import{M as L}from"./Title.47031f69.js";import"./index.cf4c23b9.js";import"./record.b6e0d210.js";import"./pubsub.a1271b13.js";import"./gateway.94d6767e.js";import"./Form.5652ed9b.js";import"./hasIn.f4bb54d3.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.252f0a18.js";import"./router.051bd37d.js";import"./index.50d90398.js";import"./url.03aeeb48.js";import"./index.6a297772.js";import"./index.26b290e3.js";import"./Text.1c53905c.js";import"./index.03af204f.js";import"./index.27c03e11.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]="f6dbd07f-52d8-49bd-8d0f-85c89314c6fb",i._sentryDebugIdIdentifier="sentry-dbid-f6dbd07f-52d8-49bd-8d0f-85c89314c6fb")}catch{}})();const we=x({__name:"Projects",setup(i){const s=[{key:"name",label:"Project Name"}],l=h().params.organizationId,k=R(),{loading:C,result:m,refetch:g}=q(()=>Promise.all([f.list(l),G.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 U("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){M.error({message:"Error deleting project",description:String(c)})}finally{await g()}},a=z({state:"idle"});function _(e){a.value={state:"renaming",projectId:e.id,newName:e.name}}async function b(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:$,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=B("ant-form");return d(),D(O,null,[r(m)?(d(),w(S,{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),u(r(L),{open:a.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=n=>b(!1)),onOk:t[2]||(t[2]=n=>b(!0))},{default:p(()=>[a.value.state==="renaming"?(d(),w(o,{key:0,layout:"vertical"},{default:p(()=>[u(r(H),{label:"New name"},{default:p(()=>[u(r(E),{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{we as default};
//# sourceMappingURL=Projects.2f5d236c.js.map
