"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3798],{67768:(e,s,a)=>{a.r(s),a.d(s,{default:()=>v});var i,r,n,t,l,d=a(76687),o=a(66315),c=a(5205),h=a(55312),x=a(28781),j=a(69369),g=a(352),m=a(97867),u=a(31271),f=a(52010);function b(e){let{orgs:s,onDelete:a}=e;const l=u.Vt.hasPermission(g.bW.OrgsDelete),[o,c]=(0,d.useState)();return(0,f.jsxs)("table",{className:"filter-table form-inline filter-table--hover",children:[(0,f.jsx)("thead",{children:(0,f.jsxs)("tr",{children:[i||(i=(0,f.jsx)("th",{children:"ID"})),r||(r=(0,f.jsx)("th",{children:"Name"})),(0,f.jsx)("th",{style:{width:"1%"}})]})}),(0,f.jsx)("tbody",{children:s.map((e=>(0,f.jsxs)("tr",{children:[(0,f.jsx)("td",{className:"link-td",children:(0,f.jsx)("a",{href:`admin/orgs/edit/${e.id}`,children:e.id})}),(0,f.jsx)("td",{className:"link-td",children:(0,f.jsx)("a",{href:`admin/orgs/edit/${e.id}`,children:e.name})}),(0,f.jsx)("td",{className:"text-right",children:(0,f.jsx)(h.zx,{variant:"destructive",size:"sm",icon:"times",onClick:()=>c(e),"aria-label":"Delete org",disabled:!l})})]},`${e.id}-${e.name}`)))}),o&&(0,f.jsx)(m.s,{isOpen:!0,icon:"trash-alt",title:"Delete",body:(0,f.jsxs)("div",{children:["Are you sure you want to delete '",o.name,"'?",n||(n=(0,f.jsx)("br",{}))," ",t||(t=(0,f.jsx)("small",{children:"All dashboards for this organization will be removed!"}))]}),confirmText:"Delete",onDismiss:()=>c(void 0),onConfirm:()=>{a(o.id),c(void 0)}})]})}function v(){const[e,s]=(0,o.default)((async()=>await(async()=>await(0,c.i)().get("/api/orgs"))()),[]),a=j.Vt.hasPermission(g.bW.OrgsCreate);return(0,d.useEffect)((()=>{s()}),[s]),(0,f.jsx)(x.T,{navId:"global-orgs",children:(0,f.jsx)(x.T.Contents,{children:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("div",{className:"page-action-bar",children:[l||(l=(0,f.jsx)("div",{className:"page-action-bar__spacer"})),(0,f.jsx)(h.Qj,{icon:"plus",href:"org/new",disabled:!a,children:"New org"})]}),e.error&&(i=e.error,(null==i||null===(r=i.data)||void 0===r?void 0:r.message)||"An unexpected error happened."),e.loading&&"Fetching organizations",e.value&&(0,f.jsx)(b,{orgs:e.value,onDelete:e=>{(async e=>await(0,c.i)().delete("/api/orgs/"+e))(e).then((()=>s()))}})]})})});var i,r}}}]);
//# sourceMappingURL=AdminListOrgsPage.7a8b63e275633a85d007.js.map