import{d as O,eA as I,r as N,H as x,b,eu as h,f as o,w as s,u as m,aC as A,eP as F,c as R,by as B,ew as D}from"./outputWidgets.f017b1ba.js";import{a as M}from"./asyncComputed.9ec0ae7d.js";import"./router.bd5e0bcd.js";import"./index.2d300106.js";import{O as u}from"./organization.b2f4c184.js";import{_ as $}from"./Navbar.vue_vue_type_script_setup_true_lang.e9e404c0.js";import{C as G}from"./CrudView.ab7e0ba9.js";import{B as V}from"./BaseLayout.1ae649d7.js";import{a as j}from"./ant-design.f8dd6064.js";import{F as E}from"./PhArrowSquareOut.vue.962eba4e.js";import{G as P}from"./PhPencil.vue.5c3890c6.js";import{A as U,F as H}from"./Form.c4ae4d63.js";import{M as L}from"./Modal.334f8812.js";import"./popupNotifcation.d47f45e7.js";import"./index.cf4c23b9.js";import"./record.e2bcfa5f.js";import"./pubsub.4d72db7b.js";import"./logo.084e5d7c.js";import"./Text.01ac3fdf.js";import"./Base.bb2b5283.js";import"./Typography.5dfc411f.js";import"./index.0750564d.js";import"./ArrowRightOutlined.08fa31dd.js";import"./Paragraph.3ffb559e.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.377064a4.js";import"./url.42b30a4e.js";import"./index.5cbbe314.js";import"./Title.4002b692.js";import"./index.b5d890a4.js";import"./index.11845c93.js";import"./hasIn.a2b4c2f9.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[l]="c27380ed-b469-42f1-bec3-94d0f45a8d7d",i._sentryDebugIdIdentifier="sentry-dbid-c27380ed-b469-42f1-bec3-94d0f45a8d7d")}catch{}})();const ke=O({__name:"Organizations",setup(i){const l=[{label:"My organizations",path:"/organizations"}],c=[{key:"name",label:"Organization Name"}],w=I(),{loading:z,result:p,refetch:f}=M(()=>u.list()),g=({key:e})=>{w.push({name:"organization",params:{organizationId:e}})},n=N({state:"idle"});function v(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 u.rename(t,a),f()}n.value={state:"idle"}}const k=async e=>{const t=await u.create(e.name);g({key:t.id})},C=async({key:e})=>{var a,r;await j("Are you sure you want to delete this organization?")&&(await((r=(a=p.value)==null?void 0:a.find(d=>d.id===e))==null?void 0:r.delete()),f())},_=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,d;return{key:a.id,cells:[{type:"link",text:a.name,to:(r=`/organizations/${encodeURIComponent(a.id)}`)!=null?r:null},{type:"text",text:(d=a.id)!=null?d:null},{type:"actions",actions:[{icon:E,label:"Go to projects",onClick:g},{icon:P,label:"Rename",onClick:()=>v(a)},{icon:F,label:"Delete",onClick:C,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),h(A,null,[o(V,null,{navbar:s(()=>[o($,{breadcrumb:l})]),content:s(()=>[o(G,{"entity-name":"organization",loading:m(z),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:_.value,fields:c,onCreate:k},null,8,["loading","table"])]),_:1}),o(m(L),{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(m(H),{key:0,layout:"vertical"},{default:s(()=>[o(m(U),{label:"New name"},{default:s(()=>[o(m(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{ke as default};
//# sourceMappingURL=Organizations.7972773f.js.map
