import{N as O}from"./Navbar.980bb3de.js";import{B as I}from"./BaseLayout.1d738bf3.js";import{C as _}from"./ContentLayout.80f1caf4.js";import{C as x}from"./CrudView.cf099838.js";import{a as R}from"./ant-design.62a6773b.js";import{a as h}from"./asyncComputed.ee6673cb.js";import{F as B}from"./PhArrowSquareOut.vue.e3c5cb58.js";import{G as D}from"./PhPencil.vue.a781bcff.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,cy as E,bK as K,cx as L,R as U,cK as P,ep as S}from"./vue-router.25496eb3.js";import"./gateway.090a2504.js";import{O as d}from"./organization.88c8710e.js";import"./tables.732c3160.js";import"./PhChats.vue.c40533ff.js";import"./PhSignOut.vue.e3cdd65d.js";import"./router.92b9eafd.js";import"./index.cdda9ded.js";import"./Avatar.ec14bfae.js";import"./index.884c1aec.js";import"./index.608a58cb.js";import"./BookOutlined.23f627d4.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.c4306070.js";import"./url.d7b430c5.js";import"./PhDotsThreeVertical.vue.eb15d37e.js";import"./Badge.0b8e6d1d.js";import"./popupNotifcation.ea7de34e.js";import"./record.0cf3393b.js";import"./string.cb42bbf3.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]="d045bb07-c9de-4cf4-92d0-4cd8aaf20afa",r._sentryDebugIdIdentifier="sentry-dbid-d045bb07-c9de-4cf4-92d0-4cd8aaf20afa")}catch{}})();const ve=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:f}=h(()=>d.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 d.rename(a,t),f()}n.value={state:"idle"}}const C=async e=>{const a=await d.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: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(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,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(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{ve as default};
//# sourceMappingURL=Organizations.9a190647.js.map
