import{d as O,eA as I,r as N,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,by as A,ew as B}from"./outputWidgets.225dd371.js";import{a as D}from"./asyncComputed.8a54909a.js";import"./router.8e23138d.js";import"./index.2924e62a.js";import{O as d}from"./organization.b100921a.js";import{_ as $}from"./Navbar.vue_vue_type_script_setup_true_lang.5ad8ef82.js";import{C as G}from"./CrudView.72bd6d5e.js";import{B as V}from"./BaseLayout.97c9eb13.js";import{a as j}from"./ant-design.a00feaec.js";import{F as E}from"./PhArrowSquareOut.vue.32437cf7.js";import{G as P}from"./PhPencil.vue.bd1d8b41.js";import{A as U,F as H}from"./Form.12e2d16e.js";import{M as L}from"./Modal.0a797886.js";import"./popupNotifcation.6873325b.js";import"./index.cf4c23b9.js";import"./record.b805ac15.js";import"./pubsub.3bce7ea8.js";import"./logo.084e5d7c.js";import"./Text.a0f2d781.js";import"./index.b8149c32.js";import"./index.36801c80.js";import"./Paragraph.253f2b2e.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.c28d2d29.js";import"./url.29c1f37b.js";import"./index.8e2737d3.js";import"./Title.bbb77099.js";import"./index.42c8bfb7.js";import"./index.86c302fc.js";import"./hasIn.1e38e049.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]="43338496-d91d-4618-9450-7224618617ad",i._sentryDebugIdIdentifier="sentry-dbid-43338496-d91d-4618-9450-7224618617ad")}catch{}})();const ze=O({__name:"Organizations",setup(i){const l=[{label:"My organizations",path:"/organizations"}],p=[{key:"name",label:"Organization Name"}],w=I(),{loading:z,result:c,refetch:f}=D(()=>d.list()),g=({key:e})=>{w.push({name:"organization",params:{organizationId:e}})},n=N({state:"idle"});function v(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())},_=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:()=>v(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(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:_.value,fields:p,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(A),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):B("",!0)]),_:1},8,["open"])],64))}});export{ze as default};
//# sourceMappingURL=Organizations.918dea05.js.map
