import{N as O}from"./Navbar.da8de173.js";import{B as I}from"./BaseLayout.ad0b261b.js";import{C as _}from"./ContentLayout.71b5aba6.js";import{C as x}from"./CrudView.121af814.js";import{a as F}from"./ant-design.50d54108.js";import{a as M}from"./asyncComputed.23e92968.js";import{F as R}from"./PhArrowSquareOut.vue.09acb7fc.js";import{G as h}from"./PhPencil.vue.a3810a80.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.161060e0.js";import"./gateway.f2530f68.js";import"./index.f8b37d25.js";import{O as u}from"./organization.2a744ca5.js";import{A as P,F as S}from"./Form.52ea0ff3.js";import{M as T}from"./Modal.27701131.js";import"./logo.084e5d7c.js";import"./PhChats.vue.e3f02138.js";import"./PhSignOut.vue.550ba3ea.js";import"./router.42dba988.js";import"./index.adff861d.js";import"./index.8684e55d.js";import"./BookOutlined.c41eff22.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.c0209c48.js";import"./url.5fda3169.js";import"./index.f997bfa4.js";import"./index.43e74cd1.js";import"./popupNotifcation.f24dac0e.js";import"./record.6a8bcc7f.js";import"./pubsub.ce004d19.js";import"./string.0c0535f5.js";import"./hasIn.9bea2804.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]="8f1edf3a-5555-436d-a6c9-88753d76d404",r._sentryDebugIdIdentifier="sentry-dbid-8f1edf3a-5555-436d-a6c9-88753d76d404")}catch{}})();const Ce=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(()=>u.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:t,newName:a}=n.value;await u.rename(t,a),f()}n.value={state:"idle"}}const C=async e=>{const t=await u.create(e.name);g({key:t.id})},k=async({key:e})=>{var a,s;await F("Are you sure you want to delete this organization?")&&(await((s=(a=c.value)==null?void 0:a.find(d=>d.id===e))==null?void 0:s.delete()),f())},N=V(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=c.value)==null?void 0:e.map(a=>{var s,d;return{key:a.id,cells:[{type:"link",text:a.name,to:(s=`/organizations/${encodeURIComponent(a.id)}`)!=null?s:null},{type:"text",text:(d=a.id)!=null?d:null},{type:"actions",actions:[{icon:R,label:"Go to projects",onClick:g},{icon:h,label:"Rename",onClick:()=>w(a)},{icon:j,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(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:t[1]||(t[1]=a=>y(!1)),onOk:t[2]||(t[2]=a=>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":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):U("",!0)]),_:1},8,["open"])],64))}});export{Ce as default};
//# sourceMappingURL=Organizations.dcdb953b.js.map
