import{N}from"./Navbar.27bba2c6.js";import{B as O}from"./BaseLayout.5967af9f.js";import{C as _}from"./ContentLayout.8a64aff0.js";import{C as x}from"./CrudView.08af3b90.js";import{a as R}from"./ant-design.468f41c3.js";import{a as D}from"./asyncComputed.a619212b.js";import{F}from"./PhArrowSquareOut.vue.03d709e6.js";import{G as M}from"./PhPencil.vue.6be3e07b.js";import{d as h,eJ as B,r as A,I as $,b,ev as G,f as o,w as i,u as l,aD as V,eR as j,c as E,by as L,ex as U}from"./outputWidgets.be3472c2.js";import"./router.87bf43b6.js";import"./index.86288308.js";import{O as d}from"./organization.4839103b.js";import{A as J,F as P}from"./Form.254a7379.js";import{M as S}from"./Modal.304207b8.js";import"./logo.084e5d7c.js";import"./PhSignOut.vue.ca4a6d5d.js";import"./Text.c9febe27.js";import"./index.ec79aad2.js";import"./index.7cde6902.js";import"./BookOutlined.53049b66.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.f9aebc41.js";import"./url.7fe1be7b.js";import"./Paragraph.7601abde.js";import"./index.ba676107.js";import"./Title.65752aa0.js";import"./index.6773e8c7.js";import"./index.f70acf7e.js";import"./popupNotifcation.9025cc7b.js";import"./record.820df198.js";import"./pubsub.1063a0da.js";import"./hasIn.bddd0a1a.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},m=new Error().stack;m&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[m]="2afac80c-19c2-4c2d-af8f-545f127e80d3",r._sentryDebugIdIdentifier="sentry-dbid-2afac80c-19c2-4c2d-af8f-545f127e80d3")}catch{}})();const ke=h({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],c=[{key:"name",label:"Organization Name"}],v=B(),{loading:z,result:p,refetch:f}=D(()=>d.list()),g=({key:e})=>{v.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 R("Are you sure you want to delete this organization?")&&(await((s=(a=p.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:s.delete()),f())},I=$(()=>{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 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:F,label:"Go to projects",onClick:g},{icon:M,label:"Rename",onClick:()=>w(a)},{icon:j,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),G(V,null,[o(O,null,{navbar:i(()=>[o(N,{breadcrumb:m})]),content:i(()=>[o(_,null,{default:i(()=>[o(x,{"entity-name":"organization",loading:l(z),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:I.value,fields:c,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(l(S),{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(),E(l(P),{key:0,layout:"vertical"},{default:i(()=>[o(l(J),{label:"New name"},{default:i(()=>[o(l(L),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):U("",!0)]),_:1},8,["open"])],64))}});export{ke as default};
//# sourceMappingURL=Organizations.d20dc4a4.js.map
