Skip to content

Commit f138cca

Browse files
author
vikasrohit
authored
Merge pull request #1247 from topcoder-platform/develop
Prod release - Forum config during challenge creation
2 parents ec46a86 + 5b33df4 commit f138cca

File tree

9 files changed

+339
-18
lines changed

9 files changed

+339
-18
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ workflows:
150150
context : org-global
151151
filters: &filters-dev
152152
branches:
153-
only: ['develop', 'feature/linking-challenge-milestone']
153+
only: ['develop', 'feature/forum-for-task']
154154

155155
# Production builds are exectuted only on tagged commits to the
156156
# master branch.

config/constants/development.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
3636
CHALLENGE_TYPE_ID: '927abff4-7af9-4145-8ba1-577c16e64e2e',
3737
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n',
38-
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c'],
38+
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c', 'ecd58c69-238f-43a4-a4bb-d172719b9f31'],
3939
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY,
4040
FILE_PICKER_CONTAINER_NAME: 'tc-challenge-v5-dev',
4141
FILE_PICKER_REGION: 'us-east-1',

config/constants/production.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
3636
CHALLENGE_TYPE_ID: '927abff4-7af9-4145-8ba1-577c16e64e2e',
3737
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF',
38-
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c'],
38+
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c', 'ecd58c69-238f-43a4-a4bb-d172719b9f31'],
3939
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY,
4040
FILE_PICKER_CONTAINER_NAME: 'tc-challenge-v5-prod',
4141
FILE_PICKER_REGION: 'us-east-1',

src/components/ChallengeEditor/ChallengeViewTabs/index.js

Lines changed: 14 additions & 11 deletions
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'
@@ -85,17 +86,19 @@ const ChallengeViewTabs = ({
8586
<div className={styles.topContainer}>
8687
<div className={styles.leftContainer}>
8788
<div className={styles.title}>{challenge.name}</div>
88-
{!isTask && (
89-
<div
90-
className={cn(
91-
styles.actionButtons,
92-
styles.button,
93-
styles.actionButtonsLeft
94-
)}
95-
>
96-
<LegacyLinks challenge={challenge} challengeView />
97-
</div>
98-
)}
89+
90+
<div
91+
className={cn(
92+
styles.actionButtons,
93+
styles.button,
94+
styles.actionButtonsLeft
95+
)}
96+
>
97+
{ isTask ? (<ForumLink challenge={challenge} />)
98+
: (<LegacyLinks challenge={challenge} challengeView />)
99+
}
100+
</div>
101+
99102
</div>
100103
<div
101104
className={cn(
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
@import '../../../styles/includes';
2+
3+
.row {
4+
box-sizing: border-box;
5+
display: flex;
6+
flex-direction: row;
7+
margin: 30px 30px 0 30px;
8+
align-content: space-between;
9+
justify-content: flex-start;
10+
11+
.fieldTitle {
12+
@include roboto-bold();
13+
font-size: 16px;
14+
line-height: 19px;
15+
font-weight: 500;
16+
color: $tc-gray-80;
17+
margin-right: 10px;
18+
}
19+
20+
.field {
21+
@include upto-sm {
22+
display: block;
23+
padding-bottom: 10px;
24+
}
25+
26+
label {
27+
@include roboto-bold();
28+
29+
font-size: 16px;
30+
line-height: 19px;
31+
font-weight: 500;
32+
color: $tc-gray-80;
33+
}
34+
35+
&.col1 {
36+
max-width: 185px;
37+
min-width: 185px;
38+
margin-right: 14px;
39+
margin-bottom: auto;
40+
margin-top: auto;
41+
padding-top: 10px;
42+
white-space: nowrap;
43+
display: flex;
44+
align-items: center;
45+
46+
span {
47+
color: $tc-red;
48+
}
49+
}
50+
51+
&.col2 {
52+
align-self: flex-end;
53+
width: 80%;
54+
margin-bottom: auto;
55+
margin-top: auto;
56+
display: flex;
57+
flex-direction: row;
58+
max-width: 600px;
59+
min-width: 600px;
60+
}
61+
}
62+
63+
.col1 {
64+
display: flex;
65+
flex-grow: 1;
66+
align-items: center;
67+
max-width: 0;
68+
min-width: 0;
69+
margin-right: 0;
70+
width: auto;
71+
margin-top: 0 !important;
72+
margin-bottom: 0 !important;
73+
padding-top: 0 !important;
74+
}
75+
76+
.col2 {
77+
width: auto;
78+
79+
.subGroup {
80+
width: 100%;
81+
display: flex;
82+
flex-direction: column;
83+
84+
.subRow {
85+
display: flex;
86+
align-items: center;
87+
margin-bottom: 18px;
88+
}
89+
90+
.subRow:last-of-type {
91+
margin-bottom: 0;
92+
}
93+
}
94+
}
95+
96+
.tcRadioButton {
97+
.tc-radioButton-label {
98+
@include roboto-light();
99+
100+
line-height: 17px;
101+
font-weight: 300;
102+
margin-left: 21px;
103+
user-select: none;
104+
cursor: pointer;
105+
width: 195px;
106+
font-size: 14px;
107+
color: #3d3d3d;
108+
}
109+
110+
height: 18px;
111+
width: 80px;
112+
margin: 0;
113+
padding: 0;
114+
vertical-align: bottom;
115+
position: relative;
116+
display: inline-block;
117+
118+
input[type=radio] {
119+
display: none;
120+
}
121+
122+
label {
123+
@include roboto-light();
124+
125+
line-height: 17px;
126+
font-weight: 300;
127+
cursor: pointer;
128+
position: absolute;
129+
display: inline-block;
130+
width: 16px;
131+
height: 16px;
132+
border-radius: 8px;
133+
top: 0;
134+
left: 0;
135+
border: none;
136+
box-shadow: none;
137+
background: $tc-gray-30;
138+
transition: all 0.15s ease-in-out;
139+
140+
&::after {
141+
opacity: 0;
142+
content: '';
143+
position: absolute;
144+
width: 8px;
145+
height: 8px;
146+
background: transparent;
147+
top: 4px;
148+
left: 4px;
149+
border: 4px solid $tc-blue-20;
150+
border-radius: 4px;
151+
transition: all 0.15s ease-in-out;
152+
}
153+
154+
&:hover::after {
155+
opacity: 0.3;
156+
}
157+
158+
div {
159+
margin-left: 24px;
160+
width: 300px;
161+
}
162+
}
163+
164+
input[type=radio]:checked ~ label {
165+
background: $tc-blue-20;
166+
}
167+
168+
input[type=radio]:checked + label::after {
169+
opacity: 1;
170+
border-color: $white;
171+
}
172+
}
173+
174+
&.error {
175+
color: $tc-red;
176+
margin-top: -25px;
177+
}
178+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import cn from 'classnames'
4+
import styles from './Discussion-Field.module.scss'
5+
6+
const DiscussionField = ({ hasForum, toggleForum, readOnly }) => {
7+
console.log('hasForummm ' + hasForum)
8+
if (readOnly) {
9+
return (
10+
<div className={styles.row}>
11+
<div className={cn(styles.field, styles.col1, styles.fieldTitle)}>Forum Discussion :</div>
12+
<div className={cn(styles.field, styles.col2)}>
13+
{ hasForum ? 'On' : 'Off' }
14+
</div>
15+
</div>
16+
)
17+
}
18+
19+
return (
20+
<div className={styles.row}>
21+
<div className={cn(styles.field, styles.col1, styles.fieldTitle)}>Forum Discussion :</div>
22+
<div className={cn(styles.field, styles.col2)}>
23+
<div className={styles.tcRadioButton}>
24+
<input
25+
name='forum'
26+
type='radio'
27+
id='forum-on'
28+
checked={hasForum}
29+
onChange={toggleForum}
30+
/>
31+
<label className={styles['tc-RadioButton-label']} htmlFor='forum-on'>
32+
<div>On</div>
33+
</label>
34+
</div>
35+
<div className={styles.tcRadioButton}>
36+
<input
37+
name='forum'
38+
type='radio'
39+
id='forum-off'
40+
checked={!hasForum}
41+
onChange={toggleForum}
42+
/>
43+
<label className={styles['tc-RadioButton-label']} htmlFor='forum-off'>
44+
<div>Off</div>
45+
</label>
46+
</div>
47+
</div>
48+
</div>
49+
)
50+
}
51+
52+
DiscussionField.defaultProps = {
53+
readOnly: false
54+
}
55+
56+
DiscussionField.propTypes = {
57+
hasForum: PropTypes.bool,
58+
toggleForum: PropTypes.func,
59+
readOnly: PropTypes.bool
60+
}
61+
62+
export default DiscussionField

src/components/ChallengeEditor/index.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import UseSchedulingAPIField from './UseSchedulingAPIField'
5757
import { getResourceRoleByName } from '../../util/tc'
5858
import { isBetaMode } from '../../util/cookie'
5959
import MilestoneField from './Milestone-Field'
60+
import DiscussionField from './Discussion-Field'
6061

6162
const theme = {
6263
container: styles.modalContainer
@@ -78,6 +79,7 @@ class ChallengeEditor extends Component {
7879
isDeleteLaunch: false,
7980
isConfirm: false,
8081
isClose: false,
82+
hasForum: false,
8183
isOpenAdvanceSettings: false,
8284
isLoading: false,
8385
isSaving: false,
@@ -135,6 +137,7 @@ class ChallengeEditor extends Component {
135137
this.updateResource = this.updateResource.bind(this)
136138
this.onDeleteChallenge = this.onDeleteChallenge.bind(this)
137139
this.deleteModalLaunch = this.deleteModalLaunch.bind(this)
140+
this.toggleForumOnCreate = this.toggleForumOnCreate.bind(this)
138141
}
139142

140143
componentDidMount () {
@@ -583,6 +586,11 @@ class ChallengeEditor extends Component {
583586
this.setState({ challenge: newChallenge })
584587
}
585588

589+
toggleForumOnCreate () {
590+
const { hasForum } = this.state
591+
this.setState({ hasForum: !hasForum })
592+
}
593+
586594
toggleAdvanceSettings () {
587595
const { isOpenAdvanceSettings } = this.state
588596
this.setState({ isOpenAdvanceSettings: !isOpenAdvanceSettings })
@@ -817,7 +825,9 @@ class ChallengeEditor extends Component {
817825
'terms',
818826
'prizeSets',
819827
'winners',
820-
'milestoneId'
828+
'milestoneId',
829+
'discussions',
830+
'task'
821831
], this.state.challenge)
822832
const isTask = _.find(metadata.challengeTypes, { id: challenge.typeId, isTask: true })
823833
challenge.legacy = _.assign(this.state.challenge.legacy, {
@@ -913,9 +923,11 @@ class ChallengeEditor extends Component {
913923
if (projectDetail.groups) {
914924
newChallenge.groups.push(...projectDetail.groups)
915925
}
916-
const discussions = this.getDiscussionsConfig(newChallenge)
917-
if (discussions) {
918-
newChallenge.discussions = discussions
926+
if (!isTask || this.state.hasForum) {
927+
const discussions = this.getDiscussionsConfig(newChallenge)
928+
if (discussions) {
929+
newChallenge.discussions = discussions
930+
}
919931
}
920932
try {
921933
const action = await createChallenge(newChallenge, projectDetail.id)
@@ -1197,6 +1209,7 @@ class ChallengeEditor extends Component {
11971209
showDesignChallengeWarningModel,
11981210
challenge,
11991211
draftChallenge,
1212+
hasForum,
12001213
isOpenAdvanceSettings,
12011214
isSaving,
12021215
isCloseTask
@@ -1435,6 +1448,7 @@ class ChallengeEditor extends Component {
14351448
)
14361449
}
14371450
</React.Fragment>
1451+
const useTask = _.find(metadata.challengeTypes, { id: challenge.typeId, isTask: true })
14381452
const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId })
14391453
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })
14401454
const selectedMilestone = _.find(projectPhases,
@@ -1454,6 +1468,7 @@ class ChallengeEditor extends Component {
14541468
<TypeField types={metadata.challengeTypes} onUpdateSelect={this.onUpdateSelect} challenge={challenge} />
14551469
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
14561470
{projectDetail.version === 'v4' && <MilestoneField milestones={activeProjectMilestones} onUpdateSelect={this.onUpdateSelect} projectId={projectDetail.id} selectedMilestoneId={selectedMilestoneId} />}
1471+
{ useTask && (<DiscussionField hasForum={hasForum} toggleForum={this.toggleForumOnCreate} />) }
14571472
</div>
14581473
{showDesignChallengeWarningModel && designChallengeModal}
14591474
{ errorContainer }

0 commit comments

Comments
 (0)