import{N}from"./Navbar.98e5f43f.js";import{B as O}from"./BaseLayout.52e288f4.js";import{C as _}from"./ContentLayout.46908c65.js";import{C as x}from"./CrudView.d77e910d.js";import{a as R}from"./ant-design.48d4c5e3.js";import{a as D}from"./asyncComputed.bb3077bb.js";import{F as h}from"./PhArrowSquareOut.vue.bdda1139.js";import{G as B}from"./PhPencil.vue.3ceaa978.js";import{d as F,eH as M,e as A,f as $,W as G,b as o,w as i,u as l,aJ as V,eI as j,o as b,c as E,co as L,bD as U,cn as H,R as J,cA as P}from"./vue-router.5e8ba7eb.js";import"./gateway.9bb9fef7.js";import{O as d}from"./organization.a9043c48.js";import"./tables.8dccf3c7.js";import"./PhChats.vue.daa3903a.js";import"./PhSignOut.vue.70d2e442.js";import"./router.1e5228d6.js";import"./index.806e571e.js";import"./index.96dc97c0.js";import"./index.de50f080.js";import"./BookOutlined.bf415405.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.af476096.js";import"./url.4683fc99.js";import"./PhDotsThree.vue.5061c9cb.js";import"./index.d0fd73d7.js";import"./popupNotifcation.b3ef9d8a.js";import"./record.98df87df.js";import"./string.3bd1e390.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]="4657044e-1dfd-4cbb-a5af-e95580903b19",r._sentryDebugIdIdentifier="sentry-dbid-4657044e-1dfd-4cbb-a5af-e95580903b19")}catch{}})();const be=F({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],c=[{key:"name",label:"Organization Name"}],v=M(),{loading:z,result:p,refetch:f}=D(()=>d.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:a,newName:t}=n.value;await d.rename(a,t),f()}n.value={state:"idle"}}const C=async e=>{const a=await d.create(e.name);g({key:a.id})},k=async({key:e})=>{var t,s;await R("Are you sure you want to delete this organization?")&&(await((s=(t=p.value)==null?void 0:t.find(u=>u.id===e))==null?void 0:s.delete()),f())},I=$(()=>{var e,a;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(a=(e=p.value)==null?void 0:e.map(t=>{var s,u;return{key:t.id,cells:[{type:"link",text:t.name,to:(s=`/organizations/${encodeURIComponent(t.id)}`)!=null?s:null},{type:"text",text:(u=t.id)!=null?u:null},{type:"actions",actions:[{icon:h,label:"Go to projects",onClick:g},{icon:B,label:"Rename",onClick:()=>w(t)},{icon:j,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(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:c,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(l(P),{open:n.value.state==="renaming",title:"Rename organization",onCancel:a[1]||(a[1]=t=>y(!1)),onOk:a[2]||(a[2]=t=>y(!0))},{default:i(()=>[n.value.state==="renaming"?(b(),E(l(H),{key:0,layout:"vertical"},{default:i(()=>[o(l(L),{label:"New name"},{default:i(()=>[o(l(U),{value:n.value.newName,"onUpdate:value":a[0]||(a[0]=t=>n.value.newName=t)},null,8,["value"])]),_:1})]),_:1})):J("",!0)]),_:1},8,["open"])],64))}});export{be as default};
//# sourceMappingURL=Organizations.0b0e3407.js.map
