-
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.
- Loading branch information
Showing
7 changed files
with
266 additions
and
35 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 striped 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> | ||
<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'; |
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
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,31 @@ | ||
import { createSelector } from 'reselect'; | ||
import { fetchManyEndpoint } from '../modules/submissionFailures'; | ||
import { isReady, getJsData } from '../helpers/resourceManager'; | ||
|
||
const getSubmissionFailures = state => state.submissionFailures; | ||
const getResources = failures => failures.get('resources'); | ||
|
||
export const submissionFailuresSelector = createSelector( | ||
getSubmissionFailures, | ||
getResources | ||
); | ||
|
||
export const fetchManyStatus = createSelector(getSubmissionFailures, state => | ||
state.getIn(['fetchManyStatus', fetchManyEndpoint]) | ||
); | ||
|
||
export const getSubmissionFailure = failureId => | ||
createSelector(submissionFailuresSelector, failures => | ||
failures.get(failureId) | ||
); | ||
|
||
export const readySubmissionFailuresSelector = createSelector( | ||
submissionFailuresSelector, | ||
failures => | ||
failures | ||
.toList() | ||
.filter(isReady) | ||
.map(getJsData) | ||
.sort((a, b) => a.createdAt - b.createdAt) | ||
.toArray() | ||
); |