Skip to content

Commit

Permalink
Merge pull request #2996 from OpenNeuroOrg/schema-validator-file-fix
Browse files Browse the repository at this point in the history
fix(app): Show file metadata for schema validator issues
  • Loading branch information
nellh authored Feb 29, 2024
2 parents 2653231 + 8babdda commit 1f3ba55
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Issue extends React.Component {
<span className="e-meta">
<label>File Metadata:</label>
<p>
{file.size / 1000} KB | {file.type}
{file.size / 1000} KB {file.type ? ` | ${file.type}` : ""}
</p>
</span>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,28 @@ class Issues extends React.Component {
</span>
)

// issue sub-errors
const subErrors = Array.from(issue.files).map((error, index2) => {
// Schema validator returns multiple files here
let subErrors = []
if (issue.files instanceof Map) {
// Schema validator returns multiple files here as a map
// map those to the old sub-issue model to display them
if (error?.length) {
return error.filter(Boolean).map((i, index3) => {
return (
<Issue
type={this.props.issueType}
file={i.file}
error={i}
index={index3}
key={index3}
/>
)
})
} else {
let index = 0
for (const [path, fObj] of issue.files) {
const error = {
reason: path,
file: fObj,
}
subErrors.push(
(<Issue
type={this.props.issueType}
error={error}
index={index}
key={index}
/>),
)
index += 1
}
} else {
subErrors = Array.from(issue.files).map((error, index2) => {
return error
? (
<Issue
Expand All @@ -59,8 +64,8 @@ class Issues extends React.Component {
/>
)
: null
}
})
})
}

if (issue.additionalFileCount > 0) {
subErrors.push(
Expand Down

0 comments on commit 1f3ba55

Please sign in to comment.