"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3798],{"./public/app/features/admin/AdminListOrgsPage.tsx":(e,s,a)=>{a.r(s),a.d(s,{AdminListOrgsPages:()=>p,default:()=>f});var n,t,r,i,l=a("./node_modules/react/index.js"),d=a("./public/app/core/selectors/navModel.ts"),o=a("./public/app/core/components/Page/Page.tsx"),c=a("./node_modules/react-redux/es/index.js"),h=a("./packages/grafana-ui/src/index.ts"),x=a("./packages/grafana-runtime/src/index.ts"),g=a("./node_modules/react/jsx-runtime.js");const u=({orgs:e,onDelete:s})=>{const[a,d]=(0,l.useState)();return(0,g.jsxs)("table",{className:"filter-table form-inline filter-table--hover",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[n||(n=(0,g.jsx)("th",{children:"ID"})),t||(t=(0,g.jsx)("th",{children:"Name"})),(0,g.jsx)("th",{style:{width:"1%"}})]})}),(0,g.jsx)("tbody",{children:e.map((e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{className:"link-td",children:(0,g.jsx)("a",{href:`admin/orgs/edit/${e.id}`,children:e.id})}),(0,g.jsx)("td",{className:"link-td",children:(0,g.jsx)("a",{href:`admin/orgs/edit/${e.id}`,children:e.name})}),(0,g.jsx)("td",{className:"text-right",children:(0,g.jsx)(h.Button,{variant:"destructive",size:"sm",icon:"times",onClick:()=>d(e),"aria-label":"Delete org"})})]},`${e.id}-${e.name}`)))}),a&&(0,g.jsx)(h.ConfirmModal,{isOpen:!0,icon:"trash-alt",title:"Delete",body:(0,g.jsxs)("div",{children:["Are you sure you want to delete '",a.name,"'?",r||(r=(0,g.jsx)("br",{}))," ",i||(i=(0,g.jsx)("small",{children:"All dashboards for this organization will be removed!"}))]}),confirmText:"Delete",onDismiss:()=>d(void 0),onConfirm:()=>{s(a.id),d(void 0)}})]})};var m,j=a("./node_modules/react-use/lib/useAsyncFn.js");const p=()=>{const e=(0,c.useSelector)((e=>e.navIndex)),s=(0,d.h)(e,"global-orgs"),[a,n]=(0,j.default)((async()=>await(async()=>await(0,x.getBackendSrv)().get("/api/orgs"))()),[]);return(0,l.useEffect)((()=>{n()}),[n]),(0,g.jsx)(o.Z,{navModel:s,children:(0,g.jsx)(o.Z.Contents,{children:(0,g.jsxs)(g.Fragment,{children:[m||(m=(0,g.jsxs)("div",{className:"page-action-bar",children:[(0,g.jsx)("div",{className:"page-action-bar__spacer"}),(0,g.jsx)(h.LinkButton,{icon:"plus",href:"org/new",children:"New org"})]})),a.loading&&"Fetching organizations",a.error,a.value&&(0,g.jsx)(u,{orgs:a.value,onDelete:e=>{(async e=>await(0,x.getBackendSrv)().delete("/api/orgs/"+e))(e).then((()=>n()))}})]})})})},f=p}}]);
//# sourceMappingURL=AdminListOrgsPage.8128b05ac04b15cbf98d.js.map