Skip to content

Commit

Permalink
Fixed SHIBUI-1960
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 11, 2021
1 parent 86b1f78 commit 8a50af8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
2 changes: 2 additions & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ message.name-must-be-unique=Name must be unique.
message.uri-valid-format=URI must be valid format.
message.id-unique=ID must be unique.
message.array-items-must-be-unique=Items in list must be unique.
message.valid-duration=Must be a valid duration.
message.required=Missing required property.

message.org-name-required=Organization Name is required.
message.org-displayName-required=Organization Name is required.
Expand Down
25 changes: 25 additions & 0 deletions ui/src/app/metadata/domain/transform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const invisErrors = ['const', 'oneOf'];

export const transformErrors = (errors) => {

let list = [
...errors.filter(e => invisErrors.indexOf(e.name) === -1)
].map(e => {
if (e.name === 'pattern') {
if (e.property.includes('email')) {
e.message = 'message.valid-email';
} else {
e.message = 'message.valid-duration';
}
}

if (e.name === 'type') {
if (e.message === 'should be string') {
e.message = 'message.required'
}
}
return e;
});

return list;
}
6 changes: 1 addition & 5 deletions ui/src/app/metadata/editor/MetadataEditorForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { templates } from '../../form/component';
import { useUiSchema } from '../hooks/schema';
import Alert from 'react-bootstrap/Alert';

const invisErrors = ['const', 'oneOf']
import { transformErrors } from '../domain/transform';

function ErrorListTemplate () {
return (<></>);
Expand All @@ -26,10 +26,6 @@ export function MetadataEditorForm({ metadata, definition, schema, current, onCh

const onSubmit = () => {};

const transformErrors = (errors) => {
return errors.filter(e => invisErrors.indexOf(e.name) === -1);
}

const onFormChange = (form) => {
onChange(definition.bindings ? { ...form, formData: definition.bindings(data, form.formData) }: form);
};
Expand Down
15 changes: 1 addition & 14 deletions ui/src/app/metadata/wizard/MetadataWizardForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fields, widgets } from '../../form/component';
import { templates } from '../../form/component';
import { useUiSchema } from '../hooks/schema';

const invisErrors = ['const', 'oneOf']
import { transformErrors } from '../domain/transform';

function ErrorListTemplate () {
return (<></>);
Expand All @@ -22,19 +22,6 @@ export function MetadataWizardForm ({ metadata, definition, schema, current, onC

const onSubmit = () => {};

const transformErrors = (errors) => {
let list = [
...errors.filter(e => invisErrors.indexOf(e.name) === -1)
].map(e => {
if (e.name === 'pattern' && e.property.includes('email')) {
e.message = 'message.valid-email';
}
return e;
});

return list;
}

const onFormChange = (form) => {
onChange(definition.bindings ? { ...form, formData: definition.bindings(data, form.formData) } : form);
};
Expand Down

0 comments on commit 8a50af8

Please sign in to comment.