Skip to content

Commit f064d2b

Browse files
authored
Merge pull request #1706 from topcoder-platform/develop
Don't force skills selection on Topgear challenge edits
2 parents 2596dce + 46ed479 commit f064d2b

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/components/ChallengeEditor/SkillsField/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Select from '../../Select'
44
import { searchSkills } from '../../../services/skills'
55
import cn from 'classnames'
66
import styles from './styles.module.scss'
7-
import { AUTOCOMPLETE_DEBOUNCE_TIME_MS } from '../../../config/constants'
7+
import { AUTOCOMPLETE_DEBOUNCE_TIME_MS, SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS } from '../../../config/constants'
88
import _ from 'lodash'
99

1010
const fetchSkills = _.debounce((inputValue, callback) => {
@@ -27,12 +27,15 @@ const SkillsField = ({ readOnly, challenge, onUpdateSkills }) => {
2727
value: skill.id
2828
})), [challenge.skills])
2929
const existingSkills = useMemo(() => selectedSkills.map(item => item.label).join(','), [selectedSkills])
30+
const billingAccountId = _.get(challenge, 'billing.billingAccountId')
31+
const normalizedBillingAccountId = _.isNil(billingAccountId) ? null : String(billingAccountId)
32+
const skillsRequired = normalizedBillingAccountId ? !SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS.includes(normalizedBillingAccountId) : true
3033

3134
return (
3235
<>
3336
<div className={styles.row}>
3437
<div className={cn(styles.field, styles.col1)}>
35-
<label htmlFor='keywords'>Skills {!readOnly && (<span>*</span>)} :</label>
38+
<label htmlFor='keywords'>Skills {!readOnly && skillsRequired && (<span>*</span>)} :</label>
3639
</div>
3740
<div className={cn(styles.field, styles.col2)}>
3841
<input type='hidden' />
@@ -58,7 +61,7 @@ const SkillsField = ({ readOnly, challenge, onUpdateSkills }) => {
5861
</div>
5962
</div>
6063

61-
{ !readOnly && challenge.submitTriggered && (!selectedSkills || !selectedSkills.length) && <div className={styles.row}>
64+
{ !readOnly && skillsRequired && challenge.submitTriggered && (!selectedSkills || !selectedSkills.length) && <div className={styles.row}>
6265
<div className={cn(styles.field, styles.col1)} />
6366
<div className={cn(styles.field, styles.col2, styles.error)}>
6467
Select at least one skill

src/components/ChallengeEditor/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import {
2626
PHASE_PRODUCT_CHALLENGE_ID_FIELD,
2727
QA_TRACK_ID, DESIGN_CHALLENGE_TYPES, ROUND_TYPES,
2828
MULTI_ROUND_CHALLENGE_TEMPLATE_ID, DS_TRACK_ID,
29-
CHALLENGE_STATUS
29+
CHALLENGE_STATUS,
30+
SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS
3031
} from '../../config/constants'
3132
import {
3233
getDomainTypes,
@@ -867,14 +868,20 @@ class ChallengeEditor extends Component {
867868
return false
868869
}
869870

871+
const billingAccountId = _.get(challenge, 'billing.billingAccountId')
872+
const normalizedBillingAccountId = _.isNil(billingAccountId) ? null : String(billingAccountId)
873+
const isSkillsRequired = normalizedBillingAccountId ? !SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS.includes(normalizedBillingAccountId) : true
874+
870875
const requiredFields = [
871876
'trackId',
872877
'typeId',
873878
'name',
874879
'description',
875-
'skills',
876880
'prizeSets'
877881
]
882+
if (isSkillsRequired) {
883+
requiredFields.push('skills')
884+
}
878885
let isRequiredMissing = false
879886

880887
requiredFields.forEach((key) => {

src/config/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const {
4040

4141
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
4242
export const PROJECTS_API_URL = process.env.PROJECTS_API_URL || process.env.PROJECT_API_URL
43+
export const SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS = ['80000062']
4344

4445
/**
4546
* Filepicker config

0 commit comments

Comments
 (0)