"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3798],{40174:(D,o,a)=>{a.r(o),a.d(o,{default:()=>C});var e=a(27702),u=a(58281),s=a(73289),m=a(66670),d=a(44644),E=a(91368),g=a(18771),v=a(3613),h=a(66574);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.9902734b79fa599d102f.js.map