Skip to content

Commit cef3c7c

Browse files
Added new Forums Object to Challenge Details
1 parent 21f27f5 commit cef3c7c

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

src/shared/components/challenge-detail/Header/TabSelector/index.jsx

+20-7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export default function ChallengeViewSelector(props) {
3636

3737
const numOfSub = numOfSubmissions + (numOfCheckpointSubmissions || 0);
3838
const forumId = _.get(challenge, 'legacy.forumId') || 0;
39+
const discuss = (_.get(challenge, 'discussions') || 0).filter(d => (
40+
d.type === 'challenge' && !_.isEmpty(d.url)
41+
));
3942
const roles = _.get(challenge, 'userDetails.roles') || [];
4043
const isDesign = trackLower === 'design';
4144

@@ -174,13 +177,23 @@ export default function ChallengeViewSelector(props) {
174177
) : null
175178
}
176179
{ (hasRegistered || Boolean(roles.length))
177-
&& (
178-
<a
179-
href={`${config.URL.FORUMS}${forumEndpoint}`}
180-
styleName={getSelectorStyle(selectedView, DETAIL_TABS.CHALLENGE_FORUM)}
181-
>
182-
CHALLENGE FORUM
183-
</a>
180+
&& _.isEmpty(discuss)
181+
? (
182+
<a
183+
href={`${config.URL.FORUMS}${forumEndpoint}`}
184+
styleName={getSelectorStyle(selectedView, DETAIL_TABS.CHALLENGE_FORUM)}
185+
>
186+
CHALLENGE FORUM
187+
</a>
188+
) : (
189+
discuss.map(d => (
190+
<a
191+
href={d.url}
192+
styleName={getSelectorStyle(selectedView, DETAIL_TABS.CHALLENGE_FORUM)}
193+
>
194+
{d.name}
195+
</a>
196+
))
184197
)
185198
}
186199
</div>

src/shared/components/challenge-detail/Specification/SideBar/index.jsx

+21-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default function SideBar({
2121
eventDetail,
2222
shareable,
2323
forumLink,
24+
discuss,
2425
hasRegistered,
2526
reviewType,
2627
isDesign,
@@ -266,10 +267,25 @@ export default function SideBar({
266267
<p styleName="link-like-paragraph">
267268
Questions?
268269
&zwnj;
269-
<a href={forumLink}>
270-
Ask in the Challenge Discussion Forums.
271-
</a>
270+
{_.isEmpty(discuss) && (
271+
<a href={forumLink}>
272+
Ask in the Challenge Discussion Forums.
273+
</a>
274+
)}
272275
</p>
276+
{!_.isEmpty(discuss) && (
277+
<ul>
278+
{ discuss.map(d => (
279+
<li>
280+
<a
281+
href={d.url}
282+
>
283+
{d.name}
284+
</a>
285+
</li>
286+
))}
287+
</ul>
288+
)}
273289
<h2>
274290
SOURCE FILES:
275291
</h2>
@@ -351,6 +367,7 @@ export default function SideBar({
351367

352368
SideBar.defaultProps = {
353369
eventDetail: null,
370+
discuss: [],
354371
documents: undefined,
355372
hasRegistered: false,
356373
reviewType: 'COMMUNITY',
@@ -376,6 +393,7 @@ SideBar.propTypes = {
376393
documents: PT.arrayOf(PT.shape()),
377394
shareable: PT.bool.isRequired,
378395
forumLink: PT.string.isRequired,
396+
discuss: PT.arrayOf(PT.shape()),
379397
hasRegistered: PT.bool,
380398
reviewType: PT.string,
381399
isDesign: PT.bool,

src/shared/components/challenge-detail/Specification/index.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ export default function ChallengeDetailsView(props) {
7676
codeRepo = codeRepoData.value;
7777
}
7878

79+
const discuss = (_.get(challenge, 'discussions') || 0).filter(d => (
80+
d.type === 'challenge' && !_.isEmpty(d.url)
81+
));
82+
7983
let forumLink = track.toLowerCase() === 'design'
8084
? `/?module=ThreadList&forumID=${forumId}`
8185
: `/?module=Category&categoryID=${forumId}`;
@@ -351,6 +355,7 @@ export default function ChallengeDetailsView(props) {
351355
challengesUrl={challengesUrl}
352356
legacyId={legacyId}
353357
forumLink={forumLink}
358+
discuss={discuss}
354359
documents={documents}
355360
hasRegistered={hasRegistered}
356361
isDesign={track.toLowerCase() === 'design'}

0 commit comments

Comments
 (0)