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 F,bO as R,ex as B}from"./outputWidgets.84fe9cdf.js";import{e as D,t as M,F as $}from"./icons.fb80f0dd.js";import{a as V}from"./asyncComputed.6b982433.js";import"./router.55b997dc.js";import"./index.46fac088.js";import{O as u}from"./organization.03c05399.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.4e7727c6.js";import{C as E}from"./CrudView.d7e7652b.js";import{B as L}from"./BaseLayout.62d29ec0.js";import{a as U}from"./ant-design.53be314d.js";import{A as G}from"./FormItem.3f0afd7c.js";import{F as H}from"./Form.ff60b0b9.js";import{M as P}from"./Modal.47a21763.js";import"./index.cf4c23b9.js";import"./record.d584e714.js";import"./pubsub.e099f5f1.js";import"./logo.084e5d7c.js";import"./Text.6c3b9f60.js";import"./Base.3448c1ef.js";import"./index.f71c4aee.js";import"./Paragraph.7a7aafbc.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.41277f9f.js";import"./url.8de5cd7a.js";import"./index.7b2adc4e.js";import"./Title.59475fea.js";import"./index.2424aba1.js";import"./index.0be37f33.js";import"./hasIn.892e96d0.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]="bdeb1a45-76e8-4ffd-948d-6cdfbc70ec66",i._sentryDebugIdIdentifier="sentry-dbid-bdeb1a45-76e8-4ffd-948d-6cdfbc70ec66")}catch{}})();const ze=_({__name:"Organizations",setup(i){const m=[{label:"My organizations",path:"/organizations"}],c=[{key:"name",label:"Organization Name"}],z=I(),{loading:v,result:p,refetch:f}=V(()=>u.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 u.rename(t,a),f()}n.value={state:"idle"}}const k=async e=>{const t=await u.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=p.value)==null?void 0:a.find(d=>d.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=p.value)==null?void 0:e.map(a=>{var r,d;return{key:a.id,cells:[{type:"link",text:a.name,to:(r=`/organizations/${encodeURIComponent(a.id)}`)!=null?r:null},{type:"text",text:(d=a.id)!=null?d:null},{type:"actions",actions:[{icon:D,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(L,null,{navbar:s(()=>[o(j,{breadcrumb:m})]),content:s(()=>[o(E,{"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:c,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(),F(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":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):B("",!0)]),_:1},8,["open"])],64))}});export{ze as default};
//# sourceMappingURL=Organizations.be4bcc42.js.map
