import{N as O}from"./Navbar.fb207271.js";import{B as I}from"./BaseLayout.f6d81952.js";import{C as _}from"./ContentLayout.dbb291db.js";import{C as x}from"./CrudView.542c4e4e.js";import{a as M}from"./ant-design.03b4c57f.js";import{a as B}from"./asyncComputed.2210bd1a.js";import{F as D}from"./PhArrowSquareOut.vue.4e3beb6a.js";import{G as F}from"./PhPencil.vue.155bd1a7.js";import{d as R,eM as h,r as A,D as G,b,ey as $,f as o,w as i,u as m,aG as V,eS as j,c as E,bB as L,eA as S}from"./outputWidgets.e5f9ffc6.js";import"./router.dd631582.js";import"./index.889e1616.js";import{O as p}from"./organization.5e74a4d5.js";import{A as U,F as P}from"./Form.b45c0335.js";import{M as T}from"./Modal.e18542c5.js";import"./logo.084e5d7c.js";import"./PhChats.vue.159c1659.js";import"./PhSignOut.vue.507253b1.js";import"./Text.e6c27a3b.js";import"./Base.d0d329e2.js";import"./index.5b4bc824.js";import"./index.8d271185.js";import"./BookOutlined.7d01e6a5.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.670b5628.js";import"./url.c11ddd9f.js";import"./Paragraph.1cbc8077.js";import"./index.2570caf9.js";import"./Title.f988141d.js";import"./index.f056a823.js";import"./index.6b873e6f.js";import"./popupNotifcation.9671db62.js";import"./record.3c5b5204.js";import"./pubsub.75396d00.js";import"./hasIn.54609e4a.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[l]="95a5636b-5a10-40f7-9e8d-3e3aa155e230",r._sentryDebugIdIdentifier="sentry-dbid-95a5636b-5a10-40f7-9e8d-3e3aa155e230")}catch{}})();const Oe=R({__name:"Organizations",setup(r){const l=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],v=h(),{loading:z,result:c,refetch:f}=B(()=>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),f()}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 M("Are you sure you want to delete this organization?")&&(await((s=(a=c.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:s.delete()),f())},N=G(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=c.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:D,label:"Go to projects",onClick:g},{icon:F,label:"Rename",onClick:()=>w(a)},{icon:j,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),$(V,null,[o(I,null,{navbar:i(()=>[o(O,{breadcrumb:l})]),content:i(()=>[o(_,null,{default:i(()=>[o(x,{"entity-name":"organization",loading:m(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:N.value,fields:d,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(m(T),{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(m(P),{key:0,layout:"vertical"},{default:i(()=>[o(m(U),{label:"New name"},{default:i(()=>[o(m(L),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):S("",!0)]),_:1},8,["open"])],64))}});export{Oe as default};
//# sourceMappingURL=Organizations.eed80af0.js.map
