Skip to content

Commit f7507e1

Browse files
committed
Add data dashboard flag to display when creating a DS challenge
#1418
1 parent 2207958 commit f7507e1

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import {
2424
REVIEW_TYPES,
2525
CONNECT_APP_URL,
2626
PHASE_PRODUCT_CHALLENGE_ID_FIELD,
27-
MULTI_ROUND_CHALLENGE_TEMPLATE_ID
27+
MULTI_ROUND_CHALLENGE_TEMPLATE_ID,
28+
DS_TRACK_ID
2829
} from '../../../config/constants'
2930
import PhaseInput from '../../PhaseInput'
3031
import CheckpointPrizesField from '../CheckpointPrizes-Field'
@@ -98,6 +99,9 @@ const ChallengeView = ({
9899
const isTask = _.get(challenge, 'task.isTask', false)
99100
const phases = _.get(challenge, 'phases', [])
100101
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
101105

102106
return (
103107
<div className={styles.wrapper}>
@@ -140,6 +144,13 @@ const ChallengeView = ({
140144
<span><span className={styles.fieldTitle}>Challenge Name:</span> {challenge.name}</span>
141145
</div>
142146
</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+
)}
143154
{isTask &&
144155
<AssignedMemberField challenge={challenge} assignedMemberDetails={assignedMemberDetails} readOnly />}
145156
<CopilotField challenge={{

src/components/ChallengeEditor/index.js

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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'
3030
import { PrimaryButton, OutlineButton } from '../Buttons'
3131
import 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

Comments
 (0)