Skip to content

Commit

Permalink
feat: git#995-Disable selection of Community Review type for Design c…
Browse files Browse the repository at this point in the history
…hallenges
  • Loading branch information
Vikas Agarwal committed Dec 16, 2020
1 parent 44f7cc0 commit 1e1a06d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
49 changes: 31 additions & 18 deletions src/components/ChallengeEditor/ReviewType-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@ import PropTypes from 'prop-types'
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'

const ReviewTypeField = ({ reviewers, challenge, onUpdateOthers, onUpdateSelect }) => {
const reviewType = challenge.reviewType ? challenge.reviewType.toLowerCase() : 'community'
const isCommunity = reviewType === 'community'
const isInternal = reviewType === 'internal'
const isDesignChallenge = challenge.trackId === DES_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
const isInternal = reviewType === REVIEW_TYPES.INTERNAL
const communityOption = (disabled) => (<div className={styles.tcRadioButton}>
<input
name='community'
type='radio'
id='community'
checked={isCommunity}
disabled={disabled}
onChange={(e) => e.target.checked && onUpdateOthers({ field: 'reviewType', value: 'community' })}
/>
<label htmlFor='community'>
<div className={styles.radioButtonLabel}>
Community
</div>
<input type='hidden' />
</label>
</div>)
return (
<div>
<div className={styles.row}>
Expand All @@ -17,21 +37,14 @@ const ReviewTypeField = ({ reviewers, challenge, onUpdateOthers, onUpdateSelect
<div className={cn(styles.field, styles.col2)}>
<div className={styles.subGroup}>
<div className={styles.subRow}>
<div className={styles.tcRadioButton}>
<input
name='community'
type='radio'
id='community'
checked={isCommunity}
onChange={(e) => e.target.checked && onUpdateOthers({ field: 'reviewType', value: 'community' })}
/>
<label htmlFor='community'>
<div className={styles.radioButtonLabel}>
Community
</div>
<input type='hidden' />
</label>
</div>
{ isDesignChallenge &&
<Tooltip content={MESSAGE.COMMUNITY_REVIEW_DISABLED}>
{ communityOption(true) }
</Tooltip>
}
{ !isDesignChallenge &&
communityOption()
}
</div>
<div className={styles.subRow}>
<div className={styles.tcRadioButton}>
Expand Down
7 changes: 5 additions & 2 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import {
SUBMITTER_ROLE_UUID,
CREATE_FORUM_TYPE_IDS,
MESSAGE,
COMMUNITY_APP_URL
COMMUNITY_APP_URL,
DES_TRACK_ID,
REVIEW_TYPES
} from '../../config/constants'
import { PrimaryButton, OutlineButton } from '../Buttons'
import TrackField from './Track-Field'
Expand Down Expand Up @@ -784,6 +786,7 @@ class ChallengeEditor extends Component {
const { metadata, createChallenge } = this.props
const { name, trackId, typeId } = this.state.challenge
const { timelineTemplates } = metadata
const isDesignChallenge = trackId === DES_TRACK_ID

// indicate that creating process has started
this.setState({ isSaving: true })
Expand All @@ -802,7 +805,7 @@ class ChallengeEditor extends Component {
trackId,
startDate: moment().add(1, 'days').format(),
legacy: {
reviewType: 'community'
reviewType: isDesignChallenge ? REVIEW_TYPES.INTERNAL : REVIEW_TYPES.COMMUNITY
},
descriptionFormat: 'markdown',
timelineTemplateId: defaultTemplate.id,
Expand Down
8 changes: 7 additions & 1 deletion src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ export const PRIZE_SETS_TYPE = {
CHECKPOINT_PRIZES: 'checkpoint'
}

export const REVIEW_TYPES = {
INTERNAL: 'internal',
COMMUNITY: 'community'
}

// List of subtracks that should be considered as Marathon Matches
export const MARATHON_MATCH_SUBTRACKS = [
'DEVELOP_MARATHON_MATCH'
Expand Down Expand Up @@ -186,5 +191,6 @@ export const MESSAGE = {
NO_LEGACY_CHALLENGE: 'Legacy challenge is not yet created',
NO_TASK_ASSIGNEE: 'Task is not assigned yet',
TASK_CLOSE_SUCCESS: 'Task closed successfully',
CHALLENGE_LAUNCH_SUCCESS: 'Challenge activated successfully'
CHALLENGE_LAUNCH_SUCCESS: 'Challenge activated successfully',
COMMUNITY_REVIEW_DISABLED: 'Community review is NOT available for design challenges'
}

0 comments on commit 1e1a06d

Please sign in to comment.