import{N as O}from"./Navbar.1f1ef45f.js";import{B as I}from"./BaseLayout.5e237fd8.js";import{C as _}from"./ContentLayout.f6dd01ab.js";import{C as x}from"./CrudView.d2e5841c.js";import{a as F}from"./ant-design.039e95cf.js";import{a as M}from"./asyncComputed.e188c84d.js";import{F as R}from"./PhArrowSquareOut.vue.40da27c6.js";import{G as h}from"./PhPencil.vue.ecceca31.js";import{d as B,f7 as D,r as A,y as V,b,eV as $,f as o,w as i,u as l,ay as G,fd as j,c as E,bx as L,eX as U}from"./outputWidgets.abde7be7.js";import"./gateway.e5c93921.js";import"./index.2e366912.js";import{O as d}from"./organization.484f355f.js";import{A as P,F as S}from"./Form.8489fb6d.js";import{M as T}from"./Modal.b9769244.js";import"./logo.084e5d7c.js";import"./PhChats.vue.51217c5c.js";import"./PhSignOut.vue.34a67eb6.js";import"./router.aff593c1.js";import"./index.17d825a9.js";import"./index.d3caf38b.js";import"./BookOutlined.ef6ccb36.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.2107de83.js";import"./url.578d50c3.js";import"./index.42ebfb5e.js";import"./index.a7c0b349.js";import"./popupNotifcation.51a8836c.js";import"./record.4adc9d27.js";import"./pubsub.7f579dee.js";import"./hasIn.b8f131ab.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]="d72426eb-4d03-4307-950c-e3aa068a7f61",r._sentryDebugIdIdentifier="sentry-dbid-d72426eb-4d03-4307-950c-e3aa068a7f61")}catch{}})();const we=B({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],p=[{key:"name",label:"Organization Name"}],v=D(),{loading:z,result:c,refetch:f}=M(()=>d.list()),g=({key:e})=>{v.push({name:"organization",params:{organizationId:e}})},n=A({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 F("Are you sure you want to delete this organization?")&&(await((s=(t=c.value)==null?void 0:t.find(u=>u.id===e))==null?void 0:s.delete()),f())},N=V(()=>{var e,a;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(a=(e=c.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:R,label:"Go to projects",onClick:g},{icon:h,label:"Rename",onClick:()=>w(t)},{icon:j,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(b(),$(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:p,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(),E(l(S),{key:0,layout:"vertical"},{default:i(()=>[o(l(P),{label:"New name"},{default:i(()=>[o(l(L),{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{we as default};
//# sourceMappingURL=Organizations.a932299b.js.map
