import{N as O}from"./Navbar.f03e6034.js";import{B as I}from"./BaseLayout.0633c69d.js";import{C as _}from"./ContentLayout.cab4f09c.js";import{C as x}from"./CrudView.b6646971.js";import{a as F}from"./ant-design.c2710ff5.js";import{a as M}from"./asyncComputed.a7fc1aad.js";import{F as R}from"./PhArrowSquareOut.vue.f84527d3.js";import{G as h}from"./PhPencil.vue.2e2de584.js";import{d as B,f7 as D,r as A,y as V,b,eV as $,f as o,w as i,u as l,ay as G,fd as j,c as E,bx as L,eX as U}from"./outputWidgets.b408cd47.js";import"./gateway.5649747e.js";import"./index.a96bb8d2.js";import{O as d}from"./organization.433b3f56.js";import{A as P,F as S}from"./Form.30ca3c8c.js";import{M as T}from"./Modal.7c3fbdf2.js";import"./logo.084e5d7c.js";import"./PhChats.vue.1210ea9e.js";import"./PhSignOut.vue.0c854838.js";import"./router.49371dd0.js";import"./index.294c8e67.js";import"./index.1b5ac821.js";import"./BookOutlined.9049fb63.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.21e15a66.js";import"./url.266b2c44.js";import"./index.c368a61e.js";import"./index.37f20755.js";import"./popupNotifcation.e99572f9.js";import"./record.7a308bd3.js";import"./pubsub.e8c4900b.js";import"./string.3b3d0b2e.js";import"./hasIn.dda5a20c.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]="eef688d1-7b21-41dc-8ef4-892921f3faf0",r._sentryDebugIdIdentifier="sentry-dbid-eef688d1-7b21-41dc-8ef4-892921f3faf0")}catch{}})();const Ce=B({__name:"Organizations",setup(r){const m=[{label:"My organizations",path:"/organizations"}],p=[{key:"name",label:"Organization Name"}],v=D(),{loading:z,result:f,refetch:c}=M(()=>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),c()}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 F("Are you sure you want to delete this organization?")&&(await((s=(a=f.value)==null?void 0:a.find(u=>u.id===e))==null?void 0:s.delete()),c())},N=V(()=>{var e,t;return{columns:[{name:"Organization Name",align:"left"},{name:"Path"},{name:"",align:"right"}],rows:(t=(e=f.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:R,label:"Go to projects",onClick:g},{icon:h,label:"Rename",onClick:()=>w(a)},{icon:j,label:"Delete",onClick:k,dangerous:!0}]}]}}))!=null?t:[]}});return(e,t)=>(b(),$(G,null,[o(I,null,{navbar:i(()=>[o(O,{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:N.value,fields:p,onCreate:C},null,8,["loading","table"])]),_:1})]),_:1}),o(l(T),{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(S),{key:0,layout:"vertical"},{default:i(()=>[o(l(P),{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{Ce as default};
//# sourceMappingURL=Organizations.5eea1caa.js.map
