"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3798],{87162:(z,i,t)=>{t.r(i),t.d(i,{default:()=>$});var e=t(85960),v=t(31622),o=t(85445),d=t(29165),g=t(20989),f=t(41879),E=t(95162),y=t(66681),c=t(34785),O=t(77980),A=t(47257),C=t(31560),D=t(49683);const u=()=>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 b({orgs:n,onDelete:l}){const r=D.Vt.hasPermission(E.AccessControlAction.OrgsDelete),[a,m]=(0,e.useState)();return e.createElement("table",{className:"filter-table form-inline filter-table--hover"},u(),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.zx,{variant:"destructive",size:"sm",icon:"times",onClick:()=>m(s),"aria-label":"Delete org",disabled:!r}))))),a&&e.createElement(O.s,{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 N=({rootProps:n})=>{const l=(0,A.wW)(T);return e.createElement("table",{className:"filter-table",...n},u(),e.createElement("tbody",null,new Array(3).fill(null).map((r,a)=>e.createElement("tr",{key:a},e.createElement("td",null,e.createElement(c.Z,{width:16})),e.createElement("td",null,e.createElement(c.Z,{width:240})),e.createElement("td",null,e.createElement(c.Z,{containerClassName:l.deleteButton,width:22,height:24}))))))},h=(0,C.y)(b,N),T=n=>({deleteButton:(0,y.css)({alignItems:"center",display:"flex",height:30,lineHeight:1})}),x=async n=>await(0,o.i)().delete("/api/orgs/"+n),S=async()=>await(0,o.i)().get("/api/orgs"),P=n=>(0,o.kW)(n)?n?.data?.message:"An unexpected error happened.";function $(){const[n,l]=(0,v.default)(async()=>await S(),[]),r=f.contextSrv.hasPermission(E.AccessControlAction.OrgsCreate);return(0,e.useEffect)(()=>{l()},[l]),e.createElement(g.T,{navId:"global-orgs",actions:e.createElement(d.Qj,{icon:"plus",href:"org/new",disabled:!r},"New org")},e.createElement(g.T.Contents,null,n.error&&P(n.error),n.loading&&e.createElement(h.Skeleton,null),n.value&&e.createElement(h,{orgs:n.value,onDelete:a=>{x(a).then(()=>l())}})))}}}]);

//# sourceMappingURL=AdminListOrgsPage.23a891a50104b88979f5.js.map