Skip to content

Moving latest and greatest to prod #862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/constants/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ module.exports = {
DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8',
DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d',
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n'
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n',
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c']
}
3 changes: 2 additions & 1 deletion config/constants/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ module.exports = {
DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8',
DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d',
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF'
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF',
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c']
}
38 changes: 11 additions & 27 deletions src/actions/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import {
UPLOAD_ATTACHMENT_FAILURE,
UPLOAD_ATTACHMENT_PENDING,
UPLOAD_ATTACHMENT_SUCCESS,
LOAD_CHALLENGE_RESOURCES_PENDING,
LOAD_CHALLENGE_RESOURCES_SUCCESS,
LOAD_CHALLENGE_RESOURCES_FAILURE,
CREATE_CHALLENGE_RESOURCE,
DELETE_CHALLENGE_RESOURCE,
REMOVE_ATTACHMENT,
Expand All @@ -40,7 +37,8 @@ import {
UPDATE_CHALLENGE_DETAILS_FAILURE,
CREATE_CHALLENGE_PENDING,
CREATE_CHALLENGE_SUCCESS,
CREATE_CHALLENGE_FAILURE
CREATE_CHALLENGE_FAILURE,
LOAD_CHALLENGE_RESOURCES
} from '../config/constants'
import { loadProject } from './projects'

Expand Down Expand Up @@ -174,7 +172,7 @@ export function loadChallengeDetails (projectId, challengeId) {
payload: fetchChallenge(challengeId).then((challenge) => {
// TODO remove this unncessary check, or better utilize the the case when given project id
// does not match with challenge's project id
if (challenge.projectId === projectId) {
if (challenge.projectId == projectId) { // eslint-disable-line
dispatch(loadProject(projectId))
}
return challenge
Expand Down Expand Up @@ -203,10 +201,12 @@ export function updateChallengeDetails (challengeId, challengeDetails) {
type: UPDATE_CHALLENGE_DETAILS_SUCCESS,
challengeDetails: challenge
})
}).catch(() => {
}).catch((error) => {
dispatch({
type: UPDATE_CHALLENGE_DETAILS_FAILURE
type: UPDATE_CHALLENGE_DETAILS_FAILURE,
error
})
return Promise.reject(error)
})
}
}
Expand Down Expand Up @@ -394,27 +394,11 @@ export function loadChallengeTerms () {
}

export function loadResources (challengeId) {
return async (dispatch) => {
dispatch({
type: LOAD_CHALLENGE_RESOURCES_PENDING,
challengeResources: {}
})

return (dispatch, getState) => {
if (challengeId) {
return fetchResources(challengeId).then((resources) => {
dispatch({
type: LOAD_CHALLENGE_RESOURCES_SUCCESS,
challengeResources: resources
})
}).catch(() => {
dispatch({
type: LOAD_CHALLENGE_RESOURCES_FAILURE
})
})
} else {
dispatch({
type: LOAD_CHALLENGE_RESOURCES_SUCCESS,
challengeResources: null
return dispatch({
type: LOAD_CHALLENGE_RESOURCES,
payload: fetchResources(challengeId)
})
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/ChallengeEditor/ChallengeEditor.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,9 @@
align-items: center;
}

.errorContainer {
.errorMessage {
color: $red;
}
}

4 changes: 2 additions & 2 deletions src/components/ChallengeEditor/ChallengePrizes-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ChallengePrizesField extends Component {

addNewPrize () {
const challengePrize = this.getChallengePrize()
challengePrize.prizes = [...challengePrize.prizes, { type: CHALLENGE_PRIZE_TYPE.MONEY, value: 1 }]
challengePrize.prizes = [...challengePrize.prizes, { type: CHALLENGE_PRIZE_TYPE.USD, value: 1 }]
this.onUpdateValue(challengePrize)
}

Expand Down Expand Up @@ -55,7 +55,7 @@ class ChallengePrizesField extends Component {

getChallengePrize () {
const type = PRIZE_SETS_TYPE.CHALLENGE_PRIZES
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 }] }
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 }] }
}

renderPrizes () {
Expand Down
16 changes: 13 additions & 3 deletions src/components/ChallengeEditor/ChallengeView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ import PhaseInput from '../../PhaseInput'
import LegacyLinks from '../../LegacyLinks'
import AssignedMemberField from '../AssignedMember-Field'

const ChallengeView = ({ projectDetail, challenge, metadata, challengeResources, token, isLoading, challengeId, assignedMemberDetails }) => {
const ChallengeView = ({
projectDetail,
challenge,
metadata,
challengeResources,
token,
isLoading,
challengeId,
assignedMemberDetails,
enableEdit }) => {
const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId })
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })

Expand Down Expand Up @@ -64,7 +73,7 @@ const ChallengeView = ({ projectDetail, challenge, metadata, challengeResources,
</div>
<div className={styles.title}>View Details</div>
<div className={cn(styles.actionButtons, styles.button, styles.actionButtonsRight)}>
<PrimaryButton text={'Edit'} type={'info'} submit link={`./edit`} />
{ enableEdit && <PrimaryButton text={'Edit'} type={'info'} submit link={`./edit`} /> }
<PrimaryButton text={'Back'} type={'info'} submit link={`..`} />
</div>
<div className={styles.container}>
Expand Down Expand Up @@ -202,7 +211,8 @@ ChallengeView.propTypes = {
isLoading: PropTypes.bool.isRequired,
challengeId: PropTypes.string.isRequired,
challengeResources: PropTypes.arrayOf(PropTypes.object),
assignedMemberDetails: PropTypes.shape()
assignedMemberDetails: PropTypes.shape(),
enableEdit: PropTypes.bool
}

export default withRouter(ChallengeView)
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import styles from './CheckpointPrizes-Field.module.scss'
import cn from 'classnames'
import { range } from 'lodash'
import { validateValue } from '../../../util/input-check'
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE } from '../../../config/constants'
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE, CHALLENGE_PRIZE_TYPE } from '../../../config/constants'

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

function onChange (number, amount) {
checkpointPrize.prizes = range(validateValue(number, VALIDATION_VALUE_TYPE.INTEGER))
.map(i => ({ type: 'Prize ' + i, value: validateValue(amount, VALIDATION_VALUE_TYPE.INTEGER, '$') }))
.map(i => ({ type: CHALLENGE_PRIZE_TYPE.USD, value: validateValue(amount, VALIDATION_VALUE_TYPE.INTEGER, '$') }))
onUpdateOthers({ field: 'prizeSets', value: [...challenge.prizeSets.filter(p => p.type !== type), +number && checkpointPrize].filter(p => p) })
}
return (
Expand Down
6 changes: 3 additions & 3 deletions src/components/ChallengeEditor/CopilotFee-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import PropTypes from 'prop-types'
import { validateValue } from '../../../util/input-check'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faDollarSign } from '@fortawesome/free-solid-svg-icons'
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE } from '../../../config/constants'
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE, CHALLENGE_PRIZE_TYPE } from '../../../config/constants'

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

function onChange (e) {
let value = validateValue(e.target.value, VALIDATION_VALUE_TYPE.INTEGER)
if (parseInt(value) > 1000000) {
value = '1000000'
}
copilotFee.prizes = [{ type, value }]
copilotFee.prizes = [{ type: CHALLENGE_PRIZE_TYPE.USD, value }]
onUpdateOthers({ field: 'prizeSets', value: [...challenge.prizeSets.filter(p => p.type !== type), copilotFee] })
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/ChallengeEditor/ReviewCost-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import PropTypes from 'prop-types'
import styles from './ReviewCost-Field.module.scss'
import cn from 'classnames'
import { validateValue } from '../../../util/input-check'
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE } from '../../../config/constants'
import { VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE, CHALLENGE_PRIZE_TYPE } from '../../../config/constants'

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

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

Expand Down
51 changes: 26 additions & 25 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
PRIZE_SETS_TYPE,
DEFAULT_TERM_UUID,
DEFAULT_NDA_UUID,
SUBMITTER_ROLE_UUID
SUBMITTER_ROLE_UUID,
CREATE_FORUM_TYPE_IDS
} from '../../config/constants'
import { PrimaryButton, OutlineButton } from '../Buttons'
import TrackField from './Track-Field'
Expand Down Expand Up @@ -767,6 +768,10 @@ class ChallengeEditor extends Component {
phases: this.getTemplatePhases(defaultTemplate)
// prizeSets: this.getDefaultPrizeSets()
}
const discussions = this.getDiscussionsConfig(newChallenge)
if (discussions) {
newChallenge.discussions = discussions
}
try {
const action = await createChallenge(newChallenge)
const draftChallenge = {
Expand All @@ -779,6 +784,18 @@ class ChallengeEditor extends Component {
}
}

getDiscussionsConfig (challenge) {
if (_.includes(CREATE_FORUM_TYPE_IDS, challenge.typeId)) {
return ([
{
name: `${challenge.name} Discussion`,
type: 'challenge',
provider: 'vanilla'
}
])
}
}

getTemplatePhases (template) {
const timelinePhaseIds = template.phases.map(timelinePhase => timelinePhase.phaseId || timelinePhase)
const validPhases = _.cloneDeep(this.props.metadata.challengePhases).filter(challengePhase => {
Expand Down Expand Up @@ -919,11 +936,7 @@ class ChallengeEditor extends Component {
}

async onlySave () {
this.updateAllChallengeInfo(this.state.challenge.status, () => {
this.resetModal()
const { history } = this.props
history.push('./view')
})
this.updateAllChallengeInfo(this.state.challenge.status)
}

getResourceRoleByName (name) {
Expand Down Expand Up @@ -1008,7 +1021,7 @@ class ChallengeEditor extends Component {
return <div>Error loading challenge</div>
}
const isTask = _.get(challenge, 'task.isTask', false)
const { assignedMemberDetails } = this.state
const { assignedMemberDetails, error } = this.state
let isActive = false
let isDraft = false
let isCompleted = false
Expand Down Expand Up @@ -1044,7 +1057,6 @@ class ChallengeEditor extends Component {
let activateModal = null
let closeTaskModal = null
let draftModal = null
let savedModal = null

let { type } = challenge
if (!type) {
Expand All @@ -1056,20 +1068,6 @@ class ChallengeEditor extends Component {
}
}
}
if (!isNew && challenge.status === 'New' && isLaunch && isConfirm) {
savedModal = (
<AlertModal
title='Saved Challenge'
message={`Challenge "${challenge.name}" is saved successfuly`}
theme={theme}
onCancel={this.resetModal}
closeText='Close'
okText='View Challenge'
okLink='./view'
onClose={this.resetModal}
/>
)
}

if (!isNew && isLaunch && !isConfirm) {
activateModal = (
Expand Down Expand Up @@ -1162,6 +1160,8 @@ class ChallengeEditor extends Component {
)
}

const errorContainer = <div className={styles.errorContainer}><div className={styles.errorMessage}>{error}</div></div>

const actionButtons = <React.Fragment>
{!isLoading && this.state.hasValidationErrors && <div className={styles.error}>Please fix the errors before saving</div>}
{
Expand All @@ -1182,7 +1182,7 @@ class ChallengeEditor extends Component {
<OutlineButton text={'Save Draft'} type={'success'} onClick={this.createDraftHandler} />
</div>
{ isDraft && <div className={styles.button}>
<PrimaryButton text={'Launch as Active'} type={'info'} submit />
<PrimaryButton text={'Launch as Active'} type={'info'} onClick={this.toggleLaunch} />
</div>}
</div>}
{!isLoading && isActive && <div className={styles.buttonContainer}>
Expand Down Expand Up @@ -1211,10 +1211,11 @@ class ChallengeEditor extends Component {
<TypeField types={metadata.challengeTypes} onUpdateSelect={this.onUpdateSelect} challenge={challenge} />
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
</div>
{ errorContainer }
{ actionButtons }
</form>
) : (
<form name='challenge-info-form' noValidate autoComplete='off' onSubmit={this.toggleLaunch}>
<form name='challenge-info-form' noValidate autoComplete='off' onSubmit={(e) => e.preventDefault()}>
<div className={styles.group}>

<div className={cn(styles.row, styles.topRow)}>
Expand Down Expand Up @@ -1331,6 +1332,7 @@ class ChallengeEditor extends Component {
<CopilotFeeField challenge={challenge} onUpdateOthers={this.onUpdateOthers} />
<ChallengeTotalField challenge={challenge} />
</div>
{ errorContainer }
{ actionButtons }
</form>
)
Expand All @@ -1349,7 +1351,6 @@ class ChallengeEditor extends Component {
<div className={styles.container}>
{ activateModal }
{ draftModal }
{ savedModal }
{ closeTaskModal }
<div className={styles.formContainer}>
{ challengeForm }
Expand Down
4 changes: 2 additions & 2 deletions src/components/Sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const Sidebar = ({
Active challenges
</div>
</Link>
<Link to='#' className='chameleon-feedback'>
<a href='https://forms.gle/CsaVawSDkdR5E92B8' target='_blank' rel='noopener noreferrer' className='chameleon-feedback'>
<div className={cn(styles.homeLink, { [styles.active]: !projectId })}>
Give Application Feedback
</div>
</Link>
</a>
<p className={styles.supportLink}>
Have an urgent issue?<br />
E: <a href='mailto:support@topcoder.com'>support@topcoder.com</a>
Expand Down
4 changes: 3 additions & 1 deletion src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const {
QA_TRACK_ID,
SEGMENT_API_KEY
} = process.env
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

// Actions
export const LOAD_PROJECTS_SUCCESS = 'LOAD_PROJECTS_SUCCESS'
Expand Down Expand Up @@ -65,6 +66,7 @@ export const UPLOAD_ATTACHMENT_PENDING = 'UPLOAD_ATTACHMENT_PENDING'
export const UPLOAD_ATTACHMENT_FAILURE = 'UPLOAD_ATTACHMENT_FAILURE'
export const UPLOAD_ATTACHMENT_SUCCESS = 'UPLOAD_ATTACHMENT_SUCCESS'

export const LOAD_CHALLENGE_RESOURCES = 'LOAD_CHALLENGE_RESOURCES'
export const LOAD_CHALLENGE_RESOURCES_SUCCESS = 'LOAD_CHALLENGE_RESOURCES_SUCCESS'
export const LOAD_CHALLENGE_RESOURCES_PENDING = 'LOAD_CHALLENGE_RESOURCES_PENDING'
export const LOAD_CHALLENGE_RESOURCES_FAILURE = 'LOAD_CHALLENGE_RESOURCES_FAILURE'
Expand Down Expand Up @@ -134,7 +136,7 @@ export const VALIDATION_VALUE_TYPE = {
}

export const CHALLENGE_PRIZE_TYPE = {
MONEY: 'money'
USD: 'USD'
}

export const ALLOWED_USER_ROLES = [
Expand Down
Loading