Skip to content

Commit 8e321de

Browse files
committed
Show the data dashboard switch
#1418
1 parent 2207958 commit 8e321de

File tree

3 files changed

+117
-2
lines changed

3 files changed

+117
-2
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
@import "../../../styles/includes";
2+
3+
.row {
4+
box-sizing: border-box;
5+
display: flex;
6+
flex-direction: row;
7+
margin: 30px 30px 0 30px;
8+
align-content: space-between;
9+
justify-content: flex-start;
10+
11+
.field {
12+
@include upto-sm {
13+
display: block;
14+
padding-bottom: 10px;
15+
}
16+
17+
label {
18+
@include roboto-bold();
19+
20+
font-size: 16px;
21+
line-height: 19px;
22+
font-weight: 500;
23+
color: $tc-gray-80;
24+
}
25+
26+
&.col1 {
27+
max-width: 185px;
28+
min-width: 185px;
29+
margin-right: 14px;
30+
white-space: nowrap;
31+
display: flex;
32+
align-items: center;
33+
34+
span {
35+
color: $tc-red;
36+
}
37+
}
38+
39+
&.col2.error {
40+
color: $tc-red;
41+
margin-top: -25px;
42+
}
43+
&.col2 {
44+
align-self: flex-end;
45+
margin-bottom: auto;
46+
margin-top: auto;
47+
display: flex;
48+
flex-direction: row;
49+
max-width: 600px;
50+
min-width: 600px;
51+
}
52+
}
53+
}
54+
55+
@-moz-document url-prefix() {
56+
.challengeName {
57+
&::-moz-placeholder { /* Mozilla Firefox 19+ */
58+
line-height: 38px;
59+
}
60+
&::-webkit-input-placeholder { /* Webkit */
61+
line-height: 38px;
62+
}
63+
&:-ms-input-placeholder { /* IE */
64+
line-height: 38px;
65+
}
66+
}
67+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import styles from './ShowDataDashboard-Field.module.scss'
4+
import cn from 'classnames'
5+
6+
const ShowDataDashboardField = ({ onUpdateInput, value }) => {
7+
return (
8+
<>
9+
<div className={styles.row}>
10+
<div className={cn(styles.field, styles.col1)}>
11+
<label htmlFor='challengeName'>Show Data Dashboard :</label>
12+
</div>
13+
<div className={cn(styles.field, styles.col2)}>
14+
<input
15+
type='checkbox'
16+
label='Show data dashboard'
17+
onChange={(e) => onUpdateInput('show_data_dashboard', e.target.checked)}
18+
checked={value === 'true' || value === true}
19+
readOnly={false}
20+
/>
21+
</div>
22+
</div>
23+
</>
24+
)
25+
}
26+
27+
ShowDataDashboardField.propTypes = {
28+
onUpdateInput: PropTypes.func.isRequired,
29+
value: PropTypes.any.isRequired
30+
}
31+
32+
export default ShowDataDashboardField

src/components/ChallengeEditor/index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
MESSAGE,
2121
COMMUNITY_APP_URL,
2222
DES_TRACK_ID,
23+
DS_TRACK_ID,
2324
CHALLENGE_TYPE_ID,
2425
REVIEW_TYPES,
2526
MILESTONE_STATUS,
@@ -33,6 +34,7 @@ import TypeField from './Type-Field'
3334
import RoundTypeField from './RoundType-Field'
3435
import ChallengeTypeField from './ChallengeType-Field'
3536
import ChallengeNameField from './ChallengeName-Field'
37+
import ShowDataDashboardField from './ShowDataDashboard-Field'
3638
import CopilotField from './Copilot-Field'
3739
import ReviewTypeField from './ReviewType-Field'
3840
import TermsField from './Terms-Field'
@@ -91,7 +93,13 @@ class ChallengeEditor extends Component {
9193
showDesignChallengeWarningModel: false,
9294
hasValidationErrors: false,
9395
challenge: {
94-
...dropdowns['newChallenge']
96+
...dropdowns['newChallenge'],
97+
metadata: [
98+
{
99+
'name': 'show_data_dashboard',
100+
'value': true
101+
}
102+
]
95103
},
96104
draftChallenge: { data: { id: null } },
97105
currentTemplate: null,
@@ -949,9 +957,10 @@ class ChallengeEditor extends Component {
949957
async createNewChallenge () {
950958
if (!this.props.isNew) return
951959
const { metadata, createChallenge, projectDetail } = this.props
952-
const { challenge: { name, trackId, typeId, milestoneId, roundType, challengeType } } = this.state
960+
const { challenge: { name, trackId, typeId, milestoneId, roundType, challengeType, challengeMetadata } } = this.state
953961
const { timelineTemplates } = metadata
954962
const isDesignChallenge = trackId === DES_TRACK_ID
963+
const isDataScienceChallenge = trackId === DS_TRACK_ID
955964

956965
// indicate that creating process has started
957966
this.setState({ isSaving: true })
@@ -1009,6 +1018,9 @@ class ChallengeEditor extends Component {
10091018
newChallenge.discussions = discussions
10101019
}
10111020
}
1021+
if (isDataScienceChallenge) {
1022+
newChallenge.metadata = challengeMetadata
1023+
}
10121024
try {
10131025
const action = await createChallenge(newChallenge, projectDetail.id)
10141026
if (isTask) {
@@ -1548,6 +1560,9 @@ class ChallengeEditor extends Component {
15481560
const showTimeline = false // disables the timeline for time being https://github.com/topcoder-platform/challenge-engine-ui/issues/706
15491561
const copilotResources = metadata.members || challengeResources
15501562
const isDesignChallenge = challenge.trackId === DES_TRACK_ID
1563+
const isDataScienceChallenge = challenge.trackId === DS_TRACK_ID
1564+
console.log(_.find(challenge.metadata, { name: 'show_data_dashboard' }))
1565+
const showDataDashboard = _.find(challenge.metadata, { name: 'show_data_dashboard' })
15511566
const isChallengeType = challenge.typeId === CHALLENGE_TYPE_ID
15521567
const showRoundType = isDesignChallenge && isChallengeType
15531568
const showCheckpointPrizes = challenge.timelineTemplateId === MULTI_ROUND_CHALLENGE_TEMPLATE_ID
@@ -1567,6 +1582,7 @@ class ChallengeEditor extends Component {
15671582
)
15681583
}
15691584
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
1585+
{isDataScienceChallenge && <ShowDataDashboardField value={showDataDashboard.value} onUpdateInput={this.onUpdateMetadata} />}
15701586
{projectDetail.version === 'v4' && <MilestoneField milestones={activeProjectMilestones} onUpdateSelect={this.onUpdateSelect} projectId={projectDetail.id} selectedMilestoneId={selectedMilestoneId} />}
15711587
{useTask && (<DiscussionField hasForum={hasForum} toggleForum={this.toggleForumOnCreate} />)}
15721588
</div>

0 commit comments

Comments
 (0)