Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit a2751cc

Browse files
Merge pull request #807 from unitaryfund/645_indicate_submission_required_fields
#645: Indicate submission required fields
2 parents 3355e1d + c29cb5e commit a2751cc

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/components/CategoryItemBox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const CategoryItemBox = (props) => {
6060
<tr>
6161
<td>
6262
<div className='row submission'>
63-
<div className={'col-12 col-md-7'}>
63+
<div className='col-12 col-md-7'>
6464
<Link to={pickDetailUrl(props.type, props.item)}>
6565
{props.type !== 'tag' && props.item.description &&
6666
<div>

src/components/FormFieldRow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const TooltipTrigger = React.lazy(() => import('./TooltipTrigger'))
77
const FormFieldRow = (props) => {
88
const [value, setValue] = useState(props.value)
99
const [checked, setChecked] = useState(props.checked ? props.checked : false)
10-
const [isValid, setIsValid] = useState(true)
10+
const [isValid, setIsValid] = useState((props.isValidatedOnStart && props.validRegex) ? props.validRegex.test(props.value) : true)
1111
const [imagePreviewUrl, setImagePreviewUrl] = useState('')
1212

1313
useEffect(() => { setValue(props.value) }, [props.value])

src/components/ValidationRegex.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ const urlValidRegex = new RegExp('^(https?:\\/\\/)?' + // protocol
1414
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
1515
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
1616
'(\\#[-a-z\\d_]*)?$', 'i') // fragment locator
17-
const blankOrurlValidRegex = new RegExp('^(^(https?:\\/\\/)?' + // protocol
17+
const blankOrurlValidRegex = new RegExp('^$|(^(^(https?:\\/\\/)?' + // protocol
1818
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
1919
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
2020
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
2121
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
22-
'(\\#[-a-z\\d_]*)?$)$', 'i') // fragment locator
22+
'(\\#[-a-z\\d_]*)?$)$)', 'i') // fragment locator
2323
const usernameValidRegex = /^(?!\s*$).+/
2424

2525
module.exports = {

src/views/AddSubmission.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ class AddSubmission extends React.Component {
477477
onChange={this.handleOnChange}
478478
onBlur={this.handleOnFieldBlur}
479479
validRegex={this.state.isAlreadyInDatabase ? /^$/ : urlValidRegex}
480+
isValidatedOnStart
480481
/>
481482
<FormFieldAlertRow>
482483
<b>The external content URL points to the full content of the submission.<br />(This could be a link to arXiv, for example.)<br /><i>This cannot be changed after hitting "Submit."</i></b>
@@ -503,6 +504,7 @@ class AddSubmission extends React.Component {
503504
onChange={this.handleOnChange}
504505
validRegex={nonblankRegex}
505506
value={this.state.name}
507+
isValidatedOnStart
506508
/>
507509
<FormFieldAlertRow>
508510
<b>The submission name must be unique.</b>
@@ -522,6 +524,7 @@ class AddSubmission extends React.Component {
522524
onChange={this.handleOnChange}
523525
validRegex={blankOrurlValidRegex}
524526
value={this.state.thumbnailUrl}
527+
isValidatedOnStart
525528
/>
526529
<FormFieldAlertRow>
527530
<b>The image URL is loaded as a thumbnail, for the submission.<br />(For free image hosting, see <a href='https://imgbb.com/' target='_blank' rel='noreferrer'>https://imgbb.com/</a>, for example.)</b>

0 commit comments

Comments
 (0)