From 14df18a158ba0bc74245af8811247ec57ecfaeee Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Mon, 5 Sep 2022 15:14:40 +0300 Subject: [PATCH 01/16] TCA-354 - fix handler for external urls when url is fcc lesson --- client/src/components/layouts/tc-integration.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/layouts/tc-integration.tsx b/client/src/components/layouts/tc-integration.tsx index 136cd7f7acd1a3..6b5d61eca74c67 100755 --- a/client/src/components/layouts/tc-integration.tsx +++ b/client/src/components/layouts/tc-integration.tsx @@ -144,7 +144,7 @@ class TcIntegrationLayout extends Component { // provider. // set the pathname for the 2 flavors of lesson URL - const platformPathPrefix = 'learn/freecodecamp'; + const platformPathPrefix = 'learn/freeCodeCamp'; const learnPrefix = '/learn/'; let updateHost = false; if (url.host === `learn.${fccHost}`) { From 6271c9732c215db9625e2b69f5635c26b41a3482 Mon Sep 17 00:00:00 2001 From: Chris McCann Date: Tue, 6 Sep 2022 11:36:26 -0700 Subject: [PATCH 02/16] Removes logging of Mongo URL --- .husky/pre-commit | 4 ---- api-server/src/server/middlewares/sessions.js | 2 -- 2 files changed, 6 deletions(-) delete mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index 36af219892fda8..00000000000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx lint-staged diff --git a/api-server/src/server/middlewares/sessions.js b/api-server/src/server/middlewares/sessions.js index f24141c7038fea..219ed97724a5b8 100644 --- a/api-server/src/server/middlewares/sessions.js +++ b/api-server/src/server/middlewares/sessions.js @@ -5,8 +5,6 @@ const MongoStore = MongoStoreFactory(session); const sessionSecret = process.env.SESSION_SECRET; const url = process.env.MONGODB || process.env.MONGOHQ_URL; -console.log('session DB url', url); - export default function sessionsMiddleware() { return session({ // 900 day session cookie From 35794441f83d0bff9a96942f26d67fcd5a208ca7 Mon Sep 17 00:00:00 2001 From: Brooke Date: Tue, 6 Sep 2022 12:13:50 -0700 Subject: [PATCH 03/16] TCA-397 #comment This commit adds the gtm module declaration #time 5m --- client/src/declarations.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/declarations.d.ts b/client/src/declarations.d.ts index 53d7d2fe927ce2..5591e3a3edc2f9 100644 --- a/client/src/declarations.d.ts +++ b/client/src/declarations.d.ts @@ -4,6 +4,7 @@ declare module '@freecodecamp/strip-comments'; declare module '@types/react-redux'; declare module '@types/validator'; declare module '@types/lodash-es'; +declare module 'react-gtm-module'; declare module 'react-lazy-load'; declare module '*.svg' { const content: string; From 95bf94ba667baa30c15192c5b252a8184af1bf22 Mon Sep 17 00:00:00 2001 From: Brooke Date: Tue, 6 Sep 2022 12:15:07 -0700 Subject: [PATCH 04/16] TCA-397 #comment This commit adds the pre-commit check back to the dev branch #time 5m --- .husky/pre-commit | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000000000..36af219892fda8 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged From 617639bdfd115f89ba9b5638a264ab9f8aba3faa Mon Sep 17 00:00:00 2001 From: Brooke Date: Tue, 6 Sep 2022 12:32:46 -0700 Subject: [PATCH 05/16] TCA-397 #comment This commit adds more loggingn to the call to save a challenge #time 15m --- api-server/src/server/boot/challenge.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api-server/src/server/boot/challenge.js b/api-server/src/server/boot/challenge.js index 4ead5426a9e277..27357ab5c0dae7 100644 --- a/api-server/src/server/boot/challenge.js +++ b/api-server/src/server/boot/challenge.js @@ -258,16 +258,24 @@ export function isValidChallengeCompletion(req, res, next) { message: 'That does not appear to be a valid challenge submission.' }; + console.debug('console.debug'); + console.info('console.info'); + console.error('console.error'); + console.log('console.log'); + if (!ObjectID.isValid(id)) { log('isObjectId', id, ObjectID.isValid(id)); + console.debug('isObjectId', id, ObjectID.isValid(id)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } if ('challengeType' in req.body && !isNumeric(String(challengeType))) { log('challengeType', challengeType, isNumeric(challengeType)); + console.debug('challengeType', challengeType, isNumeric(challengeType)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } if ('solution' in req.body && !isURL(solution)) { - log('isObjectId', id, ObjectID.isValid(id)); + log('solution', solution, !isURL(solution)); + console.debug('solution', solution, !isURL(solution)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } return next(); From 54b1a70b96fe3b74440a92f2f47b522fbeee3b06 Mon Sep 17 00:00:00 2001 From: Brooke Date: Tue, 6 Sep 2022 12:34:20 -0700 Subject: [PATCH 06/16] TCA-397 revert errant changes #time 5m --- api-server/src/server/boot/challenge.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/api-server/src/server/boot/challenge.js b/api-server/src/server/boot/challenge.js index 27357ab5c0dae7..4ead5426a9e277 100644 --- a/api-server/src/server/boot/challenge.js +++ b/api-server/src/server/boot/challenge.js @@ -258,24 +258,16 @@ export function isValidChallengeCompletion(req, res, next) { message: 'That does not appear to be a valid challenge submission.' }; - console.debug('console.debug'); - console.info('console.info'); - console.error('console.error'); - console.log('console.log'); - if (!ObjectID.isValid(id)) { log('isObjectId', id, ObjectID.isValid(id)); - console.debug('isObjectId', id, ObjectID.isValid(id)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } if ('challengeType' in req.body && !isNumeric(String(challengeType))) { log('challengeType', challengeType, isNumeric(challengeType)); - console.debug('challengeType', challengeType, isNumeric(challengeType)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } if ('solution' in req.body && !isURL(solution)) { - log('solution', solution, !isURL(solution)); - console.debug('solution', solution, !isURL(solution)); + log('isObjectId', id, ObjectID.isValid(id)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } return next(); From 775209423b92539e00e9faacc354c8ccb7b6b12e Mon Sep 17 00:00:00 2001 From: Brooke Date: Tue, 6 Sep 2022 12:36:02 -0700 Subject: [PATCH 07/16] TCA-385 #comment This commit adds logging #time 5m --- api-server/src/server/boot/challenge.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api-server/src/server/boot/challenge.js b/api-server/src/server/boot/challenge.js index 4ead5426a9e277..27357ab5c0dae7 100644 --- a/api-server/src/server/boot/challenge.js +++ b/api-server/src/server/boot/challenge.js @@ -258,16 +258,24 @@ export function isValidChallengeCompletion(req, res, next) { message: 'That does not appear to be a valid challenge submission.' }; + console.debug('console.debug'); + console.info('console.info'); + console.error('console.error'); + console.log('console.log'); + if (!ObjectID.isValid(id)) { log('isObjectId', id, ObjectID.isValid(id)); + console.debug('isObjectId', id, ObjectID.isValid(id)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } if ('challengeType' in req.body && !isNumeric(String(challengeType))) { log('challengeType', challengeType, isNumeric(challengeType)); + console.debug('challengeType', challengeType, isNumeric(challengeType)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } if ('solution' in req.body && !isURL(solution)) { - log('isObjectId', id, ObjectID.isValid(id)); + log('solution', solution, !isURL(solution)); + console.debug('solution', solution, !isURL(solution)); return res.status(403).json(isValidChallengeCompletionErrorMsg); } return next(); From ee95a5e9741f7c1724f5df67a2f8697b65b130e3 Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Wed, 7 Sep 2022 12:42:10 +0530 Subject: [PATCH 08/16] Delete Jenkinsfile --- Jenkinsfile | 160 ---------------------------------------------------- 1 file changed, 160 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 663064f06fe2fe..00000000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,160 +0,0 @@ -// Define Application name -def APPNAME = "freecodecamp" - -// Define which branch build and deploy need to run in the below array -def branchfilter = ['dev', 'prod'] - -if (!branchfilter.contains(env.BRANCH_NAME)) { - println 'Now is not the time to run the pipeline.' - println 'Exiting without running subsequent stages.' - println env.BRANCH_NAME - currentBuild.result = 'SUCCESS' - return -} - -// Define dev-specific vars -if (env.BRANCH_NAME == 'dev') { - DEPLOY_ENV = 'DEV' - LOGICAL_ENV = 'dev' - IS_BUILD = true - IS_DEPLOY = true - IS_APP_DEPLOY = true - IS_API_DEPLOY = true - ENABLE_CACHE = false -} - -// Define prod-specific vars -if (env.BRANCH_NAME == 'prod') { - DEPLOY_ENV = 'PROD' - LOGICAL_ENV = 'prod' - IS_BUILD = true - IS_DEPLOY = true - IS_APP_DEPLOY = true - IS_API_DEPLOY = true - ENABLE_CACHE = true -} - -pipeline { - agent { - label 'tc-ecs-agent-large' - } - - environment { - CI_AUTH0_URL = credentials('CI_AUTH0_URL') - CI_AUTH0_CLIENTID = credentials('CI_AUTH0_CLIENTID') - CI_AUTH0_CLIENTSECRET = credentials('CI_AUTH0_CLIENTSECRET') - CI_AUTH0_AUDIENCE = credentials('CI_AUTH0_AUDIENCE') - } - - options { skipDefaultCheckout() } - - stages - { - stage('checkout') - { - steps { - //cheking out code - checkout scm - script { - giturltoken = scm.getUserRemoteConfigs()[0].getUrl().tokenize('/') - env.TC_GIT_ORG = giturltoken.get(giturltoken.size()-2) - env.TC_REPONAME = scm.getUserRemoteConfigs()[0].getUrl().tokenize('/').last().split("\\.")[0] - env.TC_GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() - env.TC_GIT_AUTHOR = sh (script: 'git log -1 --pretty=%an ${GIT_COMMIT}', returnStdout: true).trim() - env.TC_GIT_HASH = sh (script: 'git log -1 --pretty=%h ${GIT_COMMIT}', returnStdout: true).trim() - if (sh(script: "git log -1 --pretty=%B | fgrep -ie '[skip ci]' -e '[ci skip]'", returnStatus: true) == 0) { - currentBuild.result = 'NOT_BUILT' - error 'Aborting because commit message contains [skip ci]' - } - } - } - - } - stage('pre-req install') - { - steps { - //Installing required pre-req software - sh ''' - #!/bin/bash - apt update -y - apt install awscli jq curl sudo -y - curl https://get.docker.com/ > dockerinstall && chmod 777 dockerinstall && ./dockerinstall - git clone --branch dev-jenkins https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript - cp ./../buildscript/master_deploy.sh . - cp ./../buildscript/buildenv.sh . - cp ./../buildscript/awsconfiguration.sh . - curl -sL https://deb.nodesource.com/setup_16.x | sudo bash - - apt -y install nodejs - ''' - } - } - stage('fetching configuration') - { - steps { - //fetching pre-req - sh """ - #!/bin/bash - ./awsconfiguration.sh ${DEPLOY_ENV} - echo "Fetching deployvar" - ./buildenv.sh -e ${DEPLOY_ENV} -b ${LOGICAL_ENV}-${APPNAME}-deployvarj - mv buildenvvar deployenvvar - mv buildenvvarg deployenvvarg - echo "Fetching Buildvar" - ./buildenv.sh -e ${DEPLOY_ENV} -b ${LOGICAL_ENV}-${APPNAME}-buildvar - aws s3 cp s3://tc-platform-${LOGICAL_ENV}/securitymanager/${LOGICAL_ENV}-freecodecamp.env ./.env - """ - load 'awsenvconfg' - load 'deployenvvarg' - load 'buildenvvarg' - } - } - stage('build application') - { - //Building Application - when { expression { IS_BUILD } } - steps { - // Doing Build - sh """ - #!/bin/bash - node --version - npm --version - git config --global url."https://git@".insteadOf git:// - npm ci - npm run build - ls -lath - """ - } - } - stage('appdeploy') - { - //Deploying app - when { expression { IS_APP_DEPLOY } } - steps { - //Doing Deployment - echo "Deploying application" - //input(message: 'Hello World!', ok: 'Submit') - sh """ - #!/bin/bash - ./master_deploy.sh -d CFRONT -e $DEPLOY_ENV -c $ENABLE_CACHE - """ - } - } - stage('apideploy') - { - //Deploying app - when { expression { IS_API_DEPLOY } } - steps { - //Doing Deployment - echo "Deploying Api" - // input(message: 'Hello World!', ok: 'Submit') - sh """ - #!/bin/bash - sed -i '/node_modules/d' ./.dockerignore - docker build -f docker/api/ECSDockerfile -t $APPNAME-api:latest . - ./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}-api - """ - } - } - } - -} From 70823678f8d53a1e6ffe75b0e6f65afed36573fb Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Wed, 7 Sep 2022 12:45:29 +0530 Subject: [PATCH 09/16] Create Jenkinsfile --- Jenkinsfile | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000000000..663064f06fe2fe --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,160 @@ +// Define Application name +def APPNAME = "freecodecamp" + +// Define which branch build and deploy need to run in the below array +def branchfilter = ['dev', 'prod'] + +if (!branchfilter.contains(env.BRANCH_NAME)) { + println 'Now is not the time to run the pipeline.' + println 'Exiting without running subsequent stages.' + println env.BRANCH_NAME + currentBuild.result = 'SUCCESS' + return +} + +// Define dev-specific vars +if (env.BRANCH_NAME == 'dev') { + DEPLOY_ENV = 'DEV' + LOGICAL_ENV = 'dev' + IS_BUILD = true + IS_DEPLOY = true + IS_APP_DEPLOY = true + IS_API_DEPLOY = true + ENABLE_CACHE = false +} + +// Define prod-specific vars +if (env.BRANCH_NAME == 'prod') { + DEPLOY_ENV = 'PROD' + LOGICAL_ENV = 'prod' + IS_BUILD = true + IS_DEPLOY = true + IS_APP_DEPLOY = true + IS_API_DEPLOY = true + ENABLE_CACHE = true +} + +pipeline { + agent { + label 'tc-ecs-agent-large' + } + + environment { + CI_AUTH0_URL = credentials('CI_AUTH0_URL') + CI_AUTH0_CLIENTID = credentials('CI_AUTH0_CLIENTID') + CI_AUTH0_CLIENTSECRET = credentials('CI_AUTH0_CLIENTSECRET') + CI_AUTH0_AUDIENCE = credentials('CI_AUTH0_AUDIENCE') + } + + options { skipDefaultCheckout() } + + stages + { + stage('checkout') + { + steps { + //cheking out code + checkout scm + script { + giturltoken = scm.getUserRemoteConfigs()[0].getUrl().tokenize('/') + env.TC_GIT_ORG = giturltoken.get(giturltoken.size()-2) + env.TC_REPONAME = scm.getUserRemoteConfigs()[0].getUrl().tokenize('/').last().split("\\.")[0] + env.TC_GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() + env.TC_GIT_AUTHOR = sh (script: 'git log -1 --pretty=%an ${GIT_COMMIT}', returnStdout: true).trim() + env.TC_GIT_HASH = sh (script: 'git log -1 --pretty=%h ${GIT_COMMIT}', returnStdout: true).trim() + if (sh(script: "git log -1 --pretty=%B | fgrep -ie '[skip ci]' -e '[ci skip]'", returnStatus: true) == 0) { + currentBuild.result = 'NOT_BUILT' + error 'Aborting because commit message contains [skip ci]' + } + } + } + + } + stage('pre-req install') + { + steps { + //Installing required pre-req software + sh ''' + #!/bin/bash + apt update -y + apt install awscli jq curl sudo -y + curl https://get.docker.com/ > dockerinstall && chmod 777 dockerinstall && ./dockerinstall + git clone --branch dev-jenkins https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript + cp ./../buildscript/master_deploy.sh . + cp ./../buildscript/buildenv.sh . + cp ./../buildscript/awsconfiguration.sh . + curl -sL https://deb.nodesource.com/setup_16.x | sudo bash - + apt -y install nodejs + ''' + } + } + stage('fetching configuration') + { + steps { + //fetching pre-req + sh """ + #!/bin/bash + ./awsconfiguration.sh ${DEPLOY_ENV} + echo "Fetching deployvar" + ./buildenv.sh -e ${DEPLOY_ENV} -b ${LOGICAL_ENV}-${APPNAME}-deployvarj + mv buildenvvar deployenvvar + mv buildenvvarg deployenvvarg + echo "Fetching Buildvar" + ./buildenv.sh -e ${DEPLOY_ENV} -b ${LOGICAL_ENV}-${APPNAME}-buildvar + aws s3 cp s3://tc-platform-${LOGICAL_ENV}/securitymanager/${LOGICAL_ENV}-freecodecamp.env ./.env + """ + load 'awsenvconfg' + load 'deployenvvarg' + load 'buildenvvarg' + } + } + stage('build application') + { + //Building Application + when { expression { IS_BUILD } } + steps { + // Doing Build + sh """ + #!/bin/bash + node --version + npm --version + git config --global url."https://git@".insteadOf git:// + npm ci + npm run build + ls -lath + """ + } + } + stage('appdeploy') + { + //Deploying app + when { expression { IS_APP_DEPLOY } } + steps { + //Doing Deployment + echo "Deploying application" + //input(message: 'Hello World!', ok: 'Submit') + sh """ + #!/bin/bash + ./master_deploy.sh -d CFRONT -e $DEPLOY_ENV -c $ENABLE_CACHE + """ + } + } + stage('apideploy') + { + //Deploying app + when { expression { IS_API_DEPLOY } } + steps { + //Doing Deployment + echo "Deploying Api" + // input(message: 'Hello World!', ok: 'Submit') + sh """ + #!/bin/bash + sed -i '/node_modules/d' ./.dockerignore + docker build -f docker/api/ECSDockerfile -t $APPNAME-api:latest . + ./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}-api + """ + } + } + } + +} From e833c37e7cf3b8c37fbf1503c2aaa6aeb7944956 Mon Sep 17 00:00:00 2001 From: Brooke Date: Wed, 7 Sep 2022 12:10:11 -0700 Subject: [PATCH 10/16] TCA-397 #comment This commit fixes a lint issue that only appears in github #time 5m --- client/src/analytics/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/analytics/index.tsx b/client/src/analytics/index.tsx index 7979177022806b..8362761097bd8e 100644 --- a/client/src/analytics/index.tsx +++ b/client/src/analytics/index.tsx @@ -7,8 +7,10 @@ import envData from '../../../config/env.json'; const { deploymentEnv } = envData; -const analyticsId = - deploymentEnv === 'staging' ? devAnalyticsId : prodAnalyticsId; +const analyticsId: string = + deploymentEnv === 'staging' + ? (devAnalyticsId as string) + : (prodAnalyticsId as string); ReactGA.initialize(analyticsId); From 26d9fdc0beb9213057aad6c0f5711a084a5acf64 Mon Sep 17 00:00:00 2001 From: Brooke Date: Wed, 7 Sep 2022 12:45:43 -0700 Subject: [PATCH 11/16] TCA-385 #comment This commit adds more logging to the request to save a challenge #time 10m --- api-server/src/server/boot/challenge.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/api-server/src/server/boot/challenge.js b/api-server/src/server/boot/challenge.js index 27357ab5c0dae7..3ba95a139f65a8 100644 --- a/api-server/src/server/boot/challenge.js +++ b/api-server/src/server/boot/challenge.js @@ -30,6 +30,12 @@ import { const log = debug('fcc:boot:challenges'); +console.debug('console.debug'); +console.info('console.info'); +console.error('console.error'); +console.log('console.log'); +log('log'); + export default async function bootChallenge(app, done) { const send200toNonUser = ifNoUserSend(true); const api = app.loopback.Router(); @@ -258,10 +264,11 @@ export function isValidChallengeCompletion(req, res, next) { message: 'That does not appear to be a valid challenge submission.' }; - console.debug('console.debug'); - console.info('console.info'); - console.error('console.error'); - console.log('console.log'); + console.debug('console.debug', 'isValidChallengeCompletion'); + console.info('console.info', 'isValidChallengeCompletion'); + console.error('console.error', 'isValidChallengeCompletion'); + console.log('console.log', 'isValidChallengeCompletion'); + log('log isValidChallengeCompletion'); if (!ObjectID.isValid(id)) { log('isObjectId', id, ObjectID.isValid(id)); From bf5b1c226cd398a3c7bc59559860d74823ee0de9 Mon Sep 17 00:00:00 2001 From: Brooke Date: Wed, 7 Sep 2022 14:29:38 -0700 Subject: [PATCH 12/16] TCA-385 #comment This commit adds more logging #time 5m --- api-server/src/server/utils/middleware.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api-server/src/server/utils/middleware.js b/api-server/src/server/utils/middleware.js index 52f5551fc85fb3..3b6a7364eee2cf 100644 --- a/api-server/src/server/utils/middleware.js +++ b/api-server/src/server/utils/middleware.js @@ -24,7 +24,9 @@ export function ifNoUserRedirectHome(message, type = 'errors') { } export function ifNoUserSend(sendThis) { + console.debug('ifNoUserSend', sendThis); return function (req, res, next) { + console.debug('ifNoUserSend function', req.user); if (req.user) { return next(); } From 4398cc3946aa28c9ad89825e41068611d49a08bd Mon Sep 17 00:00:00 2001 From: Brooke Date: Fri, 9 Sep 2022 08:42:59 -0700 Subject: [PATCH 13/16] TCA-385 remove extra logging #time 5m --- api-server/src/server/boot/challenge.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/api-server/src/server/boot/challenge.js b/api-server/src/server/boot/challenge.js index 3ba95a139f65a8..38ac25098e3a73 100644 --- a/api-server/src/server/boot/challenge.js +++ b/api-server/src/server/boot/challenge.js @@ -30,12 +30,6 @@ import { const log = debug('fcc:boot:challenges'); -console.debug('console.debug'); -console.info('console.info'); -console.error('console.error'); -console.log('console.log'); -log('log'); - export default async function bootChallenge(app, done) { const send200toNonUser = ifNoUserSend(true); const api = app.loopback.Router(); @@ -264,12 +258,6 @@ export function isValidChallengeCompletion(req, res, next) { message: 'That does not appear to be a valid challenge submission.' }; - console.debug('console.debug', 'isValidChallengeCompletion'); - console.info('console.info', 'isValidChallengeCompletion'); - console.error('console.error', 'isValidChallengeCompletion'); - console.log('console.log', 'isValidChallengeCompletion'); - log('log isValidChallengeCompletion'); - if (!ObjectID.isValid(id)) { log('isObjectId', id, ObjectID.isValid(id)); console.debug('isObjectId', id, ObjectID.isValid(id)); From 328900578dd539c862e372f714440bf80a754ebe Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Thu, 15 Sep 2022 17:08:18 +0300 Subject: [PATCH 14/16] TCA-425 - Update backend projects to advance to next lesson without completion modal --- .../Challenges/projects/backend/Show.tsx | 53 ++++++++++--------- .../Challenges/projects/solution-form.tsx | 5 +- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/client/src/templates/Challenges/projects/backend/Show.tsx b/client/src/templates/Challenges/projects/backend/Show.tsx index f27009fc4523e4..5b56ab017cdb7b 100644 --- a/client/src/templates/Challenges/projects/backend/Show.tsx +++ b/client/src/templates/Challenges/projects/backend/Show.tsx @@ -21,8 +21,6 @@ import { import ChallengeDescription from '../../components/Challenge-Description'; import Hotkeys from '../../components/Hotkeys'; import ChallengeTitle from '../../components/challenge-title'; -import CompletionModal from '../../components/completion-modal'; -import HelpModal from '../../components/help-modal'; import Output from '../../components/output'; import TestSuite from '../../components/test-suite'; import { @@ -33,12 +31,12 @@ import { initConsole, initTests, isChallengeCompletedSelector, + testsRunningSelector, updateChallengeMeta, - updateSolutionFormValues + updateSolutionFormValues, + submitChallenge } from '../../redux'; -import { getGuideUrl } from '../../utils'; import SolutionForm from '../solution-form'; -import ProjectToolPanel from '../tool-panel'; import '../../components/test-frame.css'; @@ -48,16 +46,19 @@ const mapStateToProps = createSelector( challengeTestsSelector, isChallengeCompletedSelector, isSignedInSelector, + testsRunningSelector, ( output: string[], tests: Test[], isChallengeCompleted: boolean, - isSignedIn: boolean + isSignedIn: boolean, + testsRunningSelector: boolean ) => ({ tests, output, isChallengeCompleted, - isSignedIn + isSignedIn, + testsRunningSelector }) ); @@ -67,7 +68,8 @@ const mapDispatchToActions = { initConsole, initTests, updateChallengeMeta, - updateSolutionFormValues + updateSolutionFormValues, + submitChallenge }; // Types @@ -86,8 +88,10 @@ interface BackEndProps { pageContext: { challengeMeta: ChallengeMeta; }; + submitChallenge: () => void; t: TFunction; tests: Test[]; + testsRunning: boolean; title: string; updateChallengeMeta: (arg0: ChallengeMeta) => void; updateSolutionFormValues: () => void; @@ -175,9 +179,16 @@ class BackEnd extends Component { } handleSubmit(): void { - this.props.executeChallenge({ - showCompletionModal: false - }); + const { tests, submitChallenge } = this.props; + const isChallengeComplete = tests.every(test => test.pass && !test.err); + + if (isChallengeComplete) { + submitChallenge(); + } else { + this.props.executeChallenge({ + showCompletionModal: false + }); + } } render() { @@ -185,14 +196,11 @@ class BackEnd extends Component { data: { challengeNode: { challenge: { - fields: { blockName }, challengeType, - forumTopicId, title, description, instructions, translationPending, - certification, superBlock, block } @@ -205,9 +213,15 @@ class BackEnd extends Component { }, t, tests, + testsRunning, updateSolutionFormValues } = this.props; + const isChallengeComplete = tests.every(test => test.pass && !test.err); + const submitBtnLabel: string = !isChallengeComplete ? ( + `${t('buttons.run-test')}${testsRunning ? ' ...' : ''}` + ) : t('buttons.submit-and-go'); + const blockNameTitle = `${t( `intro:${superBlock}.blocks.${block}.title` )} - ${title}`; @@ -243,9 +257,7 @@ class BackEnd extends Component { // eslint-disable-next-line @typescript-eslint/unbound-method onSubmit={this.handleSubmit} updateSolutionForm={updateSolutionFormValues} - /> -
{ - - diff --git a/client/src/templates/Challenges/projects/solution-form.tsx b/client/src/templates/Challenges/projects/solution-form.tsx index 712081077fb0a0..0f7a5cc1afda9b 100644 --- a/client/src/templates/Challenges/projects/solution-form.tsx +++ b/client/src/templates/Challenges/projects/solution-form.tsx @@ -16,6 +16,7 @@ interface SubmitProps { } interface FormProps extends WithTranslation { + buttonLabel?: string; challengeType: number; description?: string; onSubmit: (arg0: SubmitProps) => void; @@ -46,7 +47,7 @@ export class SolutionForm extends Component { }; render(): JSX.Element { - const { challengeType, description, t } = this.props; + const { buttonLabel, challengeType, description, t } = this.props; // back end challenges and front end projects use a single form field const solutionField = [ @@ -57,7 +58,7 @@ export class SolutionForm extends Component { { name: 'githubLink', label: t('learn.github-link') } ]; - const buttonCopy = t('learn.submit-and-go'); + const buttonCopy: string = buttonLabel ?? t('learn.submit-and-go'); const options = { types: { From d22a7f234fba361214952691780b49b423eb1060 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Thu, 15 Sep 2022 17:14:12 +0300 Subject: [PATCH 15/16] lint --- client/src/templates/Challenges/projects/backend/Show.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/templates/Challenges/projects/backend/Show.tsx b/client/src/templates/Challenges/projects/backend/Show.tsx index 5b56ab017cdb7b..161a266442b699 100644 --- a/client/src/templates/Challenges/projects/backend/Show.tsx +++ b/client/src/templates/Challenges/projects/backend/Show.tsx @@ -218,9 +218,9 @@ class BackEnd extends Component { } = this.props; const isChallengeComplete = tests.every(test => test.pass && !test.err); - const submitBtnLabel: string = !isChallengeComplete ? ( - `${t('buttons.run-test')}${testsRunning ? ' ...' : ''}` - ) : t('buttons.submit-and-go'); + const submitBtnLabel: string = !isChallengeComplete + ? `${t('buttons.run-test')}${testsRunning ? ' ...' : ''}` + : t('buttons.submit-and-go'); const blockNameTitle = `${t( `intro:${superBlock}.blocks.${block}.title` From 0321879b356ac8d2aa41f1512e9e160b93084d20 Mon Sep 17 00:00:00 2001 From: Brooke Date: Thu, 15 Sep 2022 12:42:15 -0700 Subject: [PATCH 16/16] TCA-385 clean up logging #time 15 --- api-server/src/server/utils/middleware.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/api-server/src/server/utils/middleware.js b/api-server/src/server/utils/middleware.js index 3b6a7364eee2cf..52f5551fc85fb3 100644 --- a/api-server/src/server/utils/middleware.js +++ b/api-server/src/server/utils/middleware.js @@ -24,9 +24,7 @@ export function ifNoUserRedirectHome(message, type = 'errors') { } export function ifNoUserSend(sendThis) { - console.debug('ifNoUserSend', sendThis); return function (req, res, next) { - console.debug('ifNoUserSend function', req.user); if (req.user) { return next(); }