import{d as y,K as g,z as r,b as k,t as C,D as b,J as h,H as w}from"./registerWidgets.802bba2f.js";import{f as _,g as x,h as z}from"./icons.97625e56.js";import{a as I}from"./asyncComputed.1364aaa9.js";import{P as l}from"./project.7c905308.js";import"./utils.acbba3b4.js";import{O as N}from"./organization.843e0012.js";import{C as O}from"./CrudView.9eafd43a.js";import"./passwordlessManager.d5134797.js";import"./pubsub.a0411919.js";import"./DropdownMenu.32db0ef2.js";import"./CircularLoading.5c7f2ad7.js";import"./Modal.e13f7972.js";const q=y({__name:"Projects",setup(v){const m=[{key:"name",label:"Project Name"}],n=h().params.organizationId,d=w(),{loading:p,result:a,refetch:i}=I(()=>Promise.all([l.list(n),N.get(n)]).then(([e,t])=>({projects:e,organization:t}))),s=({key:e})=>d.push({name:"project",params:{projectId:e}}),u=async({key:e})=>{var t,o;await((o=(t=a.value)==null?void 0:t.projects.find(c=>c.id===e))==null?void 0:o.duplicate()),i()},j=async e=>{const t=await l.create({organizationId:n,name:e.name});s({key:t.id})},f=async({key:e})=>{var t,o;confirm("Are you sure you want to delete this project?")&&(await((o=(t=a.value)==null?void 0:t.projects.find(c=>c.id===e))==null?void 0:o.delete()),i())},P=g(()=>{var e,t;return{columns:[{name:"Project Name"},{name:"Path"},{name:"Project Actions"}],rows:(t=(e=a.value)==null?void 0:e.projects.map(o=>({key:o.id,cells:[{text:o.name,classes:["title","centered"],link:`/projects/${encodeURIComponent(o.id)}`},{text:o.id},{text:"",classes:["centered"],actions:[{icon:_,label:"Delete",onClick:f,dangerous:!0},{icon:x,label:"Edit Project",onClick:s},{icon:z,label:"Duplicate",onClick:u}]}]})))!=null?t:[]}});return(e,t)=>r(a)?(k(),C(O,{key:0,"entity-name":"project","ask-name-on-create":!0,loading:r(p),title:`${r(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:r(P),fields:m,onCreate:j},null,8,["loading","title","table"])):b("",!0)}});export{q as default};
//# sourceMappingURL=Projects.bc5aec23.js.map
