"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7497,8039],{2667:(re,L,a)=>{a.r(L),a.d(L,{default:()=>_});var e=a(9892),t=a(66111),D=a(68183),N=a(35645),M=a(66121),U=a(79841),f=a(72648),d=a(72142),h=a(82002),p=a(8412),T=a(27876),R=a(71221),x=a(68082),B=a(61860),W=a(39904),y=a(52081),C=a(34719),S=a(10655),I=a(35029),o=a(61744),v=a(5191),g=a(31403),P=a(80882);const F=D.wl.pages.UserListPage.UsersListPublicDashboardsPage.DashboardsListModal,H=({email:n,onDismiss:c})=>{const r=(0,f.wW)(Y),{data:V,isLoading:u}=(0,S.Bl)(n);return t.createElement(I.u,{className:r.modal,isOpen:!0,title:"Public dashboards",onDismiss:c},u?t.createElement("div",{className:r.loading},t.createElement(o.u,{text:"Loading..."})):V?.map(m=>t.createElement("div",{key:m.dashboardUid,className:r.listItem,"data-testid":F.listItem(m.dashboardUid)},t.createElement("p",{className:r.dashboardTitle},m.dashboardTitle),t.createElement("div",{className:r.urlsContainer},t.createElement("a",{rel:"noreferrer",target:"_blank",className:(0,e.cx)("external-link",r.url),href:(0,P._M)(m.publicDashboardAccessToken),onClick:c},"Public dashboard URL"),t.createElement("span",{className:r.urlsDivider},"\u2022"),t.createElement("a",{className:(0,e.cx)("external-link",r.url),href:(0,P.Ez)(m.dashboardUid),onClick:c},"Public dashboard settings")),t.createElement("hr",{className:r.divider}))))},J=({email:n})=>t.createElement(v.JY,null,({showModal:c,hideModal:r})=>t.createElement(g.zx,{variant:"secondary",size:"sm",icon:"question-circle",title:"Open dashboards list","aria-label":"Open dashboards list",onClick:()=>c(H,{email:n,onDismiss:r})})),Y=n=>({modal:e.css`
    width: 590px;
  `,loading:e.css`
    display: flex;
    justify-content: center;
  `,listItem:e.css`
    display: flex;
    flex-direction: column;
    gap: ${n.spacing(.5)};
  `,divider:e.css`
    margin: ${n.spacing(1.5,0)};
    color: ${n.colors.text.secondary};
  `,urlsContainer:e.css`
    display: flex;
    gap: ${n.spacing(.5)};

    ${n.breakpoints.down("sm")} {
      flex-direction: column;
    }
  `,urlsDivider:e.css`
    color: ${n.colors.text.secondary};
    ${n.breakpoints.down("sm")} {
      display: none;
    }
  `,dashboardTitle:e.css`
    font-size: ${n.typography.body.fontSize};
    font-weight: ${n.typography.fontWeightBold};
    margin-bottom: 0;
  `,url:e.css`
    font-size: ${n.typography.body.fontSize};
  `}),X=({user:n,onDismiss:c})=>{const r=(0,f.wW)(w);return t.createElement(I.u,{className:r.modal,isOpen:!0,title:"Delete",onDismiss:c},t.createElement("p",{className:r.description},"The user ",n.email," is currently present in ",n.totalDashboards," public dashboard(s). If you wish to remove this user, please navigate to the settings of the corresponding public dashboard."),t.createElement(I.u.ButtonRow,null,t.createElement(g.zx,{type:"button",variant:"secondary",onClick:c,fill:"outline"},"Close")))},Q=({user:n})=>t.createElement(v.JY,null,({showModal:c,hideModal:r})=>t.createElement(g.zx,{size:"sm",variant:"destructive",onClick:()=>c(X,{user:n,onDismiss:r}),icon:"times","aria-label":"Delete user",title:"Delete user"})),w=n=>({modal:e.css`
    width: 500px;
  `,description:e.css`
    font-size: ${n.typography.body.fontSize};
    margin: 0;
  `}),b=D.wl.pages.UserListPage.publicDashboards,O=()=>{const{data:n,isLoading:c}=(0,S.jI)();return t.createElement(p.T.Contents,{isLoading:c},t.createElement("table",{className:"filter-table form-inline","data-testid":b.container},t.createElement("thead",null,t.createElement("tr",null,t.createElement("th",null,"Email"),t.createElement("th",null,t.createElement("span",null,"Activated "),t.createElement(B.u,{placement:"top",content:"Earliest time user has been an active user to a dashboard"},t.createElement(W.J,{name:"question-circle"}))),t.createElement("th",null,"Origin"),t.createElement("th",null,"Role"),t.createElement("th",null))),t.createElement("tbody",null,n?.map(r=>t.createElement("tr",{key:r.email},t.createElement("td",{className:"max-width-10"},t.createElement("span",{className:"ellipsis",title:r.email},r.email)),t.createElement("td",{className:"max-width-10"},r.firstSeenAtAge),t.createElement("td",{className:"max-width-10"},t.createElement(y.Lh,{spacing:"sm"},t.createElement("span",null,r.totalDashboards," dashboard(s)"),t.createElement(J,{email:r.email}))),t.createElement("td",{className:"max-width-10"},t.createElement(C.V,{name:"Viewer",colorIndex:19})),t.createElement("td",{className:"text-right"},t.createElement(Q,{user:r})))))))};var k=(n=>(n.ADMIN="admin",n.ORG="org",n.PUBLIC_DASHBOARDS="public-dashboards",n))(k||{});const $=D.wl.pages.UserListPage,j=({view:n,setView:c})=>t.createElement(U.O,{label:"Public dashboard users",active:n==="public-dashboards",onChangeTab:()=>c("public-dashboards"),"data-testid":$.tabs.publicDashboardsUsers}),q={admin:t.createElement(x.As,null),org:t.createElement(R.UsersListPageContent,null),["public-dashboards"]:t.createElement(O,null)};function _(){const n=(0,f.wW)(ee),c=h.Vt.hasAccess(T.AccessControlAction.UsersRead,h.Vt.isGrafanaAdmin),r=h.Vt.hasPermission(T.AccessControlAction.OrgUsersRead),V=Boolean(N.v.featureToggles.publicDashboards)&&Boolean(N.v.featureToggles.publicDashboardsEmailSharing)&&(0,M.v)("publicDashboardsEmailSharing"),[u,m]=(0,t.useState)(()=>c?"admin":r?"org":null),te=r&&c;return t.createElement(p.T,{navId:"global-users"},te?t.createElement(d.J,{className:n.tabsMargin},t.createElement(U.O,{label:"All users",active:u==="admin",onChangeTab:()=>m("admin"),"data-testid":$.tabs.allUsers}),t.createElement(U.O,{label:"Organization users",active:u==="org",onChangeTab:()=>m("org"),"data-testid":$.tabs.orgUsers}),V&&t.createElement(j,{view:u,setView:m})):V&&t.createElement(d.J,{className:n.tabsMargin},t.createElement(U.O,{label:"Users",active:u==="org",onChangeTab:()=>m("org"),"data-testid":$.tabs.users}),t.createElement(j,{view:u,setView:m})),u?q[u]:t.createElement(R.UsersListPageContent,null))}const ee=n=>({tabsMargin:(0,e.css)({marginBottom:n.spacing(3)})})},71221:(re,L,a)=>{a.r(L),a.d(L,{UsersListPageContent:()=>ce,UsersListPageUnconnected:()=>oe,default:()=>he});var e=a(66111),t=a(67948),D=a(2631),N=a(68183),M=a(52081),U=a(78889),f=a(8412),d=a(77582),h=a(94599),p=a(31403),T=a(90336);const R={revokeInvite:T.GY},x=(0,t.connect)(null,R);class B extends e.PureComponent{render(){const{invitee:l,revokeInvite:i}=this.props;return e.createElement("tr",null,e.createElement("td",null,l.email),e.createElement("td",null,l.name),e.createElement("td",{className:"text-right"},e.createElement(h.m,{icon:"copy",variant:"secondary",size:"sm",getText:()=>l.url},"Copy Invite"),"\xA0"),e.createElement("td",null,e.createElement(p.zx,{variant:"destructive",size:"sm",icon:"times",onClick:()=>i(l.code),"aria-label":"Revoke Invite"})))}}const W=x(B);class y extends e.PureComponent{render(){const{invitees:l}=this.props;return e.createElement("table",{className:"filter-table form-inline"},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Email"),e.createElement("th",null,"Name"),e.createElement("th",null),e.createElement("th",{style:{width:"34px"}}))),e.createElement("tbody",{"data-testid":"InviteesTable-body"},l.map((i,A)=>e.createElement(W,{key:`${i.id}-${A}`,invitee:i}))))}}var C=a(90158),S=a(75804);const{selectAll:I,selectById:o,selectTotal:v}=S.wl,g=(s,l)=>l,P=(0,C.P1)([I,g],(s,l)=>{const i=new RegExp(l,"i");return s.filter(E=>i.test(E.name)||i.test(E.email))});var F=a(14747),H=a(2594),J=a(47694),Y=a(27876),X=a(82897),Q=a(54899),w=a(95156),b=a(12142);function O(){return async(s,l)=>{try{const{perPage:i,page:A,searchQuery:E}=l().users,z=await(0,Q.i)().get("/api/org/users/search",(0,w.y)({perpage:i,page:A,query:E}));s((0,b.eT)(z))}catch{(0,b.k7)()}}}const k=(0,X.debounce)(s=>s(O()),300);function $(s){return async l=>{await(0,Q.i)().patch(`/api/org/users/${s.userId}`,{role:s.role}),l(O())}}function j(s){return async l=>{await(0,Q.i)().delete(`/api/org/users/${s}`),l(O())}}function q(s){return async l=>{l((0,b.tZ)()),l((0,b.PJ)(s)),l(O())}}function _(s){return async l=>{l((0,b.tZ)()),l((0,b.w4)(s)),k(l)}}const ee=s=>{const l=new RegExp(s.searchQuery,"i");return s.users.filter(i=>l.test(i.login)||l.test(i.email)||l.test(i.name))},n=s=>s.searchQuery;function c(s){return{searchQuery:n(s.users),pendingInvitesCount:v(s.invites),externalUserMngLinkName:s.users.externalUserMngLinkName,externalUserMngLinkUrl:s.users.externalUserMngLinkUrl,canInvite:s.users.canInvite}}const r={changeSearchQuery:_},m=(0,t.connect)(c,r)(({canInvite:s,externalUserMngLinkName:l,externalUserMngLinkUrl:i,searchQuery:A,pendingInvitesCount:E,changeSearchQuery:z,onShowInvites:G,showInvites:Z})=>{const ae=[{label:"Users",value:"users"},{label:`Pending Invites (${E})`,value:"invites"}],se=d.Vt.hasAccess(Y.AccessControlAction.OrgUsersAdd,s)&&!(J.ZP.disableLoginForm&&J.ZP.externalUserMngInfo);return e.createElement("div",{className:"page-action-bar","data-testid":"users-action-bar"},e.createElement("div",{className:"gf-form gf-form--grow"},e.createElement(F.H,{value:A,onChange:z,placeholder:"Search user by login, email or name"})),E>0&&e.createElement("div",{style:{marginLeft:"1rem"}},e.createElement(H.S,{value:Z?"invites":"users",options:ae,onChange:G})),se&&e.createElement(p.Qj,{href:"org/users/invite"},"Invite"),i&&e.createElement(p.Qj,{href:i,target:"_blank",rel:"noopener"},l))});var te=a(68903);function de(s){const l=n(s.users);return{users:ee(s.users),searchQuery:n(s.users),page:s.users.page,totalPages:s.users.totalPages,perPage:s.users.perPage,invitees:P(s.invites,l),externalUserMngInfo:s.users.externalUserMngInfo,isLoading:s.users.isLoading}}const ge={loadUsers:O,fetchInvitees:T.nW,changePage:q,updateUser:$,removeUser:j},ue=(0,t.connect)(de,ge),Ee=N.wl.pages.UserListPage.UsersListPage,oe=({users:s,page:l,totalPages:i,invitees:A,externalUserMngInfo:E,isLoading:z,loadUsers:G,fetchInvitees:Z,changePage:ae,updateUser:ie,removeUser:se})=>{const[ne,ve]=(0,e.useState)(!1),me=E?(0,D.a)(E):"";(0,e.useEffect)(()=>{G(),Z()},[Z,G]);const Pe=(K,le)=>{ie({...le,role:K})},Ue=()=>{ve(!ne)},fe=()=>ne?e.createElement(y,{invitees:A}):e.createElement(M.wc,{spacing:"md","data-testid":Ee.container},e.createElement(te.P,{users:s,orgId:d.Vt.user.orgId,onRoleChange:(K,le)=>Pe(K,le),onRemoveUser:K=>se(K.userId)}),e.createElement(M.Lh,{justify:"flex-end"},e.createElement(U.t,{onNavigate:ae,currentPage:l,numberOfPages:i,hideWhenSinglePage:!0})));return e.createElement(f.T.Contents,{isLoading:!z},e.createElement(m,{onShowInvites:Ue,showInvites:ne}),me&&e.createElement("div",{className:"grafana-info-box",dangerouslySetInnerHTML:{__html:me}}),z&&fe())},ce=ue(oe);function he(){return e.createElement(f.T,{navId:"users"},e.createElement(ce,null))}},68903:(re,L,a)=>{a.d(L,{P:()=>T});var e=a(66111),t=a(31403),D=a(98102),N=a(66226),M=a(11630),U=a(21731),f=a(47694),d=a(77582),h=a(27876),p=a(65135);const T=({users:R,orgId:x,onRoleChange:B,onRemoveUser:W})=>{const[y,C]=(0,e.useState)(null),[S,I]=(0,e.useState)([]);return(0,e.useEffect)(()=>{async function o(){try{if(d.Vt.hasPermission(h.AccessControlAction.ActionRolesList)){let v=await(0,M.ul)(x);I(v)}}catch{console.error("Error loading options")}}d.Vt.licensedAccessControlEnabled()&&o()},[x]),e.createElement(e.Fragment,null,e.createElement("table",{className:"filter-table form-inline"},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null),e.createElement("th",null,"Login"),e.createElement("th",null,"Email"),e.createElement("th",null,"Name"),e.createElement("th",null,"Seen"),e.createElement("th",null,"Role"),e.createElement("th",{style:{width:"34px"}}),e.createElement("th",null,"Origin"),e.createElement("th",null))),e.createElement("tbody",null,R.map((o,v)=>{let g=!d.Vt.hasPermissionInMetadata(h.AccessControlAction.OrgUsersWrite,o);return f.ZP.featureToggles.onlyExternalOrgRoleSync&&(g=o?.isExternallySynced||g),e.createElement("tr",{key:`${o.userId}-${v}`},e.createElement("td",{className:"width-2 text-center"},e.createElement("img",{className:"filter-table__avatar",src:o.avatarUrl,alt:"User avatar"})),e.createElement("td",{className:"max-width-6"},e.createElement("span",{className:"ellipsis",title:o.login},o.login)),e.createElement("td",{className:"max-width-5"},e.createElement("span",{className:"ellipsis",title:o.email},o.email)),e.createElement("td",{className:"max-width-5"},e.createElement("span",{className:"ellipsis",title:o.name},o.name)),e.createElement("td",{className:"width-1"},o.lastSeenAtAge),e.createElement("td",{className:"width-8"},d.Vt.licensedAccessControlEnabled()?e.createElement(N.R,{userId:o.userId,orgId:x,roleOptions:S,basicRole:o.role,onBasicRoleChange:P=>B(P,o),basicRoleDisabled:g}):e.createElement(p.A,{"aria-label":"Role",value:o.role,disabled:g,onChange:P=>B(P,o)})),e.createElement("td",{className:"width-1 text-center"},o.isDisabled&&e.createElement("span",{className:"label label-tag label-tag--gray"},"Disabled")),e.createElement("td",{className:"width-1"},Array.isArray(o.authLabels)&&o.authLabels.length>0&&e.createElement(U.e,{label:o.authLabels[0],removeIcon:!1,count:0})),d.Vt.hasPermissionInMetadata(h.AccessControlAction.OrgUsersRemove,o)&&e.createElement("td",{className:"text-right"},e.createElement(t.zx,{size:"sm",variant:"destructive",onClick:()=>{C(o)},icon:"times","aria-label":"Delete user"})))}))),Boolean(y)&&e.createElement(D.s,{body:`Are you sure you want to delete user ${y?.login}?`,confirmText:"Delete",title:"Delete",onDismiss:()=>{C(null)},isOpen:!0,onConfirm:()=>{y&&(W(y),C(null))}}))}}}]);

//# sourceMappingURL=UserListPage.29b67c23ebf0ac75467f.js.map