feat: show project preview on MultiFile challenges

This commit is contained in:
Oliver Eyton-Williams
2021-10-21 15:14:36 +02:00
committed by moT01
parent 943aa975d3
commit f5c13436cc
4 changed files with 8 additions and 7 deletions

View File

@ -101,6 +101,7 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
superBlock superBlock
superOrder superOrder
template template
usesMultifileEditor
} }
} }
} }

View File

@ -96,7 +96,7 @@ interface ShowClassicProps {
output: string[]; output: string[];
pageContext: { pageContext: {
challengeMeta: ChallengeMeta; challengeMeta: ChallengeMeta;
projectPreview: PreviewConfig & { isFirstChallengeInBlock: boolean }; projectPreview: PreviewConfig & { showProjectPreview: boolean };
}; };
t: TFunction; t: TFunction;
tests: Test[]; tests: Test[];
@ -255,13 +255,13 @@ class ShowClassic extends Component<ShowClassicProps, ShowClassicState> {
}, },
pageContext: { pageContext: {
challengeMeta, challengeMeta,
projectPreview: { isFirstChallengeInBlock } projectPreview: { showProjectPreview }
} }
} = this.props; } = this.props;
initConsole(''); initConsole('');
createFiles(challengeFiles ?? []); createFiles(challengeFiles ?? []);
initTests(tests); initTests(tests);
if (isFirstChallengeInBlock) openModal('projectPreview'); if (showProjectPreview) openModal('projectPreview');
updateChallengeMeta({ updateChallengeMeta({
...challengeMeta, ...challengeMeta,
title, title,

View File

@ -240,8 +240,8 @@ function* previewChallengeSaga({ flushLogs = true } = {}) {
// TODO: remove everything about proxyLogger here // TODO: remove everything about proxyLogger here
function* previewProjectSolutionSaga({ payload }) { function* previewProjectSolutionSaga({ payload }) {
if (!payload) return; if (!payload) return;
const { isFirstChallengeInBlock, challengeData } = payload; const { showProjectPreview, challengeData } = payload;
if (!isFirstChallengeInBlock) return; if (!showProjectPreview) return;
const logProxy = yield channel(); const logProxy = yield channel();
const proxyLogger = args => logProxy.put(args); const proxyLogger = args => logProxy.put(args);

View File

@ -100,7 +100,7 @@ exports.createChallengePages = function (createPage) {
}; };
function getProjectPreviewConfig(challenge, allChallengeEdges) { function getProjectPreviewConfig(challenge, allChallengeEdges) {
const { block, challengeOrder } = challenge; const { block, challengeOrder, usesMultifileEditor } = challenge;
const challengesInBlock = allChallengeEdges const challengesInBlock = allChallengeEdges
.filter(({ node }) => node.block === block) .filter(({ node }) => node.block === block)
@ -120,7 +120,7 @@ function getProjectPreviewConfig(challenge, allChallengeEdges) {
); );
return { return {
isFirstChallengeInBlock: challengeOrder === 0, showProjectPreview: challengeOrder === 0 && usesMultifileEditor,
challengeData: { challengeData: {
challengeType: lastChallenge.challengeType, challengeType: lastChallenge.challengeType,
challengeFiles: projectPreviewChallengeFiles, challengeFiles: projectPreviewChallengeFiles,