import{N as O}from"./Navbar.ad237c01.js";import{B as I}from"./BaseLayout.e08ba971.js";import{C as _}from"./ContentLayout.a837d946.js";import{C as x}from"./CrudView.30543074.js";import{a as D}from"./ant-design.3e244f71.js";import{a as R}from"./asyncComputed.c7982027.js";import{F as h}from"./PhArrowSquareOut.vue.efaf22f5.js";import{G as B}from"./PhPencil.vue.5fbcac5a.js";import{d as F,eJ as M,q as $,J as j,o as y,eu as A,b as o,w as i,u as l,aD as G,eP as V,c as E,cj as J,bx as L,ci as P,ew as U,ct as q}from"./vue-router.6b399b0b.js";import"./gateway.34f2a318.js";import"./index.c3b84c4d.js";import{O as d}from"./organization.c27666c7.js";import"./Logo.f554efd3.js";import"./logo.084e5d7c.js";import"./PhChats.vue.c013bdec.js";import"./PhSignOut.vue.66574882.js";import"./router.ab3f179a.js";import"./index.2e72b67b.js";import"./index.ab218211.js";import"./index.e61aa379.js";import"./BookOutlined.7993dbf1.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.e21048fc.js";import"./url.2f4a4260.js";import"./index.57cdc892.js";import"./popupNotifcation.17b9c327.js";import"./record.f5201a57.js";import"./string.79d7b0e1.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]="f6bd8781-e9ca-404e-bb31-81178094b4fb",r._sentryDebugIdIdentifier="sentry-dbid-f6bd8781-e9ca-404e-bb31-81178094b4fb")}catch{}})();const ve=F({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],c=[{key:"name",label:"Organization Name"}],v=M(),{loading:w,result:p,refetch:f}=R(()=>d.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 b(e){if(n.value.state==="renaming"&&e){const{organizationId:t,newName:a}=n.value;await d.rename(t,a),f()}n.value={state:"idle"}}const C=async e=>{const t=await d.create(e.name);g({key:t.id})},k=async({key:e})=>{var a,s;await D("Are you sure you want to delete this organization?")&&(await((s=(a=p.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:s.delete()),f())},N=j(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=p.value)==null?void 0:e.map(a=>{var s,u;return{key:a.id,cells:[{type:"link",text:a.name,to:(s=`/organizations/${encodeURIComponent(a.id)}`)!=null?s:null},{type:"text",text:(u=a.id)!=null?u:null},{type:"actions",actions:[{icon:h,label:"Go to projects",onClick:g},{icon:B,label:"Rename",onClick:()=>z(a)},{icon:V,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(y(),A(G,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:c,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(l(q),{open:n.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=a=>b(!1)),onOk:t[2]||(t[2]=a=>b(!0))},{default:i(()=>[n.value.state==="renaming"?(y(),E(l(P),{key:0,layout:"vertical"},{default:i(()=>[o(l(J),{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{ve as default};
//# sourceMappingURL=Organizations.2b8a75bf.js.map
