Skip to content

Commit

Permalink
feat(plugin): fix UI limit-req
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdmomo committed Jul 24, 2021
1 parent ff10080 commit 102c929
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions web/src/components/Plugin/UI/limit-req.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useIntl } from 'umi';

type Props = {
form: FormInstance;
schema: Record<string, any> | undefined;
ref?: any;
};

Expand All @@ -33,8 +34,9 @@ export const FORM_ITEM_LAYOUT = {
},
};

const LimitReq: React.FC<Props> = ({ form }) => {
const LimitReq: React.FC<Props> = ({ form, schema }) => {
const { formatMessage } = useIntl();
const propertires = schema?.properties;
return (
<Form
form={form}
Expand All @@ -50,7 +52,7 @@ const LimitReq: React.FC<Props> = ({ form }) => {
tooltip={formatMessage({ id: 'component.pluginForm.limit-req.rate.tooltip' })}
validateTrigger={['onChange', 'onBlur', 'onClick']}
>
<InputNumber min={1} required />
<InputNumber min={propertires.rate.exclusiveMinimum} required />
</Form.Item>
<Form.Item
label="burst"
Expand All @@ -62,7 +64,7 @@ const LimitReq: React.FC<Props> = ({ form }) => {
tooltip={formatMessage({ id: 'component.pluginForm.limit-req.burst.tooltip' })}
validateTrigger={['onChange', 'onBlur', 'onClick']}
>
<InputNumber min={0} required />
<InputNumber min={propertires.burst.minimum} required />
</Form.Item>
<Form.Item
label="key"
Expand All @@ -75,18 +77,18 @@ const LimitReq: React.FC<Props> = ({ form }) => {
validateTrigger={['onChange', 'onBlur', 'onClick']}
>
<Select>
{["remote_addr", "server_addr", "http_x_real_ip", "http_x_forwarded_for", "consumer_name"].map(item => {
{propertires.key.enum.map((item: string) => {
return <Select.Option value={item} key={item}>{item}</Select.Option>
})}
</Select>
</Form.Item>
<Form.Item
label="rejected_code"
name="rejected_code"
initialValue={503}
initialValue={propertires.rejected_code.default}
tooltip={formatMessage({ id: 'component.pluginForm.limit-req.rejected_code.tooltip' })}
>
<InputNumber min={200} max={599} />
<InputNumber min={propertires.rejected_code.minimum} max={propertires.rejected_code.maximum} />
</Form.Item>
</Form>
);
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Plugin/UI/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const PluginForm: React.FC<Props> = ({ name, schema, renderForm, form })
case 'cors':
return <Cors form={form} />
case 'limit-req':
return <LimitReq form={form} />
return <LimitReq form={form} schema={schema} />
case 'proxy-mirror':
return <ProxyMirror form={form} />
case 'limit-conn':
Expand Down

0 comments on commit 102c929

Please sign in to comment.