"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8580],{61663:(e,s,a)=>{a.r(s),a.d(s,{addExtraFilters:()=>q,default:()=>W});var i,l,n,t,r,c,d,o,h,m,g,u,x=a(77813),j=a(76687),p=a(30415),f=a(27668),b=a(3357),N=a(81377),v=a(55312),w=a(33097),A=a(39756),L=a(3526),y=a(28781),$=a(63984),k=a(31271),P=a(58601),E=a(352),R=a(81047),C=a(52010);const F=[],q=e=>{F.push(e)},I={fetchUsers:R.uh,changeQuery:R.R5,changePage:R.oO,changeFilter:R.M6},J=(0,p.connect)((e=>({users:e.userListAdmin.users,query:e.userListAdmin.query,showPaging:e.userListAdmin.showPaging,totalPages:e.userListAdmin.totalPages,page:e.userListAdmin.page,filters:e.userListAdmin.filters,isLoading:e.userListAdmin.isLoading})),I),S=e=>`Edit user's ${e} details`,T=(0,j.memo)((e=>{var s;let{user:a,showLicensedRole:i}=e;const l=(0,f.wW)(D),n=`admin/users/edit/${a.id}`;return(0,C.jsxs)("tr",{children:[(0,C.jsx)("td",{className:"width-4 text-center link-td",children:(0,C.jsx)("a",{href:n,"aria-label":`Edit user's ${a.name} details`,children:(0,C.jsx)("img",{className:"filter-table__avatar",src:a.avatarUrl,alt:`Avatar for user ${a.name}`})})}),(0,C.jsx)("td",{className:"link-td max-width-10",children:(0,C.jsx)("a",{className:"ellipsis",href:n,title:a.login,"aria-label":S(a.name),children:a.login})}),(0,C.jsx)("td",{className:"link-td max-width-10",children:(0,C.jsx)("a",{className:"ellipsis",href:n,title:a.email,"aria-label":S(a.name),children:a.email})}),(0,C.jsx)("td",{className:"link-td max-width-10",children:(0,C.jsx)("a",{className:"ellipsis",href:n,title:a.name,"aria-label":S(a.name),children:a.name})}),(0,C.jsxs)("td",{className:l.row,title:null!==(s=a.orgs)&&void 0!==s&&s.length?`The user is a member of the following organizations: ${a.orgs.map((e=>e.name)).join(",")}`:void 0,children:[(0,C.jsx)(U,{units:a.orgs,icon:"building"}),a.isAdmin&&(0,C.jsx)("a",{href:n,"aria-label":S(a.name),children:m||(m=(0,C.jsx)(w.u,{placement:"top",content:"Grafana Admin",children:(0,C.jsx)(A.J,{name:"shield"})}))})]}),i&&(0,C.jsx)("td",{className:(0,x.cx)("link-td",l.iconRow),children:(0,C.jsx)("a",{className:"ellipsis",href:n,title:a.name,"aria-label":S(a.name),children:"None"===a.licensedRole?(0,C.jsxs)("span",{className:l.disabled,children:["Not assigned"," ",g||(g=(0,C.jsx)(w.u,{placement:"top",content:"A licensed role will be assigned when this user signs in",children:(0,C.jsx)(A.J,{name:"question-circle"})}))]}):a.licensedRole})}),(0,C.jsx)("td",{className:"link-td",children:a.lastSeenAtAge&&(0,C.jsx)("a",{href:n,"aria-label":`Last seen at ${a.lastSeenAtAge}. Follow to edit user's ${a.name} details.`,children:"10 years"===a.lastSeenAtAge?(0,C.jsx)("span",{className:l.disabled,children:"Never"}):a.lastSeenAtAge})}),(0,C.jsx)("td",{className:"text-right",children:Array.isArray(a.authLabels)&&a.authLabels.length>0&&(0,C.jsx)($.e,{label:a.authLabels[0],removeIcon:!1,count:0})}),(0,C.jsx)("td",{className:"text-right",children:a.isDisabled&&(u||(u=(0,C.jsx)("span",{className:"label label-tag label-tag--gray",children:"Disabled"})))})]},a.id)}));T.displayName="UserListItem";const U=e=>{let{units:s,icon:a}=e;const i=(0,f.wW)(D);return null!=s&&s.length?s.length>1?(0,C.jsx)(w.u,{placement:"top",content:(0,C.jsx)("div",{className:i.unitTooltip,children:null==s?void 0:s.map((e=>(0,C.jsx)("a",{href:e.url,className:i.link,title:e.name,"aria-label":`Edit ${e.name}`,children:e.name},e.name)))}),children:(0,C.jsxs)("div",{className:i.unitItem,children:[(0,C.jsx)(A.J,{name:a})," ",(0,C.jsx)("span",{children:s.length})]})}):(0,C.jsxs)("a",{href:s[0].url,className:i.unitItem,title:s[0].name,"aria-label":`Edit ${s[0].name}`,children:[(0,C.jsx)(A.J,{name:a})," ",s[0].name]},s[0].name):null},D=e=>({table:x.css`
      margin-top: ${e.spacing(3)};
    `,filter:x.css`
      margin: 0 ${e.spacing(1)};
    `,iconRow:x.css`
      svg {
        margin-left: ${e.spacing(.5)};
      }
    `,row:x.css`
      display: flex;
      align-items: center;
      height: 100% !important;

      a {
        padding: ${e.spacing(.5)} 0 !important;
      }
    `,unitTooltip:x.css`
      display: flex;
      flex-direction: column;
    `,unitItem:x.css`
      cursor: pointer;
      padding: ${e.spacing(.5)} 0;
      margin-right: ${e.spacing(1)};
    `,disabled:x.css`
      color: ${e.colors.text.disabled};
    `,link:x.css`
      color: inherit;
      cursor: pointer;
      text-decoration: underline;
    `}),W=J((e=>{var s;let{fetchUsers:a,query:m,changeQuery:g,users:u,showPaging:p,totalPages:$,page:R,changePage:q,changeFilter:I,filters:J,isLoading:S}=e;const U=(0,f.wW)(D);(0,j.useEffect)((()=>{a()}),[a]);const W=(0,j.useMemo)((()=>u.some((e=>e.licensedRole))),[u]);return(0,C.jsx)(y.T,{navId:"global-users",children:(0,C.jsxs)(y.T.Contents,{children:[(0,C.jsxs)("div",{className:"page-action-bar",children:[(0,C.jsxs)("div",{className:"gf-form gf-form--grow",children:[(0,C.jsx)(b.H,{placeholder:"Search user by login, email, or name.",autoFocus:!0,value:m,onChange:g}),(0,C.jsx)(N.S,{options:[{label:"All users",value:!1},{label:"Active last 30 days",value:!0}],onChange:e=>I({name:"activeLast30Days",value:e}),value:null===(s=J.find((e=>"activeLast30Days"===e.name)))||void 0===s?void 0:s.value,className:U.filter}),F.map(((e,s)=>(0,C.jsx)(e,{filters:J,onChange:I,className:U.filter},s)))]}),k.Vt.hasPermission(E.bW.UsersCreate)&&(i||(i=(0,C.jsx)(v.Qj,{href:"admin/users/create",variant:"primary",children:"New user"})))]}),S?l||(l=(0,C.jsx)(P.Z,{})):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("div",{className:(0,x.cx)(U.table,"admin-list-table"),children:(0,C.jsxs)("table",{className:"filter-table form-inline filter-table--hover",children:[(0,C.jsx)("thead",{children:(0,C.jsxs)("tr",{children:[n||(n=(0,C.jsx)("th",{})),t||(t=(0,C.jsx)("th",{children:"Login"})),r||(r=(0,C.jsx)("th",{children:"Email"})),c||(c=(0,C.jsx)("th",{children:"Name"})),d||(d=(0,C.jsx)("th",{children:"Belongs to"})),W&&(0,C.jsxs)("th",{children:["Licensed role"," ",(0,C.jsx)(w.u,{placement:"top",content:(0,C.jsxs)(C.Fragment,{children:["Licensed role is based on a user's Org role (i.e. Viewer, Editor, Admin) and their dashboard/folder permissions."," ",(0,C.jsx)("a",{className:U.link,target:"_blank",rel:"noreferrer noopener",href:"https://grafana.com/docs/grafana/next/enterprise/license/license-restrictions/#active-users-limit",children:"Learn more"})]}),children:o||(o=(0,C.jsx)(A.J,{name:"question-circle"}))})]}),h||(h=(0,C.jsxs)("th",{children:["Last active ",(0,C.jsx)(w.u,{placement:"top",content:"Time since user was seen using Grafana",children:(0,C.jsx)(A.J,{name:"question-circle"})})]})),(0,C.jsx)("th",{style:{width:"1%"}})]})}),(0,C.jsx)("tbody",{children:u.map((e=>(0,C.jsx)(T,{user:e,showLicensedRole:W},e.id)))})]})}),p&&(0,C.jsx)(L.t,{numberOfPages:$,currentPage:R,onNavigate:q})]})]})})}))}}]);
//# sourceMappingURL=UserListAdminPage.71dde740a8d12ebd9180.js.map