@@ -20,6 +20,7 @@ import {
2020 MESSAGE ,
2121 COMMUNITY_APP_URL ,
2222 DES_TRACK_ID ,
23+ CHALLENGE_TYPE_ID ,
2324 REVIEW_TYPES
2425} from '../../config/constants'
2526import { PrimaryButton , OutlineButton } from '../Buttons'
@@ -52,7 +53,6 @@ import Tooltip from '../Tooltip'
5253import UseSchedulingAPIField from './UseSchedulingAPIField'
5354import { getResourceRoleByName } from '../../util/tc'
5455import { isBetaMode } from '../../util/cookie'
55- import TimelineTemplateField from './TimelineTemplate-Field'
5656
5757const theme = {
5858 container : styles . modalContainer
@@ -77,6 +77,7 @@ class ChallengeEditor extends Component {
7777 isOpenAdvanceSettings : false ,
7878 isLoading : false ,
7979 isSaving : false ,
80+ showDesignChallengeWarningModel : false ,
8081 hasValidationErrors : false ,
8182 challenge : {
8283 ...dropdowns [ 'newChallenge' ]
@@ -111,9 +112,11 @@ class ChallengeEditor extends Component {
111112 this . onUpdateDescription = this . onUpdateDescription . bind ( this )
112113 this . onActiveChallenge = this . onActiveChallenge . bind ( this )
113114 this . resetModal = this . resetModal . bind ( this )
115+ this . resetDesignChallengeWarningModal = this . resetDesignChallengeWarningModal . bind ( this )
114116 this . openCloseTaskConfirmation = this . openCloseTaskConfirmation . bind ( this )
115117 this . onCloseTask = this . onCloseTask . bind ( this )
116118 this . createNewChallenge = this . createNewChallenge . bind ( this )
119+ this . createNewDesignChallenge = this . createNewDesignChallenge . bind ( this )
117120 this . getCurrentChallengeId = this . getCurrentChallengeId . bind ( this )
118121 this . isValidChallengePrizes = this . isValidChallengePrizes . bind ( this )
119122 this . isValidChallenge = this . isValidChallenge . bind ( this )
@@ -236,6 +239,10 @@ class ChallengeEditor extends Component {
236239 }
237240 }
238241
242+ resetDesignChallengeWarningModal ( ) {
243+ this . setState ( { showDesignChallengeWarningModel : false } )
244+ }
245+
239246 resetModal ( ) {
240247 this . setState ( { isLoading : false , isConfirm : false , isLaunch : false , error : null , isCloseTask : false , isDeleteLaunch : false } )
241248 }
@@ -825,12 +832,25 @@ class ChallengeEditor extends Component {
825832 history . push ( newPath )
826833 } ;
827834
835+ createNewDesignChallenge ( ) {
836+ this . resetDesignChallengeWarningModal ( )
837+ this . createNewChallenge ( )
838+ }
839+
828840 async createNewChallenge ( ) {
829841 if ( ! this . props . isNew ) return
830842 const { metadata, createChallenge, projectDetail } = this . props
831- const { name, trackId, typeId } = this . state . challenge
843+ const { showDesignChallengeWarningModel , challenge : { name, trackId, typeId } } = this . state
832844 const { timelineTemplates } = metadata
833845 const isDesignChallenge = trackId === DES_TRACK_ID
846+ const isChallengeType = typeId === CHALLENGE_TYPE_ID
847+
848+ if ( ! showDesignChallengeWarningModel && isDesignChallenge && isChallengeType ) {
849+ this . setState ( {
850+ showDesignChallengeWarningModel : true
851+ } )
852+ return
853+ }
834854
835855 // indicate that creating process has started
836856 this . setState ( { isSaving : true } )
@@ -839,7 +859,7 @@ class ChallengeEditor extends Component {
839859 const STD_DEV_TIMELINE_TEMPLATE = _ . find ( timelineTemplates , { name : 'Standard Development' } )
840860 const avlTemplates = this . getAvailableTimelineTemplates ( )
841861 // chooses first available timeline template or fallback template for the new challenge
842- const defaultTemplate = _ . find ( avlTemplates || [ ] , t => t . isDefault ) || STD_DEV_TIMELINE_TEMPLATE
862+ const defaultTemplate = avlTemplates && avlTemplates . length > 0 ? avlTemplates [ 0 ] : STD_DEV_TIMELINE_TEMPLATE
843863 const isTask = _ . find ( metadata . challengeTypes , { id : typeId , isTask : true } )
844864 const newChallenge = {
845865 status : 'New' ,
@@ -852,7 +872,7 @@ class ChallengeEditor extends Component {
852872 reviewType : isTask || isDesignChallenge ? REVIEW_TYPES . INTERNAL : REVIEW_TYPES . COMMUNITY
853873 } ,
854874 descriptionFormat : 'markdown' ,
855- timelineTemplateId : _ . get ( this . getCurrentTemplate ( ) , 'id' , defaultTemplate . id ) ,
875+ timelineTemplateId : defaultTemplate . id ,
856876 terms : [ { id : DEFAULT_TERM_UUID , roleId : SUBMITTER_ROLE_UUID } ] ,
857877 groups : [ ]
858878 // prizeSets: this.getDefaultPrizeSets()
@@ -1141,16 +1161,15 @@ class ChallengeEditor extends Component {
11411161
11421162 // all timeline template ids available for the challenge type
11431163 const availableTemplateIds = _ . filter ( challengeTimelines , ct => ct . typeId === challenge . typeId && ct . trackId === challenge . trackId ) . map ( tt => tt . timelineTemplateId )
1144- const defaultChallengeTimeline = _ . find ( challengeTimelines , ct => ct . typeId === challenge . typeId && ct . trackId === challenge . trackId && ct . isDefault )
11451164 // filter and return timeline templates that are available for this challenge type
1146- const avlTemplates = _ . filter ( timelineTemplates , tt => availableTemplateIds . indexOf ( tt . id ) !== - 1 )
1147- return _ . map ( avlTemplates , tt => tt . id === defaultChallengeTimeline . timelineTemplateId ? { ...tt , isDefault : true } : tt )
1165+ return _ . filter ( timelineTemplates , tt => availableTemplateIds . indexOf ( tt . id ) !== - 1 )
11481166 }
11491167
11501168 render ( ) {
11511169 const {
11521170 isLaunch,
11531171 isConfirm,
1172+ showDesignChallengeWarningModel,
11541173 challenge,
11551174 draftChallenge,
11561175 isOpenAdvanceSettings,
@@ -1222,6 +1241,30 @@ class ChallengeEditor extends Component {
12221241 }
12231242 }
12241243
1244+ let designChallengeModal
1245+ if ( showDesignChallengeWarningModel ) {
1246+ const messageBody = (
1247+ < div >
1248+ < div >
1249+ At this time, Work Manager only supports single-round (no checkpoint) challenges for design. If you want to run a multi-round (has checkpoints) design challenge, please use Direct.
1250+ </ div >
1251+ < div >
1252+ Do you want to proceed with set-up?
1253+ </ div >
1254+ </ div >
1255+ )
1256+ designChallengeModal = (
1257+ < ConfirmationModal
1258+ title = 'Reminder'
1259+ message = { messageBody }
1260+ theme = { theme }
1261+ cancelText = 'Cancel Set-Up'
1262+ confirmText = 'Continue Set-Up'
1263+ onCancel = { this . resetDesignChallengeWarningModal }
1264+ onConfirm = { this . createNewDesignChallenge }
1265+ />
1266+ )
1267+ }
12251268 if ( ! isNew && isLaunch && ! isConfirm ) {
12261269 activateModal = (
12271270 < ConfirmationModal
@@ -1363,15 +1406,9 @@ class ChallengeEditor extends Component {
13631406 < div className = { styles . newFormContainer } >
13641407 < TrackField tracks = { metadata . challengeTracks } challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
13651408 < TypeField types = { metadata . challengeTypes } onUpdateSelect = { this . onUpdateSelect } challenge = { challenge } />
1366- < TimelineTemplateField
1367- currentTemplate = { this . state . currentTemplate }
1368- challengeTimelines = { metadata . challengeTimelines }
1369- timelineTemplates = { metadata . timelineTemplates }
1370- challenge = { challenge }
1371- onUpdateSelect = { this . resetPhase }
1372- />
13731409 < ChallengeNameField challenge = { challenge } onUpdateInput = { this . onUpdateInput } />
13741410 </ div >
1411+ { showDesignChallengeWarningModel && designChallengeModal }
13751412 { errorContainer }
13761413 { actionButtons }
13771414 </ form >
@@ -1399,6 +1436,7 @@ class ChallengeEditor extends Component {
13991436 < span > < span className = { styles . fieldTitle } > Status:</ span > { challenge . status } </ span >
14001437 </ div >
14011438 </ div >
1439+
14021440 < ChallengeNameField challenge = { challenge } onUpdateInput = { this . onUpdateInput } />
14031441 { isTask && (
14041442 < AssignedMemberField
@@ -1447,13 +1485,6 @@ class ChallengeEditor extends Component {
14471485 { isBetaMode ( ) && (
14481486 < UseSchedulingAPIField challenge = { challenge } toggleUseSchedulingAPI = { this . toggleUseSchedulingAPI } />
14491487 ) }
1450- < TimelineTemplateField
1451- challengeTimelines = { metadata . challengeTimelines }
1452- timelineTemplates = { metadata . timelineTemplates }
1453- challenge = { challenge }
1454- currentTemplate = { this . state . currentTemplate }
1455- onUpdateSelect = { this . resetPhase }
1456- />
14571488 </ React . Fragment >
14581489 ) }
14591490 { ! isTask && (
0 commit comments