Skip to content

Commit c7a0fef

Browse files
committed
fixes based on feedback
1 parent b23b116 commit c7a0fef

File tree

6 files changed

+70
-120
lines changed

6 files changed

+70
-120
lines changed

src/components/ChallengeEditor/ChallengeViewTabs/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import _ from 'lodash'
1010
import ChallengeViewComponent from '../ChallengeView'
1111
import { PrimaryButton } from '../../Buttons'
1212
import LegacyLinks from '../../LegacyLinks'
13+
import ForumLink from '../../ForumLink'
1314
import Registrants from '../Registrants'
1415
import Submissions from '../Submissions'
1516
import { getResourceRoleByName } from '../../../util/tc'
@@ -93,7 +94,9 @@ const ChallengeViewTabs = ({
9394
styles.actionButtonsLeft
9495
)}
9596
>
96-
<LegacyLinks challenge={challenge} challengeView />
97+
{ isTask ? (<ForumLink challenge={challenge} />)
98+
: (<LegacyLinks challenge={challenge} challengeView />)
99+
}
97100
</div>
98101

99102
</div>

src/components/ChallengeEditor/Forum-Field/Forum-Field.module.scss

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/components/ChallengeEditor/Forum-Field/index.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/components/ChallengeEditor/index.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ class ChallengeEditor extends Component {
138138
this.onDeleteChallenge = this.onDeleteChallenge.bind(this)
139139
this.deleteModalLaunch = this.deleteModalLaunch.bind(this)
140140
this.toggleForumOnCreate = this.toggleForumOnCreate.bind(this)
141-
this.onSelectForum = this.onSelectForum.bind(this)
142-
this.toggleForumOnCreate = this.toggleForumOnCreate.bind(this)
143141
}
144142

145143
componentDidMount () {
@@ -593,10 +591,6 @@ class ChallengeEditor extends Component {
593591
this.setState({ hasForum: !hasForum })
594592
}
595593

596-
onSelectForum (hasForum) {
597-
this.setState({ hasForum })
598-
}
599-
600594
toggleAdvanceSettings () {
601595
const { isOpenAdvanceSettings } = this.state
602596
this.setState({ isOpenAdvanceSettings: !isOpenAdvanceSettings })
@@ -929,14 +923,7 @@ class ChallengeEditor extends Component {
929923
if (projectDetail.groups) {
930924
newChallenge.groups.push(...projectDetail.groups)
931925
}
932-
if (isTask) {
933-
if (this.state.hasForum) {
934-
const discussions = this.getDiscussionsConfig(newChallenge)
935-
if (discussions) {
936-
newChallenge.discussions = discussions
937-
}
938-
}
939-
} else {
926+
if (!isTask || this.state.hasForum) {
940927
const discussions = this.getDiscussionsConfig(newChallenge)
941928
if (discussions) {
942929
newChallenge.discussions = discussions
@@ -1461,7 +1448,7 @@ class ChallengeEditor extends Component {
14611448
)
14621449
}
14631450
</React.Fragment>
1464-
const useTask = _.find(metadata.challengeTypes, { id: challenge.typeId, isTask: true })
1451+
// const useTask = _.find(metadata.challengeTypes, { id: challenge.typeId, isTask: true })
14651452
const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId })
14661453
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })
14671454
const selectedMilestone = _.find(projectPhases,
@@ -1481,7 +1468,7 @@ class ChallengeEditor extends Component {
14811468
<TypeField types={metadata.challengeTypes} onUpdateSelect={this.onUpdateSelect} challenge={challenge} />
14821469
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
14831470
{projectDetail.version === 'v4' && <MilestoneField milestones={activeProjectMilestones} onUpdateSelect={this.onUpdateSelect} projectId={projectDetail.id} selectedMilestoneId={selectedMilestoneId} />}
1484-
{ useTask && (<DiscussionField hasForum={hasForum} toggleForum={this.toggleForumOnCreate} />) }
1471+
{ isTask && (<DiscussionField hasForum={hasForum} toggleForum={this.toggleForumOnCreate} />) }
14851472
</div>
14861473
{showDesignChallengeWarningModel && designChallengeModal}
14871474
{ errorContainer }
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@import "../../styles/includes";
2+
.container {
3+
display: flex;
4+
align-items: center;
5+
white-space: nowrap;
6+
7+
> a {
8+
margin: 0 5px;
9+
}
10+
11+
.row {
12+
margin-bottom: 0;
13+
14+
&.topRow {
15+
flex-wrap: wrap;
16+
}
17+
}
18+
19+
.col {
20+
margin-right: 20px;
21+
display: flex;
22+
align-items: center;
23+
24+
.fieldTitle {
25+
@include roboto-bold();
26+
27+
font-size: 16px;
28+
line-height: 19px;
29+
font-weight: 500;
30+
color: $tc-gray-80;
31+
margin-right: 10px;
32+
}
33+
}
34+
}

src/components/ForumLink/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Component to render ForumLink of the app
3+
*/
4+
import React from 'react'
5+
import PropTypes from 'prop-types'
6+
import cn from 'classnames'
7+
import styles from './ForumLink.module.scss'
8+
9+
const ForumLink = ({ challenge }) => {
10+
return (
11+
<div className={styles.container}>
12+
<div>
13+
{ challenge.discussions && challenge.discussions.map(d => (
14+
<div key={d.id} className={cn(styles.row, styles.topRow)}>
15+
<div className={styles.col} >
16+
<span><span className={styles.fieldTitle}><a href={d.url} target='_blank' rel='noopener noreferrer'>Forum</a></span></span>
17+
</div>
18+
</div>
19+
))}
20+
</div>
21+
</div>
22+
)
23+
}
24+
25+
ForumLink.propTypes = {
26+
challenge: PropTypes.object
27+
}
28+
29+
export default ForumLink

0 commit comments

Comments
 (0)