Skip to content

Commit

Permalink
feat: git#1001-Disable selection of Internal Review type for QA chall…
Browse files Browse the repository at this point in the history
…enges
  • Loading branch information
Vikas Agarwal committed Dec 16, 2020
1 parent 1e1a06d commit 6b7fb0e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
45 changes: 28 additions & 17 deletions src/components/ChallengeEditor/ReviewType-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import Select from '../../Select'
import cn from 'classnames'
import styles from './ReviewType-Field.module.scss'
import Tooltip from '../../Tooltip'
import { DES_TRACK_ID, REVIEW_TYPES, MESSAGE } from '../../../config/constants'
import { DES_TRACK_ID, REVIEW_TYPES, MESSAGE, QA_TRACK_ID } from '../../../config/constants'

const ReviewTypeField = ({ reviewers, challenge, onUpdateOthers, onUpdateSelect }) => {
const isDesignChallenge = challenge.trackId === DES_TRACK_ID
const isQAChallenge = challenge.trackId === QA_TRACK_ID
const defaultReviewType = isDesignChallenge ? REVIEW_TYPES.INTERNAL : REVIEW_TYPES.COMMUNITY
const reviewType = challenge.reviewType ? challenge.reviewType.toLowerCase() : defaultReviewType
const isCommunity = reviewType === REVIEW_TYPES.COMMUNITY
Expand All @@ -19,7 +20,7 @@ const ReviewTypeField = ({ reviewers, challenge, onUpdateOthers, onUpdateSelect
id='community'
checked={isCommunity}
disabled={disabled}
onChange={(e) => e.target.checked && onUpdateOthers({ field: 'reviewType', value: 'community' })}
onChange={(e) => e.target.checked && onUpdateOthers({ field: 'reviewType', value: REVIEW_TYPES.COMMUNITY })}
/>
<label htmlFor='community'>
<div className={styles.radioButtonLabel}>
Expand All @@ -28,6 +29,22 @@ const ReviewTypeField = ({ reviewers, challenge, onUpdateOthers, onUpdateSelect
<input type='hidden' />
</label>
</div>)
const internalOption = (disabled) => (<div className={styles.tcRadioButton}>
<input
name='internal'
type='radio'
id='internal'
disabled={disabled}
checked={isInternal}
onChange={(e) => e.target.checked && onUpdateOthers({ field: 'reviewType', value: REVIEW_TYPES.INTERNAL })}
/>
<label htmlFor='internal'>
<div className={styles.radioButtonLabel}>
Internal
</div>
<input type='hidden' />
</label>
</div>)
return (
<div>
<div className={styles.row}>
Expand All @@ -47,21 +64,15 @@ const ReviewTypeField = ({ reviewers, challenge, onUpdateOthers, onUpdateSelect
}
</div>
<div className={styles.subRow}>
<div className={styles.tcRadioButton}>
<input
name='internal'
type='radio'
id='internal'
checked={isInternal}
onChange={(e) => e.target.checked && onUpdateOthers({ field: 'reviewType', value: 'internal' })}
/>
<label htmlFor='internal'>
<div className={styles.radioButtonLabel}>
Internal
</div>
<input type='hidden' />
</label>
</div>
{
isQAChallenge &&
<Tooltip content={MESSAGE.INTERNAL_REVIEW_DISABLED}>
{ internalOption(true) }
</Tooltip>
}
{ !isQAChallenge &&
internalOption()
}
{
isInternal && (
<Select
Expand Down
3 changes: 2 additions & 1 deletion src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,6 @@ export const MESSAGE = {
NO_TASK_ASSIGNEE: 'Task is not assigned yet',
TASK_CLOSE_SUCCESS: 'Task closed successfully',
CHALLENGE_LAUNCH_SUCCESS: 'Challenge activated successfully',
COMMUNITY_REVIEW_DISABLED: 'Community review is NOT available for design challenges'
COMMUNITY_REVIEW_DISABLED: 'Community review is NOT available for Design challenges',
INTERNAL_REVIEW_DISABLED: 'Internal review is NOT available for QA challenges'
}

0 comments on commit 6b7fb0e

Please sign in to comment.