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 R,bO as B,ex as D}from"./outputWidgets.0a8e4948.js";import{e as F,H as M,K as $}from"./icons.b13f0b09.js";import{a as V}from"./asyncComputed.059a4705.js";import"./router.a730a2c1.js";import"./index.fea4a6f4.js";import{O as u}from"./organization.9a1833bb.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.a9fd617c.js";import{C as E}from"./CrudView.d727886c.js";import{B as H}from"./BaseLayout.41f796b7.js";import{a as L}from"./ant-design.efb76e31.js";import{A as U,F as G}from"./Form.c559c050.js";import{M as K}from"./Modal.7e08920e.js";import"./index.cf4c23b9.js";import"./record.68d70ea4.js";import"./pubsub.dcb12b9f.js";import"./logo.084e5d7c.js";import"./Text.ec9c769b.js";import"./Base.dda5d58b.js";import"./Typography.fd999a5c.js";import"./index.3a967032.js";import"./ArrowRightOutlined.08fa31dd.js";import"./Paragraph.b4aaf7da.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.db2454e0.js";import"./url.5c05e609.js";import"./index.2673874d.js";import"./Title.ca8d43a3.js";import"./index.e5d762a8.js";import"./index.ab9ed469.js";import"./hasIn.8bcc6abb.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]="014aeedd-e4db-4aa9-a7df-a64ad02b1b2d",i._sentryDebugIdIdentifier="sentry-dbid-014aeedd-e4db-4aa9-a7df-a64ad02b1b2d")}catch{}})();const ve=_({__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(()=>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:a,newName:t}=n.value;await u.rename(a,t),f()}n.value={state:"idle"}}const k=async e=>{const a=await u.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=c.value)==null?void 0:t.find(d=>d.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,d;return{key:t.id,cells:[{type:"link",text:t.name,to:(r=`/organizations/${encodeURIComponent(t.id)}`)!=null?r:null},{type:"text",text:(d=t.id)!=null?d:null},{type:"actions",actions:[{icon:F,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(H,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(K),{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(G),{key:0,layout:"vertical"},{default:s(()=>[o(l(U),{label:"New name"},{default:s(()=>[o(l(B),{value:n.value.newName,"onUpdate:value":a[0]||(a[0]=t=>n.value.newName=t)},null,8,["value"])]),_:1})]),_:1})):D("",!0)]),_:1},8,["open"])],64))}});export{ve as default};
//# sourceMappingURL=Organizations.7658a089.js.map
