import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import PaginationWrapper from '../PaginationWrapper'; import { createSubscribedElement } from '../UnstatedUtils'; import { toastError } from '../../util/apiNotification'; import AppContainer from '../../services/AppContainer'; import AdminUsersContainer from '../../services/AdminUsersContainer'; import PasswordResetModal from './Users/PasswordResetModal'; import InviteUserControl from './Users/InviteUserControl'; import UserTable from './Users/UserTable'; class UserManagement extends React.Component { constructor(props) { super(); this.handlePage = this.handlePage.bind(this); this.handleChangeSearchText = this.handleChangeSearchText.bind(this); } componentWillMount() { this.handlePage(1); } async handlePage(selectedPage) { try { await this.props.adminUsersContainer.retrieveUsersByPagingNum(selectedPage); } catch (err) { toastError(err); } } /** * For checking same check box twice * @param {string} statusType */ handleClick(statusType) { const { adminUsersContainer } = this.props; if (!this.validateToggleStatus(statusType)) { adminUsersContainer.setNotifyComment('You should check at least one checkbox.'); return; } if (adminUsersContainer.state.notifyComment.length > 0) { adminUsersContainer.setNotifyComment(''); } adminUsersContainer.handleClick(statusType); } /** * Workaround user status check box * @param {string} statusType */ validateToggleStatus(statusType) { if (this.props.adminUsersContainer.isSelected(statusType)) { return this.props.adminUsersContainer.state.selectedStatusList.size > 1; } return true; } /** * Workaround increamental search * @param {string} event */ handleChangeSearchText(event) { this.props.adminUsersContainer.handleChangeSearchText(event.target.value); } render() { const { t, adminUsersContainer } = this.props; const pager = (