refactor: files{} -> challengeFiles[], and key -> fileKey (#43023)
* fix(client): fix client * fix propType and add comment * revert user.json prettification * slight type refactor and payload correction Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * update ChallengeFile type imports * add cypress test for code-storage * update test and storage epic * fix Shaun's tired brain's logic * refactor with suggestions Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * update codeReset * increate cypress timeout because firefox is slow * remove unused import to make linter happy * use focus on editor Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * use more specific seletor for cypress editor test * account for silly null challengeFiles Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@@ -11,21 +11,25 @@ const prismLang = {
|
||||
};
|
||||
|
||||
const SolutionViewer = ({
|
||||
files,
|
||||
challengeFiles,
|
||||
solution = '// The solution is not available for this project'
|
||||
}) =>
|
||||
files && Array.isArray(files) && files.length ? (
|
||||
files.map(file => (
|
||||
<Panel bsStyle='primary' className='solution-viewer' key={file.ext}>
|
||||
<Panel.Heading>{file.ext.toUpperCase()}</Panel.Heading>
|
||||
challengeFiles?.length ? (
|
||||
challengeFiles.map(challengeFile => (
|
||||
<Panel
|
||||
bsStyle='primary'
|
||||
className='solution-viewer'
|
||||
key={challengeFile.ext}
|
||||
>
|
||||
<Panel.Heading>{challengeFile.ext.toUpperCase()}</Panel.Heading>
|
||||
<Panel.Body>
|
||||
<pre>
|
||||
<code
|
||||
className={`language-${prismLang[file.ext]}`}
|
||||
className={`language-${prismLang[challengeFile.ext]}`}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: Prism.highlight(
|
||||
file.contents.trim(),
|
||||
Prism.languages[prismLang[file.ext]]
|
||||
challengeFile.contents.trim(),
|
||||
Prism.languages[prismLang[challengeFile.ext]]
|
||||
)
|
||||
}}
|
||||
/>
|
||||
@@ -59,7 +63,7 @@ const SolutionViewer = ({
|
||||
|
||||
SolutionViewer.displayName = 'SolutionViewer';
|
||||
SolutionViewer.propTypes = {
|
||||
files: PropTypes.arrayOf(PropTypes.objectOf(PropTypes.string)),
|
||||
challengeFiles: PropTypes.array,
|
||||
solution: PropTypes.string
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user