"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3798],{27738:(D,o,a)=>{a.r(o),a.d(o,{default:()=>C});var e=a(39953),u=a(95681),s=a(4148),m=a(4919),d=a(13253),E=a(97125),g=a(57721),v=a(32840),h=a(21308);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.contextSrv.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.2e496cc4f55e6b21b209.js.map