Skip to content

Commit

Permalink
Merge pull request #185 from ReCodEx/tweaks
Browse files Browse the repository at this point in the history
Final bug-fixes, improvements, and polishing before release
  • Loading branch information
Martin Kruliš authored Feb 25, 2018
2 parents 63f3d91 + 77b76b5 commit 900ccb2
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 318 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class SubmissionDetail extends Component {
</a>
</Col>
)}
{files.length > 1 &&
<Col lg={6} md={12}>
<DownloadSolutionArchiveContainer solutionId={id} />
</Col>}
</Row>
{evaluation &&
<CompilationLogs
Expand Down Expand Up @@ -138,9 +142,6 @@ class SubmissionDetail extends Component {
<Col lg={6} md={12}>
<DownloadResultArchiveContainer submissionId={restSub.id} />
</Col>
<Col lg={6} md={12}>
<DownloadSolutionArchiveContainer solutionId={id} />
</Col>
</Row>}
{activeSubmissionId &&
isSupervisor &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { reduxForm, Field } from 'redux-form';
import { Alert } from 'react-bootstrap';
import isInt from 'validator/lib/isInt';
import Icon from 'react-fontawesome';

import FormBox from '../../widgets/FormBox';
import SubmitButton from '../SubmitButton';
import Button from '../../widgets/FlatButton';
Expand Down Expand Up @@ -72,6 +73,14 @@ const EditHardwareGroupForm = ({
</div>
}
>
<p className="text-muted text-justify small">
<Icon name="info-circle" />&nbsp;&nbsp;
<FormattedMessage
id="app.editHardwareGroupForm.about"
defaultMessage="Hardware group is a group of backend workers on which the exercise can be evaluated. The workers are bound to explicit hardware; thus, changing the hardware group of an exercise may affect the performance results. Furthermore, the workers in the group share configuration which implies the constraints for memory and time limits."
/>
</p>

{submitFailed &&
<Alert bsStyle="danger">
<FormattedMessage
Expand Down Expand Up @@ -107,26 +116,41 @@ EditHardwareGroupForm.propTypes = {
invalid: PropTypes.bool,
reset: PropTypes.func.isRequired,
hardwareGroups: PropTypes.array.isRequired,
addEmptyOption: PropTypes.bool
addEmptyOption: PropTypes.bool,
warnDropLimits: PropTypes.func.isRequired
};

const validate = ({ bonusPoints }) => {
const validate = ({ hardwareGroup }) => {
const errors = {};
if (!isInt(String(bonusPoints))) {
errors['bonusPoints'] = (
if (!hardwareGroup) {
errors['hardwareGroup'] = (
<FormattedMessage
id="app.bonusPointsForm.validation.points"
defaultMessage="The bonus must be an integer."
id="app.editHardwareGroupForm.validationFailed"
defaultMessage="Hardware group must be selected."
/>
);
}

return errors;
};

const warn = ({ hardwareGroup }, { warnDropLimits }) => {
const warnings = {};
if (warnDropLimits(hardwareGroup)) {
warnings['hardwareGroup'] = (
<FormattedMessage
id="app.editHardwareGroupForm.warnLimitsDrop"
defaultMessage="Limits of some environments do not meet the constraints of the selected hardware group. These limits will be removed when the hardware group is changed."
/>
);
}
return warnings;
};

export default reduxForm({
form: 'editHardwareGroup',
enableReinitialize: true,
keepDirtyOnReinitialize: false,
validate
validate,
warn
})(EditHardwareGroupForm);
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {
joinGroup,
leaveGroup,
fetchGroupIfNeeded
} from '../../redux/modules/groups';
import { joinGroup, leaveGroup, fetchGroup } from '../../redux/modules/groups';
import { fetchGroupsStatsIfNeeded } from '../../redux/modules/stats';
import { fetchAssignmentsForGroup } from '../../redux/modules/assignments';
import { loggedInUserIdSelector } from '../../redux/selectors/auth';
Expand All @@ -23,38 +19,34 @@ const LeaveJoinGroupButtonContainer = ({
joinGroup,
leaveGroup,
fetchAssignmentsForGroup,
fetchGroupIfNeeded,
fetchGroup,
fetchGroupsStatsIfNeeded,
...props
}) =>
isStudent ? (
userId === currentUserId ? (
<LeaveGroupButton
{...props}
onClick={() => leaveGroup(groupId, userId)}
bsSize="xs"
/>
) : (
<RemoveFromGroupButton
isStudent
? userId === currentUserId
? <LeaveGroupButton
{...props}
onClick={() => leaveGroup(groupId, userId)}
bsSize="xs"
/>
: <RemoveFromGroupButton
{...props}
onClick={() => leaveGroup(groupId, userId)}
bsSize="xs"
/>
: <JoinGroupButton
{...props}
onClick={() => leaveGroup(groupId, userId)}
onClick={() =>
joinGroup(groupId, userId).then(() =>
Promise.all([
fetchGroup(groupId),
fetchAssignmentsForGroup(groupId),
fetchGroupsStatsIfNeeded(groupId)
])
)}
bsSize="xs"
/>
)
) : (
<JoinGroupButton
{...props}
onClick={() =>
joinGroup(groupId, userId).then(() =>
Promise.all([
fetchGroupIfNeeded(groupId),
fetchAssignmentsForGroup(groupId),
fetchGroupsStatsIfNeeded(groupId)
])
)}
bsSize="xs"
/>
);
/>;

LeaveJoinGroupButtonContainer.propTypes = {
groupId: PropTypes.string.isRequired,
Expand All @@ -64,7 +56,7 @@ LeaveJoinGroupButtonContainer.propTypes = {
joinGroup: PropTypes.func.isRequired,
leaveGroup: PropTypes.func.isRequired,
fetchAssignmentsForGroup: PropTypes.func.isRequired,
fetchGroupIfNeeded: PropTypes.func.isRequired,
fetchGroup: PropTypes.func.isRequired,
fetchGroupsStatsIfNeeded: PropTypes.func.isRequired
};

Expand All @@ -77,7 +69,7 @@ const mapDispatchToProps = {
joinGroup,
leaveGroup,
fetchAssignmentsForGroup,
fetchGroupIfNeeded,
fetchGroup,
fetchGroupsStatsIfNeeded
};

Expand Down
Loading

0 comments on commit 900ccb2

Please sign in to comment.