Skip to content

Commit 1e1a06d

Browse files
author
Vikas Agarwal
committed
feat: git#995-Disable selection of Community Review type for Design challenges
1 parent 44f7cc0 commit 1e1a06d

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

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

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,31 @@ import PropTypes from 'prop-types'
33
import Select from '../../Select'
44
import cn from 'classnames'
55
import styles from './ReviewType-Field.module.scss'
6+
import Tooltip from '../../Tooltip'
7+
import { DES_TRACK_ID, REVIEW_TYPES, MESSAGE } from '../../../config/constants'
68

79
const ReviewTypeField = ({ reviewers, challenge, onUpdateOthers, onUpdateSelect }) => {
8-
const reviewType = challenge.reviewType ? challenge.reviewType.toLowerCase() : 'community'
9-
const isCommunity = reviewType === 'community'
10-
const isInternal = reviewType === 'internal'
10+
const isDesignChallenge = challenge.trackId === DES_TRACK_ID
11+
const defaultReviewType = isDesignChallenge ? REVIEW_TYPES.INTERNAL : REVIEW_TYPES.COMMUNITY
12+
const reviewType = challenge.reviewType ? challenge.reviewType.toLowerCase() : defaultReviewType
13+
const isCommunity = reviewType === REVIEW_TYPES.COMMUNITY
14+
const isInternal = reviewType === REVIEW_TYPES.INTERNAL
15+
const communityOption = (disabled) => (<div className={styles.tcRadioButton}>
16+
<input
17+
name='community'
18+
type='radio'
19+
id='community'
20+
checked={isCommunity}
21+
disabled={disabled}
22+
onChange={(e) => e.target.checked && onUpdateOthers({ field: 'reviewType', value: 'community' })}
23+
/>
24+
<label htmlFor='community'>
25+
<div className={styles.radioButtonLabel}>
26+
Community
27+
</div>
28+
<input type='hidden' />
29+
</label>
30+
</div>)
1131
return (
1232
<div>
1333
<div className={styles.row}>
@@ -17,21 +37,14 @@ const ReviewTypeField = ({ reviewers, challenge, onUpdateOthers, onUpdateSelect
1737
<div className={cn(styles.field, styles.col2)}>
1838
<div className={styles.subGroup}>
1939
<div className={styles.subRow}>
20-
<div className={styles.tcRadioButton}>
21-
<input
22-
name='community'
23-
type='radio'
24-
id='community'
25-
checked={isCommunity}
26-
onChange={(e) => e.target.checked && onUpdateOthers({ field: 'reviewType', value: 'community' })}
27-
/>
28-
<label htmlFor='community'>
29-
<div className={styles.radioButtonLabel}>
30-
Community
31-
</div>
32-
<input type='hidden' />
33-
</label>
34-
</div>
40+
{ isDesignChallenge &&
41+
<Tooltip content={MESSAGE.COMMUNITY_REVIEW_DISABLED}>
42+
{ communityOption(true) }
43+
</Tooltip>
44+
}
45+
{ !isDesignChallenge &&
46+
communityOption()
47+
}
3548
</div>
3649
<div className={styles.subRow}>
3750
<div className={styles.tcRadioButton}>

src/components/ChallengeEditor/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import {
1818
SUBMITTER_ROLE_UUID,
1919
CREATE_FORUM_TYPE_IDS,
2020
MESSAGE,
21-
COMMUNITY_APP_URL
21+
COMMUNITY_APP_URL,
22+
DES_TRACK_ID,
23+
REVIEW_TYPES
2224
} from '../../config/constants'
2325
import { PrimaryButton, OutlineButton } from '../Buttons'
2426
import TrackField from './Track-Field'
@@ -784,6 +786,7 @@ class ChallengeEditor extends Component {
784786
const { metadata, createChallenge } = this.props
785787
const { name, trackId, typeId } = this.state.challenge
786788
const { timelineTemplates } = metadata
789+
const isDesignChallenge = trackId === DES_TRACK_ID
787790

788791
// indicate that creating process has started
789792
this.setState({ isSaving: true })
@@ -802,7 +805,7 @@ class ChallengeEditor extends Component {
802805
trackId,
803806
startDate: moment().add(1, 'days').format(),
804807
legacy: {
805-
reviewType: 'community'
808+
reviewType: isDesignChallenge ? REVIEW_TYPES.INTERNAL : REVIEW_TYPES.COMMUNITY
806809
},
807810
descriptionFormat: 'markdown',
808811
timelineTemplateId: defaultTemplate.id,

src/config/constants.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ export const PRIZE_SETS_TYPE = {
110110
CHECKPOINT_PRIZES: 'checkpoint'
111111
}
112112

113+
export const REVIEW_TYPES = {
114+
INTERNAL: 'internal',
115+
COMMUNITY: 'community'
116+
}
117+
113118
// List of subtracks that should be considered as Marathon Matches
114119
export const MARATHON_MATCH_SUBTRACKS = [
115120
'DEVELOP_MARATHON_MATCH'
@@ -186,5 +191,6 @@ export const MESSAGE = {
186191
NO_LEGACY_CHALLENGE: 'Legacy challenge is not yet created',
187192
NO_TASK_ASSIGNEE: 'Task is not assigned yet',
188193
TASK_CLOSE_SUCCESS: 'Task closed successfully',
189-
CHALLENGE_LAUNCH_SUCCESS: 'Challenge activated successfully'
194+
CHALLENGE_LAUNCH_SUCCESS: 'Challenge activated successfully',
195+
COMMUNITY_REVIEW_DISABLED: 'Community review is NOT available for design challenges'
190196
}

0 commit comments

Comments
 (0)