@@ -57,6 +57,7 @@ import UseSchedulingAPIField from './UseSchedulingAPIField'
5757import { getResourceRoleByName } from '../../util/tc'
5858import { isBetaMode } from '../../util/cookie'
5959import MilestoneField from './Milestone-Field'
60+ import DiscussionField from './Discussion-Field'
6061
6162const 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