From 13a605fb2f207fbc195c1e9061982e1e633dc028 Mon Sep 17 00:00:00 2001 From: Ger Hean Date: Fri, 15 Mar 2019 18:15:43 +0800 Subject: [PATCH 1/2] bug fixes --- src/components/Application.tsx | 9 +-- .../__snapshots__/Application.tsx.snap | 2 +- src/components/incubator/EditingWorkspace.tsx | 1 + src/components/incubator/index.tsx | 57 +++++-------------- src/containers/incubator/index.ts | 16 ++---- 5 files changed, 26 insertions(+), 59 deletions(-) diff --git a/src/components/Application.tsx b/src/components/Application.tsx index 0dcf27abdc..51511abfeb 100644 --- a/src/components/Application.tsx +++ b/src/components/Application.tsx @@ -31,9 +31,6 @@ export interface IDispatchProps { handlePlaygroundExternalSelect: (external: ExternalLibraryName) => void; } -const assessmentRenderFactory = (cat: string) => (routerProps: RouteComponentProps) => ( - -); const assessmentRegExp = ':assessmentId(-?\\d+)?/:questionId(\\d+)?'; @@ -56,7 +53,7 @@ class Application extends React.Component { @@ -97,6 +94,10 @@ const parsePlayground = (props: IApplicationProps) => { } }; +const toIncubator = (routerProps: RouteComponentProps) => ( + +); + const parsePrgrm = (props: RouteComponentProps<{}>) => { const qsParsed = qs.parse(props.location.hash); // legacy support diff --git a/src/components/__tests__/__snapshots__/Application.tsx.snap b/src/components/__tests__/__snapshots__/Application.tsx.snap index 08abf477e4..059cf23338 100644 --- a/src/components/__tests__/__snapshots__/Application.tsx.snap +++ b/src/components/__tests__/__snapshots__/Application.tsx.snap @@ -6,7 +6,7 @@ exports[`Application renders correctly 1`] = `
- + diff --git a/src/components/incubator/EditingWorkspace.tsx b/src/components/incubator/EditingWorkspace.tsx index cac1ea6bcb..5a3b8f10de 100644 --- a/src/components/incubator/EditingWorkspace.tsx +++ b/src/components/incubator/EditingWorkspace.tsx @@ -356,6 +356,7 @@ class AssessmentWorkspace extends React.Component, IStateProps {} @@ -30,12 +27,7 @@ export interface IDispatchProps { handleSubmitAssessment: (id: number) => void; } -export interface IOwnProps { - assessmentCategory: string; -} - export interface IStateProps { - assessmentOverviews?: IAssessmentOverview[]; isStudent: boolean; } @@ -79,40 +71,21 @@ class Assessment extends React.Component { } } - // If there is an assessment to render, create a workspace. The assessment - // overviews must still be loaded for this, to send the due date. - // else if (assessmentId !== null && this.props.assessmentOverviews !== undefined) { - // const overview = this.props.assessmentOverviews.filter(a => a.id === assessmentId)[0] - // const assessmentProps: AssessmentProps = { - // assessmentId, - // questionId, - // notAttempted: overview.status === AssessmentStatuses.not_attempted, - // closeDate: overview.closeAt - // } - // return - // } - - // Otherwise, render a list of assessments to the user. - let display: JSX.Element; - if (this.props.assessmentOverviews === undefined) { - display = } />; - } else { - /** Mission editing card */ - const missionEditingCard = this.state.editingOverview ? ( - - ) : null; - - display = ( - <> - - {missionEditingCard} - - ); - } + /** Mission editing card */ + const missionEditingCard = this.state.editingOverview ? ( + + ) : null; + + const display = ( + <> + + {missionEditingCard} + + ); // Finally, render the ContentDisplay. return ( diff --git a/src/containers/incubator/index.ts b/src/containers/incubator/index.ts index 9f63746feb..d988d4f8b6 100644 --- a/src/containers/incubator/index.ts +++ b/src/containers/incubator/index.ts @@ -4,20 +4,13 @@ import { bindActionCreators, Dispatch } from 'redux'; import { fetchAssessmentOverviews, - submitAssessment, - updateAssessment + submitAssessment } from '../../actions/session'; -import { IAssessmentOverview } from '../../components/assessment/assessmentShape'; -import Assessment, { IDispatchProps, IOwnProps, IStateProps } from '../../components/incubator'; +import Assessment, { IDispatchProps, IStateProps } from '../../components/incubator'; import { IState, Role } from '../../reducers/states'; -const mapStateToProps: MapStateToProps = (state, props) => { - const categoryFilter = (overview: IAssessmentOverview) => - overview.category === props.assessmentCategory; +const mapStateToProps: MapStateToProps = (state, props) => { const stateProps: IStateProps = { - assessmentOverviews: state.session.assessmentOverviews - ? state.session.assessmentOverviews.filter(categoryFilter) - : undefined, isStudent: state.session.role ? state.session.role === Role.Student : true }; return stateProps; @@ -27,8 +20,7 @@ const mapDispatchToProps: MapDispatchToProps = (dispatch: Di bindActionCreators( { handleAssessmentOverviewFetch: fetchAssessmentOverviews, - handleSubmitAssessment: submitAssessment, - newAssessment: updateAssessment + handleSubmitAssessment: submitAssessment }, dispatch ); From 050d702eb9604cdd32137a79de62a56626f8658e Mon Sep 17 00:00:00 2001 From: Ger Hean Date: Fri, 15 Mar 2019 18:20:40 +0800 Subject: [PATCH 2/2] yarn format --- src/components/Application.tsx | 10 ++-------- src/containers/incubator/index.ts | 5 +---- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/components/Application.tsx b/src/components/Application.tsx index 51511abfeb..a3c750e19f 100644 --- a/src/components/Application.tsx +++ b/src/components/Application.tsx @@ -31,7 +31,6 @@ export interface IDispatchProps { handlePlaygroundExternalSelect: (external: ExternalLibraryName) => void; } - const assessmentRegExp = ':assessmentId(-?\\d+)?/:questionId(\\d+)?'; class Application extends React.Component { @@ -51,10 +50,7 @@ class Application extends React.Component {
- + @@ -94,9 +90,7 @@ const parsePlayground = (props: IApplicationProps) => { } }; -const toIncubator = (routerProps: RouteComponentProps) => ( - -); +const toIncubator = (routerProps: RouteComponentProps) => ; const parsePrgrm = (props: RouteComponentProps<{}>) => { const qsParsed = qs.parse(props.location.hash); diff --git a/src/containers/incubator/index.ts b/src/containers/incubator/index.ts index d988d4f8b6..885473ea8a 100644 --- a/src/containers/incubator/index.ts +++ b/src/containers/incubator/index.ts @@ -2,10 +2,7 @@ import { connect, MapDispatchToProps, MapStateToProps } from 'react-redux'; import { withRouter } from 'react-router'; import { bindActionCreators, Dispatch } from 'redux'; -import { - fetchAssessmentOverviews, - submitAssessment -} from '../../actions/session'; +import { fetchAssessmentOverviews, submitAssessment } from '../../actions/session'; import Assessment, { IDispatchProps, IStateProps } from '../../components/incubator'; import { IState, Role } from '../../reducers/states';