refactor: remove release code (#57957)

This commit is contained in:
Oliver Eyton-Williams
2025-01-06 17:44:57 +01:00
committed by GitHub
parent be6736f5df
commit d68cbdb2c4
16 changed files with 35 additions and 177 deletions
+5 -25
View File
@@ -5,10 +5,6 @@ const uniq = require('lodash/uniq');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const webpack = require('webpack'); const webpack = require('webpack');
const {
superBlockStages,
SuperBlockStage
} = require('../shared/config/curriculum');
const env = require('./config/env.json'); const env = require('./config/env.json');
const { const {
createChallengePages, createChallengePages,
@@ -143,14 +139,6 @@ exports.createPages = async function createPages({
({ node }) => node ({ node }) => node
); );
const inCurrentCurriculum = superBlock =>
!superBlockStages[SuperBlockStage.Next].includes(superBlock) &&
!superBlockStages[SuperBlockStage.NextEnglish].includes(superBlock);
const currentChallengeNodes = allChallengeNodes.filter(node =>
inCurrentCurriculum(node.challenge.superBlock)
);
const createIdToNextPathMap = nodes => const createIdToNextPathMap = nodes =>
nodes.reduce((map, node, index) => { nodes.reduce((map, node, index) => {
const nextNode = nodes[index + 1]; const nextNode = nodes[index + 1];
@@ -167,25 +155,17 @@ exports.createPages = async function createPages({
return map; return map;
}, {}); }, {});
const idToNextPathCurrentCurriculum = createIdToNextPathMap( const idToNextPathCurrentCurriculum =
currentChallengeNodes createIdToNextPathMap(allChallengeNodes);
);
const idToPrevPathCurrentCurriculum = createIdToPrevPathMap( const idToPrevPathCurrentCurriculum =
currentChallengeNodes createIdToPrevPathMap(allChallengeNodes);
);
const idToNextPathNextCurriculum = createIdToNextPathMap(allChallengeNodes);
const idToPrevPathNextCurriculum = createIdToPrevPathMap(allChallengeNodes);
// Create challenge pages. // Create challenge pages.
result.data.allChallengeNode.edges.forEach( result.data.allChallengeNode.edges.forEach(
createChallengePages(createPage, { createChallengePages(createPage, {
idToNextPathCurrentCurriculum, idToNextPathCurrentCurriculum,
idToPrevPathCurrentCurriculum, idToPrevPathCurrentCurriculum
idToNextPathNextCurriculum,
idToPrevPathNextCurriculum
}) })
); );
+1 -4
View File
@@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { Spacer } from '@freecodecamp/ui'; import { Spacer } from '@freecodecamp/ui';
import { useFeature } from '@growthbook/growthbook-react';
import { import {
type SuperBlocks, type SuperBlocks,
@@ -139,7 +138,6 @@ function Map({
allChallenges allChallenges
}: MapProps): React.ReactElement { }: MapProps): React.ReactElement {
const { t } = useTranslation(); const { t } = useTranslation();
const showNextCurriculum = useFeature('fcc-10').on;
const allSuperblockChallengesCompleted = (superblock: SuperBlocks) => { const allSuperblockChallengesCompleted = (superblock: SuperBlocks) => {
// array of all challenge ID's in the superblock // array of all challenge ID's in the superblock
@@ -168,8 +166,7 @@ function Map({
<div className='map-ui' data-test-label='curriculum-map'> <div className='map-ui' data-test-label='curriculum-map'>
{getStageOrder({ {getStageOrder({
showNewCurriculum, showNewCurriculum,
showUpcomingChanges, showUpcomingChanges
showNextCurriculum
}).map(stage => ( }).map(stage => (
<Fragment key={stage}> <Fragment key={stage}>
<h2 className={forLanding ? 'big-heading' : ''}> <h2 className={forLanding ? 'big-heading' : ''}>
@@ -21,7 +21,6 @@ import {
ChallengeMeta, ChallengeMeta,
ChallengeNode, ChallengeNode,
CompletedChallenge, CompletedChallenge,
NavigationPaths,
ResizeProps, ResizeProps,
SavedChallengeFiles, SavedChallengeFiles,
Test Test
@@ -113,7 +112,6 @@ interface ShowClassicProps extends Pick<PreviewProps, 'previewMounted'> {
output: string[]; output: string[];
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
projectPreview: { projectPreview: {
challengeData: CompletedChallenge; challengeData: CompletedChallenge;
}; };
@@ -208,7 +206,6 @@ function ShowClassic({
pageContext: { pageContext: {
challengeMeta, challengeMeta,
challengeMeta: { isFirstStep, nextChallengePath }, challengeMeta: { isFirstStep, nextChallengePath },
nextCurriculumPaths,
projectPreview: { challengeData } projectPreview: { challengeData }
}, },
createFiles, createFiles,
@@ -236,7 +233,6 @@ function ShowClassic({
const isMobile = useMediaQuery({ const isMobile = useMediaQuery({
query: `(max-width: ${MAX_MOBILE_WIDTH}px)` query: `(max-width: ${MAX_MOBILE_WIDTH}px)`
}); });
const showNextCurriculum = useFeature('fcc-10').on;
const guideUrl = getGuideUrl({ forumTopicId, title }); const guideUrl = getGuideUrl({ forumTopicId, title });
@@ -378,9 +374,7 @@ function ShowClassic({
// freeform, so the preview is shown on demand. // freeform, so the preview is shown on demand.
if (demoType === 'onLoad') openModal('projectPreview'); if (demoType === 'onLoad') openModal('projectPreview');
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
@@ -9,7 +9,6 @@ import { bindActionCreators } from 'redux';
import type { Dispatch } from 'redux'; import type { Dispatch } from 'redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { Container, Col, Row, Alert, Spacer } from '@freecodecamp/ui'; import { Container, Col, Row, Alert, Spacer } from '@freecodecamp/ui';
import { useFeature } from '@growthbook/growthbook-react';
// Local Utilities // Local Utilities
import LearnLayout from '../../../components/layouts/learn'; import LearnLayout from '../../../components/layouts/learn';
@@ -40,7 +39,6 @@ import {
ChallengeNode, ChallengeNode,
ChallengeMeta, ChallengeMeta,
CompletedChallenge, CompletedChallenge,
NavigationPaths,
Test Test
} from '../../../redux/prop-types'; } from '../../../redux/prop-types';
import ProjectToolPanel from '../projects/tool-panel'; import ProjectToolPanel from '../projects/tool-panel';
@@ -102,7 +100,6 @@ interface ShowCodeAllyProps {
openCompletionModal: () => void; openCompletionModal: () => void;
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
}; };
partiallyCompletedChallenges: CompletedChallenge[]; partiallyCompletedChallenges: CompletedChallenge[];
t: TFunction; t: TFunction;
@@ -115,8 +112,6 @@ interface ShowCodeAllyProps {
function ShowCodeAlly(props: ShowCodeAllyProps) { function ShowCodeAlly(props: ShowCodeAllyProps) {
const container = useRef<HTMLElement>(null); const container = useRef<HTMLElement>(null);
const showNextCurriculum = useFeature('fcc-10').on;
const { const {
completedChallenges, completedChallenges,
data: { data: {
@@ -136,7 +131,6 @@ function ShowCodeAlly(props: ShowCodeAllyProps) {
}, },
isChallengeCompleted, isChallengeCompleted,
isSignedIn, isSignedIn,
pageContext: { nextCurriculumPaths },
partiallyCompletedChallenges, partiallyCompletedChallenges,
t, t,
updateSolutionFormValues updateSolutionFormValues
@@ -174,9 +168,7 @@ function ShowCodeAlly(props: ShowCodeAllyProps) {
} = props; } = props;
initTests(tests); initTests(tests);
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
@@ -11,7 +11,6 @@ import type { Dispatch } from 'redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { Container, Col, Alert, Row, Button, Spacer } from '@freecodecamp/ui'; import { Container, Col, Alert, Row, Button, Spacer } from '@freecodecamp/ui';
import { micromark } from 'micromark'; import { micromark } from 'micromark';
import { useFeature } from '@growthbook/growthbook-react';
// Local Utilities // Local Utilities
import LearnLayout from '../../../components/layouts/learn'; import LearnLayout from '../../../components/layouts/learn';
@@ -47,7 +46,6 @@ import {
CompletedChallenge, CompletedChallenge,
UserExamQuestion, UserExamQuestion,
UserExam, UserExam,
NavigationPaths,
GeneratedExamResults, GeneratedExamResults,
GeneratedExamQuestion, GeneratedExamQuestion,
PrerequisiteChallenge, PrerequisiteChallenge,
@@ -130,7 +128,6 @@ interface ShowExamProps {
closeFinishExamModal: () => void; closeFinishExamModal: () => void;
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
}; };
t: TFunction; t: TFunction;
startExam: () => void; startExam: () => void;
@@ -168,13 +165,11 @@ function ShowExam(props: ShowExamProps) {
isChallengeCompleted, isChallengeCompleted,
openExitExamModal, openExitExamModal,
openFinishExamModal, openFinishExamModal,
pageContext: { nextCurriculumPaths },
t t
} = props; } = props;
let timerInterval: NodeJS.Timeout; let timerInterval: NodeJS.Timeout;
const showNextCurriculum = useFeature('fcc-10').on;
const container = useRef<HTMLElement>(null); const container = useRef<HTMLElement>(null);
const [examTimeInSeconds, setExamTimeInSeconds] = useState(0); const [examTimeInSeconds, setExamTimeInSeconds] = useState(0);
@@ -205,9 +200,7 @@ function ShowExam(props: ShowExamProps) {
} = props; } = props;
initTests(tests); initTests(tests);
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
@@ -1,7 +1,6 @@
// Package Utilities // Package Utilities
import { graphql } from 'gatsby'; import { graphql } from 'gatsby';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { useFeature } from '@growthbook/growthbook-react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { ObserveKeys } from 'react-hotkeys'; import { ObserveKeys } from 'react-hotkeys';
import type { TFunction } from 'i18next'; import type { TFunction } from 'i18next';
@@ -15,12 +14,7 @@ import ShortcutsModal from '../components/shortcuts-modal';
// Local Utilities // Local Utilities
import LearnLayout from '../../../components/layouts/learn'; import LearnLayout from '../../../components/layouts/learn';
import { import { ChallengeNode, ChallengeMeta, Test } from '../../../redux/prop-types';
ChallengeNode,
ChallengeMeta,
NavigationPaths,
Test
} from '../../../redux/prop-types';
import Hotkeys from '../components/hotkeys'; import Hotkeys from '../components/hotkeys';
import ChallengeTitle from '../components/challenge-title'; import ChallengeTitle from '../components/challenge-title';
import ChallegeExplanation from '../components/challenge-explanation'; import ChallegeExplanation from '../components/challenge-explanation';
@@ -72,7 +66,6 @@ interface ShowFillInTheBlankProps {
openHelpModal: () => void; openHelpModal: () => void;
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
}; };
t: TFunction; t: TFunction;
updateChallengeMeta: (arg0: ChallengeMeta) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
@@ -102,7 +95,7 @@ const ShowFillInTheBlank = ({
openHelpModal, openHelpModal,
updateChallengeMeta, updateChallengeMeta,
openCompletionModal, openCompletionModal,
pageContext: { challengeMeta, nextCurriculumPaths }, pageContext: { challengeMeta },
isChallengeCompleted isChallengeCompleted
}: ShowFillInTheBlankProps) => { }: ShowFillInTheBlankProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -117,14 +110,11 @@ const ShowFillInTheBlank = ({
const [showFeedback, setShowFeedback] = useState(false); const [showFeedback, setShowFeedback] = useState(false);
const container = useRef<HTMLElement | null>(null); const container = useRef<HTMLElement | null>(null);
const showNextCurriculum = useFeature('fcc-10').on;
useEffect(() => { useEffect(() => {
initTests(tests); initTests(tests);
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
@@ -1,6 +1,5 @@
import { graphql } from 'gatsby'; import { graphql } from 'gatsby';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { useFeature } from '@growthbook/growthbook-react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
@@ -9,12 +8,7 @@ import { isEqual } from 'lodash';
// Local Utilities // Local Utilities
import LearnLayout from '../../../components/layouts/learn'; import LearnLayout from '../../../components/layouts/learn';
import { import { ChallengeNode, ChallengeMeta, Test } from '../../../redux/prop-types';
ChallengeNode,
ChallengeMeta,
NavigationPaths,
Test
} from '../../../redux/prop-types';
import ChallengeDescription from '../components/challenge-description'; import ChallengeDescription from '../components/challenge-description';
import Hotkeys from '../components/hotkeys'; import Hotkeys from '../components/hotkeys';
import ChallengeTitle from '../components/challenge-title'; import ChallengeTitle from '../components/challenge-title';
@@ -66,7 +60,6 @@ interface ShowQuizProps {
openHelpModal: () => void; openHelpModal: () => void;
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
}; };
updateChallengeMeta: (arg0: ChallengeMeta) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
updateSolutionFormValues: () => void; updateSolutionFormValues: () => void;
@@ -97,7 +90,7 @@ const ShowGeneric = ({
} }
} }
}, },
pageContext: { challengeMeta, nextCurriculumPaths }, pageContext: { challengeMeta },
initTests, initTests,
updateChallengeMeta, updateChallengeMeta,
openCompletionModal, openCompletionModal,
@@ -114,9 +107,7 @@ const ShowGeneric = ({
useEffect(() => { useEffect(() => {
initTests(tests); initTests(tests);
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
@@ -161,8 +152,6 @@ const ShowGeneric = ({
const [showFeedback, setShowFeedback] = useState(false); const [showFeedback, setShowFeedback] = useState(false);
const showNextCurriculum = useFeature('fcc-10').on;
const handleMcqOptionChange = ( const handleMcqOptionChange = (
questionIndex: number, questionIndex: number,
answerIndex: number answerIndex: number
@@ -7,16 +7,10 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import type { Dispatch } from 'redux'; import type { Dispatch } from 'redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { useFeature } from '@growthbook/growthbook-react';
import { Container, Col, Row, Button, Spacer } from '@freecodecamp/ui'; import { Container, Col, Row, Button, Spacer } from '@freecodecamp/ui';
import LearnLayout from '../../../components/layouts/learn'; import LearnLayout from '../../../components/layouts/learn';
import { import { ChallengeNode, ChallengeMeta, Test } from '../../../redux/prop-types';
ChallengeNode,
ChallengeMeta,
NavigationPaths,
Test
} from '../../../redux/prop-types';
import ChallengeDescription from '../components/challenge-description'; import ChallengeDescription from '../components/challenge-description';
import Hotkeys from '../components/hotkeys'; import Hotkeys from '../components/hotkeys';
import ChallengeTitle from '../components/challenge-title'; import ChallengeTitle from '../components/challenge-title';
@@ -83,7 +77,6 @@ interface MsTrophyProps {
openHelpModal: () => void; openHelpModal: () => void;
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
}; };
submitChallenge: () => void; submitChallenge: () => void;
t: TFunction; t: TFunction;
@@ -91,7 +84,6 @@ interface MsTrophyProps {
} }
function MsTrophy(props: MsTrophyProps) { function MsTrophy(props: MsTrophyProps) {
const showNextCurriculum = useFeature('fcc-10').on;
const container = useRef<HTMLElement>(null); const container = useRef<HTMLElement>(null);
const { const {
data: { data: {
@@ -113,15 +105,13 @@ function MsTrophy(props: MsTrophyProps) {
} }
} }
}, },
pageContext: { challengeMeta, nextCurriculumPaths }, pageContext: { challengeMeta },
initTests, initTests,
updateChallengeMeta updateChallengeMeta
} = props; } = props;
initTests(tests); initTests(tests);
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
@@ -6,14 +6,12 @@ import type { TFunction } from 'i18next';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { Container, Col, Row, Spacer } from '@freecodecamp/ui'; import { Container, Col, Row, Spacer } from '@freecodecamp/ui';
import { useFeature } from '@growthbook/growthbook-react';
import LearnLayout from '../../../../components/layouts/learn'; import LearnLayout from '../../../../components/layouts/learn';
import { isSignedInSelector } from '../../../../redux/selectors'; import { isSignedInSelector } from '../../../../redux/selectors';
import { import {
ChallengeMeta, ChallengeMeta,
ChallengeNode, ChallengeNode,
NavigationPaths,
Test Test
} from '../../../../redux/prop-types'; } from '../../../../redux/prop-types';
import ChallengeDescription from '../../components/challenge-description'; import ChallengeDescription from '../../components/challenge-description';
@@ -87,7 +85,6 @@ interface BackEndProps {
output: string[]; output: string[];
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
}; };
t: TFunction; t: TFunction;
tests: Test[]; tests: Test[];
@@ -97,7 +94,6 @@ interface BackEndProps {
} }
const ShowBackEnd = (props: BackEndProps) => { const ShowBackEnd = (props: BackEndProps) => {
const showNextCurriculum = useFeature('fcc-10').on;
const container = useRef<HTMLElement>(null); const container = useRef<HTMLElement>(null);
const handleSubmit = ({ const handleSubmit = ({
@@ -124,14 +120,12 @@ const ShowBackEnd = (props: BackEndProps) => {
} }
} }
}, },
pageContext: { challengeMeta, nextCurriculumPaths } pageContext: { challengeMeta }
} = props; } = props;
initConsole(); initConsole();
initTests(tests); initTests(tests);
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
@@ -8,13 +8,11 @@ import { bindActionCreators } from 'redux';
import type { Dispatch } from 'redux'; import type { Dispatch } from 'redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { Container, Col, Row, Spacer } from '@freecodecamp/ui'; import { Container, Col, Row, Spacer } from '@freecodecamp/ui';
import { useFeature } from '@growthbook/growthbook-react';
import LearnLayout from '../../../../components/layouts/learn'; import LearnLayout from '../../../../components/layouts/learn';
import { import {
ChallengeNode, ChallengeNode,
ChallengeMeta, ChallengeMeta,
NavigationPaths,
Test Test
} from '../../../../redux/prop-types'; } from '../../../../redux/prop-types';
import ChallengeDescription from '../../components/challenge-description'; import ChallengeDescription from '../../components/challenge-description';
@@ -64,7 +62,6 @@ interface ProjectProps {
openCompletionModal: () => void; openCompletionModal: () => void;
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
}; };
t: TFunction; t: TFunction;
updateChallengeMeta: (arg0: ChallengeMeta) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
@@ -82,7 +79,6 @@ const ShowFrontEndProject = (props: ProjectProps) => {
} }
}; };
const showNextCurriculum = useFeature('fcc-10').on;
const container = useRef<HTMLElement>(null); const container = useRef<HTMLElement>(null);
useEffect(() => { useEffect(() => {
@@ -93,15 +89,13 @@ const ShowFrontEndProject = (props: ProjectProps) => {
challenge: { fields, title, challengeType, helpCategory } challenge: { fields, title, challengeType, helpCategory }
} }
}, },
pageContext: { challengeMeta, nextCurriculumPaths }, pageContext: { challengeMeta },
initTests, initTests,
updateChallengeMeta updateChallengeMeta
} = props; } = props;
initTests(fields.tests); initTests(fields.tests);
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
+3 -13
View File
@@ -17,17 +17,11 @@ import {
useQuiz, useQuiz,
Spacer Spacer
} from '@freecodecamp/ui'; } from '@freecodecamp/ui';
import { useFeature } from '@growthbook/growthbook-react';
// Local Utilities // Local Utilities
import { shuffleArray } from '../../../../../shared/utils/shuffle-array'; import { shuffleArray } from '../../../../../shared/utils/shuffle-array';
import LearnLayout from '../../../components/layouts/learn'; import LearnLayout from '../../../components/layouts/learn';
import { import { ChallengeNode, ChallengeMeta, Test } from '../../../redux/prop-types';
ChallengeNode,
ChallengeMeta,
NavigationPaths,
Test
} from '../../../redux/prop-types';
import ChallengeDescription from '../components/challenge-description'; import ChallengeDescription from '../components/challenge-description';
import Hotkeys from '../components/hotkeys'; import Hotkeys from '../components/hotkeys';
import ChallengeTitle from '../components/challenge-title'; import ChallengeTitle from '../components/challenge-title';
@@ -81,7 +75,6 @@ interface ShowQuizProps {
isChallengeCompleted: boolean; isChallengeCompleted: boolean;
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
nextCurriculumPaths: NavigationPaths;
}; };
updateChallengeMeta: (arg0: ChallengeMeta) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
updateSolutionFormValues: () => void; updateSolutionFormValues: () => void;
@@ -109,7 +102,7 @@ const ShowQuiz = ({
} }
} }
}, },
pageContext: { challengeMeta, nextCurriculumPaths }, pageContext: { challengeMeta },
initTests, initTests,
updateChallengeMeta, updateChallengeMeta,
isChallengeCompleted, isChallengeCompleted,
@@ -134,7 +127,6 @@ const ShowQuiz = ({
const [showUnanswered, setShowUnanswered] = useState(false); const [showUnanswered, setShowUnanswered] = useState(false);
const [exitConfirmed, setExitConfirmed] = useState(false); const [exitConfirmed, setExitConfirmed] = useState(false);
const showNextCurriculum = useFeature('fcc-10').on;
const blockNameTitle = `${t( const blockNameTitle = `${t(
`intro:${superBlock}.blocks.${block}.title` `intro:${superBlock}.blocks.${block}.title`
@@ -199,9 +191,7 @@ const ShowQuiz = ({
useEffect(() => { useEffect(() => {
initTests(tests); initTests(tests);
const challengePaths = getChallengePaths({ const challengePaths = getChallengePaths({
showNextCurriculum, currentCurriculumPaths: challengeMeta
currentCurriculumPaths: challengeMeta,
nextCurriculumPaths
}); });
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
@@ -1,23 +1,12 @@
import { NavigationPaths } from '../../../redux/prop-types'; import { NavigationPaths } from '../../../redux/prop-types';
export const getChallengePaths = ({ export const getChallengePaths = ({
showNextCurriculum, currentCurriculumPaths
currentCurriculumPaths,
nextCurriculumPaths
}: { }: {
showNextCurriculum: boolean;
currentCurriculumPaths: NavigationPaths; currentCurriculumPaths: NavigationPaths;
nextCurriculumPaths: NavigationPaths;
}): NavigationPaths => { }): NavigationPaths => {
const nextChallengePath = showNextCurriculum
? nextCurriculumPaths.nextChallengePath
: currentCurriculumPaths.nextChallengePath;
const prevChallengePath = showNextCurriculum
? nextCurriculumPaths.prevChallengePath
: currentCurriculumPaths.prevChallengePath;
return { return {
nextChallengePath, nextChallengePath: currentCurriculumPaths.nextChallengePath,
prevChallengePath prevChallengePath: currentCurriculumPaths.prevChallengePath
}; };
}; };
+1 -10
View File
@@ -78,12 +78,7 @@ function getTemplateComponent(challengeType) {
exports.createChallengePages = function ( exports.createChallengePages = function (
createPage, createPage,
{ { idToNextPathCurrentCurriculum, idToPrevPathCurrentCurriculum }
idToNextPathCurrentCurriculum,
idToPrevPathCurrentCurriculum,
idToNextPathNextCurriculum,
idToPrevPathNextCurriculum
}
) { ) {
return function ({ node }, index, allChallengeEdges) { return function ({ node }, index, allChallengeEdges) {
const { const {
@@ -123,10 +118,6 @@ exports.createChallengePages = function (
prevChallengePath: idToPrevPathCurrentCurriculum[node.id], prevChallengePath: idToPrevPathCurrentCurriculum[node.id],
id id
}, },
nextCurriculumPaths: {
nextChallengePath: idToNextPathNextCurriculum[node.id],
prevChallengePath: idToPrevPathNextCurriculum[node.id]
},
projectPreview: getProjectPreviewConfig( projectPreview: getProjectPreviewConfig(
node.challenge, node.challenge,
allChallengeEdges allChallengeEdges
+1 -2
View File
@@ -44,8 +44,7 @@ function createSuperOrder(superBlocks) {
const flatSuperBlockMap = generateSuperBlockList({ const flatSuperBlockMap = generateSuperBlockList({
showNewCurriculum: process.env.SHOW_NEW_CURRICULUM === 'true', showNewCurriculum: process.env.SHOW_NEW_CURRICULUM === 'true',
showUpcomingChanges: process.env.SHOW_UPCOMING_CHANGES === 'true', showUpcomingChanges: process.env.SHOW_UPCOMING_CHANGES === 'true'
showNextCurriculum: true
}); });
const superOrder = createSuperOrder(flatSuperBlockMap); const superOrder = createSuperOrder(flatSuperBlockMap);
+2 -18
View File
@@ -23,8 +23,7 @@ describe('generateSuperBlockList', () => {
it('should return an array of SuperBlocks object with all elements when if all configs are true', () => { it('should return an array of SuperBlocks object with all elements when if all configs are true', () => {
const result = generateSuperBlockList({ const result = generateSuperBlockList({
showNewCurriculum: true, showNewCurriculum: true,
showUpcomingChanges: true, showUpcomingChanges: true
showNextCurriculum: true
}); });
expect(result).toHaveLength(Object.values(superBlockStages).flat().length); expect(result).toHaveLength(Object.values(superBlockStages).flat().length);
}); });
@@ -32,28 +31,13 @@ describe('generateSuperBlockList', () => {
it('should return an array of SuperBlocks without New and Upcoming when { showNewCurriculum: false, showUpcomingChanges: false }', () => { it('should return an array of SuperBlocks without New and Upcoming when { showNewCurriculum: false, showUpcomingChanges: false }', () => {
const result = generateSuperBlockList({ const result = generateSuperBlockList({
showNewCurriculum: false, showNewCurriculum: false,
showUpcomingChanges: false, showUpcomingChanges: false
showNextCurriculum: true
}); });
const tempSuperBlockMap = { ...superBlockStages }; const tempSuperBlockMap = { ...superBlockStages };
tempSuperBlockMap[SuperBlockStage.New] = []; tempSuperBlockMap[SuperBlockStage.New] = [];
tempSuperBlockMap[SuperBlockStage.Upcoming] = []; tempSuperBlockMap[SuperBlockStage.Upcoming] = [];
expect(result).toHaveLength(Object.values(tempSuperBlockMap).flat().length); expect(result).toHaveLength(Object.values(tempSuperBlockMap).flat().length);
}); });
it('should exclude the Next SuperBlocks when { showNextCurriculum: false }', () => {
const result = generateSuperBlockList({
showNewCurriculum: false,
showUpcomingChanges: false,
showNextCurriculum: false
});
const tempSuperBlockMap = { ...superBlockStages };
tempSuperBlockMap[SuperBlockStage.New] = [];
tempSuperBlockMap[SuperBlockStage.Upcoming] = [];
tempSuperBlockMap[SuperBlockStage.Next] = [];
tempSuperBlockMap[SuperBlockStage.NextEnglish] = [];
expect(result).toHaveLength(Object.values(tempSuperBlockMap).flat().length);
});
}); });
describe('Immutability of superBlockOrder, notAuditedSuperBlocks, and flatSuperBlockMap', () => { describe('Immutability of superBlockOrder, notAuditedSuperBlocks, and flatSuperBlockMap', () => {
+3 -11
View File
@@ -64,15 +64,9 @@ const defaultStageOrder = [
export function getStageOrder({ export function getStageOrder({
showNewCurriculum, showNewCurriculum,
showUpcomingChanges, showUpcomingChanges
showNextCurriculum
}: Config): SuperBlockStage[] { }: Config): SuperBlockStage[] {
const isCurrentStage = (stage: SuperBlockStage) => const stageOrder = [...defaultStageOrder];
!(stage === SuperBlockStage.Next) &&
!(stage === SuperBlockStage.NextEnglish);
const stageOrder = showNextCurriculum
? [...defaultStageOrder]
: [...defaultStageOrder.filter(isCurrentStage)];
if (showNewCurriculum) stageOrder.push(SuperBlockStage.New); if (showNewCurriculum) stageOrder.push(SuperBlockStage.New);
if (showUpcomingChanges) stageOrder.push(SuperBlockStage.Upcoming); if (showUpcomingChanges) stageOrder.push(SuperBlockStage.Upcoming);
@@ -259,7 +253,6 @@ Object.freeze(notAuditedSuperBlocks);
type Config = { type Config = {
showNewCurriculum: boolean; showNewCurriculum: boolean;
showUpcomingChanges: boolean; showUpcomingChanges: boolean;
showNextCurriculum: boolean;
}; };
export function generateSuperBlockList(config: Config): SuperBlocks[] { export function generateSuperBlockList(config: Config): SuperBlocks[] {
@@ -280,8 +273,7 @@ export function getAuditedSuperBlocks({
// To find the audited superblocks, we need to start with all superblocks. // To find the audited superblocks, we need to start with all superblocks.
const flatSuperBlockMap = generateSuperBlockList({ const flatSuperBlockMap = generateSuperBlockList({
showNewCurriculum: true, showNewCurriculum: true,
showUpcomingChanges: true, showUpcomingChanges: true
showNextCurriculum: true
}); });
const auditedSuperBlocks = flatSuperBlockMap.filter( const auditedSuperBlocks = flatSuperBlockMap.filter(
superBlock => superBlock =>