Skip to content

Commit

Permalink
[RFR] Admin Ergonomics - parsing summary
Browse files Browse the repository at this point in the history
[Trello Card](https://trello.com/c/yDw7ffgB)

Move parsing summary inside the parsing box header

![screen](https://sc-cdn.scaleengine.net/i/c3fce5f3117081174a64f54ece1d19bd.png)
  • Loading branch information
djhi committed Feb 21, 2017
1 parent ac8c0b9 commit 8a864af
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 171 deletions.
41 changes: 6 additions & 35 deletions src/app/js/admin/parsing/ParsingResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import compose from 'recompose/compose';
import { connect } from 'react-redux';
import translate from 'redux-polyglot/translate';

import { CardActions, CardHeader, CardText } from 'material-ui/Card';
import { CardHeader, CardText } from 'material-ui/Card';
import FlatButton from 'material-ui/FlatButton';
import { grey400 } from 'material-ui/styles/colors';
import Card from '../../lib/Card';
Expand All @@ -16,7 +16,6 @@ import {
fromParsing,
} from '../selectors';
import ParsingExcerpt from './ParsingExcerpt';
import ParsingSummary from './ParsingSummary';

const styles = {
list: {
Expand All @@ -29,13 +28,6 @@ const styles = {
listItem: {
whiteSpace: 'nowrap',
},
parsingContainer: {
display: 'flex',
justifyContent: 'space-between',
},
parsingRightSection: {
flexGrow: 2,
},
title: {
height: '36px',
lineHeight: '36px',
Expand All @@ -47,17 +39,6 @@ const styles = {
};

export class ParsingResultComponent extends Component {
constructor() {
super();
this.state = {
showErrors: false,
};
}

handleShowExcerpt = () => {
this.setState({ showErrors: false });
}

handleClearParsing = () => {
event.preventDefault();
event.stopPropagation();
Expand All @@ -71,13 +52,12 @@ export class ParsingResultComponent extends Component {
totalLoadedLines,
p: polyglot,
} = this.props;
const { showErrors } = this.state;

return (
<Card className="parsingResult" initiallyExpanded>
<CardHeader
showExpandableButton
title={polyglot.t('Parsing summary')}
title={polyglot.t('parsing_summary', { count: totalLoadedLines })}
titleStyle={styles.title}
>
<FlatButton
Expand All @@ -86,20 +66,11 @@ export class ParsingResultComponent extends Component {
label={polyglot.t('Upload another file')}
/>
</CardHeader>
<CardText style={styles.parsingContainer} expandable>
<ParsingSummary
onShowExcerpt={this.handleShowExcerpt}
showErrors={showErrors}
totalLoadedLines={totalLoadedLines}
<CardText expandable>
<ParsingExcerpt
columns={excerptColumns}
lines={excerptLines}
/>
<div style={styles.parsingRightSection}>
{!showErrors &&
<ParsingExcerpt
columns={excerptColumns}
lines={excerptLines}
/>
}
</div>
</CardText>
</Card>
);
Expand Down
17 changes: 1 addition & 16 deletions src/app/js/admin/parsing/ParsingResult.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,14 @@ import React from 'react';
import expect from 'expect';
import { shallow } from 'enzyme';
import ParsingExcerpt from './ParsingExcerpt';
import ParsingSummary from './ParsingSummary';

import { ParsingResultComponent as ParsingResult } from './ParsingResult';

describe('<ParsingResult />', () => {
it('should render the ParsingSummary', () => {
const wrapper = shallow(<ParsingResult
failedLines={[{}, {}]}
p={{ t: () => {} }}
totalLoadedLines={24}
/>);

const parsingSummary = wrapper.find(ParsingSummary).at(0);

expect(parsingSummary.prop('showErrors')).toEqual(false);
expect(parsingSummary.prop('totalLoadedLines')).toEqual(24);
});

it('should render the ParsingExcerpt if showErrors is false', () => {
it('should render the ParsingExcerpt', () => {
const wrapper = shallow(<ParsingResult
excerptColumns={['foo']}
excerptLines={['bar']}
failedLines={[]}
p={{ t: () => {} }}
totalLoadedLines={24}
/>);
Expand Down
38 changes: 0 additions & 38 deletions src/app/js/admin/parsing/ParsingSummary.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/app/js/admin/parsing/ParsingSummary.spec.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/app/js/admin/parsing/ParsingSummaryItem.js

This file was deleted.

28 changes: 0 additions & 28 deletions src/app/js/admin/parsing/ParsingSummaryItem.spec.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/js/i18n/translations/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export default {
Admin: 'Admin',
'Sign in': 'Sign in',
'Parsing summary': 'Parsing summary',
parsing_summary: 'Parsed %{count} lines',
'total lines': 'total lines',
'successfully parsed': 'successfully parsed',
'with errors': 'with errors',
Expand Down

0 comments on commit 8a864af

Please sign in to comment.