Skip to content

Commit

Permalink
Merge branch 'bugfix/field-errors' into feature/SHIBUI-1926
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 18, 2021
2 parents e1472c2 + 23a1c6e commit d5971ec
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/form/component/fields/FilterTargetField.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const FilterTargetField = ({

/*eslint-disable react-hooks/exhaustive-deps*/
React.useEffect(() => {
if (term && term.length >= 4) {
if (term?.length >= 4) {
searchIds(term);
}
}, [term]);
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/form/component/templates/FieldTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export function FieldTemplate ({
{children}
</div>
<div>
{rawHelp && rawErrors.length < 1 && (
<Form.Text className={rawErrors.length > 0 ? "text-danger" : "text-muted"} id={id}>
{rawHelp && rawErrors?.length < 1 && (
<Form.Text className={rawErrors?.length > 0 ? "text-danger" : "text-muted"} id={id}>
<Translate value={rawHelp} />
</Form.Text>
)}
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/form/component/widgets/OptionWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const OptionWidget = ({

return (
<Form.Group className="mb-0">
<Form.Label className={`${(touched && rawErrors.length > 0) ? "text-danger" : ""}`}>
<Form.Label className={`${(touched && rawErrors?.length > 0) ? "text-danger" : ""}`}>
<span>
<Translate value={label || schema.title} />
{(label || schema.title) && required ? <FontAwesomeIcon icon={faAsterisk} className="text-danger ml-2" size="sm" /> : null}
Expand All @@ -104,7 +104,7 @@ const OptionWidget = ({
onChange={ _onChange }
allowNew={true}
multiple={false}
className={`toggle-typeahead ${rawErrors.length > 0 ? "is-invalid" : ""}`}
className={`toggle-typeahead ${rawErrors?.length > 0 ? "is-invalid" : ""}`}
options={opts}
placeholder={uiSchema['ui:placeholder'] ? translator(uiSchema['ui:placeholder'] ): ''}
disabled={disabled || readonly}
Expand All @@ -122,7 +122,7 @@ const OptionWidget = ({
<ToggleButton isOpen={isMenuShown} onClick={e => toggleMenu()} disabled={disabled || readonly} />
)}
</Typeahead>
{rawErrors.length > 0 && touched && (
{rawErrors?.length > 0 && touched && (
<ListGroup as="ul">
{rawErrors.map((error, i) => {
return (
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/form/component/widgets/SelectWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const SelectWidget = ({

return (
<Form.Group>
<Form.Label className={`${touched && rawErrors.length > 0 ? "text-danger" : ""}`}>
<Form.Label className={`${touched && rawErrors?.length > 0 ? "text-danger" : ""}`}>
<span>
<Translate value={label || schema.title} />
{(label || schema.title) && required ? <FontAwesomeIcon icon={faAsterisk} className="ml-2 text-danger" size="sm" /> : null}
Expand All @@ -103,7 +103,7 @@ const SelectWidget = ({
disabled={disabled}
readOnly={readonly}
autoFocus={autofocus}
className={touched && rawErrors.length > 0 ? "is-invalid" : ""}
className={touched && rawErrors?.length > 0 ? "is-invalid" : ""}
onBlur={
onBlur &&
((event) => {
Expand Down Expand Up @@ -132,7 +132,7 @@ const SelectWidget = ({
</option>
)}
</Form.Control>
{rawErrors.length > 0 && touched && (
{rawErrors?.length > 0 && touched && (
<ListGroup as="ul">
{rawErrors.map((error, i) => {
return (
Expand Down
8 changes: 4 additions & 4 deletions ui/src/app/form/component/widgets/TextWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ const TextWidget = ({
_onBlur(evt);
};

// const classNames = [rawErrors.length > 0 ? "is-invalid" : "", type === 'file' ? 'custom-file-label': ""]
// const classNames = [rawErrors?.length > 0 ? "is-invalid" : "", type === 'file' ? 'custom-file-label': ""]
return (
<Form.Group className="mb-0">
<Form.Label className={`${rawErrors.length > 0 && touched ? "text-danger" : ""}`}>
<Form.Label className={`${rawErrors?.length > 0 && touched ? "text-danger" : ""}`}>
<span>
<Translate value={label || schema.title} />
{(label || schema.title) && required ?
Expand All @@ -56,7 +56,7 @@ const TextWidget = ({
required={required}
disabled={disabled}
readOnly={readonly}
className={rawErrors.length > 0 && touched ? "is-invalid" : ""}
className={rawErrors?.length > 0 && touched ? "is-invalid" : ""}
list={schema.examples ? `examples_${id}` : undefined}
type={inputType}
value={value || value === 0 ? value : ""}
Expand All @@ -73,7 +73,7 @@ const TextWidget = ({
})}
</datalist>
) : null}
{rawErrors.length > 0 && touched && (
{rawErrors?.length > 0 && touched && (
<ListGroup as="ul">
{rawErrors.map((error, i) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/form/component/widgets/TextareaWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const TextareaWidget = ({

return (
<>
<Form.Label className={`${touched && rawErrors.length > 0 ? "text-danger" : ""}`}>
<Form.Label className={`${touched && rawErrors?.length > 0 ? "text-danger" : ""}`}>
<span>
<Translate value={label || schema.title} />
{(label || schema.title) && required ? <FontAwesomeIcon icon={faAsterisk} className="ml-2 text-danger" size="sm" /> : null}
Expand All @@ -69,7 +69,7 @@ const TextareaWidget = ({
onFocus={_onFocus}
/>
</InputGroup>
{rawErrors.length > 0 && touched && (
{rawErrors?.length > 0 && touched && (
<ListGroup as="ul">
{rawErrors.map((error, i) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/form/component/widgets/UpDownWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const UpDownWidget = ({
onBlur={onCustomBlur}
onFocus={_onFocus}
/>
{rawErrors.length > 0 && touched && (
{rawErrors?.length > 0 && touched && (
<ListGroup as="ul">
{rawErrors.map((error, i) => {
return (
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/metadata/domain/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ export const MetadataProviderEditorTypes = [

export const FilterableProviders = [
FileBackedHttpMetadataProviderEditor.type,
DynamicHttpMetadataProviderEditor.type,
LocalDynamicMetadataProviderEditor.type
DynamicHttpMetadataProviderEditor.type
];
51 changes: 26 additions & 25 deletions ui/src/app/metadata/view/MetadataOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { MetadataFilters } from '../domain/filter/component/MetadataFilters';
import { MetadataFilterConfigurationList } from '../domain/filter/component/MetadataFilterConfigurationList';
import { MetadataFilterTypes } from '../domain/filter';
import { useMetadataSchema } from '../hooks/schema';
import { FilterableProviders } from '../domain/provider';

export function MetadataOptions () {

Expand Down Expand Up @@ -46,6 +47,8 @@ export function MetadataOptions () {
history.push(`/metadata/${type}/${id}/edit/${section}`);
}

const canFilter = FilterableProviders.indexOf(definition.type) > -1;

return (
<DeleteSourceConfirmation>
{(onDeleteSource) =>
Expand Down Expand Up @@ -73,7 +76,7 @@ export function MetadataOptions () {
<FontAwesomeIcon icon={ faHistory } />&nbsp;
<Translate value="action.version-history">Version History</Translate>
</Link>
{type === 'provider' &&
{type === 'provider' && canFilter &&
<Button variant="link" onClick={() => onScrollTo('filters')}>
<FontAwesomeIcon icon={faArrowDown} />&nbsp;
<Translate value="label.filters">Filters</Translate>
Expand All @@ -83,31 +86,29 @@ export function MetadataOptions () {
<MetadataViewToggle />
</div>
<MetadataConfiguration configuration={ configuration } onEdit={ (section) => edit(section) } />
<div id="filters">
{type === 'provider' &&
<>
<div className="numbered-header d-flex justify-content-start bg-light align-items-center">
<h2 className="title h4 m-0 ml-2 flex-grow-1">
<span className="text"><Translate value="label.filters">Filters</Translate></span>
</h2>
<div className="actions px-2">
<Link className="btn btn-link edit-link change-view"
to={`/metadata/provider/${id}/filter/new`}>
<FontAwesomeIcon icon={faPlus} />&nbsp;
<Translate value="action.add-filter">Add Filter</Translate>
</Link>
</div>
{type === 'provider' && canFilter &&
<div id="filters">
<div className="numbered-header d-flex justify-content-start bg-light align-items-center">
<h2 className="title h4 m-0 ml-2 flex-grow-1">
<span className="text"><Translate value="label.filters">Filters</Translate></span>
</h2>
<div className="actions px-2">
<Link className="btn btn-link edit-link change-view"
to={`/metadata/provider/${id}/filter/new`}>
<FontAwesomeIcon icon={faPlus} />&nbsp;
<Translate value="action.add-filter">Add Filter</Translate>
</Link>
</div>
<MetadataFilters providerId={metadata.resourceId} types={MetadataFilterTypes}>
{(filters, onUpdate, onDelete, loading) =>
<MetadataFilterConfigurationList
provider={metadata}
filters={filters}
onDelete={onDelete} />}
</MetadataFilters>
</>
}
</div>
</div>
<MetadataFilters providerId={metadata.resourceId} types={MetadataFilterTypes}>
{(filters, onUpdate, onDelete, loading) =>
<MetadataFilterConfigurationList
provider={metadata}
filters={filters}
onDelete={onDelete} />}
</MetadataFilters>
</div>
}
<Button variant="link" onClick={ () => onScrollTo('header', -60) }>
<FontAwesomeIcon icon={faArrowUp} className="sr-hidden" />&nbsp;
<Translate value="action.back-to-top">Back to Top</Translate>
Expand Down

0 comments on commit d5971ec

Please sign in to comment.