import{N as O}from"./Navbar.10564cb7.js";import{B as I}from"./BaseLayout.6e2aa643.js";import{C as _}from"./ContentLayout.150390bd.js";import{C as x}from"./CrudView.88823d06.js";import{a as F}from"./ant-design.f246aa2b.js";import{a as M}from"./asyncComputed.06ede41f.js";import{F as R}from"./PhArrowSquareOut.vue.b51cdf06.js";import{G as h}from"./PhPencil.vue.09a8c9d5.js";import{d as B,eK as D,r as A,J as $,b,ew as E,f as o,w as i,u as m,aE as G,eS as V,c as j,bz as L,ey as S}from"./outputWidgets.6e1c5425.js";import"./router.4a0ba06b.js";import"./index.76daa7f6.js";import{O as d}from"./organization.87dbdb1d.js";import{A as U,F as J}from"./Form.b82a2cec.js";import{M as K}from"./Modal.e50e9e9a.js";import"./logo.084e5d7c.js";import"./PhSignOut.vue.8b6374ae.js";import"./Text.b10c1140.js";import"./Base.0277cf44.js";import"./index.2d522974.js";import"./index.8f97a60b.js";import"./BookOutlined.8202b78f.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.3a6e05dd.js";import"./url.5357e9db.js";import"./Paragraph.4ce326b3.js";import"./index.c12e1c2f.js";import"./Title.dfd37452.js";import"./index.1442882a.js";import"./index.1a6a6e78.js";import"./popupNotifcation.76f4dd63.js";import"./record.c7d63161.js";import"./pubsub.4f3043c8.js";import"./hasIn.bf07751b.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[l]="211090ab-6737-4279-a773-dc992da84867",r._sentryDebugIdIdentifier="sentry-dbid-211090ab-6737-4279-a773-dc992da84867")}catch{}})();const Ne=B({__name:"Organizations",setup(r){const l=[{label:"My organizations",path:"/organizations"}],p=[{key:"name",label:"Organization Name"}],z=D(),{loading:v,result:c,refetch:f}=M(()=>d.list()),g=({key:e})=>{z.push({name:"organization",params:{organizationId:e}})},n=A({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 d.rename(t,a),f()}n.value={state:"idle"}}const C=async e=>{const t=await d.create(e.name);g({key:t.id})},k=async({key:e})=>{var a,s;await F("Are you sure you want to delete this organization?")&&(await((s=(a=c.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:s.delete()),f())},N=$(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=c.value)==null?void 0:e.map(a=>{var s,u;return{key:a.id,cells:[{type:"link",text:a.name,to:(s=`/organizations/${encodeURIComponent(a.id)}`)!=null?s:null},{type:"text",text:(u=a.id)!=null?u:null},{type:"actions",actions:[{icon:R,label:"Go to projects",onClick:g},{icon:h,label:"Rename",onClick:()=>w(a)},{icon:V,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),E(G,null,[o(I,null,{navbar:i(()=>[o(O,{breadcrumb:l})]),content:i(()=>[o(_,null,{default:i(()=>[o(x,{"entity-name":"organization",loading:m(v),title:"My organizations",description:"An organization is your company\u2019s account. Manage editors, projects and billing.","create-button-text":"Create Organization","empty-title":"No organizations here yet",table:N.value,fields:p,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(m(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:i(()=>[n.value.state==="renaming"?(b(),j(m(J),{key:0,layout:"vertical"},{default:i(()=>[o(m(U),{label:"New name"},{default:i(()=>[o(m(L),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):S("",!0)]),_:1},8,["open"])],64))}});export{Ne as default};
//# sourceMappingURL=Organizations.11dcdec6.js.map
