import{N as O}from"./Navbar.b51dae48.js";import{B as I}from"./BaseLayout.577165c3.js";import{C as _}from"./ContentLayout.5465dc16.js";import{C as R}from"./CrudView.0b1b90a7.js";import{a as x}from"./ant-design.48401d91.js";import{a as h}from"./asyncComputed.3916dfed.js";import{F as B}from"./PhArrowSquareOut.vue.2a1b339b.js";import{G as D}from"./PhPencil.vue.91f72c2e.js";import{d as F,eo as M,e as $,f as A,o as b,X as G,b as o,w as i,u as l,aR as V,c as j,cv as E,bH as H,cu as L,R as U,cH as P,ep as S}from"./vue-router.324eaed2.js";import"./gateway.edd4374b.js";import{O as c}from"./organization.0ae7dfed.js";import"./tables.842b993f.js";import"./PhChats.vue.42699894.js";import"./PhSignOut.vue.d965d159.js";import"./router.0c18ec5d.js";import"./index.7d758831.js";import"./Avatar.4c029798.js";import"./index.51467614.js";import"./index.ea51f4a9.js";import"./BookOutlined.789cce39.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.88c092e9.js";import"./url.1a1c4e74.js";import"./PhDotsThreeVertical.vue.766b7c1d.js";import"./Badge.9808092c.js";import"./popupNotifcation.5a82bc93.js";import"./record.cff1707c.js";import"./string.d698465c.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]="95375732-baeb-4b2c-a1f1-86d9c4f8115c",r._sentryDebugIdIdentifier="sentry-dbid-95375732-baeb-4b2c-a1f1-86d9c4f8115c")}catch{}})();const ve=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}=h(()=>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 x("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=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:B,label:"Go to projects",onClick:g},{icon:D,label:"Rename",onClick:()=>w(t)},{icon:S,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(R,{"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:d,create: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(),j(l(L),{key:0,layout:"vertical"},{default:i(()=>[o(l(E),{label:"New name"},{default:i(()=>[o(l(H),{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{ve as default};
//# sourceMappingURL=Organizations.c5b7c80c.js.map
