You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by li...@apache.org on 2021/08/20 08:40:00 UTC

[apisix-dashboard] branch master updated: feat(plugin): allowing proxy-mirror to dynamically adapt to the BE rules (#2000)

This is an automated email from the ASF dual-hosted git repository.

liuxiran 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 0ee6656  feat(plugin): allowing proxy-mirror to dynamically adapt to the BE rules (#2000)
0ee6656 is described below

commit 0ee6656cdb70b9972d13994fc3a620bac17ef45d
Author: wmdmomo <43...@users.noreply.github.com>
AuthorDate: Fri Aug 20 16:39:53 2021 +0800

    feat(plugin): allowing proxy-mirror to dynamically adapt to the BE rules (#2000)
---
 web/src/components/Plugin/UI/plugin.tsx       | 2 +-
 web/src/components/Plugin/UI/proxy-mirror.tsx | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/web/src/components/Plugin/UI/plugin.tsx b/web/src/components/Plugin/UI/plugin.tsx
index 13b6665..dc1979f 100644
--- a/web/src/components/Plugin/UI/plugin.tsx
+++ b/web/src/components/Plugin/UI/plugin.tsx
@@ -70,7 +70,7 @@ export const PluginForm: React.FC<Props> = ({ name, schema, renderForm, form })
     case 'limit-req':
       return <LimitReq form={form} schema={schema} />;
     case 'proxy-mirror':
-      return <ProxyMirror form={form} />;
+      return <ProxyMirror form={form} schema={schema} />
     case 'limit-conn':
       return <LimitConn form={form} schema={schema} />;
     case 'referer-restriction':
diff --git a/web/src/components/Plugin/UI/proxy-mirror.tsx b/web/src/components/Plugin/UI/proxy-mirror.tsx
index e1e9fb0..a1285bd 100644
--- a/web/src/components/Plugin/UI/proxy-mirror.tsx
+++ b/web/src/components/Plugin/UI/proxy-mirror.tsx
@@ -21,6 +21,7 @@ import { useIntl } from 'umi';
 
 type Props = {
   form: FormInstance;
+  schema: Record<string, any> | undefined;
 };
 
 const FORM_ITEM_LAYOUT = {
@@ -32,8 +33,9 @@ const FORM_ITEM_LAYOUT = {
   },
 };
 
-const ProxyMirror: React.FC<Props> = ({ form }) => {
+const ProxyMirror: React.FC<Props> = ({ form, schema }) => {
   const { formatMessage } = useIntl();
+  const properties = schema?.properties;
 
   return (
     <Form form={form} {...FORM_ITEM_LAYOUT}>
@@ -44,10 +46,7 @@ const ProxyMirror: React.FC<Props> = ({ form }) => {
         tooltip={formatMessage({ id: 'component.pluginForm.proxy-mirror.host.tooltip' })}
         rules={[
           {
-            pattern: new RegExp(
-              /^http(s)?:\/\/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:[0-9]{1,5})?$/,
-              'g',
-            ),
+            pattern: new RegExp(`${properties.host.pattern}`, 'g'),
             message: formatMessage({ id: 'component.pluginForm.proxy-mirror.host.ruletip' }),
           },
         ]}