@@ -24,11 +24,14 @@ import {
2424 REVIEW_TYPES ,
2525 MILESTONE_STATUS ,
2626 PHASE_PRODUCT_CHALLENGE_ID_FIELD ,
27- QA_TRACK_ID
27+ QA_TRACK_ID , DESIGN_CHALLENGE_TYPES , ROUND_TYPES ,
28+ MULTI_ROUND_CHALLENGE_TEMPLATE_ID , DS_TRACK_ID
2829} from '../../config/constants'
2930import { PrimaryButton , OutlineButton } from '../Buttons'
3031import TrackField from './Track-Field'
3132import TypeField from './Type-Field'
33+ import RoundTypeField from './RoundType-Field'
34+ import ChallengeTypeField from './ChallengeType-Field'
3235import ChallengeNameField from './ChallengeName-Field'
3336import CopilotField from './Copilot-Field'
3437import ReviewTypeField from './ReviewType-Field'
@@ -59,6 +62,7 @@ import { getResourceRoleByName } from '../../util/tc'
5962import { isBetaMode } from '../../util/cookie'
6063import MilestoneField from './Milestone-Field'
6164import DiscussionField from './Discussion-Field'
65+ import CheckpointPrizesField from './CheckpointPrizes-Field'
6266
6367const theme = {
6468 container : styles . modalContainer
@@ -594,6 +598,8 @@ class ChallengeEditor extends Component {
594598 submissionLimit . count = ''
595599 }
596600 existingMetadata . value = JSON . stringify ( submissionLimit )
601+ } else if ( existingMetadata . name === 'show_data_dashboard' ) {
602+ existingMetadata . value = Boolean ( value )
597603 } else {
598604 existingMetadata . value = `${ value } `
599605 }
@@ -945,17 +951,10 @@ class ChallengeEditor extends Component {
945951 async createNewChallenge ( ) {
946952 if ( ! this . props . isNew ) return
947953 const { metadata, createChallenge, projectDetail } = this . props
948- const { showDesignChallengeWarningModel , challenge : { name, trackId, typeId, milestoneId } } = this . state
954+ const { challenge : { name, trackId, typeId, milestoneId, roundType , challengeType , metadata : challengeMetadata } } = this . state
949955 const { timelineTemplates } = metadata
950956 const isDesignChallenge = trackId === DES_TRACK_ID
951- const isChallengeType = typeId === CHALLENGE_TYPE_ID
952-
953- if ( ! showDesignChallengeWarningModel && isDesignChallenge && isChallengeType ) {
954- this . setState ( {
955- showDesignChallengeWarningModel : true
956- } )
957- return
958- }
957+ const isDataScience = trackId === DS_TRACK_ID
959958
960959 // indicate that creating process has started
961960 this . setState ( { isSaving : true } )
@@ -967,6 +966,13 @@ class ChallengeEditor extends Component {
967966 const defaultTemplate = avlTemplates && avlTemplates . length > 0 ? avlTemplates [ 0 ] : STD_DEV_TIMELINE_TEMPLATE
968967 const isTask = _ . find ( metadata . challengeTypes , { id : typeId , isTask : true } )
969968 const tags = trackId === QA_TRACK_ID ? [ 'QA' ] : [ ]
969+ if ( challengeType ) {
970+ tags . push ( challengeType )
971+ }
972+ let timelineTemplateId = defaultTemplate . id
973+ if ( roundType === ROUND_TYPES . TWO_ROUNDS ) {
974+ timelineTemplateId = MULTI_ROUND_CHALLENGE_TEMPLATE_ID
975+ }
970976
971977 const newChallenge = {
972978 status : 'New' ,
@@ -979,7 +985,7 @@ class ChallengeEditor extends Component {
979985 reviewType : isTask || isDesignChallenge ? REVIEW_TYPES . INTERNAL : REVIEW_TYPES . COMMUNITY
980986 } ,
981987 descriptionFormat : 'markdown' ,
982- timelineTemplateId : defaultTemplate . id ,
988+ timelineTemplateId,
983989 terms : [ { id : DEFAULT_TERM_UUID , roleId : SUBMITTER_ROLE_UUID } ] ,
984990 groups : [ ] ,
985991 milestoneId,
@@ -1006,6 +1012,16 @@ class ChallengeEditor extends Component {
10061012 newChallenge . discussions = discussions
10071013 }
10081014 }
1015+ if ( isDataScience ) {
1016+ if ( ! newChallenge . metadata ) {
1017+ newChallenge . metadata = [ ]
1018+ }
1019+ let useDashboard = _ . find ( challengeMetadata , { name : 'show_data_dashboard' } )
1020+ if ( useDashboard === undefined ) {
1021+ useDashboard = { name : 'show_data_dashboard' , value : true }
1022+ }
1023+ newChallenge . metadata . push ( useDashboard )
1024+ }
10091025 try {
10101026 const action = await createChallenge ( newChallenge , projectDetail . id )
10111027 if ( isTask ) {
@@ -1544,13 +1560,47 @@ class ChallengeEditor extends Component {
15441560 const currentChallengeId = this . getCurrentChallengeId ( )
15451561 const showTimeline = false // disables the timeline for time being https://github.com/topcoder-platform/challenge-engine-ui/issues/706
15461562 const copilotResources = metadata . members || challengeResources
1563+ const isDesignChallenge = challenge . trackId === DES_TRACK_ID
1564+ const isChallengeType = challenge . typeId === CHALLENGE_TYPE_ID
1565+ const showRoundType = isDesignChallenge && isChallengeType
1566+ const showCheckpointPrizes = challenge . timelineTemplateId === MULTI_ROUND_CHALLENGE_TEMPLATE_ID
1567+ const isDataScience = challenge . trackId === DS_TRACK_ID
1568+ const useDashboardData = _ . find ( challenge . metadata , { name : 'show_data_dashboard' } )
1569+ const useDashboard = useDashboardData ? useDashboardData . value : true
1570+
15471571 const challengeForm = isNew
15481572 ? (
15491573 < form name = 'challenge-new-form' noValidate autoComplete = 'off' onSubmit = { this . createChallengeHandler } >
15501574 < div className = { styles . newFormContainer } >
15511575 < TrackField tracks = { metadata . challengeTracks } challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
15521576 < TypeField types = { metadata . challengeTypes } onUpdateSelect = { this . onUpdateSelect } challenge = { challenge } />
1577+ {
1578+ showRoundType && (
1579+ < >
1580+ < RoundTypeField roundType = { challenge . roundType } onUpdateOthers = { this . onUpdateOthers } />
1581+ < ChallengeTypeField types = { DESIGN_CHALLENGE_TYPES } onUpdateSelect = { this . onUpdateSelect } challenge = { challenge } />
1582+ </ >
1583+ )
1584+ }
15531585 < ChallengeNameField challenge = { challenge } onUpdateInput = { this . onUpdateInput } />
1586+ {
1587+ isDataScience && (
1588+ < div className = { styles . row } >
1589+ < div className = { cn ( styles . field , styles . col1 ) } >
1590+ < label htmlFor = 'isDashboardEnabled' > Use data dashboard :</ label >
1591+ </ div >
1592+ < div className = { cn ( styles . field , styles . col2 ) } >
1593+ < input
1594+ name = 'isDashboardEnabled'
1595+ type = 'checkbox'
1596+ id = 'isDashboardEnabled'
1597+ checked = { useDashboard }
1598+ onChange = { ( e ) => this . onUpdateMetadata ( 'show_data_dashboard' , e . target . checked ) }
1599+ />
1600+ </ div >
1601+ </ div >
1602+ )
1603+ }
15541604 { projectDetail . version === 'v4' && < MilestoneField milestones = { activeProjectMilestones } onUpdateSelect = { this . onUpdateSelect } projectId = { projectDetail . id } selectedMilestoneId = { selectedMilestoneId } /> }
15551605 { useTask && ( < DiscussionField hasForum = { hasForum } toggleForum = { this . toggleForumOnCreate } /> ) }
15561606 </ div >
@@ -1584,6 +1634,24 @@ class ChallengeEditor extends Component {
15841634 </ div >
15851635
15861636 < ChallengeNameField challenge = { challenge } onUpdateInput = { this . onUpdateInput } />
1637+ {
1638+ isDataScience && (
1639+ < div className = { styles . row } >
1640+ < div className = { cn ( styles . field , styles . col1 ) } >
1641+ < label htmlFor = 'isDashboardEnabled' > Use data dashboard :</ label >
1642+ </ div >
1643+ < div className = { cn ( styles . field , styles . col2 ) } >
1644+ < input
1645+ name = 'isDashboardEnabled'
1646+ type = 'checkbox'
1647+ id = 'isDashboardEnabled'
1648+ checked = { useDashboard }
1649+ onChange = { ( e ) => this . onUpdateMetadata ( 'show_data_dashboard' , e . target . checked ) }
1650+ />
1651+ </ div >
1652+ </ div >
1653+ )
1654+ }
15871655 { isTask && (
15881656 < AssignedMemberField
15891657 challenge = { challenge }
@@ -1707,6 +1775,11 @@ class ChallengeEditor extends Component {
17071775 removeAttachment = { removeAttachment }
17081776 /> }
17091777 < ChallengePrizesField challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
1778+ {
1779+ showCheckpointPrizes && (
1780+ < CheckpointPrizesField onUpdateOthers = { this . onUpdateOthers } challenge = { challenge } />
1781+ )
1782+ }
17101783 < CopilotFeeField challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
17111784 < ChallengeTotalField challenge = { challenge } />
17121785 </ div >
0 commit comments