From 9879d6e72b075572cfd0db13e2562dcd7857b1f9 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Fri, 22 May 2020 03:24:17 +0530 Subject: [PATCH] fix(learn): update project views for python --- .../Challenges/projects/SolutionForm.js | 58 ++++++++++++++----- .../Challenges/projects/backend/Show.js | 12 +--- .../Challenges/projects/frontend/Show.js | 6 +- client/src/templates/Challenges/video/Show.js | 6 +- cypress/integration/learn/index.js | 8 ++- 5 files changed, 58 insertions(+), 32 deletions(-) diff --git a/client/src/templates/Challenges/projects/SolutionForm.js b/client/src/templates/Challenges/projects/SolutionForm.js index 6935bf882f8..92edb4e4e5e 100644 --- a/client/src/templates/Challenges/projects/SolutionForm.js +++ b/client/src/templates/Challenges/projects/SolutionForm.js @@ -2,16 +2,21 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Form } from '../../../components/formHelpers'; +import { + backEndProject, + frontEndProject, + pythonProject +} from '../../../../utils/challengeTypes'; const propTypes = { - isFrontEnd: PropTypes.bool, - isProject: PropTypes.bool, + challengeType: PropTypes.number, + description: PropTypes.string, isSubmitting: PropTypes.bool, onSubmit: PropTypes.func.isRequired, updateSolutionForm: PropTypes.func.isRequired }; -const challengeFields = ['solution']; +const frontEndProjectFields = ['solution']; const backEndProjectFields = ['solution', 'githubLink']; const options = { @@ -35,25 +40,52 @@ export class SolutionForm extends Component { this.props.onSubmit(); } render() { - const { isSubmitting, isFrontEnd, isProject } = this.props; + const { isSubmitting, challengeType, description } = this.props; const buttonCopy = isSubmitting ? 'Submit and go to my next challenge' : "I've completed this challenge"; + + let solutionFormFields = frontEndProjectFields; + let solutionLink = 'Link, ex: '; + let solutionFormID = 'front-end-form'; + + switch (challengeType) { + case frontEndProject: + solutionFormFields = frontEndProjectFields; + solutionLink = + solutionLink + 'https://codepen.io/camperbot/full/oNvPqqo'; + break; + + case backEndProject: + solutionFormFields = backEndProjectFields; + solutionLink = solutionLink + 'https://camperbot.glitch.me'; + solutionFormID = 'back-end-form'; + break; + + case pythonProject: + solutionFormFields = frontEndProjectFields; + solutionLink = + solutionLink + + (description.includes('Colaboratory') + ? 'https://colab.research.google.com/drive/1i5EmInTWi1RFvFr2_aRXky96YxY6sbWy' + : 'https://repl.it/@camperbot/hello'); + break; + + default: + solutionFormFields = frontEndProjectFields; + solutionLink = + solutionLink + 'https://codepen.io/camperbot/full/oNvPqqo'; + } + return (
- isBackEndProject - ? updateSolutionFormValues(values) - : updateBackendFormValues(values) - } + updateSolutionForm={updateBackendFormValues} /> {blockNameTitle} diff --git a/client/src/templates/Challenges/video/Show.js b/client/src/templates/Challenges/video/Show.js index 3e38ccef64d..809d2a76029 100644 --- a/client/src/templates/Challenges/video/Show.js +++ b/client/src/templates/Challenges/video/Show.js @@ -24,7 +24,7 @@ import { challengeMounted, updateChallengeMeta, openModal, - updateProjectFormValues + updateSolutionFormValues } from '../redux'; // Styles @@ -42,7 +42,7 @@ const mapDispatchToProps = dispatch => { updateChallengeMeta, challengeMounted, - updateProjectFormValues, + updateSolutionFormValues, openCompletionModal: () => openModal('completion') }, dispatch @@ -61,7 +61,7 @@ const propTypes = { challengeMeta: PropTypes.object }), updateChallengeMeta: PropTypes.func.isRequired, - updateProjectFormValues: PropTypes.func.isRequired + updateSolutionFormValues: PropTypes.func.isRequired }; // Component diff --git a/cypress/integration/learn/index.js b/cypress/integration/learn/index.js index 2d8daf7489e..306d2f674aa 100644 --- a/cypress/integration/learn/index.js +++ b/cypress/integration/learn/index.js @@ -14,7 +14,11 @@ const superBlockNames = [ 'Front End Libraries', 'Data Visualization', 'APIs and Microservices', - 'Information Security and Quality Assurance', + 'Quality Assurance', + 'Scientific Computing with Python', + 'Data Analysis with Python', + 'Information Security', + 'Machine Learning with Python', 'Coding Interview Prep' ]; @@ -36,7 +40,7 @@ describe('Learn Landing page', function() { const superBlocks = document.querySelectorAll( `${selectors.challengeMap} > ul > li` ); - expect(superBlocks).to.have.length(7); + expect(superBlocks).to.have.length(11); superBlocks.forEach((superBlock, idx) => { expect(superBlock.innerText).to.have.string(superBlockNames[idx]);