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.3eae54a8.js";import{e as F,u as M,E as $}from"./icons.e8458af4.js";import{a as E}from"./asyncComputed.951244d5.js";import"./authorManager.8abbaff3.js";import"./index.5a75491f.js";import{O as l}from"./organization.e4c807bd.js";import{_ as V}from"./Navbar.vue_vue_type_script_setup_true_lang.7b75af0d.js";import{C as j}from"./CrudView.328264f4.js";import{B as G}from"./BaseLayout.b90c6103.js";import{a as L}from"./ant-design.8edb4f18.js";import{A as U}from"./FormItem.8edd4e05.js";import{F as q}from"./Form.f1aa0eff.js";import{M as H}from"./Title.ee79f8a8.js";import"./index.cf4c23b9.js";import"./record.a0b21aff.js";import"./pubsub.4b1da012.js";import"./gateway.350ede4a.js";import"./logo.084e5d7c.js";import"./Text.6e609d9b.js";import"./index.6ffcef0e.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.1fe6b9cc.js";import"./router.409ab4a0.js";import"./index.89d7b0fc.js";import"./url.0fe4f7e9.js";import"./index.77404c97.js";import"./index.3d7ce90e.js";import"./index.2d394d39.js";import"./index.429b3954.js";import"./hasIn.d5bc6fc2.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]="8d3d4aae-f01a-4eff-97a9-8517fa43f4c8",i._sentryDebugIdIdentifier="sentry-dbid-8d3d4aae-f01a-4eff-97a9-8517fa43f4c8")}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()),f=({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 p(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);f({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:f},{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=>p(!1)),onOk:a[2]||(a[2]=t=>p(!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.d4fc8807.js.map
