import{N as O}from"./Navbar.b813862a.js";import{B as I}from"./BaseLayout.2021f004.js";import{C as _}from"./ContentLayout.e85ba8fa.js";import{C as R}from"./CrudView.f5a5d8e5.js";import{a as x}from"./ant-design.57bf02d4.js";import{a as h}from"./asyncComputed.b83fe47e.js";import{F as B}from"./PhArrowSquareOut.vue.0f29efb5.js";import{G as D}from"./PhPencil.vue.eb898a6f.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.9fdef1c2.js";import"./gateway.48c2d7b1.js";import{O as d}from"./organization.decc8448.js";import"./tables.86324cd4.js";import"./PhChats.vue.31de16fe.js";import"./PhSignOut.vue.ea238bb3.js";import"./router.d2ac8bec.js";import"./index.dc55511c.js";import"./Avatar.790cee4f.js";import"./index.1d9ad032.js";import"./index.45850dc3.js";import"./BookOutlined.510e5f39.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.1284f4cc.js";import"./url.07fafc3a.js";import"./PhDotsThreeVertical.vue.1dec2e66.js";import"./Badge.4a06ddb5.js";import"./popupNotifcation.894bbaa5.js";import"./record.5ebff19c.js";import"./string.aab27b65.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]="5dfe91fd-1120-4c1b-b6e4-5b9dac44633e",r._sentryDebugIdIdentifier="sentry-dbid-5dfe91fd-1120-4c1b-b6e4-5b9dac44633e")}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.b835d96d.js.map
