Skip to content

Commit 5adc461

Browse files
authored
Merge pull request #1665 from topcoder-platform/develop
Hotifx - disable alphanumeric characters in challenge title
2 parents 999eca4 + b7707a5 commit 5adc461

File tree

5 files changed

+48
-99
lines changed

5 files changed

+48
-99
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ yarn-debug.log*
2525
yarn-error.log*
2626

2727
*.env
28-
28+
*.pem
2929
*.vscode
3030

3131
# e2e test case

config/constants/development.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ module.exports = {
1919
CHALLENGE_TRACKS_URL: `${DEV_API_HOSTNAME}/v5/challenge-tracks`,
2020
CHALLENGE_PHASES_URL: `${DEV_API_HOSTNAME}/v5/challenge-phases`,
2121
CHALLENGE_TIMELINES_URL: `${DEV_API_HOSTNAME}/v5/challenge-timelines`,
22-
COPILOTS_URL: `https://copilots.${DOMAIN}`,
2322
PROJECT_API_URL: `${DEV_API_HOSTNAME}/v5/projects`,
2423
GROUPS_API_URL: `${DEV_API_HOSTNAME}/v5/groups`,
2524
TERMS_API_URL: `${DEV_API_HOSTNAME}/v5/terms`,
26-
MEMBERS_API_URL: `${DEV_API_HOSTNAME}/v5/members`,
2725
RESOURCES_API_URL: `${DEV_API_HOSTNAME}/v5/resources`,
2826
RESOURCE_ROLES_API_URL: `${DEV_API_HOSTNAME}/v5/resource-roles`,
2927
SUBMISSIONS_API_URL: `${DEV_API_HOSTNAME}/v5/submissions`,

package-lock.json

Lines changed: 7 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,47 @@ import styles from './ChallengeName-Field.module.scss'
44
import cn from 'classnames'
55

66
const ChallengeNameField = ({ challenge, onUpdateInput }) => {
7+
const handleChange = (e) => {
8+
// Remove any characters that are NOT letters, numbers, or spaces
9+
const sanitizedValue = e.target.value.replace(/[^a-zA-Z0-9 ]/g, '')
10+
onUpdateInput({
11+
target: {
12+
name: e.target.name,
13+
value: sanitizedValue
14+
}
15+
})
16+
}
17+
718
return (
819
<>
920
<div className={styles.row}>
1021
<div className={cn(styles.field, styles.col1)}>
11-
<label htmlFor='challengeName'>Work Name <span>*</span> :</label>
22+
<label htmlFor='challengeName'>
23+
Work Name <span>*</span> :
24+
</label>
1225
</div>
1326
<div className={cn(styles.field, styles.col2)}>
14-
<input className={styles.challengeName} id='name' name='name' type='text' placeholder='Work Name' value={challenge.name} maxLength='200' required onChange={onUpdateInput} />
27+
<input
28+
className={styles.challengeName}
29+
id='name'
30+
name='name'
31+
type='text'
32+
placeholder='Work Name'
33+
value={challenge.name}
34+
maxLength='200'
35+
required
36+
onChange={handleChange}
37+
/>
1538
</div>
1639
</div>
17-
{ challenge.submitTriggered && !challenge.name && <div className={styles.row}>
18-
<div className={cn(styles.field, styles.col1)} />
19-
<div className={cn(styles.field, styles.col2, styles.error)}>
20-
Work Name is required field
40+
{challenge.submitTriggered && !challenge.name && (
41+
<div className={styles.row}>
42+
<div className={cn(styles.field, styles.col1)} />
43+
<div className={cn(styles.field, styles.col2, styles.error)}>
44+
Work Name is required field
45+
</div>
2146
</div>
22-
</div> }
47+
)}
2348
</>
2449
)
2550
}

src/components/ChallengesComponent/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
77
import { Helmet } from 'react-helmet'
88
import { Link } from 'react-router-dom'
99
import ProjectStatus from './ProjectStatus'
10-
import { PROJECT_ROLES, PROJECT_STATUS, COPILOTS_URL } from '../../config/constants'
10+
import { PROJECT_ROLES, PROJECT_STATUS, COPILOTS_URL, CHALLENGE_STATUS } from '../../config/constants'
1111
import { PrimaryButton, OutlineButton } from '../Buttons'
1212
import ChallengeList from './ChallengeList'
1313
import styles from './ChallengesComponent.module.scss'
@@ -53,6 +53,12 @@ const ChallengesComponent = ({
5353
const isReadOnly = checkReadOnlyRoles(auth.token) || loginUserRoleInProject === PROJECT_ROLES.READ
5454
const isAdminOrCopilot = checkAdminOrCopilot(auth.token, activeProject)
5555

56+
const projectStatus = activeProject && activeProject.status
57+
? activeProject.status.toUpperCase()
58+
: ''
59+
const isCompletedOrCancelled =
60+
projectStatus === CHALLENGE_STATUS.CANCELLED || projectStatus === CHALLENGE_STATUS.COMPLETED
61+
5662
useEffect(() => {
5763
const loggedInUser = auth.user
5864
const projectMembers = activeProject.members
@@ -94,7 +100,7 @@ const ChallengesComponent = ({
94100
className={styles.btnOutline}
95101
/>
96102
)}
97-
{(checkAdmin(auth.token) || checkManager(auth.token)) && (
103+
{(checkAdmin(auth.token) || checkManager(auth.token)) && !isCompletedOrCancelled && (
98104
<OutlineButton
99105
text='Request Copilot'
100106
type={'info'}

0 commit comments

Comments
 (0)