Skip to content

Commit 19bf45c

Browse files
committed
Address review comments
1 parent c8929d9 commit 19bf45c

File tree

11 files changed

+78
-68
lines changed

11 files changed

+78
-68
lines changed

src/commons/application/Application.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,6 @@ const Application: React.FC<ApplicationProps> = props => {
203203
/>
204204
<Route path="/playground" render={ensureUserAndRoleAndRouteTo(props, <Playground />)} />
205205

206-
{/* <Route
207-
path="/sourcecast/:sourcecastId?"
208-
render={ensureUserAndRoleAndRouteTo(props, <Sourcecast />)}
209-
/>
210-
<Route
211-
path="/achievements"
212-
render={ensureUserAndRoleAndRouteTo(props, <Achievement />)}
213-
/> */}
214206
<Redirect
215207
from="/"
216208
exact={true}

src/commons/assessment/__tests__/Assessment.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { mockRouterProps } from '../../mocks/ComponentMocks';
88
import Assessment, { AssessmentProps } from '../Assessment';
99

1010
const defaultProps: AssessmentProps = {
11+
courseId: 1,
1112
assessmentConfiguration: {
1213
assessmentConfigId: 1,
1314
type: 'Missions',

src/commons/assessment/__tests__/__snapshots__/Assessment.tsx.snap

Lines changed: 37 additions & 37 deletions
Large diffs are not rendered by default.

src/commons/navigationBar/subcomponents/AcademyNavigationBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const AcademyNavigationBar: React.FunctionComponent<OwnProps> = props => (
2424
to={`/courses/${props.courseId}/${assessmentTypeLink(assessmentType)}`}
2525
activeClassName={Classes.ACTIVE}
2626
className={classNames('NavigationBar__link', Classes.BUTTON, Classes.MINIMAL)}
27-
key={assessmentType}
27+
key={idx}
2828
>
2929
<Icon icon={icons[idx]} />
3030
<div className="navbar-button-text hidden-xs hidden-sm">{assessmentType}</div>

src/commons/navigationBar/subcomponents/NavigationBarMobileSideMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const NavigationBarMobileSideMenu: React.FC<NavigationBarMobileSideMenuProps> =
5050
Classes.LARGE
5151
)}
5252
onClick={props.onClose}
53-
key={assessmentType}
53+
key={idx}
5454
>
5555
<Icon icon={icons[idx]} />
5656
<div>{assessmentType}</div>

src/commons/navigationBar/subcomponents/__tests__/NavigationBarMobileSideMenu.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ test('NavigationBarMobileSideMenu renders "Not logged in" correctly', () => {
99
onClose: () => {},
1010
handleGitHubLogIn: () => {},
1111
handleGitHubLogOut: () => {},
12-
assessmentTypes: []
12+
assessmentTypes: [],
13+
courseId: 1
1314
};
1415
const tree = shallow(<NavigationBarMobileSideMenu {...props} />);
1516
expect(tree.debug()).toMatchSnapshot();
@@ -22,7 +23,8 @@ test('NavigationBarMobileSideMenu renders correctly when logged in (no course se
2223
name: 'Avenger',
2324
handleGitHubLogIn: () => {},
2425
handleGitHubLogOut: () => {},
25-
assessmentTypes: []
26+
assessmentTypes: [],
27+
courseId: 1
2628
};
2729
const tree = shallow(<NavigationBarMobileSideMenu {...props} />);
2830
expect(tree.debug()).toMatchSnapshot();
@@ -36,7 +38,8 @@ test('NavigationBarMobileSideMenu renders correctly when logged in (with course
3638
role: Role.Student,
3739
handleGitHubLogIn: () => {},
3840
handleGitHubLogOut: () => {},
39-
assessmentTypes: ['Missions', 'Quests', 'Paths', 'Contests', 'Others']
41+
assessmentTypes: ['Missions', 'Quests', 'Paths', 'Contests', 'Others'],
42+
courseId: 1
4043
};
4144
const tree = shallow(<NavigationBarMobileSideMenu {...props} />);
4245
expect(tree.debug()).toMatchSnapshot();

src/commons/navigationBar/subcomponents/__tests__/__snapshots__/NavigationBarMobileSideMenu.tsx.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,35 @@ exports[`NavigationBarMobileSideMenu renders correctly when logged in (no course
3030
3131
exports[`NavigationBarMobileSideMenu renders correctly when logged in (with course selected) 1`] = `
3232
"<Blueprint3.Drawer isOpen={true} position=\\"left\\" onClose={[Function: onClose]} title=\\"\\" className=\\"bp3-dark\\" canOutsideClickClose={true} shouldReturnFocusOnClose={true} style={{...}} vertical={false}>
33-
<NavLink to=\\"/courses/undefined/missions\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
33+
<NavLink to=\\"/courses/1/missions\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
3434
<Blueprint3.Icon icon=\\"flame\\" />
3535
<div>
3636
Missions
3737
</div>
3838
<Connect(NotificationBadge) notificationFilter={[Function (anonymous)]} disableHover={true} />
3939
</NavLink>
40-
<NavLink to=\\"/courses/undefined/quests\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
40+
<NavLink to=\\"/courses/1/quests\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
4141
<Blueprint3.Icon icon=\\"lightbulb\\" />
4242
<div>
4343
Quests
4444
</div>
4545
<Connect(NotificationBadge) notificationFilter={[Function (anonymous)]} disableHover={true} />
4646
</NavLink>
47-
<NavLink to=\\"/courses/undefined/paths\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
47+
<NavLink to=\\"/courses/1/paths\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
4848
<Blueprint3.Icon icon=\\"predictive-analysis\\" />
4949
<div>
5050
Paths
5151
</div>
5252
<Connect(NotificationBadge) notificationFilter={[Function (anonymous)]} disableHover={true} />
5353
</NavLink>
54-
<NavLink to=\\"/courses/undefined/contests\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
54+
<NavLink to=\\"/courses/1/contests\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
5555
<Blueprint3.Icon icon=\\"comparison\\" />
5656
<div>
5757
Contests
5858
</div>
5959
<Connect(NotificationBadge) notificationFilter={[Function (anonymous)]} disableHover={true} />
6060
</NavLink>
61-
<NavLink to=\\"/courses/undefined/others\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
61+
<NavLink to=\\"/courses/1/others\\" activeClassName=\\"bp3-active\\" className=\\"NavigationBar__link__mobile bp3-button bp3-minimal bp3-large\\" onClick={[Function: onClose]}>
6262
<Blueprint3.Icon icon=\\"manual\\" />
6363
<div>
6464
Others

src/commons/profile/__tests__/Profile.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ test('Profile renders correctly when there are no closed assessments', () => {
2828
const props = {
2929
name: 'yeet',
3030
role: Role.Student,
31+
courseId: 1,
3132
assessmentOverviews: mockNoClosedAssessmentOverviews,
3233
assessmentTypes: ['Missions', 'Quests', 'Paths', 'Contests', 'Others'],
3334
isOpen: true,
@@ -56,6 +57,7 @@ test('Profile renders correctly when there are closed and graded, or closed and
5657
const props = {
5758
name: 'yeeet',
5859
role: Role.Staff,
60+
courseId: 1,
5961
assessmentOverviews: mockAssessmentOverviews,
6062
assessmentTypes: ['Missions', 'Quests', 'Paths', 'Contests', 'Others'],
6163
isOpen: true,

src/commons/profile/__tests__/__snapshots__/Profile.tsx.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`Profile renders correctly when there are closed and graded, or closed and not manually graded assessments 1`] = `
44
"<MemoryRouter initialEntries={{...}}>
55
<Router history={{...}}>
6-
<Profile name=\\"yeeet\\" role=\\"staff\\" assessmentOverviews={{...}} assessmentTypes={{...}} isOpen={true} handleAssessmentOverviewFetch={[Function: handleAssessmentOverviewFetch]} onClose={[Function: onClose]}>
6+
<Profile name=\\"yeeet\\" role=\\"staff\\" courseId={1} assessmentOverviews={{...}} assessmentTypes={{...}} isOpen={true} handleAssessmentOverviewFetch={[Function: handleAssessmentOverviewFetch]} onClose={[Function: onClose]}>
77
<Blueprint3.Drawer className=\\"profile\\" icon=\\"user\\" isCloseButtonShown={true} isOpen={true} onClose={[Function: onClose]} title=\\"User Profile\\" position=\\"left\\" size=\\"360px\\" canOutsideClickClose={true} shouldReturnFocusOnClose={true} style={{...}} vertical={false}>
88
<Blueprint3.Overlay className=\\"bp3-overlay-container\\" icon=\\"user\\" isCloseButtonShown={true} isOpen={true} onClose={[Function: onClose]} title=\\"User Profile\\" position=\\"left\\" size=\\"360px\\" canOutsideClickClose={true} shouldReturnFocusOnClose={true} style={{...}} vertical={false} onOpening={[Function (anonymous)]} onClosed={[Function (anonymous)]} autoFocus={true} backdropProps={{...}} canEscapeKeyClose={true} enforceFocus={true} hasBackdrop={true} lazy={true} transitionDuration={300} transitionName=\\"bp3-overlay\\" usePortal={true}>
99
<Blueprint3.Portal className={[undefined]} container={{...}}>
@@ -90,11 +90,11 @@ exports[`Profile renders correctly when there are closed and graded, or closed a
9090
</div>
9191
</div>
9292
<div className=\\"profile-callouts\\">
93-
<ProfileCard item={{...}} getFrac={[Function: getFrac]} parseColour={[Function: parseColour]} renderIcon={[Function: renderIcon]} courseId={[undefined]}>
94-
<NavLink className=\\"profile-summary-navlink\\" target=\\"_blank\\" to=\\"/courses/undefined/quests/5/0\\" activeClassName=\\"profile-summary-navlink\\">
93+
<ProfileCard item={{...}} getFrac={[Function: getFrac]} parseColour={[Function: parseColour]} renderIcon={[Function: renderIcon]} courseId={1}>
94+
<NavLink className=\\"profile-summary-navlink\\" target=\\"_blank\\" to=\\"/courses/1/quests/5/0\\" activeClassName=\\"profile-summary-navlink\\">
9595
<Link aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} to={{...}} target=\\"_blank\\">
96-
<LinkAnchor aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} target=\\"_blank\\" href=\\"/courses/undefined/quests/5/0\\" navigate={[Function: navigate]}>
97-
<a aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} target=\\"_blank\\" href=\\"/courses/undefined/quests/5/0\\" onClick={[Function: onClick]}>
96+
<LinkAnchor aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} target=\\"_blank\\" href=\\"/courses/1/quests/5/0\\" navigate={[Function: navigate]}>
97+
<a aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} target=\\"_blank\\" href=\\"/courses/1/quests/5/0\\" onClick={[Function: onClick]}>
9898
<Blueprint3.Callout className=\\"profile-summary-callout\\" icon=\\"lightbulb\\" title=\\"Closed (fully graded) Sidequest\\">
9999
<div className=\\"bp3-callout bp3-callout-icon profile-summary-callout\\">
100100
<Blueprint3.Icon icon=\\"lightbulb\\" size={20}>
@@ -134,11 +134,11 @@ exports[`Profile renders correctly when there are closed and graded, or closed a
134134
</Link>
135135
</NavLink>
136136
</ProfileCard>
137-
<ProfileCard item={{...}} getFrac={[Function: getFrac]} parseColour={[Function: parseColour]} renderIcon={[Function: renderIcon]} courseId={[undefined]}>
138-
<NavLink className=\\"profile-summary-navlink\\" target=\\"_blank\\" to=\\"/courses/undefined/quests/5/0\\" activeClassName=\\"profile-summary-navlink\\">
137+
<ProfileCard item={{...}} getFrac={[Function: getFrac]} parseColour={[Function: parseColour]} renderIcon={[Function: renderIcon]} courseId={1}>
138+
<NavLink className=\\"profile-summary-navlink\\" target=\\"_blank\\" to=\\"/courses/1/quests/5/0\\" activeClassName=\\"profile-summary-navlink\\">
139139
<Link aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} to={{...}} target=\\"_blank\\">
140-
<LinkAnchor aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} target=\\"_blank\\" href=\\"/courses/undefined/quests/5/0\\" navigate={[Function: navigate]}>
141-
<a aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} target=\\"_blank\\" href=\\"/courses/undefined/quests/5/0\\" onClick={[Function: onClick]}>
140+
<LinkAnchor aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} target=\\"_blank\\" href=\\"/courses/1/quests/5/0\\" navigate={[Function: navigate]}>
141+
<a aria-current={{...}} className=\\"profile-summary-navlink\\" style={[undefined]} target=\\"_blank\\" href=\\"/courses/1/quests/5/0\\" onClick={[Function: onClick]}>
142142
<Blueprint3.Callout className=\\"profile-summary-callout\\" icon=\\"lightbulb\\" title=\\"Ungraded assessment\\">
143143
<div className=\\"bp3-callout bp3-callout-icon profile-summary-callout\\">
144144
<Blueprint3.Icon icon=\\"lightbulb\\" size={20}>
@@ -197,7 +197,7 @@ exports[`Profile renders correctly when there are closed and graded, or closed a
197197
exports[`Profile renders correctly when there are no closed assessments 1`] = `
198198
"<MemoryRouter initialEntries={{...}}>
199199
<Router history={{...}}>
200-
<Profile name=\\"yeet\\" role=\\"student\\" assessmentOverviews={{...}} assessmentTypes={{...}} isOpen={true} handleAssessmentOverviewFetch={[Function: handleAssessmentOverviewFetch]} onClose={[Function: onClose]}>
200+
<Profile name=\\"yeet\\" role=\\"student\\" courseId={1} assessmentOverviews={{...}} assessmentTypes={{...}} isOpen={true} handleAssessmentOverviewFetch={[Function: handleAssessmentOverviewFetch]} onClose={[Function: onClose]}>
201201
<Blueprint3.Drawer className=\\"profile\\" icon=\\"user\\" isCloseButtonShown={true} isOpen={true} onClose={[Function: onClose]} title=\\"User Profile\\" position=\\"left\\" size=\\"360px\\" canOutsideClickClose={true} shouldReturnFocusOnClose={true} style={{...}} vertical={false}>
202202
<Blueprint3.Overlay className=\\"bp3-overlay-container\\" icon=\\"user\\" isCloseButtonShown={true} isOpen={true} onClose={[Function: onClose]} title=\\"User Profile\\" position=\\"left\\" size=\\"360px\\" canOutsideClickClose={true} shouldReturnFocusOnClose={true} style={{...}} vertical={false} onOpening={[Function (anonymous)]} onClosed={[Function (anonymous)]} autoFocus={true} backdropProps={{...}} canEscapeKeyClose={true} enforceFocus={true} hasBackdrop={true} lazy={true} transitionDuration={300} transitionName=\\"bp3-overlay\\" usePortal={true}>
203203
<Blueprint3.Portal className={[undefined]} container={{...}}>

src/commons/sagas/BackendSaga.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,10 @@ function* BackendSaga(): SagaIterator {
170170
yield put(actions.setCourseRegistration(courseRegistration));
171171
yield put(actions.setCourseConfiguration(courseConfiguration));
172172
yield put(actions.setAssessmentConfigurations(assessmentConfigurations));
173-
yield history.push(`/courses/${courseRegistration.courseId}`);
173+
return yield history.push(`/courses/${courseRegistration.courseId}`);
174174
}
175+
176+
return yield history.push(`/welcome`);
175177
});
176178

177179
yield takeEvery(
@@ -724,6 +726,16 @@ function* BackendSaga(): SagaIterator {
724726
return yield showWarningMessage('An error occurred. Please try again.');
725727
}
726728

729+
/**
730+
* setUser updates the Dropdown course selection menu with the updated courses
731+
*
732+
* Setting the role here handles an edge case where a user creates his first ever course.
733+
* Without it, the history.push below would not work as the /courses routes will not be rendered
734+
* (see Application.tsx)
735+
*/
736+
yield put(actions.setUser(user));
737+
yield put(actions.setCourseRegistration({ role: Role.Student }));
738+
727739
const placeholderAssessmentConfig = [
728740
{
729741
type: 'Missions',

0 commit comments

Comments
 (0)