import{d as R,eB as h,eA as z,r as D,G as A,a as O,b as u,ev as E,u as s,c as w,ex as b,f as p,w as f,bq as F,bH as B,cw as M}from"./outputWidgets.781e41f9.js";import{e as $,u as S,K as T,F as U}from"./icons.0ffc383b.js";import{a as V}from"./asyncComputed.d06d5356.js";import"./authorManager.2805bec3.js";import"./index.fc2f40fb.js";import{P as g}from"./project.373df54c.js";import{O as G}from"./organization.ff3609a4.js";import{C as L}from"./CrudView.331f38ea.js";import{a as q}from"./ant-design.e0bbd844.js";import{A as H}from"./FormItem.341ebdb6.js";import{M as J}from"./Modal.3a32e945.js";import"./index.cf4c23b9.js";import"./record.71f43d7d.js";import"./pubsub.2273fc34.js";import"./Title.bf1f8106.js";import"./Text.6168f33a.js";import"./Form.a1506234.js";import"./hasIn.205b6afa.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.942344e3.js";import"./router.2dba10c4.js";import"./index.db0f7a49.js";import"./url.a0d7eae0.js";import"./index.0ad8ad84.js";import"./index.574af34c.js";import"./index.b2c1bb4a.js";import"./index.609ad91a.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]="dddc9752-aed3-4b0c-9616-980069f46177",l._sentryDebugIdIdentifier="sentry-dbid-dddc9752-aed3-4b0c-9616-980069f46177")}catch{}})();const ve=R({__name:"Projects",setup(l){const c=[{key:"name",label:"Project Name"}],m=h().params.organizationId,k=z(),{loading:C,result:r,refetch:y}=V(()=>Promise.all([g.list(m),G.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 q("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=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 x=A(()=>{var t,e;return{columns:[{name:"Project Name",align:"left"},{name:"Actions",align:"right"}],rows:(e=(t=r.value)==null?void 0:t.projects.map(o=>{var a,i;return{key:o.id,cells:[{text:o.name,link:`/projects/${encodeURIComponent(o.id)}`},{text:"",actions:[{icon:$,label:"Go to project",onClick:d},{icon:S,label:"Rename project",onClick:()=>N(o)},...(i=(a=r.value)==null?void 0:a.organization)!=null&&i.featureFlags.DUPLICATE_PROJECTS?[{icon:T,label:"Duplicate",onClick:_}]:[],{icon:U,label:"Delete",onClick:I,dangerous:!0}]}]}}))!=null?e:[]}});return(t,e)=>{const o=O("ant-form");return u(),E(F,null,[s(r)?(u(),w(L,{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:x.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.11cfc78d.js.map
