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 R,bH as B,ex as D}from"./outputWidgets.fdae7e91.js";import{z as F,o as M,C as $}from"./icons.59384d21.js";import{a as V}from"./asyncComputed.43537aae.js";import"./authorManager.adc33c37.js";import"./index.30fe2a77.js";import{O as l}from"./organization.241846c8.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.0d749b6e.js";import{C as E}from"./CrudView.e3fe23cf.js";import{B as G}from"./BaseLayout.f70dd29d.js";import{a as L}from"./ant-design.f2f7cc3b.js";import{A as U}from"./FormItem.45b6065e.js";import{F as q}from"./Form.d4070d32.js";import{M as H}from"./Title.e4079793.js";import"./index.cf4c23b9.js";import"./record.f963a373.js";import"./pubsub.61789656.js";import"./gateway.8c35b4b8.js";import"./logo.084e5d7c.js";import"./Text.2d7466b9.js";import"./index.5b4488d8.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.ed9adb70.js";import"./router.ae435e74.js";import"./index.6f560850.js";import"./url.f60fbe92.js";import"./index.42add8ec.js";import"./index.9026b0b4.js";import"./index.a700463c.js";import"./index.dedb9dc3.js";import"./hasIn.e6601643.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]="e3ba6dcb-4454-44b9-8934-c1a476b77082",i._sentryDebugIdIdentifier="sentry-dbid-e3ba6dcb-4454-44b9-8934-c1a476b77082")}catch{}})();const ve=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],u=[{key:"name",label:"Organization Name"}],y=I(),{loading:z,result:d,refetch:c}=V(()=>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 g(e){if(n.value.state==="renaming"&&e){const{organizationId:a,newName:t}=n.value;await l.rename(a,t),c()}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,f;await L("Are you sure you want to delete this organization?")&&(await((f=(t=d.value)==null?void 0:t.find(O=>O.id===e))==null?void 0:f.delete()),c())},C=x(()=>{var e,a;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"Actions",align:"right"}],rows:(a=(e=d.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(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:u,onCreate:w},null,8,["loading","table"])]),_:1}),o(s(H),{open:n.value.state==="renaming",title:"Rename organization",onCancel:a[1]||(a[1]=t=>g(!1)),onOk:a[2]||(a[2]=t=>g(!0))},{default:r(()=>[n.value.state==="renaming"?(b(),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":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.5f7e31b1.js.map
