From d469cc2de706a5158c43b883c49dae9dd63d997d Mon Sep 17 00:00:00 2001 From: jansenk Date: Fri, 21 Dec 2018 15:10:07 -0500 Subject: [PATCH] implement gradebook pagination button feedback refactor buttons to a pure function component change labels disable rather than hide EDUCATOR-3825 --- src/components/Gradebook/index.jsx | 18 +- .../PageButtons/PageButtons.test.jsx | 36 ++++ .../__snapshots__/PageButtons.test.jsx.snap | 169 ++++++++++++++++++ src/components/PageButtons/index.jsx | 30 ++++ 4 files changed, 238 insertions(+), 15 deletions(-) create mode 100644 src/components/PageButtons/PageButtons.test.jsx create mode 100644 src/components/PageButtons/__snapshots__/PageButtons.test.jsx.snap create mode 100644 src/components/PageButtons/index.jsx diff --git a/src/components/Gradebook/index.jsx b/src/components/Gradebook/index.jsx index 694b7e0..6e3cede 100644 --- a/src/components/Gradebook/index.jsx +++ b/src/components/Gradebook/index.jsx @@ -10,6 +10,7 @@ import { } from '@edx/paragon'; import queryString from 'query-string'; import { configuration } from '../../config'; +import PageButtons from '../PageButtons'; const DECIMAL_PRECISION = 2; @@ -329,21 +330,6 @@ export default class Gradebook extends React.Component { onClear={() => this.props.getUserGrades(this.props.match.params.courseId, this.props.selectedCohort, this.props.selectedTrack)} value={this.state.filterValue} /> -
-

@@ -353,6 +339,7 @@ export default class Gradebook extends React.Component { onClose={() => this.props.updateBanner(false)} open={this.props.showSuccess} /> + {PageButtons(this.props)}
+ {PageButtons(this.props)} { + const assertPageButtonsSnapshot = function assertPageButtonsSnapshot(input) { + const pb = renderer.create(PageButtons(input)); + const tree = pb.toJSON(); + expect(tree).toMatchSnapshot(); + }; + + it('prev null, next null', () => { + assertPageButtonsSnapshot(createInput(null, null)); + }); + + it('prev null, next not null', () => { + assertPageButtonsSnapshot(createInput(null, 'np')); + }); + + it('prev not null, next null', () => { + assertPageButtonsSnapshot(createInput('pp', null)); + }); + + it('prev not null, next not null', () => { + assertPageButtonsSnapshot(createInput('pp', 'np')); + }); +}); diff --git a/src/components/PageButtons/__snapshots__/PageButtons.test.jsx.snap b/src/components/PageButtons/__snapshots__/PageButtons.test.jsx.snap new file mode 100644 index 0000000..61637ea --- /dev/null +++ b/src/components/PageButtons/__snapshots__/PageButtons.test.jsx.snap @@ -0,0 +1,169 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PageButtons prev not null, next not null 1`] = ` +
+ + +
+`; + +exports[`PageButtons prev not null, next null 1`] = ` +
+ + +
+`; + +exports[`PageButtons prev null, next not null 1`] = ` +
+ + +
+`; + +exports[`PageButtons prev null, next null 1`] = ` +
+ + +
+`; diff --git a/src/components/PageButtons/index.jsx b/src/components/PageButtons/index.jsx new file mode 100644 index 0000000..e74fdee --- /dev/null +++ b/src/components/PageButtons/index.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { + Button, +} from '@edx/paragon'; + + +export default function PageButtons({prevPage, nextPage, selectedTrack, selectedCohort, getPrevNextGrades}) { + return ( +
+
+ ); +} +