feat: hide isHidden challenges
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
d865e2cb0e
commit
68aef571ee
@ -78,6 +78,7 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
|
|||||||
node {
|
node {
|
||||||
block
|
block
|
||||||
challengeType
|
challengeType
|
||||||
|
isHidden
|
||||||
fields {
|
fields {
|
||||||
slug
|
slug
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,12 @@ export class SuperBlock extends Component {
|
|||||||
const blocksForSuperBlock = nodes.filter(
|
const blocksForSuperBlock = nodes.filter(
|
||||||
node => node.superBlock === superBlock
|
node => node.superBlock === superBlock
|
||||||
);
|
);
|
||||||
|
// since the nodes have been filtered based on isHidden, any blocks whose
|
||||||
|
// nodes have been entirely removed will not appear in this array.
|
||||||
const blockDashedNames = uniq(
|
const blockDashedNames = uniq(
|
||||||
blocksForSuperBlock.map(({ block }) => block)
|
blocksForSuperBlock.map(({ block }) => block)
|
||||||
);
|
);
|
||||||
|
// render all non-empty blocks
|
||||||
return (
|
return (
|
||||||
<ul>
|
<ul>
|
||||||
{blockDashedNames.map(blockDashedName => (
|
{blockDashedNames.map(blockDashedName => (
|
||||||
|
@ -111,6 +111,8 @@ export class Map extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { nodes } = this.props;
|
const { nodes } = this.props;
|
||||||
|
// if a given superBlock's nodes have been filtered (via isHidden, say) that
|
||||||
|
// superBlock will not appear in superBlocks and will not be rendered.
|
||||||
const superBlocks = uniq(nodes.map(({ superBlock }) => superBlock));
|
const superBlocks = uniq(nodes.map(({ superBlock }) => superBlock));
|
||||||
return (
|
return (
|
||||||
<Row>
|
<Row>
|
||||||
|
@ -101,7 +101,7 @@ export const LearnPage = ({
|
|||||||
isSignedIn={isSignedIn}
|
isSignedIn={isSignedIn}
|
||||||
nodes={edges
|
nodes={edges
|
||||||
.map(({ node }) => node)
|
.map(({ node }) => node)
|
||||||
.filter(({ isPrivate }) => !isPrivate)}
|
.filter(({ isPrivate, isHidden }) => !isPrivate && !isHidden)}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</LearnLayout>
|
</LearnLayout>
|
||||||
@ -136,6 +136,7 @@ export const query = graphql`
|
|||||||
isRequired
|
isRequired
|
||||||
superBlock
|
superBlock
|
||||||
dashedName
|
dashedName
|
||||||
|
isHidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ export const ChallengeNode = PropTypes.shape({
|
|||||||
guideUrl: PropTypes.string,
|
guideUrl: PropTypes.string,
|
||||||
head: PropTypes.arrayOf(PropTypes.string),
|
head: PropTypes.arrayOf(PropTypes.string),
|
||||||
instructions: PropTypes.string,
|
instructions: PropTypes.string,
|
||||||
isBeta: PropTypes.bool,
|
isHidden: PropTypes.bool,
|
||||||
isComingSoon: PropTypes.bool,
|
isComingSoon: PropTypes.bool,
|
||||||
isLocked: PropTypes.bool,
|
isLocked: PropTypes.bool,
|
||||||
isPrivate: PropTypes.bool,
|
isPrivate: PropTypes.bool,
|
||||||
|
@ -67,9 +67,12 @@ exports.createChallengePages = createPage => ({ node }, index, thisArray) => {
|
|||||||
required = [],
|
required = [],
|
||||||
template,
|
template,
|
||||||
challengeType,
|
challengeType,
|
||||||
id
|
id,
|
||||||
|
isHidden
|
||||||
} = node;
|
} = node;
|
||||||
if (challengeType === 7) {
|
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we
|
||||||
|
// should remove one of them.
|
||||||
|
if (challengeType === 7 || isHidden) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,9 +127,6 @@ async function createChallenge(fullPath, maybeMeta) {
|
|||||||
challenge.required = required.concat(challenge.required || []);
|
challenge.required = required.concat(challenge.required || []);
|
||||||
challenge.template = template;
|
challenge.template = template;
|
||||||
challenge.time = time;
|
challenge.time = time;
|
||||||
// isBeta should default to true, so if it is missing, set it to be true
|
|
||||||
// eslint-disable-next-line no-undefined
|
|
||||||
challenge.isBeta = challenge.isBeta === undefined ? true : challenge.isBeta;
|
|
||||||
|
|
||||||
return challenge;
|
return challenge;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ function getSchemaForLang(lang) {
|
|||||||
helpRoom: Joi.string(),
|
helpRoom: Joi.string(),
|
||||||
id: Joi.objectId().required(),
|
id: Joi.objectId().required(),
|
||||||
instructions: Joi.string().allow(''),
|
instructions: Joi.string().allow(''),
|
||||||
isBeta: Joi.bool(),
|
isHidden: Joi.bool().required(),
|
||||||
isComingSoon: Joi.bool(),
|
isComingSoon: Joi.bool(),
|
||||||
isLocked: Joi.bool(),
|
isLocked: Joi.bool(),
|
||||||
isPrivate: Joi.bool(),
|
isPrivate: Joi.bool(),
|
||||||
|
Reference in New Issue
Block a user