-
Notifications
You must be signed in to change notification settings - Fork 51
Hotifx - disable alphanumeric characters in challenge title #1665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a2ec0d9
cdd528c
fb89618
8ede5aa
47f89e8
fb2d638
8990be2
b70bdcc
b7707a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ yarn-debug.log* | |
yarn-error.log* | ||
|
||
*.env | ||
|
||
*.pem | ||
*.vscode | ||
|
||
# e2e test case | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,47 @@ import styles from './ChallengeName-Field.module.scss' | |
import cn from 'classnames' | ||
|
||
const ChallengeNameField = ({ challenge, onUpdateInput }) => { | ||
const handleChange = (e) => { | ||
// Remove any characters that are NOT letters, numbers, or spaces | ||
const sanitizedValue = e.target.value.replace(/[^a-zA-Z0-9 ]/g, '') | ||
onUpdateInput({ | ||
target: { | ||
name: e.target.name, | ||
value: sanitizedValue | ||
} | ||
}) | ||
} | ||
|
||
return ( | ||
<> | ||
<div className={styles.row}> | ||
<div className={cn(styles.field, styles.col1)}> | ||
<label htmlFor='challengeName'>Work Name <span>*</span> :</label> | ||
<label htmlFor='challengeName'> | ||
Work Name <span>*</span> : | ||
</label> | ||
</div> | ||
<div className={cn(styles.field, styles.col2)}> | ||
<input className={styles.challengeName} id='name' name='name' type='text' placeholder='Work Name' value={challenge.name} maxLength='200' required onChange={onUpdateInput} /> | ||
<input | ||
className={styles.challengeName} | ||
id='name' | ||
name='name' | ||
type='text' | ||
placeholder='Work Name' | ||
value={challenge.name} | ||
maxLength='200' | ||
required | ||
onChange={handleChange} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the |
||
/> | ||
</div> | ||
</div> | ||
{ challenge.submitTriggered && !challenge.name && <div className={styles.row}> | ||
<div className={cn(styles.field, styles.col1)} /> | ||
<div className={cn(styles.field, styles.col2, styles.error)}> | ||
Work Name is required field | ||
{challenge.submitTriggered && !challenge.name && ( | ||
<div className={styles.row}> | ||
<div className={cn(styles.field, styles.col1)} /> | ||
<div className={cn(styles.field, styles.col2, styles.error)}> | ||
Work Name is required field | ||
</div> | ||
</div> | ||
</div> } | ||
)} | ||
</> | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types' | |
import { Helmet } from 'react-helmet' | ||
import { Link } from 'react-router-dom' | ||
import ProjectStatus from './ProjectStatus' | ||
import { PROJECT_ROLES, PROJECT_STATUS, COPILOTS_URL } from '../../config/constants' | ||
import { PROJECT_ROLES, PROJECT_STATUS, COPILOTS_URL, CHALLENGE_STATUS } from '../../config/constants' | ||
import { PrimaryButton, OutlineButton } from '../Buttons' | ||
import ChallengeList from './ChallengeList' | ||
import styles from './ChallengesComponent.module.scss' | ||
|
@@ -53,6 +53,12 @@ const ChallengesComponent = ({ | |
const isReadOnly = checkReadOnlyRoles(auth.token) || loginUserRoleInProject === PROJECT_ROLES.READ | ||
const isAdminOrCopilot = checkAdminOrCopilot(auth.token, activeProject) | ||
|
||
const projectStatus = activeProject && activeProject.status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using optional chaining ( |
||
? activeProject.status.toUpperCase() | ||
: '' | ||
const isCompletedOrCancelled = | ||
projectStatus === CHALLENGE_STATUS.CANCELLED || projectStatus === CHALLENGE_STATUS.COMPLETED | ||
|
||
useEffect(() => { | ||
const loggedInUser = auth.user | ||
const projectMembers = activeProject.members | ||
|
@@ -94,7 +100,7 @@ const ChallengesComponent = ({ | |
className={styles.btnOutline} | ||
/> | ||
)} | ||
{(checkAdmin(auth.token) || checkManager(auth.token)) && ( | ||
{(checkAdmin(auth.token) || checkManager(auth.token)) && !isCompletedOrCancelled && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a comment to explain the logic behind the |
||
<OutlineButton | ||
text='Request Copilot' | ||
type={'info'} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment explaining the regex pattern used for sanitizing the input. This will help future developers understand the intention behind the pattern.