import{N as O}from"./Navbar.64298443.js";import{B as I}from"./BaseLayout.3e9b7375.js";import{C as _}from"./ContentLayout.b8103ab5.js";import{C as R}from"./CrudView.dfc4572e.js";import{a as x}from"./ant-design.83748870.js";import{a as h}from"./asyncComputed.cef7b9d8.js";import{F as B}from"./PhArrowSquareOut.vue.ff1add13.js";import{G as D}from"./PhPencil.vue.e4db48af.js";import{d as F,eq as M,e as $,f as A,X as G,b as o,w as i,u as l,aR as V,o as b,c as j,cv as E,bH as H,cu as L,R as U,cH as q,er as P}from"./vue-router.85c27f05.js";import"./gateway.aa5a907a.js";import{O as c}from"./organization.09284c47.js";import"./tables.8aae1278.js";import"./PhChats.vue.3c3baa59.js";import"./PhSignOut.vue.6074ad11.js";import"./router.6a11826f.js";import"./index.b39fb56f.js";import"./Avatar.77fe15dd.js";import"./index.ed82b5e0.js";import"./index.b424c289.js";import"./BookOutlined.3c422224.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.2ed94dec.js";import"./url.2f0a55dd.js";import"./PhDotsThreeVertical.vue.ceb80819.js";import"./Badge.6a9a7808.js";import"./popupNotifcation.db970277.js";import"./record.b6b15302.js";import"./string.76b61cc9.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]="51e2ff38-2b6f-4073-bfb0-77111449770c",r._sentryDebugIdIdentifier="sentry-dbid-51e2ff38-2b6f-4073-bfb0-77111449770c")}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:P,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(q),{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.1998da63.js.map
