Skip to content
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

fix(app): Show correct errors/warnings counts for schema validator #3270

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
</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)}

Check warning on line 39 in packages/openneuro-app/src/scripts/validation/validation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/validation/validation.tsx#L39

Added line #L39 was not covered by tests
</span>
<span className="dataset-status ds-danger">
<i className="fa fa-exclamation-circle" /> Invalid
Expand All @@ -53,10 +53,11 @@
)

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 @@
</span>
</div>
<br />
<Results issues={warnings} />
<Results issues={issues} />

Check warning on line 73 in packages/openneuro-app/src/scripts/validation/validation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/validation/validation.tsx#L73

Added line #L73 was not covered by tests
</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 @@
to use all of the site features.
</span>
<br />
<Results issues={errors} />
<Results issues={issues} />

Check warning on line 92 in packages/openneuro-app/src/scripts/validation/validation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/validation/validation.tsx#L92

Added line #L92 was not covered by tests
</ValidationPanel>
)

Expand All @@ -100,9 +103,9 @@
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} />

Check warning on line 106 in packages/openneuro-app/src/scripts/validation/validation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/validation/validation.tsx#L106

Added line #L106 was not covered by tests
} else if (warnings?.size) {
return <Warnings warnings={issues} />
return <Warnings issues={issues} warnings={warnings} />

Check warning on line 108 in packages/openneuro-app/src/scripts/validation/validation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/validation/validation.tsx#L108

Added line #L108 was not covered by tests
} else {
return <Valid />
}
Expand Down
Loading