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,a$ as A,c as R,bO as B,ex as D}from"./outputWidgets.6bfc0239.js";import{e as F,I as M,L as $}from"./icons.5f4f8713.js";import{a as L}from"./asyncComputed.21831dee.js";import"./router.979769f7.js";import"./index.76d87691.js";import{O as d}from"./organization.721b781f.js";import{_ as V}from"./Navbar.vue_vue_type_script_setup_true_lang.53af7a2e.js";import{C as j}from"./CrudView.26794284.js";import{B as E}from"./BaseLayout.b05ffc6b.js";import{a as U}from"./ant-design.bf757549.js";import{A as G,F as H}from"./Form.7d1a8597.js";import{M as P}from"./Modal.9595e4e0.js";import"./index.cf4c23b9.js";import"./record.dbb754fe.js";import"./pubsub.56f48661.js";import"./logo.084e5d7c.js";import"./Text.3be64ce1.js";import"./Base.3f4f4c87.js";import"./Typography.7fe49268.js";import"./index.a0291250.js";import"./ArrowRightOutlined.08fa31dd.js";import"./Paragraph.100fbd75.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.77240f7b.js";import"./url.c2408bab.js";import"./index.60dad040.js";import"./Title.84d6428e.js";import"./index.ecc37a00.js";import"./index.71301f31.js";import"./hasIn.42df2c7d.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]="34521db3-0ff2-4685-94b4-a47e45584421",i._sentryDebugIdIdentifier="sentry-dbid-34521db3-0ff2-4685-94b4-a47e45584421")}catch{}})();const ve=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],p=[{key:"name",label:"Organization Name"}],z=I(),{loading:v,result:c,refetch:f}=L(()=>d.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:t,newName:a}=n.value;await d.rename(t,a),f()}n.value={state:"idle"}}const k=async e=>{const t=await d.create(e.name);g({key:t.id})},C=async({key:e})=>{var a,r;await U("Are you sure you want to delete this organization?")&&(await((r=(a=c.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:r.delete()),f())},O=x(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=c.value)==null?void 0:e.map(a=>{var r,u;return{key:a.id,cells:[{type:"link",text:a.name,to:(r=`/organizations/${encodeURIComponent(a.id)}`)!=null?r:null},{type:"text",text:(u=a.id)!=null?u:null},{type:"actions",actions:[{icon:F,label:"Go to projects",onClick:g},{icon:M,label:"Rename",onClick:()=>w(a)},{icon:$,label:"Delete",onClick:C,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(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:p,onCreate:k},null,8,["loading","table"])]),_:1}),o(l(P),{open:n.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=a=>y(!1)),onOk:t[2]||(t[2]=a=>y(!0))},{default:s(()=>[n.value.state==="renaming"?(b(),R(l(H),{key:0,layout:"vertical"},{default:s(()=>[o(l(G),{label:"New name"},{default:s(()=>[o(l(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.a24fd103.js.map
