Skip to content

Commit 9613fdd

Browse files
committed
Add data dashboard flag to display when creating a DS challenge
#1418 # Conflicts: # src/components/ChallengeEditor/ChallengeView/index.js # src/components/ChallengeEditor/index.js
1 parent da525a2 commit 9613fdd

File tree

2 files changed

+108
-12
lines changed

2 files changed

+108
-12
lines changed

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@ import AssignedMemberField from '../AssignedMember-Field'
2020
import { getResourceRoleByName } from '../../../util/tc'
2121
import { isBetaMode } from '../../../util/cookie'
2222
import { loadGroupDetails } from '../../../actions/challenges'
23-
import { REVIEW_TYPES, CONNECT_APP_URL, PHASE_PRODUCT_CHALLENGE_ID_FIELD } from '../../../config/constants'
23+
import {
24+
REVIEW_TYPES,
25+
CONNECT_APP_URL,
26+
PHASE_PRODUCT_CHALLENGE_ID_FIELD,
27+
MULTI_ROUND_CHALLENGE_TEMPLATE_ID,
28+
DS_TRACK_ID
29+
} from '../../../config/constants'
2430
import PhaseInput from '../../PhaseInput'
31+
import CheckpointPrizesField from '../CheckpointPrizes-Field'
2532

2633
const ChallengeView = ({
2734
projectDetail,
@@ -91,6 +98,10 @@ const ChallengeView = ({
9198
const showTimeline = false // disables the timeline for time being https://github.com/topcoder-platform/challenge-engine-ui/issues/706
9299
const isTask = _.get(challenge, 'task.isTask', false)
93100
const phases = _.get(challenge, 'phases', [])
101+
const showCheckpointPrizes = _.get(challenge, 'timelineTemplateId') === MULTI_ROUND_CHALLENGE_TEMPLATE_ID
102+
const isDataScience = challenge.trackId === DS_TRACK_ID
103+
const useDashboardData = _.find(challenge.metadata, { name: 'show_data_dashboard' })
104+
const useDashboard = useDashboardData ? useDashboardData.value : true
94105

95106
return (
96107
<div className={styles.wrapper}>
@@ -133,6 +144,13 @@ const ChallengeView = ({
133144
<span><span className={styles.fieldTitle}>Challenge Name:</span> {challenge.name}</span>
134145
</div>
135146
</div>
147+
{isDataScience && (
148+
<div className={cn(styles.row, styles.topRow)}>
149+
<div className={styles.col}>
150+
<span><span className={styles.fieldTitle}>Show data dashboard:</span> {useDashboard ? 'Yes' : 'No'}</span>
151+
</div>
152+
</div>
153+
)}
136154
{isTask &&
137155
<AssignedMemberField challenge={challenge} assignedMemberDetails={assignedMemberDetails} readOnly />}
138156
<CopilotField challenge={{
@@ -224,6 +242,11 @@ const ChallengeView = ({
224242
readOnly
225243
/>}
226244
<ChallengePrizesField challenge={challenge} readOnly />
245+
{
246+
showCheckpointPrizes && (
247+
<CheckpointPrizesField challenge={challenge} readOnly />
248+
)
249+
}
227250
<CopilotFeeField challenge={challenge} readOnly />
228251
<ChallengeTotalField challenge={challenge} />
229252
</div>

src/components/ChallengeEditor/index.js

Lines changed: 84 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ import {
2424
REVIEW_TYPES,
2525
MILESTONE_STATUS,
2626
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
2829
} from '../../config/constants'
2930
import { PrimaryButton, OutlineButton } from '../Buttons'
3031
import TrackField from './Track-Field'
3132
import TypeField from './Type-Field'
33+
import RoundTypeField from './RoundType-Field'
34+
import ChallengeTypeField from './ChallengeType-Field'
3235
import ChallengeNameField from './ChallengeName-Field'
3336
import CopilotField from './Copilot-Field'
3437
import ReviewTypeField from './ReviewType-Field'
@@ -59,6 +62,7 @@ import { getResourceRoleByName } from '../../util/tc'
5962
import { isBetaMode } from '../../util/cookie'
6063
import MilestoneField from './Milestone-Field'
6164
import DiscussionField from './Discussion-Field'
65+
import CheckpointPrizesField from './CheckpointPrizes-Field'
6266

6367
const theme = {
6468
container: styles.modalContainer
@@ -594,6 +598,8 @@ class ChallengeEditor extends Component {
594598
submissionLimit.count = ''
595599
}
596600
existingMetadata.value = JSON.stringify(submissionLimit)
601+
} else if (existingMetadata.name === 'show_data_dashboard') {
602+
existingMetadata.value = Boolean(value)
597603
} else {
598604
existingMetadata.value = `${value}`
599605
}
@@ -945,17 +951,10 @@ class ChallengeEditor extends Component {
945951
async createNewChallenge () {
946952
if (!this.props.isNew) return
947953
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
949955
const { timelineTemplates } = metadata
950956
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
959958

960959
// indicate that creating process has started
961960
this.setState({ isSaving: true })
@@ -967,6 +966,13 @@ class ChallengeEditor extends Component {
967966
const defaultTemplate = avlTemplates && avlTemplates.length > 0 ? avlTemplates[0] : STD_DEV_TIMELINE_TEMPLATE
968967
const isTask = _.find(metadata.challengeTypes, { id: typeId, isTask: true })
969968
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+
}
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 (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+
}
10091025
try {
10101026
const action = await createChallenge(newChallenge, projectDetail.id)
10111027
if (isTask) {
@@ -1544,13 +1560,47 @@ 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 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+
15471571
const challengeForm = isNew
15481572
? (
15491573
<form name='challenge-new-form' noValidate autoComplete='off' onSubmit={this.createChallengeHandler}>
15501574
<div className={styles.newFormContainer}>
15511575
<TrackField tracks={metadata.challengeTracks} challenge={challenge} onUpdateOthers={this.onUpdateOthers} />
15521576
<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+
}
15531585
<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+
}
15541604
{projectDetail.version === 'v4' && <MilestoneField milestones={activeProjectMilestones} onUpdateSelect={this.onUpdateSelect} projectId={projectDetail.id} selectedMilestoneId={selectedMilestoneId} />}
15551605
{useTask && (<DiscussionField hasForum={hasForum} toggleForum={this.toggleForumOnCreate} />)}
15561606
</div>
@@ -1584,6 +1634,24 @@ class ChallengeEditor extends Component {
15841634
</div>
15851635

15861636
<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+
}
15871655
{isTask && (
15881656
<AssignedMemberField
15891657
challenge={challenge}
@@ -1707,6 +1775,11 @@ class ChallengeEditor extends Component {
17071775
removeAttachment={removeAttachment}
17081776
/>}
17091777
<ChallengePrizesField challenge={challenge} onUpdateOthers={this.onUpdateOthers} />
1778+
{
1779+
showCheckpointPrizes && (
1780+
<CheckpointPrizesField onUpdateOthers={this.onUpdateOthers} challenge={challenge} />
1781+
)
1782+
}
17101783
<CopilotFeeField challenge={challenge} onUpdateOthers={this.onUpdateOthers} />
17111784
<ChallengeTotalField challenge={challenge} />
17121785
</div>

0 commit comments

Comments
 (0)