import{d as _,eA as I,r as N,G as x,b,ev as h,f as o,w as s,u as l,bq as A,c as F,bH as R,ex as B}from"./outputWidgets.3c34606b.js";import{e as D,u as M,F as $}from"./icons.e6ec075a.js";import{a as V}from"./asyncComputed.8707f293.js";import"./router.56692652.js";import"./index.c3f2d302.js";import{O as d}from"./organization.8d89f32c.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.b6cbd5f9.js";import{C as E}from"./CrudView.7c2b0e6f.js";import{B as G}from"./BaseLayout.0cad2a63.js";import{a as L}from"./ant-design.8f4f3ad4.js";import{A as U}from"./FormItem.895a8678.js";import{F as q}from"./Form.d74c49d4.js";import{M as H}from"./Modal.10b1f4fc.js";import"./index.dd5bce3f.js";import"./index.cf4c23b9.js";import"./record.c46cf28f.js";import"./pubsub.28c1e0e3.js";import"./logo.084e5d7c.js";import"./Text.aa4a1cf1.js";import"./index.5da6d53a.js";import"./Title.f4855332.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.36eacc0b.js";import"./url.425cd9cb.js";import"./index.507e77a0.js";import"./index.5cd5e321.js";import"./hasIn.01f4de81.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]="dfe1b943-2495-4aae-ac8f-2d91252838e8",i._sentryDebugIdIdentifier="sentry-dbid-dfe1b943-2495-4aae-ac8f-2d91252838e8")}catch{}})();const ye=_({__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(()=>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:a,newName:t}=n.value;await d.rename(a,t),f()}n.value={state:"idle"}}const k=async e=>{const a=await d.create(e.name);g({key:a.id})},C=async({key:e})=>{var t,r;await L("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:D,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(G,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(H),{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(),F(l(q),{key:0,layout:"vertical"},{default:s(()=>[o(l(U),{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{ye as default};
//# sourceMappingURL=Organizations.981952e7.js.map
