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 w,ex as b,f as p,w as f,aD as B,bz as F,cy as M}from"./outputWidgets.3c3deba7.js";import{a as $}from"./asyncComputed.41e37f4b.js";import{a as L}from"./ant-design.a4c10239.js";import"./router.2687a12c.js";import"./index.79fda194.js";import{P as g}from"./project.a7f8dc6e.js";import{O as S}from"./organization.aba66f3b.js";import{C as T}from"./CrudView.44eff915.js";import{e as U,I as V,Q as G,L as H}from"./icons.c5a369ef.js";import{A as J}from"./Form.21b032af.js";import{M as Q}from"./Modal.ace70b58.js";import"./index.a5f4fbb0.js";import"./index.cf4c23b9.js";import"./record.e2163ce9.js";import"./pubsub.59f66cb7.js";import"./Paragraph.d0a77c93.js";import"./Base.c0a62eaa.js";import"./Typography.828881b4.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.86e502f6.js";import"./url.89508003.js";import"./index.c3c37865.js";import"./Title.ee2bfa7b.js";import"./Text.9ff37267.js";import"./index.66ff16a7.js";import"./hasIn.26cab181.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]="bf823422-2723-4f06-907c-dd07076bcd54",l._sentryDebugIdIdentifier="sentry-dbid-bf823422-2723-4f06-907c-dd07076bcd54")}catch{}})();const be=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 o,a;if(await L("Are you sure you want to delete this project?"))try{await((a=(o=r.value)==null?void 0:o.projects.find(i=>i.id===t))==null?void 0:a.delete())}catch(i){M.error({message:"Error deleting project",description:String(i)})}finally{await y()}},_=async({key:t})=>{var o;const e=(o=r.value)==null?void 0:o.projects.find(a=>a.id===t);if(e){const a=await e.duplicate();d({key:a.id})}},n=x({state:"idle"});function N(t){n.value={state:"renaming",projectId:t.id,newName:t.name}}async function j(t){if(n.value.state==="renaming"&&t){const{projectId:e,newName:o}=n.value;await g.rename(e,o),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(o=>{var a,i;return{key:o.id,cells:[{type:"link",text:o.name,to:`/projects/${encodeURIComponent(o.id)}`},{type:"actions",actions:[{icon:U,label:"Go to project",onClick:d},{icon:V,label:"Rename project",onClick:()=>N(o)},...(i=(a=r.value)==null?void 0:a.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 o=A("ant-form");return u(),E(B,null,[s(r)?(u(),w(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"])):b("",!0),p(s(Q),{open:n.value.state==="renaming",title:"Rename organization",onCancel:e[1]||(e[1]=a=>j(!1)),onOk:e[2]||(e[2]=a=>j(!0))},{default:f(()=>[n.value.state==="renaming"?(u(),w(o,{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]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):b("",!0)]),_:1},8,["open"])],64)}}});export{be as default};
//# sourceMappingURL=Projects.6bcaf47c.js.map
