Skip to content

Commit

Permalink
chore(chunk): show overal status (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
philloooo authored Apr 26, 2019
1 parent f01ad70 commit c7949ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Submission/SubmissionResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class SubmissionResult extends React.Component {
</ul>
</div>);
} else if (status >= 400 && status < 500) {
const errorList = (data.entities || []).filter(ent => !!ent.errors);
const errorList = (data || []).filter(ent => ent.errors && ent.errors.length);
if (errorList.length > 0) {
summary = (<div id='cd-summary__result_400'><p>
Errors:
Expand Down Expand Up @@ -106,7 +106,7 @@ class SubmissionResult extends React.Component {

SubmissionResult.propTypes = {
status: PropTypes.number.isRequired,
data: PropTypes.object.isRequired,
data: PropTypes.array.isRequired,
dataString: PropTypes.string.isRequired,
entityCounts: PropTypes.object.isRequired,
counter: PropTypes.number.isRequired,
Expand Down
6 changes: 2 additions & 4 deletions src/Submission/SubmissionResult.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import AceEditor from 'react-ace';
import SubmissionResult from './SubmissionResult';

describe('the submission result component', () => {
const testData = {
entities: [
const testData = [
{
type: 'type1',
},
Expand All @@ -21,8 +20,7 @@ describe('the submission result component', () => {
type: 'type2',
errors: ['bla bla bla'],
},
],
};
];

it('presents a summary of a successful submission', () => {
const $dom = shallow(
Expand Down
10 changes: 8 additions & 2 deletions src/Submission/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ const submission = (state = {}, action) => {
const res = db; res[type] = (res[type] || 0) + 1;
return res;
}, prevCounts);
const data = state.submit_result ?
state.submit_result.concat(action.data.entities || [])
: action.data.entities;
const status = state.submit_status ?
Math.max(state.submit_status, action.submit_status)
: action.submit_status;
return { ...state,
submit_entity_counts: newCounts,
submit_result: action.data,
submit_result: data,
submit_result_string: state.submit_result_string.concat(JSON.stringify(action.data, null, ' ')).concat('\n\n'),
submit_status: action.submit_status,
submit_status: status,
submit_counter: state.submit_counter + 1,
submit_total: action.total };
}
Expand Down

0 comments on commit c7949ea

Please sign in to comment.