@@ -20,11 +20,14 @@ import {
2020 MESSAGE ,
2121 COMMUNITY_APP_URL ,
2222 DES_TRACK_ID ,
23+ DEV_TRACK_ID ,
2324 CHALLENGE_TYPE_ID ,
25+ MARATHON_TYPE_ID ,
2426 REVIEW_TYPES ,
2527 MILESTONE_STATUS ,
2628 PHASE_PRODUCT_CHALLENGE_ID_FIELD ,
27- QA_TRACK_ID
29+ QA_TRACK_ID ,
30+ DS_TRACK_ID
2831} from '../../config/constants'
2932import { PrimaryButton , OutlineButton } from '../Buttons'
3033import TrackField from './Track-Field'
@@ -594,6 +597,8 @@ class ChallengeEditor extends Component {
594597 submissionLimit . count = ''
595598 }
596599 existingMetadata . value = JSON . stringify ( submissionLimit )
600+ } else if ( existingMetadata . name === 'show_data_dashboard' ) {
601+ existingMetadata . value = Boolean ( value )
597602 } else {
598603 existingMetadata . value = `${ value } `
599604 }
@@ -945,17 +950,14 @@ class ChallengeEditor extends Component {
945950 async createNewChallenge ( ) {
946951 if ( ! this . props . isNew ) return
947952 const { metadata, createChallenge, projectDetail } = this . props
948- const { showDesignChallengeWarningModel , challenge : { name, trackId, typeId, milestoneId } } = this . state
953+ const { challenge : { name, trackId, typeId, milestoneId, challengeType , metadata : challengeMetadata } } = this . state
949954 const { timelineTemplates } = metadata
950955 const isDesignChallenge = trackId === DES_TRACK_ID
956+ const isDataScience = trackId === DS_TRACK_ID
951957 const isChallengeType = typeId === CHALLENGE_TYPE_ID
952-
953- if ( ! showDesignChallengeWarningModel && isDesignChallenge && isChallengeType ) {
954- this . setState ( {
955- showDesignChallengeWarningModel : true
956- } )
957- return
958- }
958+ const isDevChallenge = trackId === DEV_TRACK_ID
959+ const isMM = typeId === MARATHON_TYPE_ID
960+ const showDashBoard = ( isDataScience && isChallengeType ) || ( isDevChallenge && isMM )
959961
960962 // indicate that creating process has started
961963 this . setState ( { isSaving : true } )
@@ -967,6 +969,10 @@ class ChallengeEditor extends Component {
967969 const defaultTemplate = avlTemplates && avlTemplates . length > 0 ? avlTemplates [ 0 ] : STD_DEV_TIMELINE_TEMPLATE
968970 const isTask = _ . find ( metadata . challengeTypes , { id : typeId , isTask : true } )
969971 const tags = trackId === QA_TRACK_ID ? [ 'QA' ] : [ ]
972+ if ( challengeType ) {
973+ tags . push ( challengeType )
974+ }
975+ let timelineTemplateId = defaultTemplate . id
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 ( showDashBoard ) {
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,38 @@ 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 isDevChallenge = challenge . trackId === DEV_TRACK_ID
1564+ const isMM = challenge . typeId === MARATHON_TYPE_ID
1565+ const isChallengeType = challenge . typeId === CHALLENGE_TYPE_ID
1566+ const showDashBoard = ( challenge . trackId === DS_TRACK_ID && isChallengeType ) || ( isDevChallenge && isMM )
1567+ const useDashboardData = _ . find ( challenge . metadata , { name : 'show_data_dashboard' } )
1568+ const useDashboard = useDashboardData ? useDashboardData . value : true
1569+
15471570 const challengeForm = isNew
15481571 ? (
15491572 < form name = 'challenge-new-form' noValidate autoComplete = 'off' onSubmit = { this . createChallengeHandler } >
15501573 < div className = { styles . newFormContainer } >
15511574 < TrackField tracks = { metadata . challengeTracks } challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
15521575 < TypeField types = { metadata . challengeTypes } onUpdateSelect = { this . onUpdateSelect } challenge = { challenge } />
15531576 < ChallengeNameField challenge = { challenge } onUpdateInput = { this . onUpdateInput } />
1577+ {
1578+ showDashBoard && (
1579+ < div className = { styles . row } >
1580+ < div className = { cn ( styles . field , styles . col1 ) } >
1581+ < label htmlFor = 'isDashboardEnabled' > Use data dashboard :</ label >
1582+ </ div >
1583+ < div className = { cn ( styles . field , styles . col2 ) } >
1584+ < input
1585+ name = 'isDashboardEnabled'
1586+ type = 'checkbox'
1587+ id = 'isDashboardEnabled'
1588+ checked = { useDashboard }
1589+ onChange = { ( e ) => this . onUpdateMetadata ( 'show_data_dashboard' , e . target . checked ) }
1590+ />
1591+ </ div >
1592+ </ div >
1593+ )
1594+ }
15541595 { projectDetail . version === 'v4' && < MilestoneField milestones = { activeProjectMilestones } onUpdateSelect = { this . onUpdateSelect } projectId = { projectDetail . id } selectedMilestoneId = { selectedMilestoneId } /> }
15551596 { useTask && ( < DiscussionField hasForum = { hasForum } toggleForum = { this . toggleForumOnCreate } /> ) }
15561597 </ div >
@@ -1584,6 +1625,24 @@ class ChallengeEditor extends Component {
15841625 </ div >
15851626
15861627 < ChallengeNameField challenge = { challenge } onUpdateInput = { this . onUpdateInput } />
1628+ {
1629+ showDashBoard && (
1630+ < div className = { styles . row } >
1631+ < div className = { cn ( styles . field , styles . col1 ) } >
1632+ < label htmlFor = 'isDashboardEnabled' > Use data dashboard :</ label >
1633+ </ div >
1634+ < div className = { cn ( styles . field , styles . col2 ) } >
1635+ < input
1636+ name = 'isDashboardEnabled'
1637+ type = 'checkbox'
1638+ id = 'isDashboardEnabled'
1639+ checked = { useDashboard }
1640+ onChange = { ( e ) => this . onUpdateMetadata ( 'show_data_dashboard' , e . target . checked ) }
1641+ />
1642+ </ div >
1643+ </ div >
1644+ )
1645+ }
15871646 { isTask && (
15881647 < AssignedMemberField
15891648 challenge = { challenge }
0 commit comments