From e90daa7ec766b5aa2f8fa1ed6e8b2f9d5a49f6a3 Mon Sep 17 00:00:00 2001 From: wmdmomo Date: Wed, 21 Jul 2021 22:54:47 +0800 Subject: [PATCH] feat(plugin): fix UI limit-conn --- web/src/components/Plugin/PluginDetail.tsx | 3 ++- web/src/components/Plugin/UI/limit-conn.tsx | 16 +++++++++------- web/src/components/Plugin/UI/plugin.tsx | 5 +++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/web/src/components/Plugin/PluginDetail.tsx b/web/src/components/Plugin/PluginDetail.tsx index 41480125e5..882a910c7a 100644 --- a/web/src/components/Plugin/PluginDetail.tsx +++ b/web/src/components/Plugin/PluginDetail.tsx @@ -107,6 +107,7 @@ const PluginDetail: React.FC = ({ const [UIForm] = Form.useForm(); const data = initialData[name] || {}; const pluginType = pluginList.find((item) => item.name === name)?.originType; + const pluginSchema = pluginList.find((item) => item.name === name)?.schema; const [content, setContent] = useState(JSON.stringify(data, null, 2)); const [monacoMode, setMonacoMode] = useState(monacoModeList.JSON); const modeOptions: { label: string; value: string }[] = [ @@ -411,7 +412,7 @@ const PluginDetail: React.FC = ({ ]} /> - {Boolean(monacoMode === monacoModeList.UIForm) && } + {Boolean(monacoMode === monacoModeList.UIForm) && }
| undefined; ref?: any; }; @@ -33,8 +34,9 @@ const FORM_ITEM_LAYOUT = { }, }; -const LimitConn: React.FC = ({ form }) => { +const LimitConn: React.FC = ({ form, schema }) => { const { formatMessage } = useIntl(); + const propertires = schema?.properties return (
= ({ form }) => { name="conn" tooltip={formatMessage({ id: 'component.pluginForm.limit-conn.conn.tooltip' })} > - + = ({ form }) => { name="burst" tooltip={formatMessage({ id: 'component.pluginForm.limit-conn.burst.tooltip' })} > - + = ({ form }) => { name="default_conn_delay" tooltip={formatMessage({ id: 'component.pluginForm.limit-conn.default_conn_delay.tooltip' })} > - + = ({ form }) => { tooltip={formatMessage({ id: 'component.pluginForm.limit-conn.key.tooltip' })} > @@ -81,10 +83,10 @@ const LimitConn: React.FC = ({ form }) => { - + ); diff --git a/web/src/components/Plugin/UI/plugin.tsx b/web/src/components/Plugin/UI/plugin.tsx index 0d1a2b67b2..a28c42b7f2 100644 --- a/web/src/components/Plugin/UI/plugin.tsx +++ b/web/src/components/Plugin/UI/plugin.tsx @@ -30,13 +30,14 @@ import Cors from './cors'; type Props = { name: string, + schema: Record | undefined, form: FormInstance, renderForm: boolean } export const PLUGIN_UI_LIST = ['api-breaker', 'basic-auth', 'cors', 'limit-req', 'limit-conn', 'proxy-mirror', 'referer-restriction', 'limit-count']; -export const PluginForm: React.FC = ({ name, renderForm, form }) => { +export const PluginForm: React.FC = ({ name, schema, renderForm, form }) => { const { formatMessage } = useIntl(); @@ -56,7 +57,7 @@ export const PluginForm: React.FC = ({ name, renderForm, form }) => { case 'proxy-mirror': return case 'limit-conn': - return + return case 'referer-restriction': return default: