"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9736],{73117:(B,h,s)=>{s.r(h),s.d(h,{default:()=>z});var e=s(74848),x=s(96540),u=s(5805),d=s(28082),m=s(54594),g=s(54122),i=s(11817),y=s(61351),j=s(61491),A=s(22803),o=s(70255),O=s(65164),C=s(29675),N=s(71815),D=s(87638);const v=()=>(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{children:(0,e.jsx)(i.x6,{i18nKey:"admin.orgs.id-header",children:"ID"})}),(0,e.jsx)("th",{children:(0,e.jsx)(i.x6,{i18nKey:"admin.orgs.name-header",children:"Name"})}),(0,e.jsx)("th",{style:{width:"1%"}})]})});function b({orgs:t,onDelete:n}){const r=D.TP.hasPermission(j.AccessControlAction.OrgsDelete),[a,c]=(0,x.useState)(),K=a?.name;return(0,e.jsxs)("table",{className:"filter-table form-inline filter-table--hover",children:[v(),(0,e.jsx)("tbody",{children:t.map(l=>(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{className:"link-td",children:(0,e.jsx)("a",{href:`admin/orgs/edit/${l.id}`,children:l.id})}),(0,e.jsx)("td",{className:"link-td",children:(0,e.jsx)("a",{href:`admin/orgs/edit/${l.id}`,children:l.name})}),(0,e.jsx)("td",{className:"text-right",children:(0,e.jsx)(m.$n,{variant:"destructive",size:"sm",icon:"times",onClick:()=>c(l),"aria-label":"Delete org",disabled:!r})})]},`${l.id}-${l.name}`))}),a&&(0,e.jsx)(O.u,{isOpen:!0,icon:"trash-alt",title:"Delete",body:(0,e.jsx)("div",{children:(0,e.jsxs)(i.x6,{i18nKey:"admin.orgs.delete-body",children:["Are you sure you want to delete '",{deleteOrgName:K},"'?",(0,e.jsx)("br",{})," ",(0,e.jsx)("small",{children:"All dashboards for this organization will be removed!"})]})}),confirmText:"Delete",onDismiss:()=>c(void 0),onConfirm:()=>{n(a.id),c(void 0)}})]})}const T=({rootProps:t})=>{const n=(0,C.of)(P);return(0,e.jsxs)("table",{className:"filter-table",...t,children:[v(),(0,e.jsx)("tbody",{children:new Array(3).fill(null).map((r,a)=>(0,e.jsxs)("tr",{children:[(0,e.jsx)("td",{children:(0,e.jsx)(o.A,{width:16})}),(0,e.jsx)("td",{children:(0,e.jsx)(o.A,{width:240})}),(0,e.jsx)("td",{children:(0,e.jsx)(o.A,{containerClassName:n.deleteButton,width:22,height:24})})]},a))})]})},f=(0,N.j)(b,T),P=t=>({deleteButton:(0,A.css)({alignItems:"center",display:"flex",height:30,lineHeight:1})}),S=async t=>await(0,d.AI)().delete("/api/orgs/"+t),I=async()=>await(0,d.AI)().get("/api/orgs"),$=t=>(0,d.NF)(t)?t?.data?.message:"An unexpected error happened.";function z(){const[t,n]=(0,u.default)(async()=>await I(),[]),r=y.TP.hasPermission(j.AccessControlAction.OrgsCreate);return(0,x.useEffect)(()=>{n()},[n]),(0,e.jsx)(g.Y,{navId:"global-orgs",actions:(0,e.jsx)(m.z9,{icon:"plus",href:"org/new",disabled:!r,children:(0,e.jsx)(i.x6,{i18nKey:"admin.orgs.new-org-button",children:"New org"})}),children:(0,e.jsxs)(g.Y.Contents,{children:[t.error&&$(t.error),t.loading&&(0,e.jsx)(f.Skeleton,{}),t.value&&(0,e.jsx)(f,{orgs:t.value,onDelete:a=>{S(a).then(()=>n())}})]})})}}}]);

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