Handle front-end-libs challenges
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
3550921b84
commit
5002a1069f
@ -58,6 +58,7 @@ class ShowClassic extends PureComponent {
|
|||||||
} = this.props;
|
} = this.props;
|
||||||
createFiles(files);
|
createFiles(files);
|
||||||
initTests(tests);
|
initTests(tests);
|
||||||
|
console.log(challengeMeta);
|
||||||
updateChallengeMeta(challengeMeta);
|
updateChallengeMeta(challengeMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +93,7 @@ class ShowClassic extends PureComponent {
|
|||||||
},
|
},
|
||||||
files
|
files
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
console.log(files);
|
||||||
const editors = Object.keys(files)
|
const editors = Object.keys(files)
|
||||||
.map(key => files[key])
|
.map(key => files[key])
|
||||||
.map((file, index) => (
|
.map((file, index) => (
|
||||||
@ -103,7 +105,10 @@ class ShowClassic extends PureComponent {
|
|||||||
</Fragment>
|
</Fragment>
|
||||||
));
|
));
|
||||||
|
|
||||||
const showPreview = challengeType === challengeTypes.html;
|
const showPreview = (
|
||||||
|
challengeType === challengeTypes.html ||
|
||||||
|
challengeType === challengeTypes.modern
|
||||||
|
);
|
||||||
const blockNameTitle = `${blockName} - ${title}`;
|
const blockNameTitle = `${blockName} - ${title}`;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
@ -155,6 +160,11 @@ export const query = graphql`
|
|||||||
testString
|
testString
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
required {
|
||||||
|
link
|
||||||
|
raw
|
||||||
|
src
|
||||||
|
}
|
||||||
files {
|
files {
|
||||||
indexhtml {
|
indexhtml {
|
||||||
key
|
key
|
||||||
@ -172,6 +182,14 @@ export const query = graphql`
|
|||||||
head
|
head
|
||||||
tail
|
tail
|
||||||
}
|
}
|
||||||
|
indexjsx {
|
||||||
|
key
|
||||||
|
ext
|
||||||
|
name
|
||||||
|
contents
|
||||||
|
head
|
||||||
|
tail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,11 @@ export const cssToHtml = cond([
|
|||||||
[stubTrue, identity]
|
[stubTrue, identity]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// FileStream::concactHtml(
|
// FileStream::concatHtml(
|
||||||
// required: [ ...Object ],
|
// required: [ ...Object ],
|
||||||
// template: String
|
// template: String
|
||||||
// ) => Observable[{ build: String, sources: Dictionary }]
|
// ) => Observable[{ build: String, sources: Dictionary }]
|
||||||
export function concactHtml(required, template) {
|
export function concatHtml(required, template) {
|
||||||
const createBody = template ? _.template(template) : defaultTemplate;
|
const createBody = template ? _.template(template) : defaultTemplate;
|
||||||
const source = this.shareReplay();
|
const source = this.shareReplay();
|
||||||
const sourceMap = source.flatMap(files =>
|
const sourceMap = source.flatMap(files =>
|
||||||
|
@ -87,17 +87,12 @@ export const executeChallenge = createAction(types.executeChallenge);
|
|||||||
export const submitChallenge = createAction(types.submitChallenge);
|
export const submitChallenge = createAction(types.submitChallenge);
|
||||||
|
|
||||||
export const challengeFilesSelector = state => state[ns].challengeFiles;
|
export const challengeFilesSelector = state => state[ns].challengeFiles;
|
||||||
|
|
||||||
export const challengeMetaSelector = state => state[ns].challengeMeta;
|
export const challengeMetaSelector = state => state[ns].challengeMeta;
|
||||||
|
|
||||||
export const challengeTestsSelector = state => state[ns].challengeTests;
|
export const challengeTestsSelector = state => state[ns].challengeTests;
|
||||||
|
|
||||||
export const isJSEnabledSelector = state => state[ns].isJSEnabled;
|
|
||||||
|
|
||||||
export const consoleOutputSelector = state => state[ns].consoleOut;
|
export const consoleOutputSelector = state => state[ns].consoleOut;
|
||||||
|
|
||||||
export const isCompletionModalOpenSelector = state =>
|
export const isCompletionModalOpenSelector = state =>
|
||||||
state[ns].modal.completion;
|
state[ns].modal.completion;
|
||||||
|
export const isJSEnabledSelector = state => state[ns].isJSEnabled;
|
||||||
export const successMessageSelector = state => state[ns].successMessage;
|
export const successMessageSelector = state => state[ns].successMessage;
|
||||||
|
|
||||||
export const reducer = handleActions(
|
export const reducer = handleActions(
|
||||||
|
@ -6,6 +6,7 @@ import throwers from '../rechallenge/throwers';
|
|||||||
import {
|
import {
|
||||||
challengeFilesSelector,
|
challengeFilesSelector,
|
||||||
isJSEnabledSelector,
|
isJSEnabledSelector,
|
||||||
|
challengeMetaSelector,
|
||||||
disableJSOnError
|
disableJSOnError
|
||||||
} from '../redux';
|
} from '../redux';
|
||||||
import {
|
import {
|
||||||
@ -13,7 +14,7 @@ import {
|
|||||||
proxyLoggerTransformer,
|
proxyLoggerTransformer,
|
||||||
testJS$JSX
|
testJS$JSX
|
||||||
} from '../rechallenge/transformers';
|
} from '../rechallenge/transformers';
|
||||||
import { cssToHtml, jsToHtml, concactHtml } from '../rechallenge/builders.js';
|
import { cssToHtml, jsToHtml, concatHtml } from '../rechallenge/builders.js';
|
||||||
import { createFileStream, pipe } from './polyvinyl';
|
import { createFileStream, pipe } from './polyvinyl';
|
||||||
|
|
||||||
const jQuery = {
|
const jQuery = {
|
||||||
@ -40,8 +41,7 @@ function filterJSIfDisabled(state) {
|
|||||||
|
|
||||||
export function buildFromFiles(state, shouldProxyConsole) {
|
export function buildFromFiles(state, shouldProxyConsole) {
|
||||||
const files = challengeFilesSelector(state);
|
const files = challengeFilesSelector(state);
|
||||||
const required = [];
|
const { required, template } = challengeMetaSelector(state);
|
||||||
/* challengeRequiredSelector(state);*/
|
|
||||||
const finalRequires = [...globalRequires, ...required];
|
const finalRequires = [...globalRequires, ...required];
|
||||||
const requiredFiles = Object.keys(files)
|
const requiredFiles = Object.keys(files)
|
||||||
.map(key => files[key])
|
.map(key => files[key])
|
||||||
@ -53,12 +53,8 @@ export function buildFromFiles(state, shouldProxyConsole) {
|
|||||||
::pipe(shouldProxyConsole ? proxyLoggerTransformer : identity)
|
::pipe(shouldProxyConsole ? proxyLoggerTransformer : identity)
|
||||||
::pipe(jsToHtml)
|
::pipe(jsToHtml)
|
||||||
::pipe(cssToHtml)
|
::pipe(cssToHtml)
|
||||||
::concactHtml(
|
::concatHtml(finalRequires, template)
|
||||||
finalRequires,
|
.catch(err => disableJSOnError(err));
|
||||||
false
|
|
||||||
/* challengeTemplateSelector(state) */
|
|
||||||
)
|
|
||||||
.catch(err => of(disableJSOnError(err)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// export function buildBackendChallenge(state) {
|
// export function buildBackendChallenge(state) {
|
||||||
|
Reference in New Issue
Block a user