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.ec1b7422.js";import{e as F,u as M,E as $}from"./icons.1f6f4554.js";import{a as E}from"./asyncComputed.57876dc8.js";import"./authorManager.f240882c.js";import"./index.c3f6367a.js";import{O as l}from"./organization.f15409b1.js";import{_ as V}from"./Navbar.vue_vue_type_script_setup_true_lang.84a5430e.js";import{C as j}from"./CrudView.ccacbeb0.js";import{B as G}from"./BaseLayout.2cb3efa3.js";import{a as L}from"./ant-design.1938c9ca.js";import{A as U}from"./FormItem.674c81e4.js";import{F as q}from"./Form.7cf53a7d.js";import{M as H}from"./Title.4910381d.js";import"./index.cf4c23b9.js";import"./record.a3f4df6a.js";import"./pubsub.e392a757.js";import"./gateway.7a02c698.js";import"./logo.084e5d7c.js";import"./Text.aae02753.js";import"./index.7e6b9032.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.7b07d981.js";import"./router.901d31dd.js";import"./index.0c8affc8.js";import"./url.7d2ac932.js";import"./index.058f9bc6.js";import"./index.310cb573.js";import"./index.4fad3763.js";import"./index.24928422.js";import"./hasIn.4d766825.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]="0c61e80d-9655-4d53-a86b-fc0f33152f42",i._sentryDebugIdIdentifier="sentry-dbid-0c61e80d-9655-4d53-a86b-fc0f33152f42")}catch{}})();const ve=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],b=I(),{loading:z,result:u,refetch:c}=E(()=>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 f(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,g;await L("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()),c())},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)=>(y(),A(h,null,[o(G,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:d,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"?(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":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.16172f61.js.map
