feat: show project preview on MultiFile challenges
This commit is contained in:
committed by
moT01
parent
943aa975d3
commit
f5c13436cc
@ -101,6 +101,7 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
|
||||
superBlock
|
||||
superOrder
|
||||
template
|
||||
usesMultifileEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user