Skip to content

Commit

Permalink
feat: add UIFrom validate
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteSun committed Apr 8, 2021
1 parent 59dba3e commit b9c89ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions web/src/components/Plugin/PluginDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import addFormats from 'ajv-formats';

import { fetchSchema } from './service';
import { json2yaml, yaml2json } from '../../helpers';
import { PluginForm, PLUGIN_UI_LIST } from './UI'
import { PluginForm, PLUGIN_UI_LIST } from './UI';

type Props = {
name: string;
Expand Down Expand Up @@ -290,7 +290,13 @@ const PluginDetail: React.FC<Props> = ({
} else if (codeMirrorMode === 'YAML') {
editorData = yaml2json(ref.current?.editor.getValue(), false).data;
} else {
editorData = UIForm.getFieldsValue();
UIForm.validateFields().then(value => {
editorData = value;
validateData(name, editorData).then((value) => {
onChange({ formData: form.getFieldsValue(), codemirrorData: value });
});
});
return;
}

validateData(name, editorData).then((value) => {
Expand Down
10 changes: 10 additions & 0 deletions web/src/components/Plugin/UI/basic-auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@ const BasicAuth: React.FC<Props> = ({ form }) => {
label="username"
required
name="username"
rules={[
{
required: true,
}]
}
>
<Input></Input>
</Form.Item>
<Form.Item
label="password"
name="password"
required
rules={[
{
required: true,
}]
}
>
<Input></Input>
</Form.Item>
Expand Down

0 comments on commit b9c89ae

Please sign in to comment.