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
superOrder
template
usesMultifileEditor
}
}
}

View File

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

View File

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

View File

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