import{d as _,eA as I,r as N,G as x,b,ev as A,f as o,w as r,u as s,bq as h,c as B,bH as R,ex as D}from"./outputWidgets.c7c3593b.js";import{B as F,q as M,E as $}from"./icons.e912a40c.js";import{a as E}from"./asyncComputed.87d89e82.js";import"./authorManager.33208873.js";import"./index.640c3418.js";import{O as l}from"./organization.1981f198.js";import{_ as V}from"./Navbar.vue_vue_type_script_setup_true_lang.78b85644.js";import{C as j}from"./CrudView.b146ef3d.js";import{B as q}from"./BaseLayout.f0c6220f.js";import{a as G}from"./ant-design.41fde510.js";import{A as L}from"./FormItem.9941e947.js";import{F as U}from"./Form.5652ed9b.js";import{M as H}from"./Title.47031f69.js";import"./index.cf4c23b9.js";import"./record.b6e0d210.js";import"./pubsub.a1271b13.js";import"./gateway.94d6767e.js";import"./logo.084e5d7c.js";import"./Text.1c53905c.js";import"./index.ec294f58.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.252f0a18.js";import"./router.051bd37d.js";import"./index.50d90398.js";import"./url.03aeeb48.js";import"./index.6a297772.js";import"./index.26b290e3.js";import"./index.03af204f.js";import"./index.27c03e11.js";import"./hasIn.f4bb54d3.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},m=new Error().stack;m&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[m]="b09bb2bd-fea8-4031-bc4c-bcecfee6cee9",i._sentryDebugIdIdentifier="sentry-dbid-b09bb2bd-fea8-4031-bc4c-bcecfee6cee9")}catch{}})();const ve=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],c=[{key:"name",label:"Organization Name"}],y=I(),{loading:z,result:u,refetch:d}=E(()=>l.list()),p=({key:e})=>{y.push({name:"organization",params:{organizationId:e}})},n=N({state:"idle"});function v(e){n.value={state:"renaming",organizationId:e.id,newName:e.name}}async function f(e){if(n.value.state==="renaming"&&e){const{organizationId:a,newName:t}=n.value;await l.rename(a,t),d()}n.value={state:"idle"}}const w=async e=>{const a=await l.create(e.name);p({key:a.id})},k=async({key:e})=>{var t,g;await G("Are you sure you want to delete this organization?")&&(await((g=(t=u.value)==null?void 0:t.find(O=>O.id===e))==null?void 0:g.delete()),d())},C=x(()=>{var e,a;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"Actions",align:"right"}],rows:(a=(e=u.value)==null?void 0:e.map(t=>({key:t.id,cells:[{text:t.name,link:`/organizations/${encodeURIComponent(t.id)}`},{text:t.id},{text:"",actions:[{icon:F,label:"Go to projects",onClick:p},{icon:M,label:"Rename",onClick:()=>v(t)},{icon:$,label:"Delete",onClick:k,dangerous:!0}]}]})))!=null?a:[]}});return(e,a)=>(b(),A(h,null,[o(q,null,{navbar:r(()=>[o(V,{breadcrumb:m})]),content:r(()=>[o(j,{"entity-name":"organization",loading:s(z),title:"My organizations",description:"An organization is your company\u2019s account. Add co-workers, manage their access, organize projects and billing.","create-button-text":"Create Organization","empty-title":"No organizations here yet",table:C.value,fields:c,onCreate:w},null,8,["loading","table"])]),_:1}),o(s(H),{open:n.value.state==="renaming",title:"Rename organization",onCancel:a[1]||(a[1]=t=>f(!1)),onOk:a[2]||(a[2]=t=>f(!0))},{default:r(()=>[n.value.state==="renaming"?(b(),B(s(U),{key:0,layout:"vertical"},{default:r(()=>[o(s(L),{label:"New name"},{default:r(()=>[o(s(R),{value:n.value.newName,"onUpdate:value":a[0]||(a[0]=t=>n.value.newName=t)},null,8,["value"])]),_:1})]),_:1})):D("",!0)]),_:1},8,["open"])],64))}});export{ve as default};
//# sourceMappingURL=Organizations.ec914379.js.map
