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 D,bO as R,ex as B}from"./outputWidgets.6830fc2d.js";import{e as F,q as M,D as $}from"./icons.31e4fa46.js";import{a as V}from"./asyncComputed.46a733c1.js";import"./router.c745a3c2.js";import"./index.fddb9e1e.js";import{O as d}from"./organization.fc8c0ca6.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.0ccb2e11.js";import{C as E}from"./CrudView.432fe0c4.js";import{B as L}from"./BaseLayout.950bd7b6.js";import{a as U}from"./ant-design.f8e1bed1.js";import{A as q}from"./FormItem.278e4518.js";import{F as G}from"./Form.a8618886.js";import{M as H}from"./Modal.e109cdd2.js";import"./index.cf4c23b9.js";import"./record.416df660.js";import"./pubsub.6d4f7540.js";import"./logo.084e5d7c.js";import"./Text.b2a17f23.js";import"./Base.e8ab0cc0.js";import"./index.5ed48f82.js";import"./Paragraph.c22304c7.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.6b319732.js";import"./url.1f48e231.js";import"./index.a26dbe33.js";import"./Title.10b04a9c.js";import"./index.ec7fc193.js";import"./index.e51935e8.js";import"./hasIn.48daad41.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]="524d85a3-4310-418c-a643-8b61c18a9bed",i._sentryDebugIdIdentifier="sentry-dbid-524d85a3-4310-418c-a643-8b61c18a9bed")}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:g}=V(()=>d.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 y(e){if(n.value.state==="renaming"&&e){const{organizationId:a,newName:t}=n.value;await d.rename(a,t),g()}n.value={state:"idle"}}const k=async e=>{const a=await d.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)=>(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(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(),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{ze as default};
//# sourceMappingURL=Organizations.47819cbd.js.map
