import{d as _,eA as I,r as N,H as x,b as y,ev as h,f as o,w as s,u as l,a$ as A,c as D,bO as R,ex as B}from"./outputWidgets.02d7c6ab.js";import{e as F,q as M,D as $}from"./icons.d148c279.js";import{a as V}from"./asyncComputed.6ba28f12.js";import"./router.1ffd6f3d.js";import"./index.91e5c23a.js";import{O as c}from"./organization.6d3db9f6.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.281bf392.js";import{C as E}from"./CrudView.9686d7bc.js";import{B as L}from"./BaseLayout.898ec023.js";import{a as U}from"./ant-design.cc523265.js";import{A as q}from"./FormItem.08e761e4.js";import{F as G}from"./Form.ad29b3fb.js";import{M as H}from"./Modal.04499883.js";import"./index.cf4c23b9.js";import"./record.4bf6e864.js";import"./pubsub.ee609699.js";import"./logo.084e5d7c.js";import"./Text.4830f6bb.js";import"./Base.a464e3b8.js";import"./Typography.9f15a3fb.js";import"./index.63b077a7.js";import"./Paragraph.fbd3cedb.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.754dc12b.js";import"./url.425ecd45.js";import"./index.3efceebc.js";import"./Title.5b74a8b2.js";import"./index.48b86b74.js";import"./index.dfc44b72.js";import"./hasIn.16bcfc34.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]="ebb2170e-6b5c-4a28-870c-ba5e53898a6a",i._sentryDebugIdIdentifier="sentry-dbid-ebb2170e-6b5c-4a28-870c-ba5e53898a6a")}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:g}=V(()=>c.list()),f=({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 b(e){if(n.value.state==="renaming"&&e){const{organizationId:a,newName:t}=n.value;await c.rename(a,t),g()}n.value={state:"idle"}}const k=async e=>{const a=await c.create(e.name);f({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()),g())},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:f},{icon:M,label:"Rename",onClick:()=>w(t)},{icon:$,label:"Delete",onClick:C,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(y(),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:d,onCreate:k},null,8,["loading","table"])]),_:1}),o(l(H),{open:n.value.state==="renaming",title:"Rename organization",onCancel:a[1]||(a[1]=t=>b(!1)),onOk:a[2]||(a[2]=t=>b(!0))},{default:s(()=>[n.value.state==="renaming"?(y(),D(l(G),{key:0,layout:"vertical"},{default:s(()=>[o(l(q),{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.fd8cc7b0.js.map
