import{N as O}from"./Navbar.8540b324.js";import{B as I}from"./BaseLayout.54b05b86.js";import{C as _}from"./ContentLayout.ee970dbc.js";import{C as x}from"./CrudView.cec93544.js";import{a as R}from"./ant-design.a27edffa.js";import{a as h}from"./asyncComputed.37a42e7b.js";import{F as B}from"./PhArrowSquareOut.vue.b410841e.js";import{G as D}from"./PhPencil.vue.ad2722bd.js";import{d as F,eq as M,e as $,f as A,X as G,b as o,w as i,u as l,aR as V,o as b,c as j,cy as E,bK as K,cx as L,R as U,cK as q,er as P}from"./vue-router.36bc5188.js";import"./gateway.6a3fe533.js";import{O as u}from"./organization.f0cd756c.js";import"./tables.d43a3134.js";import"./PhChats.vue.dd9b3cbf.js";import"./PhSignOut.vue.af876aa6.js";import"./router.748a95a3.js";import"./index.87f1e4b3.js";import"./Avatar.e26f498d.js";import"./index.72a903ce.js";import"./index.b25281da.js";import"./BookOutlined.de962338.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.7b7ee2ef.js";import"./url.a7891bdc.js";import"./PhDotsThreeVertical.vue.ac77e5a6.js";import"./popupNotifcation.a7b5eb5c.js";import"./record.2cf5df84.js";import"./string.8a83f3d1.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]="89c59655-4ded-44ab-b7a4-21aa4adadd61",r._sentryDebugIdIdentifier="sentry-dbid-89c59655-4ded-44ab-b7a4-21aa4adadd61")}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:g}=h(()=>u.list()),f=({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 u.rename(a,t),g()}n.value={state:"idle"}}const C=async e=>{const a=await u.create(e.name);f({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(d=>d.id===e))==null?void 0:s.delete()),g())},N=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,d;return{key:t.id,cells:[{type:"link",text:t.name,to:(s=`/organizations/${encodeURIComponent(t.id)}`)!=null?s:null},{type:"text",text:(d=t.id)!=null?d:null},{type:"actions",actions:[{icon:B,label:"Go to projects",onClick:f},{icon:D,label:"Rename",onClick:()=>w(t)},{icon:P,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(b(),G(V,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:N.value,fields:c,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(l(q),{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(),j(l(L),{key:0,layout:"vertical"},{default:i(()=>[o(l(E),{label:"New name"},{default:i(()=>[o(l(K),{value:n.value.newName,"onUpdate:value":a[0]||(a[0]=t=>n.value.newName=t)},null,8,["value"])]),_:1})]),_:1})):U("",!0)]),_:1},8,["open"])],64))}});export{be as default};
//# sourceMappingURL=Organizations.cea21d15.js.map
