import{N as O}from"./Navbar.e82054e6.js";import{B as I}from"./BaseLayout.3b732e48.js";import{C as _}from"./ContentLayout.9508ac8e.js";import{C as R}from"./CrudView.6dee12dd.js";import{a as x}from"./ant-design.ab86670b.js";import{a as h}from"./asyncComputed.e840076d.js";import{F as B}from"./PhArrowSquareOut.vue.a3cf64eb.js";import{G as D}from"./PhPencil.vue.c5b74fb4.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,cv as E,bH as H,cu as L,R as U,cH as P,ep as S}from"./vue-router.e3ef87f0.js";import"./gateway.e3730daa.js";import{O as d}from"./organization.365449ea.js";import"./tables.8b5b16f2.js";import"./PhChats.vue.e1264b9f.js";import"./PhSignOut.vue.4fb59e20.js";import"./router.7553e78c.js";import"./index.45410f8d.js";import"./Avatar.715e2ca3.js";import"./index.74f6e7f5.js";import"./index.6f617d93.js";import"./BookOutlined.2206ef88.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.7e26700d.js";import"./url.d7fc9f74.js";import"./PhDotsThreeVertical.vue.4a059a70.js";import"./Badge.e09547ac.js";import"./popupNotifcation.bf248d47.js";import"./record.9f354c97.js";import"./string.5524ff61.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]="0d568e3e-831c-4768-b282-cea42ff1de24",r._sentryDebugIdIdentifier="sentry-dbid-0d568e3e-831c-4768-b282-cea42ff1de24")}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: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 x("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=A(()=>{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:B,label:"Go to projects",onClick:g},{icon:D,label:"Rename",onClick:()=>w(a)},{icon:S,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),G(V,null,[o(I,null,{navbar:i(()=>[o(O,{breadcrumb:m})]),content:i(()=>[o(_,null,{default:i(()=>[o(R,{"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:t[1]||(t[1]=a=>y(!1)),onOk:t[2]||(t[2]=a=>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(H),{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.b4791359.js.map
