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.b2f2adf2.js";import{a as A}from"./asyncComputed.0eb432f7.js";import"./router.778927b3.js";import"./index.914bcef3.js";import{O as p}from"./organization.273160a5.js";import{N as $}from"./Navbar.c9f376f8.js";import{C as G}from"./CrudView.5c233833.js";import{B as V}from"./BaseLayout.c9230dd9.js";import{a as j}from"./ant-design.c95e6c48.js";import{F as E}from"./PhArrowSquareOut.vue.c0b575b0.js";import{G as U}from"./PhPencil.vue.04f8aa4c.js";import{A as H,F as L}from"./Form.151a806c.js";import{M as P}from"./Modal.29dbfea8.js";import"./popupNotifcation.45645a97.js";import"./index.cf4c23b9.js";import"./record.01220836.js";import"./pubsub.56b36b75.js";import"./logo.084e5d7c.js";import"./PhSignOut.vue.2ace8ff5.js";import"./Text.9554a64b.js";import"./index.14c519b5.js";import"./index.f265c294.js";import"./BookOutlined.312749b0.js";import"./Paragraph.038d3c4a.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.204f99fb.js";import"./url.de379c40.js";import"./index.c47b0dc1.js";import"./Title.d1ce9cd1.js";import"./index.0f294ac7.js";import"./index.239ed389.js";import"./hasIn.2f264b73.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]="3df944e2-908a-4930-ae97-3c37af847b45",i._sentryDebugIdIdentifier="sentry-dbid-3df944e2-908a-4930-ae97-3c37af847b45")}catch{}})();const Ce=N({__name:"Organizations",setup(i){const l=[{label:"My organizations",path:"/organizations"}],d=[{key:"name",label:"Organization Name"}],v=O(),{loading:w,result:c,refetch:f}=A(()=>p.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:a,newName:t}=n.value;await p.rename(a,t),f()}n.value={state:"idle"}}const C=async e=>{const a=await p.create(e.name);g({key:a.id})},k=async({key:e})=>{var t,r;await j("Are you sure you want to delete this organization?")&&(await((r=(t=c.value)==null?void 0:t.find(u=>u.id===e))==null?void 0:r.delete()),f())},I=x(()=>{var e,a;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(a=(e=c.value)==null?void 0:e.map(t=>{var r,u;return{key:t.id,cells:[{type:"link",text:t.name,to:(r=`/organizations/${encodeURIComponent(t.id)}`)!=null?r:null},{type:"text",text:(u=t.id)!=null?u:null},{type:"actions",actions:[{icon:E,label:"Go to projects",onClick:g},{icon:U,label:"Rename",onClick:()=>z(t)},{icon:R,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?a:[]}});return(e,a)=>(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:d,onCreate:C},null,8,["loading","table"])]),_:1}),o(m(P),{open:n.value.state==="renaming",title:"Rename organization",onCancel:a[1]||(a[1]=t=>y(!1)),onOk:a[2]||(a[2]=t=>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":a[0]||(a[0]=t=>n.value.newName=t)},null,8,["value"])]),_:1})]),_:1})):D("",!0)]),_:1},8,["open"])],64))}});export{Ce as default};
//# sourceMappingURL=Organizations.47956e23.js.map
