"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3798],{"./public/app/features/admin/AdminListOrgsPage.tsx":(e,a,s)=>{s.r(a),s.d(a,{default:()=>f});var r,n,t,i,c=s("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),d=s("./public/app/core/selectors/navModel.ts"),l=s("./public/app/core/components/Page/Page.tsx"),o=s("./.yarn/__virtual__/react-redux-virtual-7ad20a440e/3/opt/drone/yarncache/react-redux-npm-7.2.6-134f5ed64d-0bf142ce0d.zip/node_modules/react-redux/es/index.js"),u=s("./packages/grafana-ui/src/index.ts"),p=s("./packages/grafana-runtime/src/index.ts"),h=s("./public/app/types/index.ts"),x=s("./public/app/core/core.ts"),m=s("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");function g(e){let{orgs:a,onDelete:s}=e;const d=x.Vt.hasPermission(h.bW.OrgsDelete),[l,o]=(0,c.useState)();return(0,m.jsxs)("table",{className:"filter-table form-inline filter-table--hover",children:[(0,m.jsx)("thead",{children:(0,m.jsxs)("tr",{children:[r||(r=(0,m.jsx)("th",{children:"ID"})),n||(n=(0,m.jsx)("th",{children:"Name"})),(0,m.jsx)("th",{style:{width:"1%"}})]})}),(0,m.jsx)("tbody",{children:a.map((e=>(0,m.jsxs)("tr",{children:[(0,m.jsx)("td",{className:"link-td",children:(0,m.jsx)("a",{href:`admin/orgs/edit/${e.id}`,children:e.id})}),(0,m.jsx)("td",{className:"link-td",children:(0,m.jsx)("a",{href:`admin/orgs/edit/${e.id}`,children:e.name})}),(0,m.jsx)("td",{className:"text-right",children:(0,m.jsx)(u.Button,{variant:"destructive",size:"sm",icon:"times",onClick:()=>o(e),"aria-label":"Delete org",disabled:!d})})]},`${e.id}-${e.name}`)))}),l&&(0,m.jsx)(u.ConfirmModal,{isOpen:!0,icon:"trash-alt",title:"Delete",body:(0,m.jsxs)("div",{children:["Are you sure you want to delete '",l.name,"'?",t||(t=(0,m.jsx)("br",{}))," ",i||(i=(0,m.jsx)("small",{children:"All dashboards for this organization will be removed!"}))]}),confirmText:"Delete",onDismiss:()=>o(void 0),onConfirm:()=>{s(l.id),o(void 0)}})]})}var b,j=s("./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/lib/useAsyncFn.js"),v=s("./public/app/core/services/context_srv.ts");function f(){const e=(0,o.useSelector)((e=>e.navIndex)),a=(0,d.h)(e,"global-orgs"),[s,r]=(0,j.default)((async()=>await(async()=>await(0,p.getBackendSrv)().get("/api/orgs"))()),[]),n=v.Vt.hasPermission(h.bW.OrgsCreate);return(0,c.useEffect)((()=>{r()}),[r]),(0,m.jsx)(l.Z,{navModel:a,children:(0,m.jsx)(l.Z.Contents,{children:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("div",{className:"page-action-bar",children:[b||(b=(0,m.jsx)("div",{className:"page-action-bar__spacer"})),(0,m.jsx)(u.LinkButton,{icon:"plus",href:"org/new",disabled:!n,children:"New org"})]}),s.error&&(t=s.error,(null==t||null===(i=t.data)||void 0===i?void 0:i.message)||"An unexpected error happened."),s.loading&&"Fetching organizations",s.value&&(0,m.jsx)(g,{orgs:s.value,onDelete:e=>{(async e=>await(0,p.getBackendSrv)().delete("/api/orgs/"+e))(e).then((()=>r()))}})]})})});var t,i}}}]);
//# sourceMappingURL=AdminListOrgsPage.cd4ada1146b53ad3284f.js.map