import{N as O}from"./Navbar.517b1b4a.js";import{B as I}from"./BaseLayout.b924aa67.js";import{C as _}from"./ContentLayout.aab5963f.js";import{C as R}from"./CrudView.81c72183.js";import{a as x}from"./ant-design.79c08f53.js";import{a as h}from"./asyncComputed.83d82971.js";import{F as B}from"./PhArrowSquareOut.vue.b49e75f5.js";import{G as D}from"./PhPencil.vue.225376db.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.f3adf768.js";import"./gateway.9d2e1477.js";import{O as c}from"./organization.ca990c57.js";import"./tables.f76abbb4.js";import"./PhChats.vue.609fe13b.js";import"./PhSignOut.vue.1e827602.js";import"./router.e48ec16b.js";import"./index.eac32d6d.js";import"./Avatar.4775f847.js";import"./index.c827c851.js";import"./index.6a697fc3.js";import"./BookOutlined.9465c5e6.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.f36536ce.js";import"./url.05ebda4d.js";import"./PhDotsThreeVertical.vue.0274c806.js";import"./Badge.e393c721.js";import"./popupNotifcation.271a2b0b.js";import"./record.c1c318a9.js";import"./string.10d66498.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]="629fc417-a8f0-467e-9648-b16f98e31114",r._sentryDebugIdIdentifier="sentry-dbid-629fc417-a8f0-467e-9648-b16f98e31114")}catch{}})();const ve=F({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],v=M(),{loading:z,result:p,refetch:f}=h(()=>c.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 c.rename(t,a),f()}n.value={state:"idle"}}const C=async e=>{const t=await c.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:d,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.ba4ac807.js.map
