import{N}from"./Navbar.f90abc27.js";import{B as I}from"./BaseLayout.ca3956cd.js";import{C as _}from"./ContentLayout.d34b8e7d.js";import{C as x}from"./CrudView.f04f853e.js";import{a as R}from"./ant-design.f29af77f.js";import{a as D}from"./asyncComputed.95993e52.js";import{F as h}from"./PhArrowSquareOut.vue.f7ba9bd2.js";import{G as B}from"./PhPencil.vue.50044340.js";import{d as F,eO as M,e as $,f as A,W as G,b as o,w as i,u as l,aJ as V,eP as j,o as b,c as E,co as L,bD as P,cn as U,R as J,cy as S}from"./vue-router.78d58ff0.js";import"./gateway.3d93841d.js";import"./tables.aed54935.js";import{O as c}from"./organization.0a3e2485.js";import"./PhChats.vue.a9cb8ab5.js";import"./PhSignOut.vue.f80d6de9.js";import"./router.ce687edb.js";import"./index.e96c19f7.js";import"./index.20fea1a7.js";import"./index.ffdb60ac.js";import"./BookOutlined.238416cb.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.c6ea29d9.js";import"./url.f92f4d36.js";import"./PhDotsThree.vue.4c71ca22.js";import"./index.8e2351ec.js";import"./popupNotifcation.466d80c0.js";import"./record.6c05e3f5.js";import"./string.b574f1fa.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]="08fdba81-bccf-4a9c-8c42-55101555888b",r._sentryDebugIdIdentifier="sentry-dbid-08fdba81-bccf-4a9c-8c42-55101555888b")}catch{}})();const be=F({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],v=M(),{loading:z,result:p,refetch:f}=D(()=>c.list()),g=({key:e})=>{v.push({name:"organization",params:{organizationId:e}})},n=$({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 c.rename(a,t),f()}n.value={state:"idle"}}const C=async e=>{const a=await c.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())},O=A(()=>{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(I,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:O.value,fields:d,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(l(S),{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(U),{key:0,layout:"vertical"},{default:i(()=>[o(l(L),{label:"New name"},{default:i(()=>[o(l(P),{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.3df01989.js.map
