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.83ad65aa.js";import{e as F,H as M,K as $}from"./icons.ec92f7f9.js";import{a as V}from"./asyncComputed.eebec89e.js";import"./router.1b8539af.js";import"./index.9f577453.js";import{O as c}from"./organization.84b53f22.js";import{_ as j}from"./Navbar.vue_vue_type_script_setup_true_lang.613af5f6.js";import{C as E}from"./CrudView.fb55c5f4.js";import{B as H}from"./BaseLayout.5a1484a1.js";import{a as L}from"./ant-design.a75cbb2f.js";import{A as U,F as G}from"./Form.5deb3adb.js";import{M as K}from"./Modal.00c72438.js";import"./index.cf4c23b9.js";import"./record.df4e3ae7.js";import"./pubsub.6c6cbc8d.js";import"./logo.084e5d7c.js";import"./Text.72dc1978.js";import"./Base.5de97c83.js";import"./Typography.fea800b8.js";import"./index.b1fc61d4.js";import"./ArrowRightOutlined.08fa31dd.js";import"./Paragraph.eee68d2f.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.d125b27a.js";import"./url.27ce9387.js";import"./index.677f843d.js";import"./Title.50be6d8b.js";import"./index.06a93781.js";import"./index.dbec653f.js";import"./hasIn.597d0078.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]="985ff6c5-fcc0-4105-bec3-4203d7267ef5",i._sentryDebugIdIdentifier="sentry-dbid-985ff6c5-fcc0-4105-bec3-4203d7267ef5")}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:f}=V(()=>c.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:t,newName:a}=n.value;await c.rename(t,a),f()}n.value={state:"idle"}}const k=async e=>{const t=await c.create(e.name);g({key:t.id})},C=async({key:e})=>{var a,r;await L("Are you sure you want to delete this organization?")&&(await((r=(a=p.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:r.delete()),f())},O=x(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=p.value)==null?void 0:e.map(a=>{var r,u;return{key:a.id,cells:[{type:"link",text:a.name,to:(r=`/organizations/${encodeURIComponent(a.id)}`)!=null?r:null},{type:"text",text:(u=a.id)!=null?u:null},{type:"actions",actions:[{icon:F,label:"Go to projects",onClick:g},{icon:M,label:"Rename",onClick:()=>w(a)},{icon:$,label:"Delete",onClick:C,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(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:d,onCreate:k},null,8,["loading","table"])]),_:1}),o(l(K),{open:n.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=a=>y(!1)),onOk:t[2]||(t[2]=a=>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":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):D("",!0)]),_:1},8,["open"])],64))}});export{ve as default};
//# sourceMappingURL=Organizations.b0dedb4b.js.map
