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

//# sourceMappingURL=AdminListOrgsPage.f01c8496fd635e20124b.js.map