import{N as O}from"./Navbar.1a4dde12.js";import{B as I}from"./BaseLayout.76b9d34c.js";import{C as _}from"./ContentLayout.e60f6cb7.js";import{C as x}from"./CrudView.797f086e.js";import{a as R}from"./ant-design.c0f2ec4c.js";import{a as D}from"./asyncComputed.72143f3b.js";import{F as h}from"./PhArrowSquareOut.vue.93a854fa.js";import{G as B}from"./PhPencil.vue.bb6c5a6a.js";import{d as F,ek as M,e as $,f as A,W as E,b as o,w as i,u as l,aJ as G,el as V,o as b,c as j,cs as L,bD as U,cr as J,R as P,cE as S}from"./vue-router.97d0d8a6.js";import"./gateway.91a35dd3.js";import{O as c}from"./organization.c9b277ba.js";import"./tables.8944c1e2.js";import"./PhChats.vue.83f33538.js";import"./PhSignOut.vue.3ede16d6.js";import"./router.bf9d2a86.js";import"./index.557e8025.js";import"./Avatar.ea229645.js";import"./index.5452647c.js";import"./index.8472dd28.js";import"./BookOutlined.868baafb.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.05d4ef76.js";import"./url.6a6403b0.js";import"./PhDotsThree.vue.3d83613d.js";import"./popupNotifcation.80047f06.js";import"./record.a84b6d90.js";import"./string.4a3650cc.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]="8b5d8468-389c-4cfc-958a-a1c6bf092d15",r._sentryDebugIdIdentifier="sentry-dbid-8b5d8468-389c-4cfc-958a-a1c6bf092d15")}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())},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:h,label:"Go to projects",onClick:g},{icon:B,label:"Rename",onClick:()=>w(t)},{icon:V,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(b(),E(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:N.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(),j(l(J),{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})):P("",!0)]),_:1},8,["open"])],64))}});export{be as default};
//# sourceMappingURL=Organizations.35271e8d.js.map
