Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 394787b

Browse files
authoredMar 19, 2021
Merge pull request #1123 from yoution/issue-1122
fix: issue #1122
2 parents bc9fadd + 6b22ae6 commit 394787b

File tree

12 files changed

+77
-230
lines changed

12 files changed

+77
-230
lines changed
 

‎.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ workflows:
8383
branches:
8484
only:
8585
- develop
86-
- feature/timeline-template
8786

8887
# Production builds are exectuted only on tagged commits to the
8988
# master branch.

‎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/ChallengeName-Field/ChallengeName-Field.module.scss

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,16 @@
5252
}
5353
}
5454

55-
.challengeName {
56-
&::-moz-placeholder { /* Mozilla Firefox 19+ */
57-
line-height: 38px;
58-
color: $tc-gray-80;
59-
}
60-
&::-webkit-input-placeholder { /* Webkit */
61-
line-height: 38px;
62-
color: $tc-gray-80;
63-
}
64-
&:-ms-input-placeholder { /* IE */
65-
line-height: 38px;
66-
color: $tc-gray-80;
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+
}
6766
}
6867
}
69-

‎src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { isBetaMode } from '../../../util/cookie'
2626
import { loadGroupDetails } from '../../../actions/challenges'
2727
import Tooltip from '../../Tooltip'
2828
import { MESSAGE, REVIEW_TYPES } from '../../../config/constants'
29-
import TimelineTemplateField from '../TimelineTemplate-Field'
3029

3130
const ChallengeView = ({
3231
projectDetail,
@@ -201,13 +200,6 @@ const ChallengeView = ({
201200
{isBetaMode() && (
202201
<UseSchedulingAPIField challenge={challenge} readOnly />
203202
)}
204-
<TimelineTemplateField
205-
challengeTimelines={metadata.challengeTimelines}
206-
timelineTemplates={metadata.timelineTemplates}
207-
challenge={challenge}
208-
onUpdateSelect={() => {}}
209-
readOnly
210-
/>
211203
</>
212204
)}
213205
{

‎src/components/ChallengeEditor/TimelineTemplate-Field/TimelineTemplate-Field.module.scss

Lines changed: 0 additions & 55 deletions
This file was deleted.

‎src/components/ChallengeEditor/TimelineTemplate-Field/index.js

Lines changed: 0 additions & 126 deletions
This file was deleted.

‎src/components/ChallengeEditor/index.js

Lines changed: 52 additions & 21 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+
CHALLENGE_TYPE_ID,
2324
REVIEW_TYPES
2425
} from '../../config/constants'
2526
import { PrimaryButton, OutlineButton } from '../Buttons'
@@ -52,7 +53,6 @@ import Tooltip from '../Tooltip'
5253
import UseSchedulingAPIField from './UseSchedulingAPIField'
5354
import { getResourceRoleByName } from '../../util/tc'
5455
import { isBetaMode } from '../../util/cookie'
55-
import TimelineTemplateField from './TimelineTemplate-Field'
5656

5757
const theme = {
5858
container: styles.modalContainer
@@ -77,6 +77,7 @@ class ChallengeEditor extends Component {
7777
isOpenAdvanceSettings: false,
7878
isLoading: false,
7979
isSaving: false,
80+
showDesignChallengeWarningModel: false,
8081
hasValidationErrors: false,
8182
challenge: {
8283
...dropdowns['newChallenge']
@@ -111,9 +112,11 @@ class ChallengeEditor extends Component {
111112
this.onUpdateDescription = this.onUpdateDescription.bind(this)
112113
this.onActiveChallenge = this.onActiveChallenge.bind(this)
113114
this.resetModal = this.resetModal.bind(this)
115+
this.resetDesignChallengeWarningModal = this.resetDesignChallengeWarningModal.bind(this)
114116
this.openCloseTaskConfirmation = this.openCloseTaskConfirmation.bind(this)
115117
this.onCloseTask = this.onCloseTask.bind(this)
116118
this.createNewChallenge = this.createNewChallenge.bind(this)
119+
this.createNewDesignChallenge = this.createNewDesignChallenge.bind(this)
117120
this.getCurrentChallengeId = this.getCurrentChallengeId.bind(this)
118121
this.isValidChallengePrizes = this.isValidChallengePrizes.bind(this)
119122
this.isValidChallenge = this.isValidChallenge.bind(this)
@@ -236,6 +239,10 @@ class ChallengeEditor extends Component {
236239
}
237240
}
238241

242+
resetDesignChallengeWarningModal () {
243+
this.setState({ showDesignChallengeWarningModel: false })
244+
}
245+
239246
resetModal () {
240247
this.setState({ isLoading: false, isConfirm: false, isLaunch: false, error: null, isCloseTask: false, isDeleteLaunch: false })
241248
}
@@ -825,12 +832,25 @@ class ChallengeEditor extends Component {
825832
history.push(newPath)
826833
};
827834

835+
createNewDesignChallenge () {
836+
this.resetDesignChallengeWarningModal()
837+
this.createNewChallenge()
838+
}
839+
828840
async createNewChallenge () {
829841
if (!this.props.isNew) return
830842
const { metadata, createChallenge, projectDetail } = this.props
831-
const { name, trackId, typeId } = this.state.challenge
843+
const { showDesignChallengeWarningModel, challenge: { name, trackId, typeId } } = this.state
832844
const { timelineTemplates } = metadata
833845
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+
}
834854

835855
// indicate that creating process has started
836856
this.setState({ isSaving: true })
@@ -839,7 +859,7 @@ class ChallengeEditor extends Component {
839859
const STD_DEV_TIMELINE_TEMPLATE = _.find(timelineTemplates, { name: 'Standard Development' })
840860
const avlTemplates = this.getAvailableTimelineTemplates()
841861
// chooses first available timeline template or fallback template for the new challenge
842-
const defaultTemplate = _.find(avlTemplates || [], t => t.isDefault) || STD_DEV_TIMELINE_TEMPLATE
862+
const defaultTemplate = avlTemplates && avlTemplates.length > 0 ? avlTemplates[0] : STD_DEV_TIMELINE_TEMPLATE
843863
const isTask = _.find(metadata.challengeTypes, { id: typeId, isTask: true })
844864
const newChallenge = {
845865
status: 'New',
@@ -852,7 +872,7 @@ class ChallengeEditor extends Component {
852872
reviewType: isTask || isDesignChallenge ? REVIEW_TYPES.INTERNAL : REVIEW_TYPES.COMMUNITY
853873
},
854874
descriptionFormat: 'markdown',
855-
timelineTemplateId: _.get(this.getCurrentTemplate(), 'id', defaultTemplate.id),
875+
timelineTemplateId: defaultTemplate.id,
856876
terms: [{ id: DEFAULT_TERM_UUID, roleId: SUBMITTER_ROLE_UUID }],
857877
groups: []
858878
// prizeSets: this.getDefaultPrizeSets()
@@ -1141,16 +1161,15 @@ class ChallengeEditor extends Component {
11411161

11421162
// all timeline template ids available for the challenge type
11431163
const availableTemplateIds = _.filter(challengeTimelines, ct => ct.typeId === challenge.typeId && ct.trackId === challenge.trackId).map(tt => tt.timelineTemplateId)
1144-
const defaultChallengeTimeline = _.find(challengeTimelines, ct => ct.typeId === challenge.typeId && ct.trackId === challenge.trackId && ct.isDefault)
11451164
// filter and return timeline templates that are available for this challenge type
1146-
const avlTemplates = _.filter(timelineTemplates, tt => availableTemplateIds.indexOf(tt.id) !== -1)
1147-
return _.map(avlTemplates, tt => tt.id === defaultChallengeTimeline.timelineTemplateId ? { ...tt, isDefault: true } : tt)
1165+
return _.filter(timelineTemplates, tt => availableTemplateIds.indexOf(tt.id) !== -1)
11481166
}
11491167

11501168
render () {
11511169
const {
11521170
isLaunch,
11531171
isConfirm,
1172+
showDesignChallengeWarningModel,
11541173
challenge,
11551174
draftChallenge,
11561175
isOpenAdvanceSettings,
@@ -1222,6 +1241,30 @@ class ChallengeEditor extends Component {
12221241
}
12231242
}
12241243

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+
}
12251268
if (!isNew && isLaunch && !isConfirm) {
12261269
activateModal = (
12271270
<ConfirmationModal
@@ -1363,15 +1406,9 @@ class ChallengeEditor extends Component {
13631406
<div className={styles.newFormContainer}>
13641407
<TrackField tracks={metadata.challengeTracks} challenge={challenge} onUpdateOthers={this.onUpdateOthers} />
13651408
<TypeField types={metadata.challengeTypes} onUpdateSelect={this.onUpdateSelect} challenge={challenge} />
1366-
<TimelineTemplateField
1367-
currentTemplate={this.state.currentTemplate}
1368-
challengeTimelines={metadata.challengeTimelines}
1369-
timelineTemplates={metadata.timelineTemplates}
1370-
challenge={challenge}
1371-
onUpdateSelect={this.resetPhase}
1372-
/>
13731409
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
13741410
</div>
1411+
{showDesignChallengeWarningModel && designChallengeModal}
13751412
{ errorContainer }
13761413
{ actionButtons }
13771414
</form>
@@ -1399,6 +1436,7 @@ class ChallengeEditor extends Component {
13991436
<span><span className={styles.fieldTitle}>Status:</span> {challenge.status}</span>
14001437
</div>
14011438
</div>
1439+
14021440
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
14031441
{isTask && (
14041442
<AssignedMemberField
@@ -1447,13 +1485,6 @@ class ChallengeEditor extends Component {
14471485
{isBetaMode() && (
14481486
<UseSchedulingAPIField challenge={challenge} toggleUseSchedulingAPI={this.toggleUseSchedulingAPI} />
14491487
)}
1450-
<TimelineTemplateField
1451-
challengeTimelines={metadata.challengeTimelines}
1452-
timelineTemplates={metadata.timelineTemplates}
1453-
challenge={challenge}
1454-
currentTemplate={this.state.currentTemplate}
1455-
onUpdateSelect={this.resetPhase}
1456-
/>
14571488
</React.Fragment>
14581489
)}
14591490
{!isTask && (

‎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

‎src/services/challenges.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export async function fetchTimelineTemplates () {
9191
* @returns {Promise<*>}
9292
*/
9393
export async function fetchChallengeTimelines () {
94-
const response = await axiosInstance.get(`${CHALLENGE_TIMELINES_URL}?page=1&perPage=100`)
94+
const response = await axiosInstance.get(`${CHALLENGE_TIMELINES_URL}?isDefault=true&page=1&perPage=100`)
9595
return _.get(response, 'data', [])
9696
}
9797

0 commit comments

Comments
 (0)
Please sign in to comment.