Skip to content

Commit

Permalink
Group name is localized
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE committed Nov 10, 2017
1 parent 4b681c8 commit bf72560
Show file tree
Hide file tree
Showing 33 changed files with 196 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LinkContainer } from 'react-router-bootstrap';
import DeleteAssignmentButtonContainer from '../../../containers/DeleteAssignmentButtonContainer';

import withLinks from '../../../hoc/withLinks';
import LocalizedExerciseName from '../../helpers/LocalizedExerciseName';
import { LocalizedExerciseName } from '../../helpers/LocalizedNames';
import {
EditIcon,
MaybePublicIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AssignmentStatusIcon from '../AssignmentStatusIcon/AssignmentStatusIcon';
import { FormattedDate, FormattedTime } from 'react-intl';

import withLinks from '../../../../hoc/withLinks';
import LocalizedExerciseName from '../../../helpers/LocalizedExerciseName';
import { LocalizedExerciseName } from '../../../helpers/LocalizedNames';
import { MaybeBonusAssignmentIcon } from '../../../icons';

const AssignmentTableRow = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Exercises/ExerciseDetail/ExerciseDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import GroupsNameContainer from '../../../containers/GroupsNameContainer';
import styles from './ExerciseDetail.less';
import { MaybeSucceededIcon } from '../../icons';
import { getLocalizedDescription } from '../../../helpers/getLocalizedData';
import LocalizedExerciseName from '../../helpers/LocalizedExerciseName';
import { LocalizedExerciseName } from '../../helpers/LocalizedNames';

const ExerciseDetail = ({
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import GroupsNameContainer from '../../../containers/GroupsNameContainer';
import { Link } from 'react-router';

import withLinks from '../../../hoc/withLinks';
import LocalizedExerciseName from '../../helpers/LocalizedExerciseName';
import { LocalizedExerciseName } from '../../helpers/LocalizedNames';
import { MaybeLockedExerciseIcon } from '../../icons';

const ExercisesListItem = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Exercises/ExercisesName/ExercisesName.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Link } from 'react-router';

import withLinks from '../../../hoc/withLinks';
import LocalizedExerciseName from '../../helpers/LocalizedExerciseName';
import { LocalizedExerciseName } from '../../helpers/LocalizedNames';

import { MaybeLockedExerciseIcon } from '../../icons';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import UsersNameContainer from '../../../containers/UsersNameContainer';
import { Link } from 'react-router';

import withLinks from '../../../hoc/withLinks';
import LocalizedExerciseName from '../../helpers/LocalizedExerciseName';
import { LocalizedExerciseName } from '../../helpers/LocalizedNames';
import { MaybeLockedExerciseIcon } from '../../icons';

const ExercisesSimpleListItem = ({
Expand Down
12 changes: 7 additions & 5 deletions src/components/Groups/AdminsView/AdminsView.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, injectIntl } from 'react-intl';
import { Row, Col } from 'react-bootstrap';
import { getFormValues } from 'redux-form';
import { connect } from 'react-redux';

import Box from '../../widgets/Box';
import AddSupervisor from '../AddSupervisor';
import EditGroupForm from '../../forms/EditGroupForm';
import { getLocalizedName } from '../../../helpers/getLocalizedData';

const AdminsView = ({ group, addSubgroup, formValues }) =>
const AdminsView = ({ group, addSubgroup, formValues, intl: { locale } }) =>
<div>
<Row>
<Col sm={12}>
<h3>
<FormattedMessage
id="app.group.adminsView.title"
defaultMessage="Administrator controls of {groupName}"
values={{ groupName: group.name }}
values={{ groupName: getLocalizedName(group, locale) }}
/>
</h3>
</Col>
Expand Down Expand Up @@ -51,7 +52,8 @@ const AdminsView = ({ group, addSubgroup, formValues }) =>
AdminsView.propTypes = {
group: PropTypes.object.isRequired,
addSubgroup: PropTypes.func.isRequired,
formValues: PropTypes.object
formValues: PropTypes.object,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired
};

export default connect(
Expand All @@ -61,4 +63,4 @@ export default connect(
};
},
dispatch => ({})
)(AdminsView);
)(injectIntl(AdminsView));
16 changes: 11 additions & 5 deletions src/components/Groups/GroupDetail/GroupDetail.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { FormattedMessage, FormattedNumber } from 'react-intl';
import { FormattedMessage, FormattedNumber, injectIntl } from 'react-intl';
import { Row, Col, Table } from 'react-bootstrap';
import ReactMarkdown from 'react-remarkable';

import Box from '../../widgets/Box';
import SupervisorsList from '../../Users/SupervisorsList';
import { MaybeSucceededIcon } from '../../icons';
import GroupTree from '../GroupTree';
import { getLocalizedName } from '../../../helpers/getLocalizedData';

const GroupDetail = ({
group: {
id,
externalId,
name,
localizedTexts,
description,
threshold,
parentGroupId,
Expand All @@ -26,7 +28,8 @@ const GroupDetail = ({
groups,
publicGroups,
supervisors,
isAdmin
isAdmin,
intl: { locale }
}) =>
<div>
<Row>
Expand Down Expand Up @@ -123,7 +126,9 @@ const GroupDetail = ({
<FormattedMessage
id="app.groupDetail.supervisors"
defaultMessage="Supervisors of {groupName}"
values={{ groupName: name }}
values={{
groupName: getLocalizedName({ name, localizedTexts }, locale)
}}
/>
}
>
Expand Down Expand Up @@ -157,7 +162,8 @@ GroupDetail.propTypes = {
groups: PropTypes.object.isRequired,
publicGroups: ImmutablePropTypes.map.isRequired,
supervisors: PropTypes.array.isRequired,
isAdmin: PropTypes.bool
isAdmin: PropTypes.bool,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired
};

export default GroupDetail;
export default injectIntl(GroupDetail);
22 changes: 12 additions & 10 deletions src/components/Groups/GroupsList/GroupsList.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { Table } from 'react-bootstrap';
import ResourceRenderer from '../../helpers/ResourceRenderer';
import Icon from 'react-fontawesome';

import GroupsName from '../GroupsName';
import withLinks from '../../../hoc/withLinks';

const GroupsList = ({
groups = [],
renderButtons = () => null,
links: { GROUP_URI_FACTORY },
...props
}) => (
}) =>
<ResourceRenderer resource={groups.toArray()}>
{(...groups) => (
{(...groups) =>
<Table hover {...props}>
<tbody>
{groups.map(({ id, name }) => (
{groups.map(({ id, name, localizedTexts }) =>
<tr key={id}>
<td className="text-center">
<Icon name="group" />
</td>
<td>
<Link to={GROUP_URI_FACTORY(id)}>{name}</Link>
<GroupsName
id={id}
name={name}
localizedTexts={localizedTexts}
/>
</td>
<td className="text-right">
{renderButtons(id)}
</td>
</tr>
))}
)}
</tbody>
</Table>
)}
</ResourceRenderer>
);
</Table>}
</ResourceRenderer>;

GroupsList.propTypes = {
groups: ImmutablePropTypes.map.isRequired,
Expand Down
25 changes: 17 additions & 8 deletions src/components/Groups/GroupsName/GroupsName.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router';
import withLinks from '../../../hoc/withLinks';
import { LocalizedGroupName } from '../../helpers/LocalizedNames';

const GroupsName = ({ id, name, noLink, links: { GROUP_URI_FACTORY } }) => (
const GroupsName = ({
id,
name,
localizedTexts,
noLink,
links: { GROUP_URI_FACTORY }
}) =>
<span>
{noLink ? (
<span>{name}</span>
) : (
<Link to={GROUP_URI_FACTORY(id)}>{name}</Link>
)}
</span>
);
{noLink
? <span>
<LocalizedGroupName entity={{ name, localizedTexts }} />
</span>
: <Link to={GROUP_URI_FACTORY(id)}>
<LocalizedGroupName entity={{ name, localizedTexts }} />
</Link>}
</span>;

GroupsName.propTypes = {
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
localizedTexts: PropTypes.array.isRequired,
noLink: PropTypes.bool,
links: PropTypes.object
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Groups/ResultsTable/ResultsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import LoadingResultsTableRow from './LoadingResultsTableRow';
import NoResultsAvailableRow from './NoResultsAvailableRow';
import withLinks from '../../../hoc/withLinks';
import ResourceRenderer from '../../helpers/ResourceRenderer';
import LocalizedExerciseName from '../../helpers/LocalizedExerciseName';
import { LocalizedExerciseName } from '../../helpers/LocalizedNames';
import styles from './ResultsTable.less';

const ResultsTable = ({
Expand Down
21 changes: 11 additions & 10 deletions src/components/Groups/StudentsView/StudentsView.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, injectIntl } from 'react-intl';
import { Row, Col } from 'react-bootstrap';

import Box from '../../widgets/Box';
import AssignmentsTable from '../../Assignments/Assignment/AssignmentsTable';
import StudentsListContainer from '../../../containers/StudentsListContainer';
import LeaveJoinGroupButtonContainer
from '../../../containers/LeaveJoinGroupButtonContainer';
import LeaveJoinGroupButtonContainer from '../../../containers/LeaveJoinGroupButtonContainer';
import { getLocalizedName } from '../../../helpers/getLocalizedData';

const StudentsView = ({
group,
statuses = [],
assignments,
isAdmin = false
}) => (
isAdmin = false,
intl: { locale }
}) =>
<div>
<Row>
<Col sm={12}>
<h3>
<FormattedMessage
id="app.group.studentsView.title"
defaultMessage="Student's dashboard for {groupName}"
values={{ groupName: group.name }}
values={{ groupName: getLocalizedName(group, locale) }}
/>
</h3>
</Col>
Expand Down Expand Up @@ -75,14 +76,14 @@ const StudentsView = ({
</Box>
</Col>
</Row>
</div>
);
</div>;

StudentsView.propTypes = {
group: PropTypes.object.isRequired,
assignments: ImmutablePropTypes.list.isRequired,
statuses: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
isAdmin: PropTypes.bool
isAdmin: PropTypes.bool,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired
};

export default StudentsView;
export default injectIntl(StudentsView);
Loading

0 comments on commit bf72560

Please sign in to comment.