"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3798],{61608:(D,o,a)=>{a.r(o),a.d(o,{default:()=>C});var e=a(66111),u=a(55986),s=a(54899),m=a(31403),d=a(8412),E=a(82002),g=a(27876),v=a(98102),h=a(77582);function f({orgs:t,onDelete:l}){const c=h.Vt.hasPermission(g.AccessControlAction.OrgsDelete),[r,i]=(0,e.useState)();return e.createElement("table",{className:"filter-table form-inline filter-table--hover"},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"ID"),e.createElement("th",null,"Name"),e.createElement("th",{style:{width:"1%"}}))),e.createElement("tbody",null,t.map(n=>e.createElement("tr",{key:`${n.id}-${n.name}`},e.createElement("td",{className:"link-td"},e.createElement("a",{href:`admin/orgs/edit/${n.id}`},n.id)),e.createElement("td",{className:"link-td"},e.createElement("a",{href:`admin/orgs/edit/${n.id}`},n.name)),e.createElement("td",{className:"text-right"},e.createElement(m.zx,{variant:"destructive",size:"sm",icon:"times",onClick:()=>i(n),"aria-label":"Delete org",disabled:!c}))))),r&&e.createElement(v.s,{isOpen:!0,icon:"trash-alt",title:"Delete",body:e.createElement("div",null,"Are you sure you want to delete '",r.name,"'?",e.createElement("br",null)," ",e.createElement("small",null,"All dashboards for this organization will be removed!")),confirmText:"Delete",onDismiss:()=>i(void 0),onConfirm:()=>{l(r.id),i(void 0)}}))}const O=async t=>await(0,s.i)().delete("/api/orgs/"+t),y=async()=>await(0,s.i)().get("/api/orgs"),A=t=>(0,s.kW)(t)?t?.data?.message:"An unexpected error happened.";function C(){const[t,l]=(0,u.default)(async()=>await y(),[]),c=E.Vt.hasPermission(g.AccessControlAction.OrgsCreate);return(0,e.useEffect)(()=>{l()},[l]),e.createElement(d.T,{navId:"global-orgs"},e.createElement(d.T.Contents,null,e.createElement(e.Fragment,null,e.createElement("div",{className:"page-action-bar"},e.createElement("div",{className:"page-action-bar__spacer"}),e.createElement(m.Qj,{icon:"plus",href:"org/new",disabled:!c},"New org")),t.error&&A(t.error),t.loading&&"Fetching organizations",t.value&&e.createElement(f,{orgs:t.value,onDelete:r=>{O(r).then(()=>l())}}))))}}}]);

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