import{N as O}from"./Navbar.1f474c04.js";import{B as I}from"./BaseLayout.1e49bd2f.js";import{C as _}from"./ContentLayout.143d2119.js";import{C as x}from"./CrudView.e2192329.js";import{a as M}from"./ant-design.aba87fd3.js";import{a as B}from"./asyncComputed.a50f21d4.js";import{F as D}from"./PhArrowSquareOut.vue.93f36f8d.js";import{G as F}from"./PhPencil.vue.75024b51.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.7323a17d.js";import"./router.7bb92c0e.js";import"./index.c9f11f2b.js";import{O as p}from"./organization.7a4ab869.js";import{A as U,F as P}from"./Form.4d35a934.js";import{M as T}from"./Modal.8e6a9189.js";import"./logo.084e5d7c.js";import"./PhSignOut.vue.e19ee1ae.js";import"./Text.a0b69008.js";import"./Base.003f7172.js";import"./index.4920b0cf.js";import"./index.252f049c.js";import"./BookOutlined.22bb6522.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.d07c372f.js";import"./url.50c4a8f0.js";import"./Paragraph.1e67eefb.js";import"./index.42443749.js";import"./Title.88a7d0e4.js";import"./index.211f7220.js";import"./index.e70ae279.js";import"./popupNotifcation.4e57751c.js";import"./record.1f033572.js";import"./pubsub.2c3883f4.js";import"./hasIn.adc00278.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]="13801493-d488-4e20-a659-615b67ff9e48",r._sentryDebugIdIdentifier="sentry-dbid-13801493-d488-4e20-a659-615b67ff9e48")}catch{}})();const Ne=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{Ne as default};
//# sourceMappingURL=Organizations.7db6b2e6.js.map
