@@ -20,11 +20,14 @@ import {
20
20
MESSAGE ,
21
21
COMMUNITY_APP_URL ,
22
22
DES_TRACK_ID ,
23
+ DEV_TRACK_ID ,
23
24
CHALLENGE_TYPE_ID ,
25
+ MARATHON_TYPE_ID ,
24
26
REVIEW_TYPES ,
25
27
MILESTONE_STATUS ,
26
28
PHASE_PRODUCT_CHALLENGE_ID_FIELD ,
27
- QA_TRACK_ID
29
+ QA_TRACK_ID ,
30
+ DS_TRACK_ID
28
31
} from '../../config/constants'
29
32
import { PrimaryButton , OutlineButton } from '../Buttons'
30
33
import TrackField from './Track-Field'
@@ -594,6 +597,8 @@ class ChallengeEditor extends Component {
594
597
submissionLimit . count = ''
595
598
}
596
599
existingMetadata . value = JSON . stringify ( submissionLimit )
600
+ } else if ( existingMetadata . name === 'show_data_dashboard' ) {
601
+ existingMetadata . value = Boolean ( value )
597
602
} else {
598
603
existingMetadata . value = `${ value } `
599
604
}
@@ -945,17 +950,14 @@ class ChallengeEditor extends Component {
945
950
async createNewChallenge ( ) {
946
951
if ( ! this . props . isNew ) return
947
952
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
949
954
const { timelineTemplates } = metadata
950
955
const isDesignChallenge = trackId === DES_TRACK_ID
956
+ const isDataScience = trackId === DS_TRACK_ID
951
957
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 )
959
961
960
962
// indicate that creating process has started
961
963
this . setState ( { isSaving : true } )
@@ -967,6 +969,10 @@ class ChallengeEditor extends Component {
967
969
const defaultTemplate = avlTemplates && avlTemplates . length > 0 ? avlTemplates [ 0 ] : STD_DEV_TIMELINE_TEMPLATE
968
970
const isTask = _ . find ( metadata . challengeTypes , { id : typeId , isTask : true } )
969
971
const tags = trackId === QA_TRACK_ID ? [ 'QA' ] : [ ]
972
+ if ( challengeType ) {
973
+ tags . push ( challengeType )
974
+ }
975
+ let timelineTemplateId = defaultTemplate . id
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 ( 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
+ }
1009
1025
try {
1010
1026
const action = await createChallenge ( newChallenge , projectDetail . id )
1011
1027
if ( isTask ) {
@@ -1544,13 +1560,38 @@ 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 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
+
1547
1570
const challengeForm = isNew
1548
1571
? (
1549
1572
< form name = 'challenge-new-form' noValidate autoComplete = 'off' onSubmit = { this . createChallengeHandler } >
1550
1573
< div className = { styles . newFormContainer } >
1551
1574
< TrackField tracks = { metadata . challengeTracks } challenge = { challenge } onUpdateOthers = { this . onUpdateOthers } />
1552
1575
< TypeField types = { metadata . challengeTypes } onUpdateSelect = { this . onUpdateSelect } challenge = { challenge } />
1553
1576
< 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
+ }
1554
1595
{ projectDetail . version === 'v4' && < MilestoneField milestones = { activeProjectMilestones } onUpdateSelect = { this . onUpdateSelect } projectId = { projectDetail . id } selectedMilestoneId = { selectedMilestoneId } /> }
1555
1596
{ useTask && ( < DiscussionField hasForum = { hasForum } toggleForum = { this . toggleForumOnCreate } /> ) }
1556
1597
</ div >
@@ -1584,6 +1625,24 @@ class ChallengeEditor extends Component {
1584
1625
</ div >
1585
1626
1586
1627
< 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
+ }
1587
1646
{ isTask && (
1588
1647
< AssignedMemberField
1589
1648
challenge = { challenge }
0 commit comments