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,eP as R,c as h,bx as B,ew as D}from"./outputWidgets.8f35e76b.js";import{a as A}from"./asyncComputed.b2c7682e.js";import"./router.eb6cf81e.js";import"./index.fb4a4209.js";import{O as p}from"./organization.5fe5bb3c.js";import{N as $}from"./Navbar.c17d3c02.js";import{C as G}from"./CrudView.4b14d77c.js";import{B as V}from"./BaseLayout.78fcf56e.js";import{a as j}from"./ant-design.5e6d66d7.js";import{F as E}from"./PhArrowSquareOut.vue.eae4d0a1.js";import{G as P}from"./PhPencil.vue.a25e7075.js";import{A as U,F as H}from"./Form.357810f8.js";import{M as L}from"./Modal.3cec70ce.js";import"./popupNotifcation.20f659d9.js";import"./index.cf4c23b9.js";import"./record.56272af3.js";import"./pubsub.aac2ae7d.js";import"./logo.084e5d7c.js";import"./PhSignOut.vue.2543e2c9.js";import"./Text.cb1b4ad4.js";import"./index.31b873d2.js";import"./index.11f588c6.js";import"./BookOutlined.b79ac83a.js";import"./Paragraph.5b35e944.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.7378a41f.js";import"./url.99f1e379.js";import"./index.30032ec4.js";import"./Title.984d5105.js";import"./index.1d88a799.js";import"./index.01563854.js";import"./hasIn.38270313.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]="37128439-313f-4b7a-9dc9-835c1607a22c",i._sentryDebugIdIdentifier="sentry-dbid-37128439-313f-4b7a-9dc9-835c1607a22c")}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:t,newName:a}=n.value;await p.rename(t,a),f()}n.value={state:"idle"}}const C=async e=>{const t=await p.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:P,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:d,onCreate:C},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(),h(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{Ce as default};
//# sourceMappingURL=Organizations.d6ab9892.js.map
