@@ -24,11 +24,14 @@ import {
24
24
REVIEW_TYPES ,
25
25
MILESTONE_STATUS ,
26
26
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
28
29
} from '../../config/constants'
29
30
import { PrimaryButton , OutlineButton } from '../Buttons'
30
31
import TrackField from './Track-Field'
31
32
import TypeField from './Type-Field'
33
+ import RoundTypeField from './RoundType-Field'
34
+ import ChallengeTypeField from './ChallengeType-Field'
32
35
import ChallengeNameField from './ChallengeName-Field'
33
36
import CopilotField from './Copilot-Field'
34
37
import ReviewTypeField from './ReviewType-Field'
@@ -59,6 +62,7 @@ import { getResourceRoleByName } from '../../util/tc'
59
62
import { isBetaMode } from '../../util/cookie'
60
63
import MilestoneField from './Milestone-Field'
61
64
import DiscussionField from './Discussion-Field'
65
+ import CheckpointPrizesField from './CheckpointPrizes-Field'
62
66
63
67
const theme = {
64
68
container : styles . modalContainer
@@ -594,6 +598,8 @@ class ChallengeEditor extends Component {
594
598
submissionLimit . count = ''
595
599
}
596
600
existingMetadata . value = JSON . stringify ( submissionLimit )
601
+ } else if ( existingMetadata . name === 'show_data_dashboard' ) {
602
+ existingMetadata . value = Boolean ( value )
597
603
} else {
598
604
existingMetadata . value = `${ value } `
599
605
}
@@ -945,17 +951,10 @@ class ChallengeEditor extends Component {
945
951
async createNewChallenge ( ) {
946
952
if ( ! this . props . isNew ) return
947
953
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
949
955
const { timelineTemplates } = metadata
950
956
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
959
958
960
959
// indicate that creating process has started
961
960
this . setState ( { isSaving : true } )
@@ -967,6 +966,13 @@ class ChallengeEditor extends Component {
967
966
const defaultTemplate = avlTemplates && avlTemplates . length > 0 ? avlTemplates [ 0 ] : STD_DEV_TIMELINE_TEMPLATE
968
967
const isTask = _ . find ( metadata . challengeTypes , { id : typeId , isTask : true } )
969
968
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
+ }
970
976
971
977
const newChallenge = {
972
978
status : 'New' ,
@@ -979,7 +985,7 @@ class ChallengeEditor extends Component {
979
985
reviewType : isTask || isDesignChallenge ? REVIEW_TYPES . INTERNAL : REVIEW_TYPES . COMMUNITY
980
986
} ,
981
987
descriptionFormat : 'markdown' ,
982
- timelineTemplateId : defaultTemplate . id ,
988
+ timelineTemplateId,
983
989
terms : [ { id : DEFAULT_TERM_UUID , roleId : SUBMITTER_ROLE_UUID } ] ,
984
990
groups : [ ] ,
985
991
milestoneId,
@@ -1006,6 +1012,16 @@ class ChallengeEditor extends Component {
1006
1012
newChallenge . discussions = discussions
1007
1013
}
1008
1014
}
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
+ }
1009
1025
try {
1010
1026
const action = await createChallenge ( newChallenge , projectDetail . id )
1011
1027
if ( isTask ) {
@@ -1544,13 +1560,47 @@ class ChallengeEditor extends Component {
1544
1560
const currentChallengeId = this . getCurrentChallengeId ( )
1545
1561
const showTimeline = false // disables the timeline for time being https://github.com/topcoder-platform/challenge-engine-ui/issues/706
1546
1562
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
+
1547
1571
const challengeForm = isNew
1548
1572
? (
1549
1573
< form name = 'challenge-new-form' noValidate autoComplete = 'off' onSubmit = { this . createChallengeHandler } >
1550
1574
< div className = { styles . newFormContainer } >
1551
1575
< TrackField tracks = { metadata . challengeTracks } challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
1552
1576
< 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
+ }
1553
1585
< 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
+ }
1554
1604
{ projectDetail . version === 'v4' && < MilestoneField milestones = { activeProjectMilestones } onUpdateSelect = { this . onUpdateSelect } projectId = { projectDetail . id } selectedMilestoneId = { selectedMilestoneId } /> }
1555
1605
{ useTask && ( < DiscussionField hasForum = { hasForum } toggleForum = { this . toggleForumOnCreate } /> ) }
1556
1606
</ div >
@@ -1584,6 +1634,24 @@ class ChallengeEditor extends Component {
1584
1634
</ div >
1585
1635
1586
1636
< 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
+ }
1587
1655
{ isTask && (
1588
1656
< AssignedMemberField
1589
1657
challenge = { challenge }
@@ -1707,6 +1775,11 @@ class ChallengeEditor extends Component {
1707
1775
removeAttachment = { removeAttachment }
1708
1776
/> }
1709
1777
< ChallengePrizesField challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
1778
+ {
1779
+ showCheckpointPrizes && (
1780
+ < CheckpointPrizesField onUpdateOthers = { this . onUpdateOthers } challenge = { challenge } />
1781
+ )
1782
+ }
1710
1783
< CopilotFeeField challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
1711
1784
< ChallengeTotalField challenge = { challenge } />
1712
1785
</ div >
0 commit comments