Skip to content

Commit

Permalink
Merge pull request #3270 from OpenNeuroOrg/3263-validation-count-fixes
Browse files Browse the repository at this point in the history
fix(app): Show correct errors/warnings counts for schema validator
  • Loading branch information
nellh authored Jan 10, 2025
2 parents dc8dd5c + b80d887 commit 72c9c01
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/openneuro-app/src/scripts/validation/validation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ const warningHeader = (count) => (
</div>
)

const errorHeader = (count) => (
const errorHeader = (errorCount) => (
<div>
<h3 className="metaheader">BIDS Validation</h3>

<span className="label text-warning pull-right">
{count} {pluralize("Error", count)}
{errorCount} {pluralize("Error", errorCount)}
</span>
<span className="dataset-status ds-danger">
<i className="fa fa-exclamation-circle" /> Invalid
Expand All @@ -53,10 +53,11 @@ const Valid = () => (
)

interface WarningsProps {
issues: DatasetIssues
warnings: DatasetIssues
}

const Warnings = ({ warnings }: WarningsProps) => (
const Warnings = ({ issues, warnings }: WarningsProps) => (
<ValidationPanel heading={warningHeader(warnings.size)}>
<div>
<span className="message error fade-in">
Expand All @@ -69,15 +70,17 @@ const Warnings = ({ warnings }: WarningsProps) => (
</span>
</div>
<br />
<Results issues={warnings} />
<Results issues={issues} />
</ValidationPanel>
)

interface ErrorsProps {
issues: DatasetIssues
errors: DatasetIssues
warnings: DatasetIssues
}

const Errors = ({ errors }: ErrorsProps) => (
const Errors = ({ issues, errors }: ErrorsProps) => (
<ValidationPanel heading={errorHeader(errors.size)}>
<span className="message error fade-in">
Your dataset is no longer valid. You must fix the{" "}
Expand All @@ -86,7 +89,7 @@ const Errors = ({ errors }: ErrorsProps) => (
to use all of the site features.
</span>
<br />
<Results issues={errors} />
<Results issues={issues} />
</ValidationPanel>
)

Expand All @@ -100,9 +103,9 @@ export const Validation = ({ issues }: ValidationProps) => {
const warnings = grouped.get("warning")
const errors = grouped.get("error")
if (errors?.size) {
return <Errors errors={issues} />
return <Errors issues={issues} errors={errors} warnings={warnings} />
} else if (warnings?.size) {
return <Warnings warnings={issues} />
return <Warnings issues={issues} warnings={warnings} />
} else {
return <Valid />
}
Expand Down

0 comments on commit 72c9c01

Please sign in to comment.