From 4a0519e7a64f905c66f9cf1a648ee5156783dc1c Mon Sep 17 00:00:00 2001 From: Shaun Hamilton Date: Mon, 5 Feb 2024 18:17:33 +0200 Subject: [PATCH] feat(client): adjust solution-form for gitpod (#53511) Co-authored-by: Oliver Eyton-Williams --- client/i18n/locales/english/translations.json | 2 +- client/src/components/formHelpers/form-validators.tsx | 4 +++- client/src/templates/Challenges/codeally/show.tsx | 2 +- .../templates/Challenges/projects/solution-form.tsx | 10 ++++++---- e2e/form-helper.spec.ts | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client/i18n/locales/english/translations.json b/client/i18n/locales/english/translations.json index 7253fae83d7..c2dc838ac24 100644 --- a/client/i18n/locales/english/translations.json +++ b/client/i18n/locales/english/translations.json @@ -364,7 +364,7 @@ "assignments": "Assignments", "question": "Question", "solution-link": "Solution Link", - "github-link": "GitHub Link", + "source-code-link": "Source Code Link", "ms-link": "Microsoft Link", "submit-and-go": "Submit and go to my next challenge", "congratulations": "Congratulations, your code passes. Submit your code to continue.", diff --git a/client/src/components/formHelpers/form-validators.tsx b/client/src/components/formHelpers/form-validators.tsx index 53d95087d4f..99a537d6e88 100644 --- a/client/src/components/formHelpers/form-validators.tsx +++ b/client/src/components/formHelpers/form-validators.tsx @@ -1,7 +1,9 @@ import React from 'react'; import { Trans } from 'react-i18next'; -// Matches editor links for: Replit, Glitch, CodeSandbox, GitHub +// Matches editor links for: Replit, Glitch, CodeSandbox, GitHub. NOT Codespaces, and NOT Gitpod yet +// Once safari allows negative lookbehinds, this can be used: +// |(? { const isCompleted = completedChallenges.some( challenge => challenge.id === challengeId ); - const titleContext = t('learn.github-link'); + const titleContext = t('learn.source-code-link'); return showCodeAlly ? ( diff --git a/client/src/templates/Challenges/projects/solution-form.tsx b/client/src/templates/Challenges/projects/solution-form.tsx index fd5c1d4f1f6..e616e6ac613 100644 --- a/client/src/templates/Challenges/projects/solution-form.tsx +++ b/client/src/templates/Challenges/projects/solution-form.tsx @@ -51,7 +51,7 @@ export class SolutionForm extends Component { ]; const backEndProjectFields = [ { name: 'solution', label: t('learn.solution-link') }, - { name: 'githubLink', label: t('learn.github-link') } + { name: 'githubLink', label: t('learn.source-code-link') } ]; const buttonCopy = t('learn.i-completed'); @@ -80,12 +80,14 @@ export class SolutionForm extends Component { case challengeTypes.backend: formFields = solutionField; options.isLocalLinkAllowed = true; - solutionLink = solutionLink + 'https://project-name.camperbot.repl.co/'; + solutionLink = solutionLink + 'https://3000-project-url.gitpod.io/'; break; case challengeTypes.backEndProject: formFields = backEndProjectFields; - solutionLink = solutionLink + 'https://project-name.camperbot.repl.co/'; + options.required.push('githubLink'); + options.isLocalLinkAllowed = true; + solutionLink = solutionLink + 'https://3000-project-url.gitpod.io/'; solutionFormID = 'back-end-form'; break; @@ -121,7 +123,7 @@ export class SolutionForm extends Component { ...options, placeholders: { solution: solutionLink, - githubLink: 'ex: https://github.com/camperbot/hello' + githubLink: 'ex: https://your-git-repo.url/files' } }} submit={this.handleSubmit} diff --git a/e2e/form-helper.spec.ts b/e2e/form-helper.spec.ts index 5e1e139aed3..b00119e51d5 100644 --- a/e2e/form-helper.spec.ts +++ b/e2e/form-helper.spec.ts @@ -83,7 +83,7 @@ test.describe('Test form with solution link and github link', () => { ); await expect(githubLinkInputLabel).toBeVisible(); await expect(githubLinkInputLabel).toHaveText( - translations.learn['github-link'] + translations.learn['source-code-link'] ); const githubLinkInput = solutionForm.getByTestId('githubLink-form-control');