import{N as O}from"./Navbar.ba35de0a.js";import{B as I}from"./BaseLayout.b28fb01b.js";import{C as _}from"./ContentLayout.8a2f460b.js";import{C as x}from"./CrudView.7d7772b2.js";import{a as R}from"./ant-design.5a1955fb.js";import{a as h}from"./asyncComputed.77239fe2.js";import{F as B}from"./PhArrowSquareOut.vue.33a16968.js";import{G as D}from"./PhPencil.vue.d693a2b7.js";import{d as F,eN as M,e as V,f as $,o as b,V as A,b as o,w as i,u as l,aI as G,eO as j,c as E,co as L,bC as U,cn as P,R as S,cy as T}from"./vue-router.a333e065.js";import"./gateway.1e297c44.js";import"./tables.8220507b.js";import{O as d}from"./organization.a96e7548.js";import"./PhChats.vue.87f93979.js";import"./PhSignOut.vue.b62430d1.js";import"./router.d60ced1a.js";import"./index.e9f1c85a.js";import"./index.20b6d4d1.js";import"./index.efd82712.js";import"./BookOutlined.8fb1197e.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.768d8419.js";import"./url.30f67d32.js";import"./index.d9df5c28.js";import"./popupNotifcation.32228270.js";import"./record.d2fa9f98.js";import"./string.ba08fe0f.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]="fe5f3e02-d1f6-4c4b-8452-d09e9e64fd09",r._sentryDebugIdIdentifier="sentry-dbid-fe5f3e02-d1f6-4c4b-8452-d09e9e64fd09")}catch{}})();const ye=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=V({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 R("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=$(()=>{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:j,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),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(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,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(P),{key:0,layout:"vertical"},{default:i(()=>[o(l(L),{label:"New name"},{default:i(()=>[o(l(U),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):S("",!0)]),_:1},8,["open"])],64))}});export{ye as default};
//# sourceMappingURL=Organizations.31e24e07.js.map
