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.260a3c99.js";import{a as A}from"./asyncComputed.61df0e0c.js";import"./router.c6bba0da.js";import"./index.16d63baf.js";import{O as d}from"./organization.208a3090.js";import{N as $}from"./Navbar.4fa4c2c7.js";import{C as G}from"./CrudView.9c881ed3.js";import{B as V}from"./BaseLayout.30d191dc.js";import{a as j}from"./ant-design.16592543.js";import{F as E}from"./PhArrowSquareOut.vue.fc3fa822.js";import{G as U}from"./PhPencil.vue.78f87dc9.js";import{A as H,F as L}from"./Form.46e378f9.js";import{M as P}from"./Modal.6a26a016.js";import"./popupNotifcation.87bdba7f.js";import"./index.cf4c23b9.js";import"./record.608c7c8c.js";import"./pubsub.ab27f2c0.js";import"./logo.084e5d7c.js";import"./PhSignOut.vue.7cf286a2.js";import"./Text.3b774738.js";import"./index.b2703a93.js";import"./index.26a046c1.js";import"./BookOutlined.9a33e452.js";import"./Paragraph.482f5128.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.e08dd3ee.js";import"./url.13938513.js";import"./index.34fd2dd9.js";import"./Title.9673e08a.js";import"./index.a74fba23.js";import"./index.30985d18.js";import"./hasIn.8ab3cbf4.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]="d187facd-1bec-425f-90c2-361f89e54242",i._sentryDebugIdIdentifier="sentry-dbid-d187facd-1bec-425f-90c2-361f89e54242")}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.275dad43.js.map
