Skip to content

Commit 3c478cd

Browse files
authored
Merge pull request #1052 from topcoder-platform/scheduling-api-changes
Add a field to set the legacy.useSchedulingAPI property on a challenge
2 parents 0c8b878 + 4d6bd35 commit 3c478cd

File tree

4 files changed

+140
-0
lines changed

4 files changed

+140
-0
lines changed

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import xss from 'xss'
99
import { PrimaryButton } from '../../Buttons'
1010
import Track from '../../Track'
1111
import NDAField from '../NDAField'
12+
import UseSchedulingAPIField from '../UseSchedulingAPIField'
1213
import CopilotField from '../Copilot-Field'
1314
import ChallengeScheduleField from '../ChallengeSchedule-Field'
1415
import TextEditorField from '../TextEditor-Field'
@@ -198,6 +199,9 @@ const ChallengeView = ({
198199
</div>
199200
</div>
200201
)}
202+
{isBetaMode() && (
203+
<UseSchedulingAPIField challenge={challenge} readOnly />
204+
)}
201205
</>
202206
)}
203207
{
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
.tcCheckbox {
12+
@include tc-checkbox;
13+
14+
height: 18px;
15+
width: 210px;
16+
margin: 0;
17+
padding: 0;
18+
vertical-align: bottom;
19+
position: relative;
20+
display: inline-block;
21+
22+
input[type='checkbox'] {
23+
display: none;
24+
}
25+
26+
label {
27+
@include roboto-light();
28+
29+
line-height: 17px;
30+
font-weight: 300;
31+
cursor: pointer;
32+
position: absolute;
33+
display: inline-block;
34+
width: 14px;
35+
height: 14px;
36+
top: 0;
37+
left: 0;
38+
border: none;
39+
box-shadow: none;
40+
background: $tc-gray-30;
41+
transition: all 0.15s ease-in-out;
42+
43+
44+
&.readOnly {
45+
cursor: auto;
46+
}
47+
48+
&::after {
49+
opacity: 0;
50+
content: '';
51+
position: absolute;
52+
width: 9px;
53+
height: 5px;
54+
background: transparent;
55+
top: 2px;
56+
left: 2px;
57+
border-top: none;
58+
border-right: none;
59+
transform: rotate(-45deg);
60+
transition: all 0.15s ease-in-out;
61+
}
62+
63+
&:hover::after {
64+
opacity: 0.3;
65+
}
66+
&:hover:read-only::after {
67+
opacity: 0;
68+
}
69+
70+
div {
71+
margin-left: 24px;
72+
width: 300px;
73+
}
74+
}
75+
76+
input[type='checkbox']:checked ~ label {
77+
background: $tc-blue-20;
78+
}
79+
80+
input[type='checkbox']:checked + label::after {
81+
border-color: $white;
82+
}
83+
}
84+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import _ from 'lodash'
2+
import React from 'react'
3+
import PropTypes from 'prop-types'
4+
import styles from './UseSchedulingAPIField.module.scss'
5+
6+
const UseSchedulingAPIField = ({ challenge, toggleUseSchedulingAPI, readOnly }) => {
7+
const useSchedulingAPI = _.get(challenge, 'legacy.useSchedulingAPI', false)
8+
return (
9+
<div className={styles.row}>
10+
<div className={styles.tcCheckbox}>
11+
<input
12+
name='useSchedulingAPI'
13+
type='checkbox'
14+
id='useSchedulingAPI'
15+
checked={useSchedulingAPI}
16+
onChange={toggleUseSchedulingAPI}
17+
readOnly={readOnly}
18+
/>
19+
<label htmlFor='useSchedulingAPI' className={readOnly ? styles.readOnly : ''}>
20+
<div>Use Scheduling API</div>
21+
<input type='hidden' />
22+
</label>
23+
</div>
24+
</div>
25+
)
26+
}
27+
28+
UseSchedulingAPIField.defaultProps = {
29+
toggleUseSchedulingAPI: () => {},
30+
readOnly: false
31+
}
32+
33+
UseSchedulingAPIField.propTypes = {
34+
challenge: PropTypes.shape().isRequired,
35+
toggleUseSchedulingAPI: PropTypes.func,
36+
readOnly: PropTypes.bool
37+
}
38+
39+
export default UseSchedulingAPIField

src/components/ChallengeEditor/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import PhaseInput from '../PhaseInput'
4949
import LegacyLinks from '../LegacyLinks'
5050
import AssignedMemberField from './AssignedMember-Field'
5151
import Tooltip from '../Tooltip'
52+
import UseSchedulingAPIField from './UseSchedulingAPIField'
5253
import { getResourceRoleByName } from '../../util/tc'
5354
import { isBetaMode } from '../../util/cookie'
5455

@@ -98,6 +99,7 @@ class ChallengeEditor extends Component {
9899
this.updateFileTypesMetadata = this.updateFileTypesMetadata.bind(this)
99100
this.toggleAdvanceSettings = this.toggleAdvanceSettings.bind(this)
100101
this.toggleNdaRequire = this.toggleNdaRequire.bind(this)
102+
this.toggleUseSchedulingAPI = this.toggleUseSchedulingAPI.bind(this)
101103
this.removePhase = this.removePhase.bind(this)
102104
this.resetPhase = this.resetPhase.bind(this)
103105
this.savePhases = this.savePhases.bind(this)
@@ -595,6 +597,14 @@ class ChallengeEditor extends Component {
595597
this.setState({ challenge: newChallenge })
596598
}
597599

600+
toggleUseSchedulingAPI () {
601+
const { challenge } = this.state
602+
const newChallenge = { ...challenge }
603+
const useSchedulingApi = !_.get(newChallenge, 'legacy.useSchedulingAPI', false)
604+
_.set(newChallenge, 'legacy.useSchedulingAPI', useSchedulingApi)
605+
this.setState({ challenge: newChallenge })
606+
}
607+
598608
/**
599609
* Remove Phase from challenge Phases list
600610
* @param index
@@ -1415,6 +1425,9 @@ class ChallengeEditor extends Component {
14151425
</div>
14161426
</div>
14171427
)}
1428+
{isBetaMode() && (
1429+
<UseSchedulingAPIField challenge={challenge} toggleUseSchedulingAPI={this.toggleUseSchedulingAPI} />
1430+
)}
14181431
</React.Fragment>
14191432
)}
14201433
{!isTask && (

0 commit comments

Comments
 (0)