mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-14 03:24:40 +00:00
add inline errors
This commit is contained in:
parent
7bd3ead772
commit
60aeaee91d
27
spiffworkflow-frontend/package-lock.json
generated
27
spiffworkflow-frontend/package-lock.json
generated
@ -23,6 +23,7 @@
|
|||||||
"@rjsf/core": "*",
|
"@rjsf/core": "*",
|
||||||
"@rjsf/mui": "^5.0.0-beta.13",
|
"@rjsf/mui": "^5.0.0-beta.13",
|
||||||
"@rjsf/utils": "^5.0.0-beta.13",
|
"@rjsf/utils": "^5.0.0-beta.13",
|
||||||
|
"@rjsf/validator-ajv6": "^5.0.0-beta.13",
|
||||||
"@rjsf/validator-ajv8": "^5.0.0-beta.13",
|
"@rjsf/validator-ajv8": "^5.0.0-beta.13",
|
||||||
"@tanstack/react-table": "^8.2.2",
|
"@tanstack/react-table": "^8.2.2",
|
||||||
"@testing-library/jest-dom": "^5.16.4",
|
"@testing-library/jest-dom": "^5.16.4",
|
||||||
@ -4933,6 +4934,22 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz",
|
||||||
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w=="
|
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@rjsf/validator-ajv6": {
|
||||||
|
"version": "5.0.0-beta.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rjsf/validator-ajv6/-/validator-ajv6-5.0.0-beta.13.tgz",
|
||||||
|
"integrity": "sha512-X9N3/HJYV23MjUN/VJHIdBhUdBuMTUsh4HAZm50eUvUAhWK95wIqjjhAs24rzeLajrjFeH7kFr89zAqDgIFhVQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"ajv": "^6.7.0",
|
||||||
|
"lodash": "^4.17.15",
|
||||||
|
"lodash-es": "^4.17.15"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@rjsf/utils": "^5.0.0-beta.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@rjsf/validator-ajv8": {
|
"node_modules/@rjsf/validator-ajv8": {
|
||||||
"version": "5.0.0-beta.13",
|
"version": "5.0.0-beta.13",
|
||||||
"resolved": "https://registry.npmjs.org/@rjsf/validator-ajv8/-/validator-ajv8-5.0.0-beta.13.tgz",
|
"resolved": "https://registry.npmjs.org/@rjsf/validator-ajv8/-/validator-ajv8-5.0.0-beta.13.tgz",
|
||||||
@ -34856,6 +34873,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@rjsf/validator-ajv6": {
|
||||||
|
"version": "5.0.0-beta.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rjsf/validator-ajv6/-/validator-ajv6-5.0.0-beta.13.tgz",
|
||||||
|
"integrity": "sha512-X9N3/HJYV23MjUN/VJHIdBhUdBuMTUsh4HAZm50eUvUAhWK95wIqjjhAs24rzeLajrjFeH7kFr89zAqDgIFhVQ==",
|
||||||
|
"requires": {
|
||||||
|
"ajv": "^6.7.0",
|
||||||
|
"lodash": "^4.17.15",
|
||||||
|
"lodash-es": "^4.17.15"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@rjsf/validator-ajv8": {
|
"@rjsf/validator-ajv8": {
|
||||||
"version": "5.0.0-beta.13",
|
"version": "5.0.0-beta.13",
|
||||||
"resolved": "https://registry.npmjs.org/@rjsf/validator-ajv8/-/validator-ajv8-5.0.0-beta.13.tgz",
|
"resolved": "https://registry.npmjs.org/@rjsf/validator-ajv8/-/validator-ajv8-5.0.0-beta.13.tgz",
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"@rjsf/core": "*",
|
"@rjsf/core": "*",
|
||||||
"@rjsf/mui": "^5.0.0-beta.13",
|
"@rjsf/mui": "^5.0.0-beta.13",
|
||||||
"@rjsf/utils": "^5.0.0-beta.13",
|
"@rjsf/utils": "^5.0.0-beta.13",
|
||||||
"@rjsf/validator-ajv8": "^5.0.0-beta.13",
|
"@rjsf/validator-ajv6": "^5.0.0-beta.13",
|
||||||
"@tanstack/react-table": "^8.2.2",
|
"@tanstack/react-table": "^8.2.2",
|
||||||
"@testing-library/jest-dom": "^5.16.4",
|
"@testing-library/jest-dom": "^5.16.4",
|
||||||
"@testing-library/react": "^13.3.0",
|
"@testing-library/react": "^13.3.0",
|
||||||
@ -79,8 +79,8 @@
|
|||||||
"t": "npm test -- --watchAll=false",
|
"t": "npm test -- --watchAll=false",
|
||||||
"eject": "craco eject",
|
"eject": "craco eject",
|
||||||
"format": "prettier --write src/**/*.[tj]s{,x}",
|
"format": "prettier --write src/**/*.[tj]s{,x}",
|
||||||
"lint": "./node_modules/.bin/eslint src *.[tj]s{,x}",
|
"lint": "./node_modules/.bin/eslint src",
|
||||||
"lint:fix": "./node_modules/.bin/eslint --fix src *.[tj]s{,x}"
|
"lint:fix": "./node_modules/.bin/eslint --fix src"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": [
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
import { useContext, useEffect, useState } from 'react';
|
import { useContext, useEffect, useState } from 'react';
|
||||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
import validator from '@rjsf/validator-ajv8';
|
|
||||||
|
// FIXME: npm install @rjsf/validator-ajv8 and use it as soon as
|
||||||
|
// rawErrors is fixed.
|
||||||
|
import validator from '@rjsf/validator-ajv6';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Button, Stack } from '@carbon/react';
|
import { Button, Stack } from '@carbon/react';
|
||||||
|
|
||||||
import ReactMarkdown from 'react-markdown';
|
import ReactMarkdown from 'react-markdown';
|
||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
|
// eslint-disable-next-line import/no-named-as-default
|
||||||
import Form from '../themes/carbon';
|
import Form from '../themes/carbon';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
import ErrorContext from '../contexts/ErrorContext';
|
||||||
|
@ -83,12 +83,21 @@ export default function BaseInputTemplate<
|
|||||||
labelToUse = schema.title;
|
labelToUse = schema.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let invalid = false;
|
||||||
|
let errorMessageForField = null;
|
||||||
|
if (rawErrors && rawErrors.length > 0) {
|
||||||
|
invalid = true;
|
||||||
|
errorMessageForField = `${labelToUse} ${rawErrors[0]}`;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TextInput
|
<TextInput
|
||||||
id={id}
|
id={id}
|
||||||
name={id}
|
name={id}
|
||||||
labelText={labelToUse}
|
labelText={labelToUse}
|
||||||
|
invalid={invalid}
|
||||||
|
invalidText={errorMessageForField}
|
||||||
autoFocus={autofocus}
|
autoFocus={autofocus}
|
||||||
disabled={disabled || readonly}
|
disabled={disabled || readonly}
|
||||||
value={value || value === 0 ? value : ''}
|
value={value || value === 0 ? value : ''}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user