import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; import { RadioButtonGroup, LinkButton, FilterInput } from '@grafana/ui'; import { contextSrv } from 'app/core/core'; import { AccessControlAction } from 'app/types'; import { selectTotal } from '../invites/state/selectors'; import { setUsersSearchQuery } from './state/reducers'; import { getUsersSearchQuery } from './state/selectors'; export interface Props { searchQuery: string; setUsersSearchQuery: typeof setUsersSearchQuery; onShowInvites: () => void; pendingInvitesCount: number; canInvite: boolean; showInvites: boolean; externalUserMngLinkUrl: string; externalUserMngLinkName: string; } export class UsersActionBar extends PureComponent { render() { const { canInvite, externalUserMngLinkName, externalUserMngLinkUrl, searchQuery, pendingInvitesCount, setUsersSearchQuery, onShowInvites, showInvites, } = this.props; const options = [ { label: 'Users', value: 'users' }, { label: `Pending Invites (${pendingInvitesCount})`, value: 'invites' }, ]; const canAddToOrg = contextSrv.hasAccess(AccessControlAction.UsersCreate, canInvite); return (
{pendingInvitesCount > 0 && (
)} {canAddToOrg && Invite} {externalUserMngLinkUrl && ( {externalUserMngLinkName} )}
); } } function mapStateToProps(state: any) { return { searchQuery: getUsersSearchQuery(state.users), pendingInvitesCount: selectTotal(state.invites), externalUserMngLinkName: state.users.externalUserMngLinkName, externalUserMngLinkUrl: state.users.externalUserMngLinkUrl, canInvite: state.users.canInvite, }; } const mapDispatchToProps = { setUsersSearchQuery, }; export default connect(mapStateToProps, mapDispatchToProps)(UsersActionBar);