import{N as O}from"./Navbar.669ea9c8.js";import{B as I}from"./BaseLayout.c5d4e2a2.js";import{C as _}from"./ContentLayout.129025ab.js";import{C as x}from"./CrudView.858975e6.js";import{a as F}from"./ant-design.505ee29f.js";import{a as R}from"./asyncComputed.bd2b6e70.js";import{F as h}from"./PhArrowSquareOut.vue.f5352ec6.js";import{G as B}from"./PhPencil.vue.7371bf48.js";import{d as D,eF as M,r as $,y as A,b,eq as G,f as o,w as i,u as l,aw as L,eL as V,c as j,ce as q,bq as E,cd as U,es as P,co as S}from"./outputWidgets.f7b80e9f.js";import"./gateway.58b63376.js";import"./index.f21af923.js";import{O as c}from"./organization.542230b9.js";import"./logo.084e5d7c.js";import"./PhChats.vue.9e85add8.js";import"./PhSignOut.vue.3641a16f.js";import"./router.6fb3acdf.js";import"./index.86fdb625.js";import"./index.956edd16.js";import"./index.c4af5543.js";import"./BookOutlined.12f9401e.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.b36f7510.js";import"./url.882128c4.js";import"./index.288a68e3.js";import"./popupNotifcation.6f5b518c.js";import"./record.188928bf.js";import"./pubsub.10df5fd2.js";import"./string.18a9daee.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]="d95c7e13-e339-41b6-ab1c-b6aee77888fc",r._sentryDebugIdIdentifier="sentry-dbid-d95c7e13-e339-41b6-ab1c-b6aee77888fc")}catch{}})();const ve=D({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],v=M(),{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 F("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:()=>z(t)},{icon:V,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(b(),G(L,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(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(U),{key:0,layout:"vertical"},{default:i(()=>[o(l(q),{label:"New name"},{default:i(()=>[o(l(E),{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{ve as default};
//# sourceMappingURL=Organizations.0d199703.js.map
