Skip to content

Commit 9c94454

Browse files
authored
Merge pull request #1125 from topcoder-platform/hotfix/confirm-design-challenge
[DEV] [HOTFIX] confirm design challenge
2 parents 927d737 + 394787b commit 9c94454

File tree

6 files changed

+62
-6
lines changed

6 files changed

+62
-6
lines changed

config/constants/development.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = {
3030
DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8',
3131
DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d',
3232
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
33+
CHALLENGE_TYPE_ID: '927abff4-7af9-4145-8ba1-577c16e64e2e',
3334
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n',
3435
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c'],
3536
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY,

config/constants/production.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = {
3030
DES_TRACK_ID: '5fa04185-041f-49a6-bfd1-fe82533cd6c8',
3131
DS_TRACK_ID: 'c0f5d461-8219-4c14-878a-c3a3f356466d',
3232
QA_TRACK_ID: '36e6a8d0-7e1e-4608-a673-64279d99c115',
33+
CHALLENGE_TYPE_ID: '927abff4-7af9-4145-8ba1-577c16e64e2e',
3334
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF',
3435
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c'],
3536
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY,

src/components/ChallengeEditor/index.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
MESSAGE,
2121
COMMUNITY_APP_URL,
2222
DES_TRACK_ID,
23+
CHALLENGE_TYPE_ID,
2324
REVIEW_TYPES
2425
} from '../../config/constants'
2526
import { PrimaryButton, OutlineButton } from '../Buttons'
@@ -76,6 +77,7 @@ class ChallengeEditor extends Component {
7677
isOpenAdvanceSettings: false,
7778
isLoading: false,
7879
isSaving: false,
80+
showDesignChallengeWarningModel: false,
7981
hasValidationErrors: false,
8082
challenge: {
8183
...dropdowns['newChallenge']
@@ -110,9 +112,11 @@ class ChallengeEditor extends Component {
110112
this.onUpdateDescription = this.onUpdateDescription.bind(this)
111113
this.onActiveChallenge = this.onActiveChallenge.bind(this)
112114
this.resetModal = this.resetModal.bind(this)
115+
this.resetDesignChallengeWarningModal = this.resetDesignChallengeWarningModal.bind(this)
113116
this.openCloseTaskConfirmation = this.openCloseTaskConfirmation.bind(this)
114117
this.onCloseTask = this.onCloseTask.bind(this)
115118
this.createNewChallenge = this.createNewChallenge.bind(this)
119+
this.createNewDesignChallenge = this.createNewDesignChallenge.bind(this)
116120
this.getCurrentChallengeId = this.getCurrentChallengeId.bind(this)
117121
this.isValidChallengePrizes = this.isValidChallengePrizes.bind(this)
118122
this.isValidChallenge = this.isValidChallenge.bind(this)
@@ -235,6 +239,10 @@ class ChallengeEditor extends Component {
235239
}
236240
}
237241

242+
resetDesignChallengeWarningModal () {
243+
this.setState({ showDesignChallengeWarningModel: false })
244+
}
245+
238246
resetModal () {
239247
this.setState({ isLoading: false, isConfirm: false, isLaunch: false, error: null, isCloseTask: false, isDeleteLaunch: false })
240248
}
@@ -824,12 +832,25 @@ class ChallengeEditor extends Component {
824832
history.push(newPath)
825833
};
826834

835+
createNewDesignChallenge () {
836+
this.resetDesignChallengeWarningModal()
837+
this.createNewChallenge()
838+
}
839+
827840
async createNewChallenge () {
828841
if (!this.props.isNew) return
829842
const { metadata, createChallenge, projectDetail } = this.props
830-
const { name, trackId, typeId } = this.state.challenge
843+
const { showDesignChallengeWarningModel, challenge: { name, trackId, typeId } } = this.state
831844
const { timelineTemplates } = metadata
832845
const isDesignChallenge = trackId === DES_TRACK_ID
846+
const isChallengeType = typeId === CHALLENGE_TYPE_ID
847+
848+
if (!showDesignChallengeWarningModel && isDesignChallenge && isChallengeType) {
849+
this.setState({
850+
showDesignChallengeWarningModel: true
851+
})
852+
return
853+
}
833854

834855
// indicate that creating process has started
835856
this.setState({ isSaving: true })
@@ -1148,6 +1169,7 @@ class ChallengeEditor extends Component {
11481169
const {
11491170
isLaunch,
11501171
isConfirm,
1172+
showDesignChallengeWarningModel,
11511173
challenge,
11521174
draftChallenge,
11531175
isOpenAdvanceSettings,
@@ -1219,6 +1241,30 @@ class ChallengeEditor extends Component {
12191241
}
12201242
}
12211243

1244+
let designChallengeModal
1245+
if (showDesignChallengeWarningModel) {
1246+
const messageBody = (
1247+
<div>
1248+
<div>
1249+
At this time, Work Manager only supports single-round (no checkpoint) challenges for design. If you want to run a multi-round (has checkpoints) design challenge, please use Direct.
1250+
</div>
1251+
<div>
1252+
Do you want to proceed with set-up?
1253+
</div>
1254+
</div>
1255+
)
1256+
designChallengeModal = (
1257+
<ConfirmationModal
1258+
title='Reminder'
1259+
message={messageBody}
1260+
theme={theme}
1261+
cancelText='Cancel Set-Up'
1262+
confirmText='Continue Set-Up'
1263+
onCancel={this.resetDesignChallengeWarningModal}
1264+
onConfirm={this.createNewDesignChallenge}
1265+
/>
1266+
)
1267+
}
12221268
if (!isNew && isLaunch && !isConfirm) {
12231269
activateModal = (
12241270
<ConfirmationModal
@@ -1362,6 +1408,7 @@ class ChallengeEditor extends Component {
13621408
<TypeField types={metadata.challengeTypes} onUpdateSelect={this.onUpdateSelect} challenge={challenge} />
13631409
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
13641410
</div>
1411+
{showDesignChallengeWarningModel && designChallengeModal}
13651412
{ errorContainer }
13661413
{ actionButtons }
13671414
</form>
@@ -1389,6 +1436,7 @@ class ChallengeEditor extends Component {
13891436
<span><span className={styles.fieldTitle}>Status:</span> {challenge.status}</span>
13901437
</div>
13911438
</div>
1439+
13921440
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
13931441
{isTask && (
13941442
<AssignedMemberField

src/components/Modal/ConfirmationModal.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import styles from './ConfirmationModal.module.scss'
66
import OutlineButton from '../Buttons/OutlineButton'
77
import PrimaryButton from '../Buttons/PrimaryButton'
88

9-
const ConfirmationModal = ({ title, message, errorMessage, theme, isProcessing, onCancel, onConfirm, disableConfirmButton }) => (
9+
const ConfirmationModal = ({ title, message, errorMessage, theme, isProcessing, cancelText, confirmText, onCancel, onConfirm, disableConfirmButton }) => (
1010
<Modal theme={theme} onCancel={onCancel}>
1111
<div className={styles.contentContainer}>
1212
<div className={styles.title}>{title}</div>
@@ -15,14 +15,14 @@ const ConfirmationModal = ({ title, message, errorMessage, theme, isProcessing,
1515
<div className={styles.button}>
1616
<OutlineButton
1717
className={cn({ disabled: isProcessing })}
18-
text={'Cancel'}
18+
text={cancelText || 'Cancel'}
1919
type={'danger'}
2020
onClick={onCancel}
2121
/>
2222
</div>
2323
<div className={styles.button}>
2424
<PrimaryButton
25-
text={isProcessing ? 'Processing...' : 'Confirm'}
25+
text={isProcessing ? 'Processing...' : confirmText || 'Confirm'}
2626
disabled={disableConfirmButton}
2727
type={'info'}
2828
onClick={onConfirm}
@@ -41,6 +41,8 @@ ConfirmationModal.propTypes = {
4141
theme: PropTypes.shape(),
4242
isProcessing: PropTypes.bool,
4343
disableConfirmButton: PropTypes.bool,
44+
cancelText: PropTypes.string,
45+
confirmText: PropTypes.string,
4446
onCancel: PropTypes.func,
4547
onConfirm: PropTypes.func
4648
}

src/components/Modal/ConfirmationModal.module.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@
8484
margin-top: 30px;
8585

8686
.button {
87-
width: 135px;
8887
height: 40px;
8988
margin-right: 66px;
9089

90+
> button {
91+
padding: 0 35px;
92+
}
93+
9194
span {
9295
font-size: 18px;
9396
font-weight: 500;
@@ -98,4 +101,4 @@
98101
margin-right: 0;
99102
}
100103
}
101-
}
104+
}

src/config/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const {
1414
DES_TRACK_ID,
1515
DS_TRACK_ID,
1616
QA_TRACK_ID,
17+
CHALLENGE_TYPE_ID,
1718
SEGMENT_API_KEY
1819
} = process.env
1920
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

0 commit comments

Comments
 (0)