import{d as _,eA as I,r as N,G as x,b as y,ev as A,f as o,w as r,u as s,bq as h,c as R,bH as B,ex as D}from"./outputWidgets.333243b5.js";import{z as F,o as M,C as $}from"./icons.ec7238f6.js";import{a as V}from"./asyncComputed.916d2e38.js";import"./authorManager.afcc9659.js";import"./index.cbd7b276.js";import{O as l}from"./organization.a1295e5d.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.85e90b19.js";import{C as E}from"./CrudView.270e4dd7.js";import{B as G}from"./BaseLayout.82019b78.js";import{a as L}from"./ant-design.d494077f.js";import{A as U}from"./FormItem.413481bf.js";import{F as q}from"./Form.950f385f.js";import{M as H}from"./Title.3b7d5185.js";import"./index.cf4c23b9.js";import"./record.3365b440.js";import"./pubsub.6843f3da.js";import"./gateway.d354a11c.js";import"./logo.084e5d7c.js";import"./Text.f7432746.js";import"./index.f0ba07f5.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.25cae863.js";import"./router.9264d3a7.js";import"./index.b6f16b4f.js";import"./url.2fbcdffc.js";import"./index.be8066b9.js";import"./index.7a3dbad5.js";import"./index.7e314b45.js";import"./index.e0bce9ea.js";import"./hasIn.cb198a04.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]="83885379-e918-490c-9159-3d811dc00c7c",i._sentryDebugIdIdentifier="sentry-dbid-83885379-e918-490c-9159-3d811dc00c7c")}catch{}})();const ve=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],c=[{key:"name",label:"Organization Name"}],b=I(),{loading:z,result:d,refetch:u}=V(()=>l.list()),p=({key:e})=>{b.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 g(e){if(n.value.state==="renaming"&&e){const{organizationId:t,newName:a}=n.value;await l.rename(t,a),u()}n.value={state:"idle"}}const w=async e=>{const t=await l.create(e.name);p({key:t.id})},k=async({key:e})=>{var a,f;await L("Are you sure you want to delete this organization?")&&(await((f=(a=d.value)==null?void 0:a.find(O=>O.id===e))==null?void 0:f.delete()),u())},C=x(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"Actions",align:"right"}],rows:(t=(e=d.value)==null?void 0:e.map(a=>({key:a.id,cells:[{text:a.name,link:`/organizations/${encodeURIComponent(a.id)}`},{text:a.id},{text:"",actions:[{icon:F,label:"Go to projects",onClick:p},{icon:M,label:"Rename",onClick:()=>v(a)},{icon:$,label:"Delete",onClick:k,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>(y(),A(h,null,[o(G,null,{navbar:r(()=>[o(j,{breadcrumb:m})]),content:r(()=>[o(E,{"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:t[1]||(t[1]=a=>g(!1)),onOk:t[2]||(t[2]=a=>g(!0))},{default:r(()=>[n.value.state==="renaming"?(y(),R(s(q),{key:0,layout:"vertical"},{default:r(()=>[o(s(U),{label:"New name"},{default:r(()=>[o(s(B),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):D("",!0)]),_:1},8,["open"])],64))}});export{ve as default};
//# sourceMappingURL=Organizations.322c8f86.js.map
