import{d as w,eA as _,ez as P,J as k,u as s,b as h,c as I,ew as C,cL as x}from"./outputWidgets.52de64cd.js";import{e as z,b as D}from"./icons.bf6505eb.js";import{a as v}from"./asyncComputed.00e76dd1.js";import{P as d}from"./project.3a024f51.js";import"./console.4411c7a7.js";import{O as N}from"./organization.c1c9ebf3.js";import"./index.8361ad88.js";import{_ as O}from"./CrudView.vue_vue_type_script_setup_true_lang.70304edb.js";import{a as A}from"./ant-design.20ade584.js";import"./gateway.e1457457.js";import"./activeRecord.ebcbfc07.js";import"./pubsub.6e9aa6f2.js";import"./index.a07ffcc5.js";import"./Form.09072055.js";import"./Title.baba2b21.js";import"./index.7800af0b.js";import"./index.c0e74c90.js";import"./index.e5d92658.js";import"./dayjs.7ad6aa6d.js";import"./index.5718341d.js";import"./index.3ed5d65c.js";import"./TabPane.c3c2f5a1.js";import"./index.396ff1b5.js";import"./CollapsePanel.d756b861.js";import"./index.9b3c2ba8.js";import"./index.f6c308cc.js";import"./index.f7915957.js";import"./index.1ebdd57a.js";import"./index.7fdb6bd8.js";import"./index.693f4596.js";import"./index.5a37ef67.js";import"./index.19e4a065.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},i=new Error().stack;i&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[i]="4e4d2d4c-5125-4ec5-95c1-7beec0c936e4",r._sentryDebugIdIdentifier="sentry-dbid-4e4d2d4c-5125-4ec5-95c1-7beec0c936e4")}catch{}})();const de=w({__name:"Projects",setup(r){const i=[{key:"name",label:"Project Name"}],n=_().params.organizationId,u=P(),{loading:f,result:a,refetch:y}=v(()=>Promise.all([d.list(n),N.get(n)]).then(([e,t])=>({projects:e,organization:t}))),m=({key:e})=>u.push({name:"project",params:{projectId:e}}),g=async e=>{const t=await d.create({organizationId:n,name:e.name});m({key:t.id})},b=async({key:e})=>{var o,p;if(await A("Are you sure you want to delete this project?"))try{await((p=(o=a.value)==null?void 0:o.projects.find(c=>c.id===e))==null?void 0:p.delete())}catch(c){x.error({message:"Error deleting project",description:String(c)})}finally{await y()}},j=k(()=>{var e,t;return{columns:[{name:"Id"},{name:"Project Name"},{name:"Actions",align:"right"}],rows:(t=(e=a.value)==null?void 0:e.projects.map(o=>({key:o.id,cells:[{text:o.id.slice(0,8)},{text:o.name,link:`/projects/${encodeURIComponent(o.id)}`},{text:"",actions:[{icon:z,label:"Edit Project",onClick:m},{icon:D,label:"Delete",onClick:b,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>s(a)?(h(),I(O,{key:0,"entity-name":"project",loading:s(f),title:`${s(a).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:j.value,fields:i,onCreate:g},null,8,["loading","title","table"])):C("",!0)}});export{de as default};
//# sourceMappingURL=Projects.6c27482a.js.map
