Skip to content

Commit cf5218d

Browse files
author
vikasrohit
authored
Merge pull request #862 from topcoder-platform/develop
Moving latest and greatest to prod
2 parents b37f763 + 46802ae commit cf5218d

File tree

16 files changed

+118
-78
lines changed

16 files changed

+118
-78
lines changed

config/constants/development.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ module.exports = {
3131
DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8',
3232
DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d',
3333
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
34-
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n'
34+
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n',
35+
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c']
3536
}

config/constants/production.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ module.exports = {
3131
DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8',
3232
DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d',
3333
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
34-
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF'
34+
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF',
35+
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c']
3536
}

src/actions/challenges.js

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ import {
2828
UPLOAD_ATTACHMENT_FAILURE,
2929
UPLOAD_ATTACHMENT_PENDING,
3030
UPLOAD_ATTACHMENT_SUCCESS,
31-
LOAD_CHALLENGE_RESOURCES_PENDING,
32-
LOAD_CHALLENGE_RESOURCES_SUCCESS,
33-
LOAD_CHALLENGE_RESOURCES_FAILURE,
3431
CREATE_CHALLENGE_RESOURCE,
3532
DELETE_CHALLENGE_RESOURCE,
3633
REMOVE_ATTACHMENT,
@@ -40,7 +37,8 @@ import {
4037
UPDATE_CHALLENGE_DETAILS_FAILURE,
4138
CREATE_CHALLENGE_PENDING,
4239
CREATE_CHALLENGE_SUCCESS,
43-
CREATE_CHALLENGE_FAILURE
40+
CREATE_CHALLENGE_FAILURE,
41+
LOAD_CHALLENGE_RESOURCES
4442
} from '../config/constants'
4543
import { loadProject } from './projects'
4644

@@ -174,7 +172,7 @@ export function loadChallengeDetails (projectId, challengeId) {
174172
payload: fetchChallenge(challengeId).then((challenge) => {
175173
// TODO remove this unncessary check, or better utilize the the case when given project id
176174
// does not match with challenge's project id
177-
if (challenge.projectId === projectId) {
175+
if (challenge.projectId == projectId) { // eslint-disable-line
178176
dispatch(loadProject(projectId))
179177
}
180178
return challenge
@@ -203,10 +201,12 @@ export function updateChallengeDetails (challengeId, challengeDetails) {
203201
type: UPDATE_CHALLENGE_DETAILS_SUCCESS,
204202
challengeDetails: challenge
205203
})
206-
}).catch(() => {
204+
}).catch((error) => {
207205
dispatch({
208-
type: UPDATE_CHALLENGE_DETAILS_FAILURE
206+
type: UPDATE_CHALLENGE_DETAILS_FAILURE,
207+
error
209208
})
209+
return Promise.reject(error)
210210
})
211211
}
212212
}
@@ -394,27 +394,11 @@ export function loadChallengeTerms () {
394394
}
395395

396396
export function loadResources (challengeId) {
397-
return async (dispatch) => {
398-
dispatch({
399-
type: LOAD_CHALLENGE_RESOURCES_PENDING,
400-
challengeResources: {}
401-
})
402-
397+
return (dispatch, getState) => {
403398
if (challengeId) {
404-
return fetchResources(challengeId).then((resources) => {
405-
dispatch({
406-
type: LOAD_CHALLENGE_RESOURCES_SUCCESS,
407-
challengeResources: resources
408-
})
409-
}).catch(() => {
410-
dispatch({
411-
type: LOAD_CHALLENGE_RESOURCES_FAILURE
412-
})
413-
})
414-
} else {
415-
dispatch({
416-
type: LOAD_CHALLENGE_RESOURCES_SUCCESS,
417-
challengeResources: null
399+
return dispatch({
400+
type: LOAD_CHALLENGE_RESOURCES,
401+
payload: fetchResources(challengeId)
418402
})
419403
}
420404
}

src/components/ChallengeEditor/ChallengeEditor.module.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,9 @@
397397
align-items: center;
398398
}
399399

400+
.errorContainer {
401+
.errorMessage {
402+
color: $red;
403+
}
404+
}
405+

src/components/ChallengeEditor/ChallengePrizes-Field/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ChallengePrizesField extends Component {
2626

2727
addNewPrize () {
2828
const challengePrize = this.getChallengePrize()
29-
challengePrize.prizes = [...challengePrize.prizes, { type: CHALLENGE_PRIZE_TYPE.MONEY, value: 1 }]
29+
challengePrize.prizes = [...challengePrize.prizes, { type: CHALLENGE_PRIZE_TYPE.USD, value: 1 }]
3030
this.onUpdateValue(challengePrize)
3131
}
3232

@@ -55,7 +55,7 @@ class ChallengePrizesField extends Component {
5555

5656
getChallengePrize () {
5757
const type = PRIZE_SETS_TYPE.CHALLENGE_PRIZES
58-
return (this.props.challenge.prizeSets && this.props.challenge.prizeSets.length && this.props.challenge.prizeSets.find(p => p.type === type)) || { type, prizes: [{ type: CHALLENGE_PRIZE_TYPE.MONEY, value: 0 }] }
58+
return (this.props.challenge.prizeSets && this.props.challenge.prizeSets.length && this.props.challenge.prizeSets.find(p => p.type === type)) || { type, prizes: [{ type: CHALLENGE_PRIZE_TYPE.USD, value: 0 }] }
5959
}
6060

6161
renderPrizes () {

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ import PhaseInput from '../../PhaseInput'
2121
import LegacyLinks from '../../LegacyLinks'
2222
import AssignedMemberField from '../AssignedMember-Field'
2323

24-
const ChallengeView = ({ projectDetail, challenge, metadata, challengeResources, token, isLoading, challengeId, assignedMemberDetails }) => {
24+
const ChallengeView = ({
25+
projectDetail,
26+
challenge,
27+
metadata,
28+
challengeResources,
29+
token,
30+
isLoading,
31+
challengeId,
32+
assignedMemberDetails,
33+
enableEdit }) => {
2534
const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId })
2635
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })
2736

@@ -64,7 +73,7 @@ const ChallengeView = ({ projectDetail, challenge, metadata, challengeResources,
6473
</div>
6574
<div className={styles.title}>View Details</div>
6675
<div className={cn(styles.actionButtons, styles.button, styles.actionButtonsRight)}>
67-
<PrimaryButton text={'Edit'} type={'info'} submit link={`./edit`} />
76+
{ enableEdit && <PrimaryButton text={'Edit'} type={'info'} submit link={`./edit`} /> }
6877
<PrimaryButton text={'Back'} type={'info'} submit link={`..`} />
6978
</div>
7079
<div className={styles.container}>
@@ -202,7 +211,8 @@ ChallengeView.propTypes = {
202211
isLoading: PropTypes.bool.isRequired,
203212
challengeId: PropTypes.string.isRequired,
204213
challengeResources: PropTypes.arrayOf(PropTypes.object),
205-
assignedMemberDetails: PropTypes.shape()
214+
assignedMemberDetails: PropTypes.shape(),
215+
enableEdit: PropTypes.bool
206216
}
207217

208218
export default withRouter(ChallengeView)

src/components/ChallengeEditor/CheckpointPrizes-Field/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import styles from './CheckpointPrizes-Field.module.scss'
44
import cn from 'classnames'
55
import { range } from 'lodash'
66
import { validateValue } from '../../../util/input-check'
7-
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE } from '../../../config/constants'
7+
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE, CHALLENGE_PRIZE_TYPE } from '../../../config/constants'
88

99
const CheckpointPrizesField = ({ challenge, onUpdateOthers }) => {
1010
const type = PRIZE_SETS_TYPE.CHECKPOINT_PRIZES
11-
const checkpointPrize = challenge.prizeSets.find(p => p.type === type) || { type, prizes: [] }
11+
const checkpointPrize = challenge.prizeSets.find(p => p.type === type) || { type: CHALLENGE_PRIZE_TYPE.USD, prizes: [] }
1212
const number = checkpointPrize.prizes.length
1313
const amount = checkpointPrize.prizes.length ? checkpointPrize.prizes[0].value : 0
1414

1515
function onChange (number, amount) {
1616
checkpointPrize.prizes = range(validateValue(number, VALIDATION_VALUE_TYPE.INTEGER))
17-
.map(i => ({ type: 'Prize ' + i, value: validateValue(amount, VALIDATION_VALUE_TYPE.INTEGER, '$') }))
17+
.map(i => ({ type: CHALLENGE_PRIZE_TYPE.USD, value: validateValue(amount, VALIDATION_VALUE_TYPE.INTEGER, '$') }))
1818
onUpdateOthers({ field: 'prizeSets', value: [...challenge.prizeSets.filter(p => p.type !== type), +number && checkpointPrize].filter(p => p) })
1919
}
2020
return (

src/components/ChallengeEditor/CopilotFee-Field/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import PropTypes from 'prop-types'
55
import { validateValue } from '../../../util/input-check'
66
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
77
import { faDollarSign } from '@fortawesome/free-solid-svg-icons'
8-
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE } from '../../../config/constants'
8+
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE, CHALLENGE_PRIZE_TYPE } from '../../../config/constants'
99

1010
const CopilotFeeField = ({ challenge, onUpdateOthers, readOnly }) => {
1111
const type = PRIZE_SETS_TYPE.COPILOT_PAYMENT
12-
const copilotFee = (challenge.prizeSets && challenge.prizeSets.find(p => p.type === type)) || { type, prizes: [{ type, value: 0 }] }
12+
const copilotFee = (challenge.prizeSets && challenge.prizeSets.find(p => p.type === type)) || { type, prizes: [{ type: CHALLENGE_PRIZE_TYPE.USD, value: 0 }] }
1313
const value = copilotFee.prizes[0].value
1414

1515
function onChange (e) {
1616
let value = validateValue(e.target.value, VALIDATION_VALUE_TYPE.INTEGER)
1717
if (parseInt(value) > 1000000) {
1818
value = '1000000'
1919
}
20-
copilotFee.prizes = [{ type, value }]
20+
copilotFee.prizes = [{ type: CHALLENGE_PRIZE_TYPE.USD, value }]
2121
onUpdateOthers({ field: 'prizeSets', value: [...challenge.prizeSets.filter(p => p.type !== type), copilotFee] })
2222
}
2323

src/components/ChallengeEditor/ReviewCost-Field/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import PropTypes from 'prop-types'
33
import styles from './ReviewCost-Field.module.scss'
44
import cn from 'classnames'
55
import { validateValue } from '../../../util/input-check'
6-
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE } from '../../../config/constants'
6+
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE, CHALLENGE_PRIZE_TYPE } from '../../../config/constants'
77

88
const ReviewCostField = ({ challenge, onUpdateOthers }) => {
99
const type = PRIZE_SETS_TYPE.REVIEWER_PAYMENT
10-
const reviewCost = challenge.prizeSets.find(p => p.type === type) || { type, prizes: [{ type, value: 0 }] }
10+
const reviewCost = challenge.prizeSets.find(p => p.type === type) || { type, prizes: [{ type: CHALLENGE_PRIZE_TYPE.USD, value: 0 }] }
1111
const value = reviewCost.prizes[0].value
1212

1313
function onChange (e) {
1414
const value = validateValue(e.target.value, VALIDATION_VALUE_TYPE.INTEGER, '$')
15-
reviewCost.prizes = [{ type, value }]
15+
reviewCost.prizes = [{ type: CHALLENGE_PRIZE_TYPE.USD, value }]
1616
onUpdateOthers({ field: 'prizeSets', value: [...challenge.prizeSets.filter(p => p.type !== type), reviewCost] })
1717
}
1818

src/components/ChallengeEditor/index.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
PRIZE_SETS_TYPE,
1616
DEFAULT_TERM_UUID,
1717
DEFAULT_NDA_UUID,
18-
SUBMITTER_ROLE_UUID
18+
SUBMITTER_ROLE_UUID,
19+
CREATE_FORUM_TYPE_IDS
1920
} from '../../config/constants'
2021
import { PrimaryButton, OutlineButton } from '../Buttons'
2122
import TrackField from './Track-Field'
@@ -767,6 +768,10 @@ class ChallengeEditor extends Component {
767768
phases: this.getTemplatePhases(defaultTemplate)
768769
// prizeSets: this.getDefaultPrizeSets()
769770
}
771+
const discussions = this.getDiscussionsConfig(newChallenge)
772+
if (discussions) {
773+
newChallenge.discussions = discussions
774+
}
770775
try {
771776
const action = await createChallenge(newChallenge)
772777
const draftChallenge = {
@@ -779,6 +784,18 @@ class ChallengeEditor extends Component {
779784
}
780785
}
781786

787+
getDiscussionsConfig (challenge) {
788+
if (_.includes(CREATE_FORUM_TYPE_IDS, challenge.typeId)) {
789+
return ([
790+
{
791+
name: `${challenge.name} Discussion`,
792+
type: 'challenge',
793+
provider: 'vanilla'
794+
}
795+
])
796+
}
797+
}
798+
782799
getTemplatePhases (template) {
783800
const timelinePhaseIds = template.phases.map(timelinePhase => timelinePhase.phaseId || timelinePhase)
784801
const validPhases = _.cloneDeep(this.props.metadata.challengePhases).filter(challengePhase => {
@@ -919,11 +936,7 @@ class ChallengeEditor extends Component {
919936
}
920937

921938
async onlySave () {
922-
this.updateAllChallengeInfo(this.state.challenge.status, () => {
923-
this.resetModal()
924-
const { history } = this.props
925-
history.push('./view')
926-
})
939+
this.updateAllChallengeInfo(this.state.challenge.status)
927940
}
928941

929942
getResourceRoleByName (name) {
@@ -1008,7 +1021,7 @@ class ChallengeEditor extends Component {
10081021
return <div>Error loading challenge</div>
10091022
}
10101023
const isTask = _.get(challenge, 'task.isTask', false)
1011-
const { assignedMemberDetails } = this.state
1024+
const { assignedMemberDetails, error } = this.state
10121025
let isActive = false
10131026
let isDraft = false
10141027
let isCompleted = false
@@ -1044,7 +1057,6 @@ class ChallengeEditor extends Component {
10441057
let activateModal = null
10451058
let closeTaskModal = null
10461059
let draftModal = null
1047-
let savedModal = null
10481060

10491061
let { type } = challenge
10501062
if (!type) {
@@ -1056,20 +1068,6 @@ class ChallengeEditor extends Component {
10561068
}
10571069
}
10581070
}
1059-
if (!isNew && challenge.status === 'New' && isLaunch && isConfirm) {
1060-
savedModal = (
1061-
<AlertModal
1062-
title='Saved Challenge'
1063-
message={`Challenge "${challenge.name}" is saved successfuly`}
1064-
theme={theme}
1065-
onCancel={this.resetModal}
1066-
closeText='Close'
1067-
okText='View Challenge'
1068-
okLink='./view'
1069-
onClose={this.resetModal}
1070-
/>
1071-
)
1072-
}
10731071

10741072
if (!isNew && isLaunch && !isConfirm) {
10751073
activateModal = (
@@ -1162,6 +1160,8 @@ class ChallengeEditor extends Component {
11621160
)
11631161
}
11641162

1163+
const errorContainer = <div className={styles.errorContainer}><div className={styles.errorMessage}>{error}</div></div>
1164+
11651165
const actionButtons = <React.Fragment>
11661166
{!isLoading && this.state.hasValidationErrors && <div className={styles.error}>Please fix the errors before saving</div>}
11671167
{
@@ -1182,7 +1182,7 @@ class ChallengeEditor extends Component {
11821182
<OutlineButton text={'Save Draft'} type={'success'} onClick={this.createDraftHandler} />
11831183
</div>
11841184
{ isDraft && <div className={styles.button}>
1185-
<PrimaryButton text={'Launch as Active'} type={'info'} submit />
1185+
<PrimaryButton text={'Launch as Active'} type={'info'} onClick={this.toggleLaunch} />
11861186
</div>}
11871187
</div>}
11881188
{!isLoading && isActive && <div className={styles.buttonContainer}>
@@ -1211,10 +1211,11 @@ class ChallengeEditor extends Component {
12111211
<TypeField types={metadata.challengeTypes} onUpdateSelect={this.onUpdateSelect} challenge={challenge} />
12121212
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
12131213
</div>
1214+
{ errorContainer }
12141215
{ actionButtons }
12151216
</form>
12161217
) : (
1217-
<form name='challenge-info-form' noValidate autoComplete='off' onSubmit={this.toggleLaunch}>
1218+
<form name='challenge-info-form' noValidate autoComplete='off' onSubmit={(e) => e.preventDefault()}>
12181219
<div className={styles.group}>
12191220

12201221
<div className={cn(styles.row, styles.topRow)}>
@@ -1331,6 +1332,7 @@ class ChallengeEditor extends Component {
13311332
<CopilotFeeField challenge={challenge} onUpdateOthers={this.onUpdateOthers} />
13321333
<ChallengeTotalField challenge={challenge} />
13331334
</div>
1335+
{ errorContainer }
13341336
{ actionButtons }
13351337
</form>
13361338
)
@@ -1349,7 +1351,6 @@ class ChallengeEditor extends Component {
13491351
<div className={styles.container}>
13501352
{ activateModal }
13511353
{ draftModal }
1352-
{ savedModal }
13531354
{ closeTaskModal }
13541355
<div className={styles.formContainer}>
13551356
{ challengeForm }

src/components/Sidebar/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ const Sidebar = ({
2020
Active challenges
2121
</div>
2222
</Link>
23-
<Link to='#' className='chameleon-feedback'>
23+
<a href='https://forms.gle/CsaVawSDkdR5E92B8' target='_blank' rel='noopener noreferrer' className='chameleon-feedback'>
2424
<div className={cn(styles.homeLink, { [styles.active]: !projectId })}>
2525
Give Application Feedback
2626
</div>
27-
</Link>
27+
</a>
2828
<p className={styles.supportLink}>
2929
Have an urgent issue?<br />
3030
E: <a href='mailto:support@topcoder.com'>support@topcoder.com</a>

src/config/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const {
1616
QA_TRACK_ID,
1717
SEGMENT_API_KEY
1818
} = process.env
19+
export const CREATE_FORUM_TYPE_IDS = typeof process.env.CREATE_FORUM_TYPE_IDS === 'string' ? process.env.CREATE_FORUM_TYPE_IDS.split(',') : process.env.CREATE_FORUM_TYPE_IDS
1920

2021
// Actions
2122
export const LOAD_PROJECTS_SUCCESS = 'LOAD_PROJECTS_SUCCESS'
@@ -65,6 +66,7 @@ export const UPLOAD_ATTACHMENT_PENDING = 'UPLOAD_ATTACHMENT_PENDING'
6566
export const UPLOAD_ATTACHMENT_FAILURE = 'UPLOAD_ATTACHMENT_FAILURE'
6667
export const UPLOAD_ATTACHMENT_SUCCESS = 'UPLOAD_ATTACHMENT_SUCCESS'
6768

69+
export const LOAD_CHALLENGE_RESOURCES = 'LOAD_CHALLENGE_RESOURCES'
6870
export const LOAD_CHALLENGE_RESOURCES_SUCCESS = 'LOAD_CHALLENGE_RESOURCES_SUCCESS'
6971
export const LOAD_CHALLENGE_RESOURCES_PENDING = 'LOAD_CHALLENGE_RESOURCES_PENDING'
7072
export const LOAD_CHALLENGE_RESOURCES_FAILURE = 'LOAD_CHALLENGE_RESOURCES_FAILURE'
@@ -134,7 +136,7 @@ export const VALIDATION_VALUE_TYPE = {
134136
}
135137

136138
export const CHALLENGE_PRIZE_TYPE = {
137-
MONEY: 'money'
139+
USD: 'USD'
138140
}
139141

140142
export const ALLOWED_USER_ROLES = [

0 commit comments

Comments
 (0)