From 0aee4fdcc941ac0090664d7b84ea46891b83b7ac Mon Sep 17 00:00:00 2001 From: Mint Thompson Date: Thu, 28 Mar 2024 11:34:29 -0400 Subject: [PATCH 1/2] Add link to data dictionary in validator error block Limit number of errors and warnings in table based on maximum amount. Update language describing number of errors or warnings in each table. --- package-lock.json | 6 +-- src/components/ValidationResults.jsx | 72 +++++++++++++++++++--------- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index c680963..f86726d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6418,9 +6418,9 @@ } }, "node_modules/vite": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.0.tgz", - "integrity": "sha512-ulr8rNLA6rkyFAlVWw2q5YJ91v098AFQ2R0PRFwPzREXOUJQPtFUG0t+/ZikhaOCDqFoDhN6/v8Sq0o4araFAw==", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.3.tgz", + "integrity": "sha512-kQL23kMeX92v3ph7IauVkXkikdDRsYMGTVl5KY2E9OY4ONLvkHf04MDTbnfo6NKxZiDLWzVpP5oTa8hQD8U3dg==", "dev": true, "dependencies": { "esbuild": "^0.18.10", diff --git a/src/components/ValidationResults.jsx b/src/components/ValidationResults.jsx index 53fd2bd..981044c 100644 --- a/src/components/ValidationResults.jsx +++ b/src/components/ValidationResults.jsx @@ -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) { @@ -99,16 +100,36 @@ const ValidationResults = ({ ) : ( <> + 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 : {filename}
{atMaxErrors && ( - Only the first {maxErrors} errors and warnings are shown + The first {maxErrors} errors are shown below. See the{" "} + + Hospital Price Transparency Data Dictionary GitHub + Repository + {" "} + for detailed technical specifications to understand and + address these errors. + + )} + {!atMaxErrors && ( + + See the{" "} + + Hospital Price Transparency Data Dictionary GitHub + Repository + {" "} + for detailed technical specifications to understand and + address these errors. )} @@ -124,12 +145,14 @@ const ValidationResults = ({ - {errors.map(({ path, message }, index) => ( - - {path} - {message} - - ))} + {errors + .slice(0, maxErrors) + .map(({ path, message }, index) => ( + + {path} + {message} + + ))} @@ -144,16 +167,19 @@ const ValidationResults = ({ ) : ( <> + 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 : {filename}
- {atMaxErrors && ( + {atMaxWarnings && ( - Only the first {maxErrors} errors and warnings are shown + The first {maxErrors} warnings are shown below. )}
@@ -173,12 +199,14 @@ const ValidationResults = ({ - {warnings.map(({ path, message }, index) => ( - - {path} - {message} - - ))} + {warnings + .slice(0, maxErrors) + .map(({ path, message }, index) => ( + + {path} + {message} + + ))} )} From 2447f19e25c4a6971a35ac78625d0714f663d249 Mon Sep 17 00:00:00 2001 From: shaselton-usds Date: Fri, 29 Mar 2024 09:46:27 -0700 Subject: [PATCH 2/2] using the latest version of the core validator --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f86726d..f0b542e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,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", @@ -4444,9 +4444,9 @@ } }, "node_modules/hpt-validator": { - "version": "1.0.0-rc.4", - "resolved": "https://registry.npmjs.org/hpt-validator/-/hpt-validator-1.0.0-rc.4.tgz", - "integrity": "sha512-ypWwUj4CmNGbrdh7qW5gkrGSCF6T6JqMgENREzYb/exptZbqBRCuOqsyzY6E3MDI7iGny10ddGj8Q/A4QOvcbA==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hpt-validator/-/hpt-validator-1.0.0.tgz", + "integrity": "sha512-RO11pW2krf12rbO8LMR1XqK7lnf1CLqIGXRb3w2NOpwI9KfDL9KWTsDTWlq1C8DP23Fpo6UB4S393L78snQ3Hw==", "dependencies": { "@streamparser/json": "^0.0.17", "@types/node": "^20.2.5", diff --git a/package.json b/package.json index e2a4334..e9fe29a 100644 --- a/package.json +++ b/package.json @@ -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",