diff --git a/src/components/Groups/GroupTree/GroupTree.js b/src/components/Groups/GroupTree/GroupTree.js index 0ae3d0297..2d2f0ade9 100644 --- a/src/components/Groups/GroupTree/GroupTree.js +++ b/src/components/Groups/GroupTree/GroupTree.js @@ -6,6 +6,7 @@ import Button from '../../widgets/FlatButton'; import { LinkContainer } from 'react-router-bootstrap'; import { TreeView, TreeViewItem } from '../../widgets/TreeView'; import { isReady, getJsData } from '../../../redux/helpers/resourceManager'; +import GroupsName from '../GroupsName'; import withLinks from '../../../hoc/withLinks'; @@ -59,6 +60,7 @@ class GroupTree extends Component { const { name, + localizedTexts, admins, childGroups: { all: allChildGroups, public: publicChildGroups }, canView @@ -68,7 +70,14 @@ class GroupTree extends Component { {level !== 0 && + } level={level} admins={admins} isOpen={currentGroupId === id || isOpen} diff --git a/src/components/Users/UsersStats/UsersStats.js b/src/components/Users/UsersStats/UsersStats.js index 9706f8969..51089ac14 100644 --- a/src/components/Users/UsersStats/UsersStats.js +++ b/src/components/Users/UsersStats/UsersStats.js @@ -1,37 +1,46 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { FormattedMessage, FormattedNumber } from 'react-intl'; +import { FormattedMessage, FormattedNumber, injectIntl } from 'react-intl'; import InfoBox from '../../widgets/InfoBox'; +import { getLocalizedName } from '../../../helpers/getLocalizedData'; const UsersStats = ({ id, name, - stats: { assignments, points, hasLimit, passesLimit } -}) => ( - 0 ? points.gained / points.total : 0} - style="percent" - /> - } - progress={points.total > 0 ? Math.min(1, points.gained / points.total) : 0} - description={ - - } - /> -); + localizedTexts, + stats: { assignments, points, hasLimit, passesLimit }, + intl: { locale } +}) => { + const localizedName = getLocalizedName({ name, localizedTexts }, locale); + return ( + 0 ? points.gained / points.total : 0} + style="percent" + /> + } + progress={ + points.total > 0 ? Math.min(1, points.gained / points.total) : 0 + } + description={ + + } + /> + ); +}; UsersStats.propTypes = { id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, + localizedTexts: PropTypes.array.isRequired, stats: PropTypes.shape({ assignments: PropTypes.shape({ total: PropTypes.number.isRequired, @@ -41,7 +50,8 @@ UsersStats.propTypes = { total: PropTypes.number.isRequired, gained: PropTypes.number.isRequired }) - }).isRequired + }).isRequired, + intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired }; -export default UsersStats; +export default injectIntl(UsersStats); diff --git a/src/components/forms/EditGroupForm/EditGroupForm.js b/src/components/forms/EditGroupForm/EditGroupForm.js index d82e3686c..867d9f50a 100644 --- a/src/components/forms/EditGroupForm/EditGroupForm.js +++ b/src/components/forms/EditGroupForm/EditGroupForm.js @@ -48,7 +48,7 @@ const EditGroupForm = ({ submit: createNew ? : } + title={getLocalizedName(group, locale)} /> @@ -342,7 +344,8 @@ Dashboard.propTypes = { usersStatistics: PropTypes.func.isRequired, allGroups: PropTypes.array, isAdmin: PropTypes.bool, - links: PropTypes.object + links: PropTypes.object, + intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired }; export default withLinks( @@ -373,5 +376,5 @@ export default withLinks( loadAsync: loggedInUserId => Dashboard.loadAsync(params, dispatch, loggedInUserId) }) - )(Dashboard) + )(injectIntl(Dashboard)) ); diff --git a/src/pages/EditGroup/EditGroup.js b/src/pages/EditGroup/EditGroup.js index 0713a4a9a..d8e71c7a8 100644 --- a/src/pages/EditGroup/EditGroup.js +++ b/src/pages/EditGroup/EditGroup.js @@ -5,7 +5,7 @@ import { FormattedMessage } from 'react-intl'; import { HelpBlock } from 'react-bootstrap'; import { connect } from 'react-redux'; import { push } from 'react-router-redux'; -import { reset } from 'redux-form'; +import { reset, getFormValues } from 'redux-form'; import Page from '../../components/layout/Page'; import EditGroupForm from '../../components/forms/EditGroupForm'; @@ -40,6 +40,7 @@ class EditGroup extends Component { group, links: { GROUP_URI_FACTORY }, editGroup, + formValues, push } = this.props; @@ -75,6 +76,7 @@ class EditGroup extends Component { isSupervisorOf(userId, groupId)(state) + isStudentOf: groupId => isSupervisorOf(userId, groupId)(state), + formValues: getFormValues('editGroup')(state) }; }, (dispatch, { params: { groupId } }) => ({ diff --git a/src/pages/Group/Group.js b/src/pages/Group/Group.js index 0ccadbd79..94f671b29 100644 --- a/src/pages/Group/Group.js +++ b/src/pages/Group/Group.js @@ -5,7 +5,7 @@ import { connect } from 'react-redux'; import { push } from 'react-router-redux'; import { LinkContainer } from 'react-router-bootstrap'; import Button from '../../components/widgets/FlatButton'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, injectIntl } from 'react-intl'; import { List, Map } from 'immutable'; import Page from '../../components/layout/Page'; @@ -62,6 +62,7 @@ import { getStatuses } from '../../redux/selectors/stats'; import { fetchInstanceIfNeeded } from '../../redux/modules/instances'; import { instanceSelector } from '../../redux/selectors/instances'; +import { getLocalizedName } from '../../helpers/getLocalizedData'; import withLinks from '../../hoc/withLinks'; class Group extends Component { @@ -124,7 +125,7 @@ class Group extends Component { } getBreadcrumbs = () => { - const { group, instance } = this.props; + const { group, instance, intl: { locale } } = this.props; const breadcrumbs = [ { resource: instance, @@ -139,7 +140,7 @@ class Group extends Component { resource: group, iconName: 'group', breadcrumb: data => ({ - text: data.name + text: getLocalizedName(data, locale) }) } ]; @@ -294,7 +295,8 @@ Group.propTypes = { assignExercise: PropTypes.func.isRequired, createGroupExercise: PropTypes.func.isRequired, push: PropTypes.func.isRequired, - links: PropTypes.object + links: PropTypes.object, + intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired }; Group.contextTypes = { @@ -351,4 +353,6 @@ const mapDispatchToProps = (dispatch, { params }) => ({ push: url => dispatch(push(url)) }); -export default withLinks(connect(mapStateToProps, mapDispatchToProps)(Group)); +export default withLinks( + connect(mapStateToProps, mapDispatchToProps)(injectIntl(Group)) +);