"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3798],{21539:(D,o,a)=>{a.r(o),a.d(o,{default:()=>C});var e=a(65237),u=a(89353),s=a(55041),m=a(48389),d=a(38992),E=a(96237),g=a(3315),v=a(22324),h=a(63969);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.17ff3fa0b0f434c070c7.js.map