Skip to content

Commit

Permalink
Merge pull request #32437 from code-dot-org/csf-to-non-csf
Browse files Browse the repository at this point in the history
Default to summary when toggling from standards view of csf to non-csf
  • Loading branch information
Erin007 committed Dec 20, 2019
2 parents 52187f7 + 202770b commit 488427b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
20 changes: 17 additions & 3 deletions apps/src/templates/sectionProgress/SectionProgress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
getCurrentProgress,
getCurrentScriptData,
setLessonOfInterest,
scriptDataPropType
scriptDataPropType,
setCurrentView
} from './sectionProgressRedux';
import {tooltipIdForLessonNumber} from './multiGridConstants';
import {sectionDataPropType} from '@cdo/apps/redux/sectionDataRedux';
Expand Down Expand Up @@ -71,6 +72,7 @@ class SectionProgress extends Component {
section: sectionDataPropType.isRequired,
validScripts: PropTypes.arrayOf(validScriptPropType).isRequired,
currentView: PropTypes.oneOf(Object.values(ViewType)),
setCurrentView: PropTypes.func.isRequired,
scriptData: scriptDataPropType,
loadScript: PropTypes.func.isRequired,
setScriptId: PropTypes.func.isRequired,
Expand All @@ -83,6 +85,16 @@ class SectionProgress extends Component {
this.props.loadScript(this.props.scriptId);
}

componentDidUpdate() {
// Check if we are on a non-CSF script and
// currentView is Standards. If so re-set currentView to Summary since
// Standards doesn't apply.
const isCSF = this.props.scriptData && this.props.scriptData.csf;
if (this.props.currentView === ViewType.STANDARDS && !isCSF) {
this.props.setCurrentView(ViewType.SUMMARY);
}
}

onChangeScript = scriptId => {
this.props.setScriptId(scriptId);
this.props.loadScript(scriptId);
Expand Down Expand Up @@ -150,8 +162,7 @@ class SectionProgress extends Component {

const levelDataInitialized = scriptData && !isLoadingProgress;
const lessons = scriptData ? scriptData.stages : [];
const csfCourseSelected =
levelDataInitialized && !scriptData.excludeCsfColumnInLegend;
const csfCourseSelected = levelDataInitialized && scriptData.csf;
const summaryStyle =
currentView === ViewType.SUMMARY ? styles.show : styles.hide;
const detailStyle =
Expand Down Expand Up @@ -239,6 +250,9 @@ export default connect(
},
setLessonOfInterest(lessonOfInterest) {
dispatch(setLessonOfInterest(lessonOfInterest));
},
setCurrentView(viewType) {
dispatch(setCurrentView(viewType));
}
})
)(SectionProgress);
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('SectionProgress', () => {
beforeEach(() => {
DEFAULT_PROPS = {
setLessonOfInterest: () => {},
setCurrentView: () => {},
loadScript: () => {},
setScriptId: () => {},
scriptId: 1,
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/models/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ def summarize(include_stages = true, user = nil, include_bonus_levels = false)
hideable_stages: hideable_stages?,
disablePostMilestone: disable_post_milestone?,
isHocScript: hoc?,
isCSF: csf?,
csf: csf?,
peerReviewsRequired: peer_reviews_to_complete || 0,
peerReviewStage: peer_review_stage,
student_detail_progress_view: student_detail_progress_view?,
Expand Down

0 comments on commit 488427b

Please sign in to comment.