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,a$ as $,bO as B,cz as F}from"./outputWidgets.244ba1c8.js";import{a as M}from"./asyncComputed.9805a381.js";import{a as S}from"./ant-design.2b0214de.js";import"./router.60675eeb.js";import"./index.bec3aec1.js";import{P as g}from"./project.9f9d482b.js";import{O as T}from"./organization.77001a16.js";import{C as U}from"./CrudView.47ed1f4a.js";import{e as V,q as L,I as q,D as G}from"./icons.a522dd78.js";import{A as H}from"./FormItem.e7fba2a7.js";import{M as J}from"./Modal.ff9cdc66.js";import"./index.d38d9f1b.js";import"./index.cf4c23b9.js";import"./record.5766e9f8.js";import"./pubsub.f74b1921.js";import"./Paragraph.bffb9dac.js";import"./Base.2351f159.js";import"./Typography.52981f51.js";import"./Form.f49cd330.js";import"./hasIn.d73516ff.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.aee5d1fe.js";import"./url.f5db59c1.js";import"./index.08ab98c1.js";import"./Title.eb85429e.js";import"./Text.fbfa9a45.js";import"./index.feab3270.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]="39d026a8-526e-4f7b-93c4-f54663846414",l._sentryDebugIdIdentifier="sentry-dbid-39d026a8-526e-4f7b-93c4-f54663846414")}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}=M(()=>Promise.all([g.list(m),T.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 S("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){F.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:V,label:"Go to project",onClick:d},{icon:L,label:"Rename project",onClick:()=>N(o)},...(i=(a=r.value)==null?void 0:a.organization)!=null&&i.featureFlags.DUPLICATE_PROJECTS?[{icon:q,label:"Duplicate",onClick:_}]:[],{icon:G,label:"Delete",onClick:I,dangerous:!0}]}]}}))!=null?e:[]}});return(t,e)=>{const o=A("ant-form");return u(),E($,null,[s(r)?(u(),w(U,{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(J),{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(H),{label:"New name"},{default:f(()=>[p(s(B),{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{ve as default};
//# sourceMappingURL=Projects.c125f5e2.js.map
