import{d as N,eI as O,r as _,H as x,b,eu as F,f as o,w as s,u as m,aC as M,eQ as R,c as h,bx as B,ew as D}from"./outputWidgets.cb8d4118.js";import{a as A}from"./asyncComputed.602f821b.js";import"./router.86733c93.js";import"./index.c95ca55f.js";import{O as d}from"./organization.caad8c8b.js";import{N as $}from"./Navbar.17aa51c9.js";import{C as G}from"./CrudView.e3bbbbbe.js";import{B as V}from"./BaseLayout.1ef107bc.js";import{a as j}from"./ant-design.8a1ce750.js";import{F as E}from"./PhArrowSquareOut.vue.0c60db01.js";import{G as U}from"./PhPencil.vue.1353d196.js";import{A as H,F as L}from"./Form.ecb5a9ca.js";import{M as P}from"./Modal.6ccabc4f.js";import"./popupNotifcation.901fafde.js";import"./index.cf4c23b9.js";import"./record.3c2cc598.js";import"./pubsub.6650fe4e.js";import"./logo.084e5d7c.js";import"./PhSignOut.vue.c3e3ed91.js";import"./Text.9ccde808.js";import"./index.ec60d2a0.js";import"./index.de02f809.js";import"./BookOutlined.8ba19dd1.js";import"./Paragraph.bf76481e.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.3ef122e0.js";import"./url.f415825b.js";import"./index.20961092.js";import"./Title.0c6e5569.js";import"./index.6c0be9cd.js";import"./index.8c7f6a56.js";import"./hasIn.9378fb46.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]="7116443d-f19b-4029-88f9-ea235bdb50e0",i._sentryDebugIdIdentifier="sentry-dbid-7116443d-f19b-4029-88f9-ea235bdb50e0")}catch{}})();const Ce=N({__name:"Organizations",setup(i){const l=[{label:"My organizations",path:"/organizations"}],p=[{key:"name",label:"Organization Name"}],v=O(),{loading:w,result:c,refetch:f}=A(()=>d.list()),g=({key:e})=>{v.push({name:"organization",params:{organizationId:e}})},n=_({state:"idle"});function z(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,r;await j("Are you sure you want to delete this organization?")&&(await((r=(a=c.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:r.delete()),f())},I=x(()=>{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 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:E,label:"Go to projects",onClick:g},{icon:U,label:"Rename",onClick:()=>z(a)},{icon:R,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),F(M,null,[o(V,null,{navbar:s(()=>[o($,{breadcrumb:l})]),content:s(()=>[o(G,{"entity-name":"organization",loading:m(w),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:p,onCreate:C},null,8,["loading","table"])]),_:1}),o(m(P),{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(),h(m(L),{key:0,layout:"vertical"},{default:s(()=>[o(m(H),{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{Ce as default};
//# sourceMappingURL=Organizations.aa454574.js.map
