@@ -25,7 +25,7 @@ import {
2525 MILESTONE_STATUS ,
2626 PHASE_PRODUCT_CHALLENGE_ID_FIELD ,
2727 QA_TRACK_ID , DESIGN_CHALLENGE_TYPES , ROUND_TYPES ,
28- MULTI_ROUND_CHALLENGE_TEMPLATE_ID
28+ MULTI_ROUND_CHALLENGE_TEMPLATE_ID , DS_TRACK_ID
2929} from '../../config/constants'
3030import { PrimaryButton , OutlineButton } from '../Buttons'
3131import TrackField from './Track-Field'
@@ -598,6 +598,8 @@ class ChallengeEditor extends Component {
598598 submissionLimit . count = ''
599599 }
600600 existingMetadata . value = JSON . stringify ( submissionLimit )
601+ } else if ( existingMetadata . name === 'show_data_dashboard' ) {
602+ existingMetadata . value = Boolean ( value )
601603 } else {
602604 existingMetadata . value = `${ value } `
603605 }
@@ -949,9 +951,10 @@ class ChallengeEditor extends Component {
949951 async createNewChallenge ( ) {
950952 if ( ! this . props . isNew ) return
951953 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
953955 const { timelineTemplates } = metadata
954956 const isDesignChallenge = trackId === DES_TRACK_ID
957+ const isDataScience = trackId === DS_TRACK_ID
955958
956959 // indicate that creating process has started
957960 this . setState ( { isSaving : true } )
@@ -1009,6 +1012,16 @@ class ChallengeEditor extends Component {
10091012 newChallenge . discussions = discussions
10101013 }
10111014 }
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+ }
10121025 try {
10131026 const action = await createChallenge ( newChallenge , projectDetail . id )
10141027 if ( isTask ) {
@@ -1551,6 +1564,9 @@ class ChallengeEditor extends Component {
15511564 const isChallengeType = challenge . typeId === CHALLENGE_TYPE_ID
15521565 const showRoundType = isDesignChallenge && isChallengeType
15531566 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
15541570
15551571 const challengeForm = isNew
15561572 ? (
@@ -1567,6 +1583,24 @@ class ChallengeEditor extends Component {
15671583 )
15681584 }
15691585 < 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+ }
15701604 { projectDetail . version === 'v4' && < MilestoneField milestones = { activeProjectMilestones } onUpdateSelect = { this . onUpdateSelect } projectId = { projectDetail . id } selectedMilestoneId = { selectedMilestoneId } /> }
15711605 { useTask && ( < DiscussionField hasForum = { hasForum } toggleForum = { this . toggleForumOnCreate } /> ) }
15721606 </ div >
@@ -1600,6 +1634,24 @@ class ChallengeEditor extends Component {
16001634 </ div >
16011635
16021636 < 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+ }
16031655 { isTask && (
16041656 < AssignedMemberField
16051657 challenge = { challenge }
0 commit comments