From ff100801c29929b7aff9333cc37b6ca8a7c5861f Mon Sep 17 00:00:00 2001 From: wmdmomo Date: Sat, 24 Jul 2021 13:32:40 +0800 Subject: [PATCH 1/2] feat(plugin): add basic --- web/src/components/Plugin/PluginDetail.tsx | 3 ++- web/src/components/Plugin/UI/plugin.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 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, 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(); From 102c929a170cdf279767b46b62cbd97cc98ffa16 Mon Sep 17 00:00:00 2001 From: wmdmomo Date: Sat, 24 Jul 2021 13:50:20 +0800 Subject: [PATCH 2/2] feat(plugin): fix UI limit-req --- web/src/components/Plugin/UI/limit-req.tsx | 14 ++++++++------ web/src/components/Plugin/UI/plugin.tsx | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/web/src/components/Plugin/UI/limit-req.tsx b/web/src/components/Plugin/UI/limit-req.tsx index 58b3cb2a0f..7f106a4554 100644 --- a/web/src/components/Plugin/UI/limit-req.tsx +++ b/web/src/components/Plugin/UI/limit-req.tsx @@ -21,6 +21,7 @@ import { useIntl } from 'umi'; type Props = { form: FormInstance; + schema: Record | undefined; ref?: any; }; @@ -33,8 +34,9 @@ export const FORM_ITEM_LAYOUT = { }, }; -const LimitReq: React.FC = ({ form }) => { +const LimitReq: React.FC = ({ form, schema }) => { const { formatMessage } = useIntl(); + const propertires = schema?.properties; return (
= ({ form }) => { tooltip={formatMessage({ id: 'component.pluginForm.limit-req.rate.tooltip' })} validateTrigger={['onChange', 'onBlur', 'onClick']} > - + = ({ form }) => { tooltip={formatMessage({ id: 'component.pluginForm.limit-req.burst.tooltip' })} validateTrigger={['onChange', 'onBlur', 'onClick']} > - + = ({ form }) => { validateTrigger={['onChange', 'onBlur', 'onClick']} > @@ -83,10 +85,10 @@ const LimitReq: React.FC = ({ form }) => { - + ); diff --git a/web/src/components/Plugin/UI/plugin.tsx b/web/src/components/Plugin/UI/plugin.tsx index 185d450599..d937e2e025 100644 --- a/web/src/components/Plugin/UI/plugin.tsx +++ b/web/src/components/Plugin/UI/plugin.tsx @@ -53,7 +53,7 @@ export const PluginForm: React.FC = ({ name, schema, renderForm, form }) case 'cors': return case 'limit-req': - return + return case 'proxy-mirror': return case 'limit-conn':