mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-27 11:01:38 -04:00
fix(curriculum): hide upcoming blocks (#60684)
Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Build a Color Picker App",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"usesMultifileEditor": true,
|
||||
"dashedName": "lab-color-picker",
|
||||
"superBlock": "full-stack-developer",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
}
|
||||
],
|
||||
"helpCategory": "JavaScript",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"blockLayout": "link",
|
||||
"blockType": "lab"
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
}
|
||||
],
|
||||
"helpCategory": "JavaScript",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"blockLayout": "link",
|
||||
"blockType": "lab"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
}
|
||||
],
|
||||
"helpCategory": "JavaScript",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"blockLayout": "link",
|
||||
"blockType": "lab"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "Build a Shopping List App",
|
||||
"blockType": "workshop",
|
||||
"blockLayout": "challenge-grid",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"usesMultifileEditor": true,
|
||||
"hasEditableBoundaries": true,
|
||||
"dashedName": "workshop-shopping-list-app",
|
||||
|
||||
@@ -383,14 +383,31 @@ function generateChallengeCreator(lang, englishPath, i18nPath) {
|
||||
function addMetaToChallenge(challenge, meta) {
|
||||
function addChapterAndModuleToChallenge(challenge) {
|
||||
if (chapterBasedSuperBlocks.includes(challenge.superBlock)) {
|
||||
challenge.chapter = getChapterFromBlock(
|
||||
const chapter = getChapterFromBlock(
|
||||
challenge.block,
|
||||
fullStackSuperBlockStructure
|
||||
);
|
||||
challenge.module = getModuleFromBlock(
|
||||
|
||||
if (!meta.isUpcomingChange && chapter.comingSoon) {
|
||||
throw Error(
|
||||
`The '${chapter.dashedName}' chapter is 'comingSoon', but its '${meta.dashedName}' block is not hidden. Set 'isUpcomingChange' to 'true' in the 'meta.json' for the block to hide it.`
|
||||
);
|
||||
}
|
||||
|
||||
challenge.chapter = chapter.dashedName;
|
||||
|
||||
const module = getModuleFromBlock(
|
||||
challenge.block,
|
||||
fullStackSuperBlockStructure
|
||||
);
|
||||
|
||||
if (!meta.isUpcomingChange && module.comingSoon) {
|
||||
throw Error(
|
||||
`The '${chapter.dashedName}' module is 'comingSoon', but its '${meta.dashedName}' block is not hidden. Set 'isUpcomingChange' to 'true' in the 'meta.json' for the block to hide it.`
|
||||
);
|
||||
}
|
||||
|
||||
challenge.module = module.dashedName;
|
||||
}
|
||||
}
|
||||
const challengeOrder = findIndex(
|
||||
|
||||
@@ -110,7 +110,7 @@ function getChapterFromBlock(blockName, superBlockStructure) {
|
||||
`There is no chapter corresponding to block "${blockName}". It's possible that the block is missing in the superblock structure.`
|
||||
);
|
||||
}
|
||||
return chapter.dashedName;
|
||||
return { dashedName: chapter.dashedName, comingSoon: chapter.comingSoon };
|
||||
}
|
||||
|
||||
function getModuleFromBlock(blockName, superBlockStructure) {
|
||||
@@ -125,7 +125,7 @@ function getModuleFromBlock(blockName, superBlockStructure) {
|
||||
`There is no module corresponding to block "${blockName}". It's possible that the block is missing in the superblock structure.`
|
||||
);
|
||||
}
|
||||
return module.dashedName;
|
||||
return { dashedName: module.dashedName, comingSoon: module.comingSoon };
|
||||
}
|
||||
|
||||
function getBlockOrder(blockName, superBlockStructure) {
|
||||
|
||||
@@ -74,6 +74,7 @@ const mockSuperBlockStructure = {
|
||||
},
|
||||
{
|
||||
dashedName: 'css',
|
||||
comingSoon: true,
|
||||
modules: [
|
||||
{
|
||||
dashedName: 'module-one',
|
||||
@@ -88,6 +89,7 @@ const mockSuperBlockStructure = {
|
||||
},
|
||||
{
|
||||
dashedName: 'module-two',
|
||||
comingSoon: true,
|
||||
blocks: [
|
||||
{
|
||||
dashedName: 'block-one-m2'
|
||||
@@ -218,8 +220,8 @@ describe('getSuperBlockFromPath', () => {
|
||||
describe('getChapterFromBlock', () => {
|
||||
it('returns a chapter if it exists', () => {
|
||||
expect(
|
||||
getChapterFromBlock('welcome-to-freecodecamp', mockSuperBlockStructure)
|
||||
).toEqual('html');
|
||||
getChapterFromBlock('block-one-m1', mockSuperBlockStructure)
|
||||
).toStrictEqual({ dashedName: 'css', comingSoon: true });
|
||||
});
|
||||
|
||||
it('throws if a chapter does not exist', () => {
|
||||
@@ -235,7 +237,10 @@ describe('getModuleFromBlock', () => {
|
||||
it('returns a module if it exists', () => {
|
||||
expect(
|
||||
getModuleFromBlock('welcome-to-freecodecamp', mockSuperBlockStructure)
|
||||
).toEqual('getting-started-with-freecodecamp');
|
||||
).toStrictEqual({
|
||||
dashedName: 'getting-started-with-freecodecamp',
|
||||
comingSoon: undefined
|
||||
});
|
||||
});
|
||||
|
||||
it('throws if a module does not exist', () => {
|
||||
|
||||
Reference in New Issue
Block a user