import{d as R,eB as h,eA as x,r as D,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 F,bO as $,cz as B}from"./outputWidgets.84fe9cdf.js";import{a as M}from"./asyncComputed.6b982433.js";import{a as S}from"./ant-design.53be314d.js";import"./router.55b997dc.js";import"./index.46fac088.js";import{P as g}from"./project.27c9517e.js";import{O as T}from"./organization.03c05399.js";import{C as U}from"./CrudView.d7e7652b.js";import{e as V,t as L,K as G,F as H}from"./icons.fb80f0dd.js";import{A as J}from"./FormItem.3f0afd7c.js";import{M as K}from"./Modal.47a21763.js";import"./index.0be37f33.js";import"./index.cf4c23b9.js";import"./record.d584e714.js";import"./pubsub.e099f5f1.js";import"./Paragraph.7a7aafbc.js";import"./Base.3448c1ef.js";import"./Form.ff60b0b9.js";import"./hasIn.892e96d0.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.41277f9f.js";import"./url.8de5cd7a.js";import"./index.7b2adc4e.js";import"./Title.59475fea.js";import"./Text.6c3b9f60.js";import"./index.2424aba1.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]="8f073efa-8e15-4216-b4c7-79481d263e53",l._sentryDebugIdIdentifier="sentry-dbid-8f073efa-8e15-4216-b4c7-79481d263e53")}catch{}})();const be=R({__name:"Projects",setup(l){const c=[{key:"name",label:"Project Name"}],m=h().params.organizationId,k=x(),{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){B.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=D({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: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(F,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(K),{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($),{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.4e2774c9.js.map
