@@ -25,7 +25,7 @@ import {
25
25
MILESTONE_STATUS ,
26
26
PHASE_PRODUCT_CHALLENGE_ID_FIELD ,
27
27
QA_TRACK_ID , DESIGN_CHALLENGE_TYPES , ROUND_TYPES ,
28
- MULTI_ROUND_CHALLENGE_TEMPLATE_ID
28
+ MULTI_ROUND_CHALLENGE_TEMPLATE_ID , DS_TRACK_ID
29
29
} from '../../config/constants'
30
30
import { PrimaryButton , OutlineButton } from '../Buttons'
31
31
import TrackField from './Track-Field'
@@ -598,6 +598,8 @@ class ChallengeEditor extends Component {
598
598
submissionLimit . count = ''
599
599
}
600
600
existingMetadata . value = JSON . stringify ( submissionLimit )
601
+ } else if ( existingMetadata . name === 'show_data_dashboard' ) {
602
+ existingMetadata . value = Boolean ( value )
601
603
} else {
602
604
existingMetadata . value = `${ value } `
603
605
}
@@ -949,9 +951,10 @@ class ChallengeEditor extends Component {
949
951
async createNewChallenge ( ) {
950
952
if ( ! this . props . isNew ) return
951
953
const { metadata, createChallenge, projectDetail } = this . props
952
- const { challenge : { name, trackId, typeId, milestoneId, roundType, challengeType } } = this . state
954
+ const { challenge : { name, trackId, typeId, milestoneId, roundType, challengeType, metadata : challengeMetadata } } = this . state
953
955
const { timelineTemplates } = metadata
954
956
const isDesignChallenge = trackId === DES_TRACK_ID
957
+ const isDataScience = trackId === DS_TRACK_ID
955
958
956
959
// indicate that creating process has started
957
960
this . setState ( { isSaving : true } )
@@ -1009,6 +1012,16 @@ class ChallengeEditor extends Component {
1009
1012
newChallenge . discussions = discussions
1010
1013
}
1011
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
+ }
1012
1025
try {
1013
1026
const action = await createChallenge ( newChallenge , projectDetail . id )
1014
1027
if ( isTask ) {
@@ -1551,6 +1564,9 @@ class ChallengeEditor extends Component {
1551
1564
const isChallengeType = challenge . typeId === CHALLENGE_TYPE_ID
1552
1565
const showRoundType = isDesignChallenge && isChallengeType
1553
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
1554
1570
1555
1571
const challengeForm = isNew
1556
1572
? (
@@ -1567,6 +1583,24 @@ class ChallengeEditor extends Component {
1567
1583
)
1568
1584
}
1569
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
+ }
1570
1604
{ projectDetail . version === 'v4' && < MilestoneField milestones = { activeProjectMilestones } onUpdateSelect = { this . onUpdateSelect } projectId = { projectDetail . id } selectedMilestoneId = { selectedMilestoneId } /> }
1571
1605
{ useTask && ( < DiscussionField hasForum = { hasForum } toggleForum = { this . toggleForumOnCreate } /> ) }
1572
1606
</ div >
@@ -1600,6 +1634,24 @@ class ChallengeEditor extends Component {
1600
1634
</ div >
1601
1635
1602
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
+ }
1603
1655
{ isTask && (
1604
1656
< AssignedMemberField
1605
1657
challenge = { challenge }
0 commit comments