"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9736],{55026(z,h,t){t.r(h),t.d(h,{default:()=>$});var e=t(14553),m=t(55501),y=t(5805),n=t(92745),r=t(68143),x=t(45861),g=t(13791),j=t(15130),f=t(11257),O=t(22803),o=t(70255),A=t(71599),b=t(63142),C=t(21348);const v=()=>(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{children:(0,e.jsx)(n.x6,{i18nKey:"admin.orgs.id-header",children:"ID"})}),(0,e.jsx)("th",{children:(0,e.jsx)(n.x6,{i18nKey:"admin.orgs.name-header",children:"Name"})}),(0,e.jsx)("th",{style:{width:"1%"}})]})});function N({orgs:s,onDelete:a}){const i=j.TP.hasPermission(f.w.OrgsDelete),[l,c]=(0,m.useState)(),K=l?.name;return(0,e.jsxs)("table",{className:"filter-table form-inline filter-table--hover",children:[v(),(0,e.jsx)("tbody",{children:s.map(d=>(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{className:"link-td",children:(0,e.jsx)("a",{href:`admin/orgs/edit/${d.id}`,children:d.id})}),(0,e.jsx)("td",{className:"link-td",children:(0,e.jsx)("a",{href:`admin/orgs/edit/${d.id}`,children:d.name})}),(0,e.jsx)("td",{className:"text-right",children:(0,e.jsx)(x.$n,{variant:"destructive",size:"sm",icon:"times",onClick:()=>c(d),"aria-label":(0,n.t)("admin.admin-orgs-table.aria-label-delete-org","Delete org"),disabled:!i})})]},`${d.id}-${d.name}`))}),l&&(0,e.jsx)(A.u,{isOpen:!0,title:(0,n.t)("admin.admin-orgs-table.title-delete","Delete"),body:(0,e.jsx)("div",{children:(0,e.jsxs)(n.x6,{i18nKey:"admin.orgs.delete-body",children:["Are you sure you want to delete '",{deleteOrgName:K},"'?",(0,e.jsx)("br",{})," ",(0,e.jsx)("small",{children:"All dashboards for this organization will be removed!"})]})}),confirmText:(0,n.t)("admin.admin-orgs-table.confirmText-delete","Delete"),onDismiss:()=>c(void 0),onConfirm:()=>{a(l.id),c(void 0)}})]})}const D=({rootProps:s})=>{const a=(0,b.of)(T);return(0,e.jsxs)("table",{className:"filter-table",...s,children:[v(),(0,e.jsx)("tbody",{children:new Array(3).fill(null).map((i,l)=>(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{children:(0,e.jsx)(o.A,{width:16})}),(0,e.jsx)("td",{children:(0,e.jsx)(o.A,{width:240})}),(0,e.jsx)("td",{children:(0,e.jsx)(o.A,{containerClassName:a.deleteButton,width:22,height:24})})]},l))})]})},u=(0,C.j)(N,D),T=s=>({deleteButton:(0,O.css)({alignItems:"center",display:"flex",height:30,lineHeight:1})}),P=async s=>await(0,r.AI)().delete("/api/orgs/"+s),S=async()=>await(0,r.AI)().get("/api/orgs"),I=s=>(0,r.NF)(s)?s?.data?.message:"An unexpected error happened.";function $(){const[s,a]=(0,y.default)(async()=>await S(),[]),i=j.TP.hasPermission(f.w.OrgsCreate);return(0,m.useEffect)(()=>{a()},[a]),(0,e.jsx)(g.Y,{navId:"global-orgs",actions:(0,e.jsx)(x.z9,{icon:"plus",href:"org/new",disabled:!i,children:(0,e.jsx)(n.x6,{i18nKey:"admin.orgs.new-org-button",children:"New org"})}),children:(0,e.jsxs)(g.Y.Contents,{children:[s.error&&I(s.error),s.loading&&(0,e.jsx)(u.Skeleton,{}),s.value&&(0,e.jsx)(u,{orgs:s.value,onDelete:l=>{P(l).then(()=>a())}})]})})}}}]);

//# sourceMappingURL=AdminListOrgsPage-react19.793ebae5b56d93f0f3b1.js.map