import{N}from"./Navbar.f6bee040.js";import{B as O}from"./BaseLayout.30eb0a79.js";import{C as _}from"./ContentLayout.8dd7f370.js";import{C as x}from"./CrudView.b2407c91.js";import{a as R}from"./ant-design.d41464a5.js";import{a as D}from"./asyncComputed.78ec0807.js";import{F}from"./PhArrowSquareOut.vue.587a4f7d.js";import{G as M}from"./PhPencil.vue.427485d5.js";import{d as h,eJ as B,r as A,I as $,b,ev as G,f as o,w as i,u as l,aD as V,eR as j,c as E,by as L,ex as U}from"./outputWidgets.a321903e.js";import"./router.2245534d.js";import"./index.579b421e.js";import{O as p}from"./organization.c6644029.js";import{A as J,F as P}from"./Form.e0cc6e8e.js";import{M as S}from"./Modal.bcb9f272.js";import"./logo.084e5d7c.js";import"./PhSignOut.vue.1879a91e.js";import"./Text.b25e1b1d.js";import"./index.9f566aac.js";import"./index.08346a17.js";import"./BookOutlined.425445e6.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.29f4fec4.js";import"./url.d108fea5.js";import"./Paragraph.53f5a9bc.js";import"./index.fd9a3d7c.js";import"./Title.e1cf3e99.js";import"./index.211632ef.js";import"./index.f18b9a75.js";import"./popupNotifcation.43dee970.js";import"./record.d39119c8.js";import"./pubsub.df0290b2.js";import"./hasIn.62bbbac0.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},m=new Error().stack;m&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[m]="28e80696-5ffb-49b9-9e56-90f72f9efe3f",r._sentryDebugIdIdentifier="sentry-dbid-28e80696-5ffb-49b9-9e56-90f72f9efe3f")}catch{}})();const ke=h({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],v=B(),{loading:z,result:f,refetch:c}=D(()=>p.list()),g=({key:e})=>{v.push({name:"organization",params:{organizationId:e}})},n=A({state:"idle"});function w(e){n.value={state:"renaming",organizationId:e.id,newName:e.name}}async function y(e){if(n.value.state==="renaming"&&e){const{organizationId:t,newName:a}=n.value;await p.rename(t,a),c()}n.value={state:"idle"}}const C=async e=>{const t=await p.create(e.name);g({key:t.id})},k=async({key:e})=>{var a,s;await R("Are you sure you want to delete this organization?")&&(await((s=(a=f.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:s.delete()),c())},I=$(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=f.value)==null?void 0:e.map(a=>{var s,u;return{key:a.id,cells:[{type:"link",text:a.name,to:(s=`/organizations/${encodeURIComponent(a.id)}`)!=null?s:null},{type:"text",text:(u=a.id)!=null?u:null},{type:"actions",actions:[{icon:F,label:"Go to projects",onClick:g},{icon:M,label:"Rename",onClick:()=>w(a)},{icon:j,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),G(V,null,[o(O,null,{navbar:i(()=>[o(N,{breadcrumb:m})]),content:i(()=>[o(_,null,{default:i(()=>[o(x,{"entity-name":"organization",loading:l(z),title:"My organizations",description:"An organization is your company\u2019s account. Manage editors, projects and billing.","create-button-text":"Create Organization","empty-title":"No organizations here yet",table:I.value,fields:d,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(l(S),{open:n.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=a=>y(!1)),onOk:t[2]||(t[2]=a=>y(!0))},{default:i(()=>[n.value.state==="renaming"?(b(),E(l(P),{key:0,layout:"vertical"},{default:i(()=>[o(l(J),{label:"New name"},{default:i(()=>[o(l(L),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):U("",!0)]),_:1},8,["open"])],64))}});export{ke as default};
//# sourceMappingURL=Organizations.706b3eff.js.map
