import{d as _,ey as I,r as N,F as x,b,et as F,f as o,w as s,u as l,bo as h,c as R,bF as A,ev as B}from"./outputWidgets.b703ca45.js";import{e as D,u as M,F as $}from"./icons.5202cd65.js";import{a as V}from"./asyncComputed.557fdbc3.js";import"./router.c2e4e322.js";import"./jwt-decode.esm.74bd4619.js";import"./index.58a6f7ec.js";import{O as d}from"./organization.a1bd0b97.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.a39b7838.js";import{C as E}from"./CrudView.93e41830.js";import{B as L}from"./BaseLayout.43d7cddc.js";import{a as U}from"./ant-design.db871477.js";import{A as G}from"./FormItem.39e0b98f.js";import{F as P}from"./Form.44bc3190.js";import{M as S}from"./Modal.c03e4b0a.js";import"./storage.4f0beb94.js";import"./index.cd3799ce.js";import"./index.cf4c23b9.js";import"./record.6a34e5b4.js";import"./pubsub.781c61cb.js";import"./logo.084e5d7c.js";import"./Text.4646803d.js";import"./index.f858e58b.js";import"./Title.c76d824d.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.69b7b47b.js";import"./url.7a748c18.js";import"./index.5255b475.js";import"./index.dfe99d95.js";import"./hasIn.66135dec.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]="2d868b26-2998-4821-95df-a4aab986926f",i._sentryDebugIdIdentifier="sentry-dbid-2d868b26-2998-4821-95df-a4aab986926f")}catch{}})();const ze=_({__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}=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 U("Are you sure you want to delete this organization?")&&(await((r=(t=c.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=c.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(),F(h,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:p,onCreate:k},null,8,["loading","table"])]),_:1}),o(l(S),{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(),R(l(P),{key:0,layout:"vertical"},{default:s(()=>[o(l(G),{label:"New name"},{default:s(()=>[o(l(A),{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.27f991c1.js.map
