-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from ReCodEx/submission_failures
Submission failures page
- Loading branch information
Showing
14 changed files
with
502 additions
and
5 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/components/SubmissionFailures/FailuresList/FailuresList.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Table } from 'react-bootstrap'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import FailuresListItem from '../FailuresListItem'; | ||
|
||
const FailuresList = ({ failures, createActions }) => | ||
<Table hover> | ||
<thead> | ||
<tr> | ||
<th> | ||
<FormattedMessage | ||
id="app.failureList.headType" | ||
defaultMessage="Type" | ||
/> | ||
</th> | ||
<th> | ||
<FormattedMessage | ||
id="app.failureList.headDescription" | ||
defaultMessage="Description" | ||
/> | ||
</th> | ||
<th> | ||
<FormattedMessage | ||
id="app.failureList.headCreatedAt" | ||
defaultMessage="Created at" | ||
/> | ||
</th> | ||
<th> | ||
<FormattedMessage | ||
id="app.failureList.headResolvedAt" | ||
defaultMessage="Resolved at" | ||
/> | ||
</th> | ||
<th> | ||
<FormattedMessage | ||
id="app.failureList.headResolutionNote" | ||
defaultMessage="Resolution note" | ||
/> | ||
</th> | ||
<th /> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{failures.map((failure, i) => | ||
<FailuresListItem | ||
id={failure.id} | ||
createActions={createActions} | ||
failure={failure} | ||
key={i} | ||
/> | ||
)} | ||
|
||
{failures.length === 0 && | ||
<tr> | ||
<td className="text-center"> | ||
<FormattedMessage | ||
id="app.failureList.noFailures" | ||
defaultMessage="There are no failures in this list." | ||
/> | ||
</td> | ||
</tr>} | ||
</tbody> | ||
</Table>; | ||
|
||
FailuresList.propTypes = { | ||
failures: PropTypes.array, | ||
createActions: PropTypes.func, | ||
failure: PropTypes.object | ||
}; | ||
|
||
export default FailuresList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from './FailuresList'; |
60 changes: 60 additions & 0 deletions
60
src/components/SubmissionFailures/FailuresListItem/FailuresListItem.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { FormattedDate, FormattedTime } from 'react-intl'; | ||
import Icon from 'react-fontawesome'; | ||
import { OverlayTrigger, Tooltip } from 'react-bootstrap'; | ||
|
||
const FailuresListItem = ({ id, createActions, failure }) => | ||
<tr className={failure.resolvedAt ? 'success' : 'danger'}> | ||
<td className="text-center"> | ||
<OverlayTrigger | ||
placement="top" | ||
overlay={ | ||
<Tooltip id={id}> | ||
{failure.type} | ||
</Tooltip> | ||
} | ||
> | ||
<div> | ||
{failure.type === 'broker_reject' && <Icon name="times-rectangle" />} | ||
{failure.type === 'evaluation_failure' && <Icon name="tint" />} | ||
{failure.type === 'loading_failure' && <Icon name="wrench" />} | ||
</div> | ||
</OverlayTrigger> | ||
</td> | ||
<td> | ||
{failure.description} | ||
</td> | ||
<td> | ||
<FormattedDate value={new Date(failure.createdAt * 1000)} /> | ||
{', '} | ||
<FormattedTime value={new Date(failure.createdAt * 1000)} /> | ||
</td> | ||
<td> | ||
{failure.resolvedAt | ||
? <span> | ||
<FormattedDate value={new Date(failure.resolvedAt * 1000)} /> | ||
{', '} | ||
<FormattedTime value={new Date(failure.resolvedAt * 1000)} /> | ||
</span> | ||
: <span>—</span>} | ||
</td> | ||
<td> | ||
{failure.resolutionNote | ||
? <span> | ||
{failure.resolutionNote} | ||
</span> | ||
: <span>—</span>} | ||
</td> | ||
<td className="text-right"> | ||
{createActions && createActions(id)} | ||
</td> | ||
</tr>; | ||
|
||
FailuresListItem.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
failure: PropTypes.object.isRequired, | ||
createActions: PropTypes.func | ||
}; | ||
|
||
export default FailuresListItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from './FailuresListItem'; |
105 changes: 105 additions & 0 deletions
105
src/components/SubmissionFailures/ResolveFailure/ResolveFailure.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Modal, Button } from 'react-bootstrap'; | ||
import { CloseIcon } from '../../icons'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { Field, reduxForm } from 'redux-form'; | ||
import TextField from '../../forms/Fields/TextField'; | ||
import SubmitButton from '../../forms/SubmitButton'; | ||
|
||
const maxNoteLength = value => | ||
value && value.length >= 255 | ||
? <FormattedMessage | ||
id="app.submissionFailures.resolveMaxLengthExceeded" | ||
defaultMessage="Maximum length of the note exceeded." | ||
/> | ||
: undefined; | ||
|
||
const ResolveFailure = ({ | ||
isOpen, | ||
onClose, | ||
submitting, | ||
handleSubmit, | ||
anyTouched, | ||
submitFailed = false, | ||
submitSucceeded = false, | ||
invalid, | ||
reset | ||
}) => | ||
<Modal show={isOpen} backdrop="static" onHide={onClose}> | ||
<Modal.Header closeButton> | ||
<Modal.Title> | ||
<FormattedMessage | ||
id="app.submissionFailures.resolveTitle" | ||
defaultMessage="Resolve Failure" | ||
/> | ||
</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Field | ||
name="note" | ||
component={TextField} | ||
label={ | ||
<FormattedMessage | ||
id="app.submissionFailures.resolveNote" | ||
defaultMessage="Resolve note:" | ||
/> | ||
} | ||
validate={maxNoteLength} | ||
/> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<SubmitButton | ||
id="resolve-failure" | ||
handleSubmit={data => handleSubmit(data).then(() => reset())} | ||
submitting={submitting} | ||
dirty={anyTouched} | ||
hasSucceeded={submitSucceeded} | ||
hasFailed={submitFailed} | ||
invalid={invalid} | ||
messages={{ | ||
submit: ( | ||
<FormattedMessage | ||
id="app.submissionFailures.resolveSave" | ||
defaultMessage="Save" | ||
/> | ||
), | ||
submitting: ( | ||
<FormattedMessage | ||
id="app.submissionFailures.resolveSaving" | ||
defaultMessage="Saving ..." | ||
/> | ||
), | ||
success: ( | ||
<FormattedMessage | ||
id="app.submissionFailures.resolveSuccesss" | ||
defaultMessage="Saved" | ||
/> | ||
) | ||
}} | ||
/> | ||
|
||
<Button bsStyle="default" className="btn-flat" onClick={onClose}> | ||
<CloseIcon />{' '} | ||
<FormattedMessage | ||
id="app.submissionFailures.resolveClose" | ||
defaultMessage="Close" | ||
/> | ||
</Button> | ||
</Modal.Footer> | ||
</Modal>; | ||
|
||
ResolveFailure.propTypes = { | ||
handleSubmit: PropTypes.func.isRequired, | ||
onSubmit: PropTypes.func.isRequired, | ||
submitFailed: PropTypes.bool, | ||
anyTouched: PropTypes.bool, | ||
submitSucceeded: PropTypes.bool, | ||
submitting: PropTypes.bool, | ||
invalid: PropTypes.bool, | ||
reset: PropTypes.func, | ||
onClose: PropTypes.func.isRequired, | ||
isOpen: PropTypes.bool.isRequired | ||
}; | ||
|
||
export default reduxForm({ form: 'resolve-failure' })(ResolveFailure); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default from './ResolveFailure'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.