Merge pull request #10104 from BerkeleyTrue/fix/challenge-page-title

Fix(meta): challenge should use challenge title for page title
This commit is contained in:
Mrugesh Mohapatra
2016-08-06 17:20:13 +05:30
committed by GitHub
2 changed files with 10 additions and 3 deletions

View File

@ -39,7 +39,8 @@ const mapStateToProps = createSelector(
challengeSelector, challengeSelector,
state => state.challengesApp.challenge, state => state.challengesApp.challenge,
state => state.challengesApp.superBlocks, state => state.challengesApp.superBlocks,
({ viewType }, challenge, superBlocks = []) => ({ ({ challenge: { title } = {}, viewType }, challenge, superBlocks = []) => ({
title,
challenge, challenge,
viewType, viewType,
areChallengesLoaded: superBlocks.length > 0 areChallengesLoaded: superBlocks.length > 0
@ -60,6 +61,7 @@ export class Challenges extends PureComponent {
static displayName = 'Challenges'; static displayName = 'Challenges';
static propTypes = { static propTypes = {
title: PropTypes.string,
isStep: PropTypes.bool, isStep: PropTypes.bool,
fetchChallenges: PropTypes.func.isRequired, fetchChallenges: PropTypes.func.isRequired,
replaceChallenge: PropTypes.func.isRequired, replaceChallenge: PropTypes.func.isRequired,
@ -70,7 +72,7 @@ export class Challenges extends PureComponent {
}; };
componentWillMount() { componentWillMount() {
this.props.updateTitle(this.props.params.dashedName); this.props.updateTitle(this.props.title);
} }
componentDidMount() { componentDidMount() {
@ -87,7 +89,7 @@ export class Challenges extends PureComponent {
const { block, dashedName } = nextProps.params; const { block, dashedName } = nextProps.params;
const { resetUi, updateTitle, replaceChallenge } = this.props; const { resetUi, updateTitle, replaceChallenge } = this.props;
if (this.props.params.dashedName !== dashedName) { if (this.props.params.dashedName !== dashedName) {
updateTitle(dashedName); updateTitle(nextProps.title);
resetUi(); resetUi();
replaceChallenge({ dashedName, block }); replaceChallenge({ dashedName, block });
} }

View File

@ -37,6 +37,11 @@ export class ShowMap extends PureComponent {
}; };
componentWillMount() { componentWillMount() {
// if no params then map is open in drawer
// do not update title
if (!this.props.params) {
return;
}
this.props.updateTitle( this.props.updateTitle(
'A Map to Learn to Code and Become a Software Engineer' 'A Map to Learn to Code and Become a Software Engineer'
); );