import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import dateFnsFormat from 'date-fns/format'; class UserGroupTable extends React.Component { constructor(props) { super(props); this.xss = window.xss; this.onDelete = this.onDelete.bind(this); } onDelete(e) { const { target } = e; const groupId = target.getAttribute('data-user-group-id'); const group = this.props.userGroups.find((group) => { return group._id === groupId; }); this.props.onDelete(group); } render() { const { t } = this.props; return (

{t('user_group_management.group_list')}

{this.props.userGroups.map((group) => { return ( {this.props.isAclEnabled ? ( ) : ( ) } {this.props.isAclEnabled ? ( ) : ( ) } ); })}
{ t('Name') } { t('User') } { t('Created') }
{this.xss.process(group.name)}{this.xss.process(group.name)}
    {this.props.userGroupRelations[group._id].map((user) => { return
  • {this.xss.process(user.username)}
  • ; })}
{dateFnsFormat(new Date(group.createdAt), 'YYYY-MM-DD')}
); } } UserGroupTable.propTypes = { t: PropTypes.func.isRequired, // i18next crowi: PropTypes.object.isRequired, userGroups: PropTypes.arrayOf(PropTypes.object).isRequired, userGroupRelations: PropTypes.object.isRequired, isAclEnabled: PropTypes.bool, onDelete: PropTypes.func.isRequired, }; export default withTranslation()(UserGroupTable);