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

Add link to data dictionary in validator error block #35

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"buffer": "^6.0.3",
"classnames": "^2.3.2",
"clipboard": "^2.0.11",
"hpt-validator": "1.0.0-rc.4",
"hpt-validator": "1.0.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
72 changes: 50 additions & 22 deletions src/components/ValidationResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const ValidationResults = ({
})
const downloadUrl = window.URL.createObjectURL(blob)
*/
const atMaxErrors = errors.length + warnings.length >= maxErrors
const atMaxErrors = errors.length >= maxErrors
const atMaxWarnings = warnings.length >= maxErrors

useEffect(() => {
if (didMount && !loading && resultsHeaderRef.current) {
Expand Down Expand Up @@ -99,16 +100,36 @@ const ValidationResults = ({
) : (
<>
<span className="text-bold">
There
{errors.length === 1
? "1 error"
: `${errors.length} errors`}{" "}
found in file
? " is 1 error"
: ` are ${atMaxErrors ? "at least " : ""}${
errors.length
} errors`}{" "}
found in the file
</span>
: <span className="text-underline">{filename}</span>
<br />
{atMaxErrors && (
<span>
Only the first {maxErrors} errors and warnings are shown
The first {maxErrors} errors are shown below. See the{" "}
<a href="https://github.com/CMSgov/hospital-price-transparency/">
Hospital Price Transparency Data Dictionary GitHub
Repository
</a>{" "}
for detailed technical specifications to understand and
address these errors.
</span>
)}
{!atMaxErrors && (
<span>
See the{" "}
<a href="https://github.com/CMSgov/hospital-price-transparency/">
Hospital Price Transparency Data Dictionary GitHub
Repository
</a>{" "}
for detailed technical specifications to understand and
address these errors.
</span>
)}
</>
Expand All @@ -124,12 +145,14 @@ const ValidationResults = ({
</tr>
</thead>
<tbody>
{errors.map(({ path, message }, index) => (
<tr key={index}>
<td>{path}</td>
<td>{message}</td>
</tr>
))}
{errors
.slice(0, maxErrors)
.map(({ path, message }, index) => (
<tr key={index}>
<td>{path}</td>
<td>{message}</td>
</tr>
))}
</tbody>
</Table>
</>
Expand All @@ -144,16 +167,19 @@ const ValidationResults = ({
) : (
<>
<span className="text-bold">
There
{warnings.length === 1
? "1 warning"
: `${warnings.length} warnings`}{" "}
for file
? " is 1 warning"
: ` are ${atMaxWarnings ? "at least " : ""}${
warnings.length
} warnings`}{" "}
found in the file
</span>
: <span className="text-underline">{filename}</span>
<br />
{atMaxErrors && (
{atMaxWarnings && (
<span>
Only the first {maxErrors} errors and warnings are shown
The first {maxErrors} warnings are shown below.
</span>
)}
<br />
Expand All @@ -173,12 +199,14 @@ const ValidationResults = ({
</tr>
</thead>
<tbody>
{warnings.map(({ path, message }, index) => (
<tr key={index}>
<td>{path}</td>
<td>{message}</td>
</tr>
))}
{warnings
.slice(0, maxErrors)
.map(({ path, message }, index) => (
<tr key={index}>
<td>{path}</td>
<td>{message}</td>
</tr>
))}
</tbody>
</Table>
)}
Expand Down
Loading