import{N as O}from"./Navbar.4b6eb851.js";import{B as I}from"./BaseLayout.a58db6a0.js";import{C as _}from"./ContentLayout.1036e4eb.js";import{C as x}from"./CrudView.408a4461.js";import{a as R}from"./ant-design.7d916c63.js";import{a as h}from"./asyncComputed.2bec113c.js";import{F as B}from"./PhArrowSquareOut.vue.da88caf0.js";import{G as D}from"./PhPencil.vue.10ddf5aa.js";import{d as F,eo as M,e as L,f as $,o as y,Y as A,b as o,w as i,u as l,aS as G,c as S,cz as V,bL as j,cy as E,S as U,cL as P,ep as T}from"./index.0f630b70.js";import"./gateway.50cd3949.js";import{O as u}from"./organization.54ff4f89.js";import"./tables.78c50568.js";import"./PhChats.vue.5994232f.js";import"./PhSignOut.vue.8e112f6f.js";import"./router.0f31f3f1.js";import"./index.1eaf0cd2.js";import"./Avatar.b0b40f97.js";import"./index.cc0715fd.js";import"./index.8ce42306.js";import"./BookOutlined.89f2a8c6.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.bf268869.js";import"./url.90c69b58.js";import"./PhDotsThreeVertical.vue.e2e73559.js";import"./Badge.ada44968.js";import"./popupNotifcation.dd76a56c.js";import"./record.f729e500.js";import"./string.532e13bb.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]="7534597d-b067-4d6e-8042-5071d5c7915f",r._sentryDebugIdIdentifier="sentry-dbid-7534597d-b067-4d6e-8042-5071d5c7915f")}catch{}})();const ze=F({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],b=M(),{loading:z,result:c,refetch:p}=h(()=>u.list()),f=({key:e})=>{b.push({name:"organization",params:{organizationId:e}})},n=L({state:"idle"});function v(e){n.value={state:"renaming",organizationId:e.id,newName:e.name}}async function g(e){if(n.value.state==="renaming"&&e){const{organizationId:t,newName:a}=n.value;await u.rename(t,a),p()}n.value={state:"idle"}}const w=async e=>{const t=await u.create(e.name);f({key:t.id})},C=async({key:e})=>{var a,s;await R("Are you sure you want to delete this organization?")&&(await((s=(a=c.value)==null?void 0:a.find(N=>N.id===e))==null?void 0:s.delete()),p())},k=$(()=>{var e,t;return{columns:[{title:"Organization Name",align:"left"},{title:"Path"},{title:"",align:"right"}],rows:(t=(e=c.value)==null?void 0:e.map(a=>{var s;return{key:a.id,cells:[{type:"link",text:a.name,to:`/organizations/${encodeURIComponent(a.id)}`},{type:"text",text:(s=a.id)!=null?s:null},{type:"actions",actions:[{icon:B,label:"Go to projects",onClick:f},{icon:D,label:"Rename",onClick:()=>v(a)},{icon:T,label:"Delete",onClick:C,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(y(),A(G,null,[o(I,null,{navbar:i(()=>[o(O,{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:k.value,fields:d,create:w},null,8,["loading","table"])]),_:1})]),_:1}),o(l(P),{open:n.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=a=>g(!1)),onOk:t[2]||(t[2]=a=>g(!0))},{default:i(()=>[n.value.state==="renaming"?(y(),S(l(E),{key:0,layout:"vertical"},{default:i(()=>[o(l(V),{label:"New name"},{default:i(()=>[o(l(j),{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{ze as default};
//# sourceMappingURL=Organizations.5d8ef8bf.js.map
