import{N as O}from"./Navbar.d72cd24c.js";import{B as I}from"./BaseLayout.2064c280.js";import{C as _}from"./ContentLayout.9ec4dd7a.js";import{C as x}from"./CrudView.f360b43c.js";import{a as M}from"./ant-design.7980fd18.js";import{a as R}from"./asyncComputed.7b5c3427.js";import{F as h}from"./PhArrowSquareOut.vue.0479da5c.js";import{G as B}from"./PhPencil.vue.184a28bf.js";import{d as D,eM as F,e as $,f as j,o as b,eu as A,b as o,w as i,u as l,aE as E,eN as G,c as V,ck as L,by as U,cj as P,ew as S,cu as T}from"./vue-router.74c693f1.js";import"./gateway.707771fc.js";import"./index.0791082e.js";import{O as c}from"./organization.cd76f88b.js";import"./PhChats.vue.186cf0b3.js";import"./PhSignOut.vue.ebc4d073.js";import"./router.77dea3d2.js";import"./index.33768c38.js";import"./index.08822948.js";import"./index.adf2c504.js";import"./BookOutlined.7a96a9c1.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.97a16843.js";import"./url.8b7ee03b.js";import"./index.ad2af8a3.js";import"./popupNotifcation.d39bbf9b.js";import"./record.0d85e3b6.js";import"./string.b1ebfabb.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]="69e5da48-dd05-45c5-bc6c-cf81c0afcbdf",r._sentryDebugIdIdentifier="sentry-dbid-69e5da48-dd05-45c5-bc6c-cf81c0afcbdf")}catch{}})();const ye=D({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],v=F(),{loading:w,result:p,refetch:f}=R(()=>c.list()),g=({key:e})=>{v.push({name:"organization",params:{organizationId:e}})},n=$({state:"idle"});function z(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 M("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())},N=j(()=>{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:()=>z(t)},{icon:G,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(b(),A(E,null,[o(I,null,{navbar:i(()=>[o(O,{breadcrumb:m})]),content:i(()=>[o(_,null,{default:i(()=>[o(x,{"entity-name":"organization",loading:l(w),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(l(T),{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(),V(l(P),{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})):S("",!0)]),_:1},8,["open"])],64))}});export{ye as default};
//# sourceMappingURL=Organizations.46ac8aef.js.map
