import{d as _,eA as I,r as N,H as x,b,ev as h,f as o,w as s,u as l,aD as A,c as D,bz as R,ex as B}from"./outputWidgets.3c3deba7.js";import{e as F,I as M,L as $}from"./icons.c5a369ef.js";import{a as L}from"./asyncComputed.41e37f4b.js";import"./router.2687a12c.js";import"./index.79fda194.js";import{O as c}from"./organization.aba66f3b.js";import{_ as V}from"./Navbar.vue_vue_type_script_setup_true_lang.a6eee27d.js";import{C as j}from"./CrudView.44eff915.js";import{B as E}from"./BaseLayout.da9f9b22.js";import{a as U}from"./ant-design.a4c10239.js";import{A as G,F as H}from"./Form.21b032af.js";import{M as P}from"./Modal.ace70b58.js";import"./index.cf4c23b9.js";import"./record.e2163ce9.js";import"./pubsub.59f66cb7.js";import"./logo.084e5d7c.js";import"./Text.9ff37267.js";import"./Base.c0a62eaa.js";import"./Typography.828881b4.js";import"./index.9a533a9a.js";import"./ArrowRightOutlined.08fa31dd.js";import"./Paragraph.d0a77c93.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.86e502f6.js";import"./url.89508003.js";import"./index.c3c37865.js";import"./Title.ee2bfa7b.js";import"./index.66ff16a7.js";import"./index.a5f4fbb0.js";import"./hasIn.26cab181.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]="7090c009-8884-477c-b859-af657bd9ac2f",i._sentryDebugIdIdentifier="sentry-dbid-7090c009-8884-477c-b859-af657bd9ac2f")}catch{}})();const ve=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],z=I(),{loading:v,result:p,refetch:f}=L(()=>c.list()),g=({key:e})=>{z.push({name:"organization",params:{organizationId:e}})},n=N({state:"idle"});function w(e){n.value={state:"renaming",organizationId:e.id,newName:e.name}}async function y(e){if(n.value.state==="renaming"&&e){const{organizationId:a,newName:t}=n.value;await c.rename(a,t),f()}n.value={state:"idle"}}const k=async e=>{const a=await c.create(e.name);g({key:a.id})},C=async({key:e})=>{var t,r;await U("Are you sure you want to delete this organization?")&&(await((r=(t=p.value)==null?void 0:t.find(u=>u.id===e))==null?void 0:r.delete()),f())},O=x(()=>{var e,a;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(a=(e=p.value)==null?void 0:e.map(t=>{var r,u;return{key:t.id,cells:[{type:"link",text:t.name,to:(r=`/organizations/${encodeURIComponent(t.id)}`)!=null?r:null},{type:"text",text:(u=t.id)!=null?u:null},{type:"actions",actions:[{icon:F,label:"Go to projects",onClick:g},{icon:M,label:"Rename",onClick:()=>w(t)},{icon:$,label:"Delete",onClick:C,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(b(),h(A,null,[o(E,null,{navbar:s(()=>[o(V,{breadcrumb:m})]),content:s(()=>[o(j,{"entity-name":"organization",loading:l(v),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:O.value,fields:d,onCreate:k},null,8,["loading","table"])]),_:1}),o(l(P),{open:n.value.state==="renaming",title:"Rename organization",onCancel:a[1]||(a[1]=t=>y(!1)),onOk:a[2]||(a[2]=t=>y(!0))},{default:s(()=>[n.value.state==="renaming"?(b(),D(l(H),{key:0,layout:"vertical"},{default:s(()=>[o(l(G),{label:"New name"},{default:s(()=>[o(l(R),{value:n.value.newName,"onUpdate:value":a[0]||(a[0]=t=>n.value.newName=t)},null,8,["value"])]),_:1})]),_:1})):B("",!0)]),_:1},8,["open"])],64))}});export{ve as default};
//# sourceMappingURL=Organizations.2f0ce7ff.js.map
