"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8580],{61663:(e,s,a)=>{a.r(s),a.d(s,{addExtraFilters:()=>I,default:()=>C});var i,n,l,t,r,c,d,o,h,m,g,u,x=a(68490),j=a(76687),p=a(46958),f=a(70534),b=a(36131),v=a(63984),N=a(31271),L=a(58601),w=a(3276),A=a(99462),y=a(81047),$=a(52010);const k=[],I=e=>{k.push(e)},P={fetchUsers:y.uh,changeQuery:y.R5,changePage:y.oO,changeFilter:y.M6},R=(0,p.connect)((e=>({navModel:(0,w.h)(e.navIndex,"global-users"),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})),P),T=e=>`Edit user's ${e} details`,E=(0,j.memo)((e=>{var s;let{user:a,showLicensedRole:i}=e;const n=(0,f.useStyles2)(S),l=`admin/users/edit/${a.id}`;return(0,$.jsxs)("tr",{children:[(0,$.jsx)("td",{className:"width-4 text-center link-td",children:(0,$.jsx)("a",{href:l,"aria-label":`Edit user's ${a.name} details`,children:(0,$.jsx)("img",{className:"filter-table__avatar",src:a.avatarUrl,alt:`Avatar for user ${a.name}`})})}),(0,$.jsx)("td",{className:"link-td max-width-10",children:(0,$.jsx)("a",{className:"ellipsis",href:l,title:a.login,"aria-label":T(a.name),children:a.login})}),(0,$.jsx)("td",{className:"link-td max-width-10",children:(0,$.jsx)("a",{className:"ellipsis",href:l,title:a.email,"aria-label":T(a.name),children:a.email})}),(0,$.jsx)("td",{className:"link-td max-width-10",children:(0,$.jsx)("a",{className:"ellipsis",href:l,title:a.name,"aria-label":T(a.name),children:a.name})}),(0,$.jsxs)("td",{className:n.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,$.jsx)(F,{units:a.orgs,icon:"building"}),a.isAdmin&&(0,$.jsx)("a",{href:l,"aria-label":T(a.name),children:m||(m=(0,$.jsx)(f.Tooltip,{placement:"top",content:"Grafana Admin",children:(0,$.jsx)(f.Icon,{name:"shield"})}))})]}),i&&(0,$.jsx)("td",{className:(0,x.cx)("link-td",n.iconRow),children:(0,$.jsx)("a",{className:"ellipsis",href:l,title:a.name,"aria-label":T(a.name),children:"None"===a.licensedRole?(0,$.jsxs)("span",{className:n.disabled,children:["Not assigned"," ",g||(g=(0,$.jsx)(f.Tooltip,{placement:"top",content:"A licensed role will be assigned when this user signs in",children:(0,$.jsx)(f.Icon,{name:"question-circle"})}))]}):a.licensedRole})}),(0,$.jsx)("td",{className:"link-td",children:a.lastSeenAtAge&&(0,$.jsx)("a",{href:l,"aria-label":`Last seen at ${a.lastSeenAtAge}. Follow to edit user's ${a.name} details.`,children:"10 years"===a.lastSeenAtAge?(0,$.jsx)("span",{className:n.disabled,children:"Never"}):a.lastSeenAtAge})}),(0,$.jsx)("td",{className:"text-right",children:Array.isArray(a.authLabels)&&a.authLabels.length>0&&(0,$.jsx)(v.e,{label:a.authLabels[0],removeIcon:!1,count:0})}),(0,$.jsx)("td",{className:"text-right",children:a.isDisabled&&(u||(u=(0,$.jsx)("span",{className:"label label-tag label-tag--gray",children:"Disabled"})))})]},a.id)}));E.displayName="UserListItem";const F=e=>{let{units:s,icon:a}=e;const i=(0,f.useStyles2)(S);return null!=s&&s.length?s.length>1?(0,$.jsx)(f.Tooltip,{placement:"top",content:(0,$.jsx)("div",{className:i.unitTooltip,children:null==s?void 0:s.map((e=>(0,$.jsx)("a",{href:e.url,className:i.link,title:e.name,"aria-label":`Edit ${e.name}`,children:e.name},e.name)))}),children:(0,$.jsxs)("div",{className:i.unitItem,children:[(0,$.jsx)(f.Icon,{name:a})," ",(0,$.jsx)("span",{children:s.length})]})}):(0,$.jsxs)("a",{href:s[0].url,className:i.unitItem,title:s[0].name,"aria-label":`Edit ${s[0].name}`,children:[(0,$.jsx)(f.Icon,{name:a})," ",s[0].name]},s[0].name):null},S=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;
    `}),C=R((e=>{var s;let{fetchUsers:a,navModel:m,query:g,changeQuery:u,users:p,showPaging:v,totalPages:w,page:y,changePage:I,changeFilter:P,filters:R,isLoading:T}=e;const F=(0,f.useStyles2)(S);(0,j.useEffect)((()=>{a()}),[a]);const C=(0,j.useMemo)((()=>p.some((e=>e.licensedRole))),[p]);return(0,$.jsx)(b.Z,{navModel:m,children:(0,$.jsxs)(b.Z.Contents,{children:[(0,$.jsxs)("div",{className:"page-action-bar",children:[(0,$.jsxs)("div",{className:"gf-form gf-form--grow",children:[(0,$.jsx)(f.FilterInput,{placeholder:"Search user by login, email, or name.",autoFocus:!0,value:g,onChange:u}),(0,$.jsx)(f.RadioButtonGroup,{options:[{label:"All users",value:!1},{label:"Active last 30 days",value:!0}],onChange:e=>P({name:"activeLast30Days",value:e}),value:null===(s=R.find((e=>"activeLast30Days"===e.name)))||void 0===s?void 0:s.value,className:F.filter}),k.map(((e,s)=>(0,$.jsx)(e,{filters:R,onChange:P,className:F.filter},s)))]}),N.Vt.hasPermission(A.bW.UsersCreate)&&(i||(i=(0,$.jsx)(f.LinkButton,{href:"admin/users/create",variant:"primary",children:"New user"})))]}),T?n||(n=(0,$.jsx)(L.Z,{})):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("div",{className:(0,x.cx)(F.table,"admin-list-table"),children:(0,$.jsxs)("table",{className:"filter-table form-inline filter-table--hover",children:[(0,$.jsx)("thead",{children:(0,$.jsxs)("tr",{children:[l||(l=(0,$.jsx)("th",{})),t||(t=(0,$.jsx)("th",{children:"Login"})),r||(r=(0,$.jsx)("th",{children:"Email"})),c||(c=(0,$.jsx)("th",{children:"Name"})),d||(d=(0,$.jsx)("th",{children:"Belongs to"})),C&&(0,$.jsxs)("th",{children:["Licensed role"," ",(0,$.jsx)(f.Tooltip,{placement:"top",content:(0,$.jsxs)($.Fragment,{children:["Licensed role is based on a user's Org role (i.e. Viewer, Editor, Admin) and their dashboard/folder permissions."," ",(0,$.jsx)("a",{className:F.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,$.jsx)(f.Icon,{name:"question-circle"}))})]}),h||(h=(0,$.jsxs)("th",{children:["Last active ",(0,$.jsx)(f.Tooltip,{placement:"top",content:"Time since user was seen using Grafana",children:(0,$.jsx)(f.Icon,{name:"question-circle"})})]})),(0,$.jsx)("th",{style:{width:"1%"}})]})}),(0,$.jsx)("tbody",{children:p.map((e=>(0,$.jsx)(E,{user:e,showLicensedRole:C},e.id)))})]})}),v&&(0,$.jsx)(f.Pagination,{numberOfPages:w,currentPage:y,onNavigate:I})]})]})})}))}}]);
//# sourceMappingURL=UserListAdminPage.101604b83f114b13174d.js.map