import{d as D,eB as R,eA as h,r as x,H as O,a as A,b as u,ev as E,u as s,c as j,ex as w,f as p,w as f,aD as B,bz as F,cy as M}from"./outputWidgets.91c9f730.js";import{a as $}from"./asyncComputed.5cff1726.js";import{a as L}from"./ant-design.b392f32d.js";import"./router.e4c5e9fd.js";import"./index.7bd5dae7.js";import{P as g}from"./project.7d6dd25e.js";import{O as S}from"./organization.15272921.js";import{C as T}from"./CrudView.d1c2398f.js";import{e as U,I as V,Q as G,L as H}from"./icons.e854b740.js";import{A as J}from"./Form.f24a1c0a.js";import{M as Q}from"./Modal.41a7632f.js";import"./index.49f61aa4.js";import"./popupNotifcation.e7a2b93a.js";import"./index.cf4c23b9.js";import"./record.48aae23b.js";import"./pubsub.25829540.js";import"./Paragraph.18e7082b.js";import"./Base.79932679.js";import"./Typography.c7c5698a.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.05ceca6e.js";import"./url.bd840ee9.js";import"./index.5a63d36f.js";import"./Title.69e80303.js";import"./Text.2f03529d.js";import"./index.946fdb2e.js";import"./hasIn.d8588324.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]="358afcb3-726b-46ba-9c5d-2a7b206e8476",l._sentryDebugIdIdentifier="sentry-dbid-358afcb3-726b-46ba-9c5d-2a7b206e8476")}catch{}})();const ve=D({__name:"Projects",setup(l){const c=[{key:"name",label:"Project Name"}],m=R().params.organizationId,k=h(),{loading:C,result:r,refetch:y}=$(()=>Promise.all([g.list(m),S.get(m)]).then(([t,e])=>({projects:t,organization:e}))),d=({key:t})=>k.push({name:"project",params:{projectId:t}}),P=async t=>{const e=await g.create({organizationId:m,name:t.name});d({key:e.id})},I=async({key:t})=>{var a,o;if(await L("Are you sure you want to delete this project?"))try{await((o=(a=r.value)==null?void 0:a.projects.find(i=>i.id===t))==null?void 0:o.delete())}catch(i){M.error({message:"Error deleting project",description:String(i)})}finally{await y()}},_=async({key:t})=>{var a;const e=(a=r.value)==null?void 0:a.projects.find(o=>o.id===t);if(e){const o=await e.duplicate();d({key:o.id})}},n=x({state:"idle"});function N(t){n.value={state:"renaming",projectId:t.id,newName:t.name}}async function b(t){if(n.value.state==="renaming"&&t){const{projectId:e,newName:a}=n.value;await g.rename(e,a),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(a=>{var o,i;return{key:a.id,cells:[{type:"link",text:a.name,to:`/projects/${encodeURIComponent(a.id)}`},{type:"actions",actions:[{icon:U,label:"Go to project",onClick:d},{icon:V,label:"Rename project",onClick:()=>N(a)},...(i=(o=r.value)==null?void 0:o.organization)!=null&&i.featureFlags.DUPLICATE_PROJECTS?[{icon:G,label:"Duplicate",onClick:_}]:[],{icon:H,label:"Delete",onClick:I,dangerous:!0}]}]}}))!=null?e:[]}});return(t,e)=>{const a=A("ant-form");return u(),E(B,null,[s(r)?(u(),j(T,{key:0,"entity-name":"project",loading:s(C),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:P},null,8,["loading","title","table"])):w("",!0),p(s(Q),{open:n.value.state==="renaming",title:"Rename organization",onCancel:e[1]||(e[1]=o=>b(!1)),onOk:e[2]||(e[2]=o=>b(!0))},{default:f(()=>[n.value.state==="renaming"?(u(),j(a,{key:0,layout:"vertical"},{default:f(()=>[p(s(J),{label:"New name"},{default:f(()=>[p(s(F),{value:n.value.newName,"onUpdate:value":e[0]||(e[0]=o=>n.value.newName=o)},null,8,["value"])]),_:1})]),_:1})):w("",!0)]),_:1},8,["open"])],64)}}});export{ve as default};
//# sourceMappingURL=Projects.a556e370.js.map
