| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- import React, { Fragment } from 'react';
- import PropTypes from 'prop-types';
- import { withTranslation } from 'react-i18next';
- import { createSubscribedElement } from '../../UnstatedUtils';
- import AppContainer from '../../../services/AppContainer';
- class UserMenu extends React.Component {
- activateUser() {}
- susupendUser() {}
- removeUser() {}
- removeFromAdmin() {}
- giveAdminAccess() {}
- render() {
- const { t } = this.props;
- // const users = this.props.users;
- let contentOfStatus;
- // let adminMenu;
- // {this.props.users.forEach((user) => {
- // if (user.status === 1) {
- // contentOfStatus = (
- // <a onClick={this.activateUser}>
- // <i className="icon-fw icon-user-following"></i> { t('user_management.accept') }
- // </a>
- // );
- // if (user.status === 2) {
- // contentOfStatus = (
- // <li>
- // { username !== user.username
- // ? (
- // <li>
- // <a onClick={this.susupendUser}>
- // <i className="icon-fw icon-user-unfollow"></i> { t('user_management.deactivate_account') }
- // </a>
- // </li>
- // )
- // : (
- // <li>
- // <a disabled>
- // <i className="icon-fw icon-ban"></i> { t('user_management.deactivate_account') }
- // </a>
- // <p className="alert alert-danger m-l-10 m-r-10 p-10">{ t('user_management.your_own') }</p>
- // </li>
- // )
- // }
- // </li>
- // );
- // if (user.status === 3) {
- // contentOfStatus = (
- // <a onClick={this.activateUser}>
- // <i className="icon-fw icon-action-redo"></i> { t('Undo') }
- // </a>
- // );
- // if (user.status === 1 || user.status === 5) {
- // contentOfStatus = (
- // <li className="dropdown-button">
- // <a onClick={this.removeUser}>
- // <i className="icon-fw icon-fire text-danger"></i> { t('Delete') }
- // </a>
- // </li>
- // );
- // }
- // if (user.admin === true) {
- // adminMenu = (
- // <li>
- // { username !== user.username
- // ? (
- // <li>
- // <a onClick={this.removeFromAdmin}>
- // <i className="icon-fw icon-user-unfollow"></i> { t('user_management.remove_admin_access') }
- // </a>
- // </li>
- // )
- // : (
- // <li>
- // <a disabled>
- // <i className="icon-fw icon-user-unfollow"></i> { t('user_management.remove_admin_access') }
- // </a>
- // <p className="alert alert-danger m-l-10 m-r-10 p-10">{ t('user_management.cannot_remove') }</p>
- // </li>
- // )
- // }
- // </li>
- // );
- // }
- // else {
- // adminMenu = (
- // <li>
- // <a onClick={this.giveAdminAccess}>
- // <i className="icon-fw icon-magic-wand"></i> { t('user_management.give_admin_access') }
- // </a>
- // </li>
- // );
- // }
- // }}
- return (
- <Fragment>
- <div className="btn-group admin-user-menu">
- <button type="button" className="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">
- <i className="icon-settings"></i> <span className="caret"></span>
- </button>
- <ul className="dropdown-menu" role="menu">
- <li className="dropdown-header">{ t('user_management.edit_menu') }</li>
- <li>
- <a
- href="#"
- data-user-id="{{ userId }}"
- data-user-email="{{ user.email }}"
- data-target="#admin-password-reset-modal"
- data-toggle="modal"
- >
- <i className="icon-fw icon-key"></i>
- { t('user_management.reset_password') }
- </a>
- </li>
- <li className="divider"></li>
- <li className="dropdown-header">{ t('status') }</li>
- <li>{contentOfStatus}</li>
- {/* <li>{user.status === 2 && adminMenu}</li> */}
- </ul>
- </div>
- {/* password reset modal */}
- <div className="modal fade" id="admin-password-reset-modal">
- <div className="modal-dialog">
- <div className="modal-content">
- <div className="modal-header">
- <button type="button" className="close" data-dismiss="modal" aria-hidden="true">×</button>
- <div className="modal-title">{ t('user_management.reset_password')}</div>
- </div>
- <div className="modal-body">
- <p>
- { t('user_management.password_never_seen') }<br />
- <span className="text-danger">{ t('user_management.send_new_password') }</span>
- </p>
- <p>
- { t('user_management.target_user') }: <code id="admin-password-reset-user"></code>
- </p>
- </div>
- </div>
- </div>
- </div>
- <div className="modal fade" id="admin-password-reset-modal-done">
- <div className="modal-dialog">
- <div className="modal-content">
- <div className="modal-header">
- <button type="button" className="close" data-dismiss="modal" aria-hidden="true">×</button>
- <div className="modal-title">{ t('user_management.reset_password') }</div>
- </div>
- <div className="modal-body">
- <p className="alert alert-danger">Let the user know the new password below and strongly recommend to change another one immediately. </p>
- <p>
- Reset user: <code id="admin-password-reset-done-user"></code>
- </p>
- <p>
- New password: <code id="admin-password-reset-done-password"></code>
- </p>
- </div>
- <div className="modal-footer">
- <button type="submit" className="btn btn-primary" data-dismiss="modal">OK</button>
- </div>
- </div>
- </div>
- </div>
- </Fragment>
- );
- }
- }
- const UserMenuWrapper = (props) => {
- return createSubscribedElement(UserMenu, props, [AppContainer]);
- };
- UserMenu.propTypes = {
- t: PropTypes.func.isRequired, // i18next
- users: PropTypes.array,
- };
- export default withTranslation()(UserMenuWrapper);
|