This is an automated email from the ASF dual-hosted git repository.
sunyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 930e47a feat(plugin): allowing limit-conn to dynamically adapt to
the BE rules (#1990)
930e47a is described below
commit 930e47a1178933b3ed50b7c896b59a23f07808b6
Author: wmdmomo <[email protected]>
AuthorDate: Tue Aug 10 08:14:32 2021 +0800
feat(plugin): allowing limit-conn to dynamically adapt to the BE rules
(#1990)
---
web/src/components/Plugin/UI/limit-conn.tsx | 28 ++++++++++------------------
web/src/components/Plugin/UI/plugin.tsx | 2 +-
2 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/web/src/components/Plugin/UI/limit-conn.tsx
b/web/src/components/Plugin/UI/limit-conn.tsx
index 558ed39..6e358df 100644
--- a/web/src/components/Plugin/UI/limit-conn.tsx
+++ b/web/src/components/Plugin/UI/limit-conn.tsx
@@ -21,6 +21,7 @@ import { useIntl } from 'umi';
type Props = {
form: FormInstance;
+ schema: Record<string, any> | undefined;
ref?: any;
};
@@ -33,8 +34,9 @@ const FORM_ITEM_LAYOUT = {
},
};
-const LimitConn: React.FC<Props> = ({ form }) => {
+const LimitConn: React.FC<Props> = ({ form, schema }) => {
const { formatMessage } = useIntl();
+ const propertires = schema?.properties
return (
<Form form={form} {...FORM_ITEM_LAYOUT}>
<Form.Item
@@ -43,7 +45,7 @@ const LimitConn: React.FC<Props> = ({ form }) => {
name="conn"
tooltip={formatMessage({ id:
'component.pluginForm.limit-conn.conn.tooltip' })}
>
- <InputNumber min={1} required />
+ <InputNumber min={propertires.conn.exclusiveMinimum} required />
</Form.Item>
<Form.Item
label="burst"
@@ -51,7 +53,7 @@ const LimitConn: React.FC<Props> = ({ form }) => {
name="burst"
tooltip={formatMessage({ id:
'component.pluginForm.limit-conn.burst.tooltip' })}
>
- <InputNumber min={0} required />
+ <InputNumber min={propertires.burst.minimum} required />
</Form.Item>
<Form.Item
label="default_conn_delay"
@@ -61,7 +63,7 @@ const LimitConn: React.FC<Props> = ({ form }) => {
id: 'component.pluginForm.limit-conn.default_conn_delay.tooltip',
})}
>
- <InputNumber step={0.001} min={0.001} required />
+ <InputNumber step={0.001}
min={propertires.default_conn_delay.exclusiveMinimum} required />
</Form.Item>
<Form.Item
@@ -71,18 +73,8 @@ const LimitConn: React.FC<Props> = ({ form }) => {
tooltip={formatMessage({ id:
'component.pluginForm.limit-conn.key.tooltip' })}
>
<Select>
- {[
- 'remote_addr',
- 'server_addr',
- 'http_x_real_ip',
- 'http_x_forwarded_for',
- 'consumer_name',
- ].map((item) => {
- return (
- <Select.Option value={item} key={item}>
- {item}
- </Select.Option>
- );
+ {propertires.key.enum.map((item: string) => {
+ return <Select.Option value={item}
key={item}>{item}</Select.Option>
})}
</Select>
</Form.Item>
@@ -90,10 +82,10 @@ const LimitConn: React.FC<Props> = ({ form }) => {
<Form.Item
label="rejected_code"
name="rejected_code"
- initialValue={503}
+ initialValue={propertires.rejected_code.default}
tooltip={formatMessage({ id:
'component.pluginForm.limit-conn.rejected_code.tooltip' })}
>
- <InputNumber min={200} max={599} required />
+ <InputNumber min={propertires.rejected_code.minimum}
max={propertires.rejected_code.maximum} required />
</Form.Item>
</Form>
);
diff --git a/web/src/components/Plugin/UI/plugin.tsx
b/web/src/components/Plugin/UI/plugin.tsx
index d0ea0de..088b50d 100644
--- a/web/src/components/Plugin/UI/plugin.tsx
+++ b/web/src/components/Plugin/UI/plugin.tsx
@@ -72,7 +72,7 @@ export const PluginForm: React.FC<Props> = ({ name, schema,
renderForm, form })
case 'proxy-mirror':
return <ProxyMirror form={form} />;
case 'limit-conn':
- return <LimitConn form={form} />;
+ return <LimitConn form={form} schema={schema}/>
case 'referer-restriction':
return <RefererRestriction form={form} />;
default: