Skip to content

Commit 406d47d

Browse files
Naomi Carriganlasjorg
Naomi Carrigan
andauthored
feat: add search link to help modal (freeCodeCamp#47385)
Co-authored-by: =?UTF-8?q?Lasse=20J=C3=B8rgensen?= <28780271+lasjorg@users.noreply.github.com>
1 parent 4d1a2d5 commit 406d47d

File tree

7 files changed

+44
-5
lines changed

7 files changed

+44
-5
lines changed

client/i18n/locales/english/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@
286286
"percent-complete": "{{percent}}% complete",
287287
"tried-rsa": "If you've already tried the <0>Read-Search-Ask</0> method, then you can ask for help on the freeCodeCamp forum.",
288288
"rsa": "Read, search, ask",
289+
"rsa-forum": "<strong>Before making a new post</strong> please see if your question has <0>already been answered on the forum</0>.",
289290
"reset": "Reset this lesson?",
290291
"reset-warn": "Are you sure you wish to reset this lesson? The editors and tests will be reset.",
291292
"reset-warn-2": "This cannot be undone",

client/src/templates/Challenges/classic/show.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ class ShowClassic extends Component<ShowClassicProps, ShowClassicState> {
532532
certification={certification}
533533
superBlock={superBlock}
534534
/>
535-
<HelpModal />
535+
<HelpModal challengeTitle={title} challengeBlock={blockName} />
536536
<VideoModal videoUrl={this.getVideoUrl()} />
537537
<ResetModal />
538538
<ProjectPreviewModal

client/src/templates/Challenges/codeally/show.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class ShowCodeAlly extends Component<ShowCodeAllyProps> {
368368
certification={certification}
369369
superBlock={superBlock}
370370
/>
371-
<HelpModal />
371+
<HelpModal challengeTitle={title} challengeBlock={blockName} />
372372
</Row>
373373
</Grid>
374374
</LearnLayout>

client/src/templates/Challenges/components/help-modal.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
.alert > p > strong {
2+
color: inherit;
3+
}
4+
5+
.fa-circle-exclamation {
6+
font-size: 3rem;
7+
padding-bottom: 10px;
8+
}
9+
110
@media screen and (max-width: 767px) {
211
.help-modal .btn-lg {
312
font-size: 16px;

client/src/templates/Challenges/components/help-modal.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { faExclamationCircle } from '@fortawesome/free-solid-svg-icons';
2+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
13
import { Button, Modal } from '@freecodecamp/react-bootstrap';
24
import React from 'react';
35
import { Trans, withTranslation } from 'react-i18next';
@@ -16,6 +18,8 @@ interface HelpModalProps {
1618
executeGA: (attributes: { type: string; data: string }) => void;
1719
isOpen?: boolean;
1820
t: (text: string) => string;
21+
challengeTitle: string;
22+
challengeBlock: string;
1923
}
2024

2125
const { forumLocation } = envData;
@@ -31,12 +35,22 @@ const mapDispatchToProps = (dispatch: Dispatch) =>
3135

3236
const RSA = forumLocation + '/t/19514';
3337

38+
const generateSearchLink = (title: string, block: string) => {
39+
const query = /^step\s*\d*$/i.test(title)
40+
? encodeURIComponent(`${block} - ${title}`)
41+
: encodeURIComponent(title);
42+
const search = `${forumLocation}/search?q=${query}`;
43+
return search;
44+
};
45+
3446
export function HelpModal({
3547
closeHelpModal,
3648
createQuestion,
3749
executeGA,
3850
isOpen,
39-
t
51+
t,
52+
challengeBlock,
53+
challengeTitle
4054
}: HelpModalProps): JSX.Element {
4155
if (isOpen) {
4256
executeGA({ type: 'modal', data: '/help-modal' });
@@ -61,6 +75,21 @@ export function HelpModal({
6175
</a>
6276
</Trans>
6377
</h3>
78+
<div className='alert alert-danger'>
79+
<FontAwesomeIcon icon={faExclamationCircle} />
80+
<p>
81+
<Trans i18nKey='learn.rsa-forum'>
82+
<a
83+
href={generateSearchLink(challengeTitle, challengeBlock)}
84+
rel='noopener noreferrer'
85+
target='_blank'
86+
>
87+
placeholder
88+
</a>
89+
placeholder
90+
</Trans>
91+
</p>
92+
</div>
6493
<Button
6594
block={true}
6695
bsSize='lg'

client/src/templates/Challenges/projects/backend/Show.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class BackEnd extends Component<BackEndProps> {
270270
certification={certification}
271271
superBlock={superBlock}
272272
/>
273-
<HelpModal />
273+
<HelpModal challengeTitle={title} challengeBlock={blockName} />
274274
</Row>
275275
</Grid>
276276
</LearnLayout>

client/src/templates/Challenges/projects/frontend/Show.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class Project extends Component<ProjectProps> {
204204
certification={certification}
205205
superBlock={superBlock}
206206
/>
207-
<HelpModal />
207+
<HelpModal challengeTitle={title} challengeBlock={blockName} />
208208
</Row>
209209
</Grid>
210210
</LearnLayout>

0 commit comments

Comments
 (0)