Skip to content

Commit

Permalink
Fixed cosmetic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jul 18, 2022
1 parent cc0d388 commit c46437c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 10 additions & 5 deletions ui/src/app/form/component/fields/FilterTargetField.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import useFetch from 'use-http';
import queryString from 'query-string';
import API_BASE_PATH from '../../../App.constant';
import isNil from 'lodash/isNil';
import capitalize from 'lodash/capitalize';
import Editor from 'react-simple-code-editor';
// import { highlight, languages } from 'prismjs/components/prism-core';
// import 'prismjs/components/prism-clike';
Expand Down Expand Up @@ -68,6 +69,9 @@ const FilterTargetField = ({
const [touched, setTouched] = React.useState(false);
const [ids, setSearchIds] = React.useState([]);

const [errors, setErrors] = React.useState();
const translator = useTranslator();

const { get, response } = useFetch(`${API_BASE_PATH}/EntityIds/search`, {
cachePolicy: 'no-cache'
});
Expand Down Expand Up @@ -128,6 +132,10 @@ const FilterTargetField = ({
setSelectedType(option);
};

React.useEffect(() => {
setErrors(errorSchema?.value?.__errors?.map((error, eIdx) => capitalize(translator(error))).join(', '));
}, [errorSchema]);

return (
<fieldset>
<legend><Translate value={label || schema.title} /></legend>
Expand Down Expand Up @@ -231,11 +239,8 @@ const FilterTargetField = ({
onChange={ ({target: { value }}) => handleTextChange(value) } />
{errorSchema?.value?.__errors ?
<small className="form-text text-danger">
{errorSchema?.value?.__errors?.map((error, eIdx) =>
<React.Fragment key={eIdx}>
<Translate value={error}>{error}</Translate>
</React.Fragment>
)}
{errors}

</small> :
<small id="regex-help" className="form-text text-secondary">
<Translate value="message.required-for-regex">Required for Regex</Translate>
Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/form/component/widgets/TextWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Form from "react-bootstrap/Form";

import Translate from "../../../i18n/components/translate";
import { InfoIcon } from "../InfoIcon";
import { useTranslator } from "../../../i18n/hooks";

const TextWidget = ({
id,
Expand Down Expand Up @@ -43,6 +44,8 @@ const TextWidget = ({
onChange(fieldValue);
}, [fieldValue, onChange]);

const translator = useTranslator();

// const classNames = [rawErrors?.length > 0 ? "is-invalid" : "", type === 'file' ? 'custom-file-label': ""]
return (
<Form.Group>
Expand All @@ -57,7 +60,7 @@ const TextWidget = ({
<Form.Control
id={id}
name=""
placeholder={placeholder}
placeholder={translator(placeholder)}
autoFocus={autofocus}
required={required}
disabled={disabled}
Expand Down

0 comments on commit c46437c

Please sign in to comment.