juzhiyuan commented on a change in pull request #1725:
URL: https://github.com/apache/apisix-dashboard/pull/1725#discussion_r613070726



##########
File path: web/src/components/Plugin/UI/proxy-mirror.tsx
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React from 'react';
+import type { FormInstance } from 'antd/es/form';
+import { Form, Input } from 'antd';
+import { useIntl } from 'umi';
+
+type Props = {
+  form: FormInstance;
+};
+
+const FORM_ITEM_LAYOUT = {
+  labelCol: {
+    span: 4,
+  },
+  wrapperCol: {
+    span: 10
+  },
+};
+
+const ProxyMirror: React.FC<Props> = ({ form }) => {
+  const { formatMessage } = useIntl();
+
+  return (
+    <Form
+      form={form}
+      {...FORM_ITEM_LAYOUT}
+    >
+      <Form.Item
+        label="host"
+        name="host"
+        extra={formatMessage({ id: 
'component.pluginForm.proxy-mirror.host.extra' })}
+        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'),
+            message: formatMessage({ id: 
'component.pluginForm.proxy-mirror.host.ruletip' }),
+          }
+        ]}
+      >
+        <Input />

Review comment:
       Does this need `disable` property? When we edit a Route & in the preview 
page, all properties should be readonly.

##########
File path: web/src/components/Plugin/UI/proxy-mirror.tsx
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React from 'react';
+import type { FormInstance } from 'antd/es/form';
+import { Form, Input } from 'antd';
+import { useIntl } from 'umi';
+
+type Props = {
+  form: FormInstance;
+};
+
+const FORM_ITEM_LAYOUT = {
+  labelCol: {
+    span: 4,
+  },
+  wrapperCol: {
+    span: 10
+  },
+};
+
+const ProxyMirror: React.FC<Props> = ({ form }) => {
+  const { formatMessage } = useIntl();
+
+  return (
+    <Form
+      form={form}
+      {...FORM_ITEM_LAYOUT}
+    >
+      <Form.Item
+        label="host"
+        name="host"
+        extra={formatMessage({ id: 
'component.pluginForm.proxy-mirror.host.extra' })}

Review comment:
       Because we have `tooltip`, so we don't need this `extra`.

##########
File path: web/src/components/Plugin/locales/en-US.ts
##########
@@ -22,6 +22,11 @@ export default {
   'component.plugin.pluginTemplate.tip1': '1. When a route already have 
plugins field configured, the plugins in the plugin template will be merged 
into it.',
   'component.plugin.pluginTemplate.tip2': '2. The same plugin in the plugin 
template will override one in the plugins',
 
+  // proxy-mirror
+  'component.pluginForm.proxy-mirror.host.tooltip': 'Specify a mirror service 
address, e.g. http://127.0.0.1:9797 (address needs to contain schema: http or 
https, not URI part)',

Review comment:
       ```suggestion
     'component.pluginForm.proxy-mirror.host.tooltip': 'Mirror service address. 
e.g. http://127.0.0.1:9797 (address needs to start with http or https, no URI 
part)',
   ```

##########
File path: web/src/components/Plugin/locales/zh-CN.ts
##########
@@ -22,6 +22,11 @@ export default {
   'component.plugin.pluginTemplate.tip1': '1. 若路由已配置插件,则插件模板数据将与已配置的插件数据合并。',
   'component.plugin.pluginTemplate.tip2': '2. 插件模板相同的插件会覆盖掉原有的插件。',
 
+  // proxy-mirror
+  'component.pluginForm.proxy-mirror.host.tooltip': 
'指定镜像服务地址,例如:http://127.0.0.1:9797(地址中需要包含 schema :http或https,不能包含 URI 部分)',

Review comment:
       When users input an invalid URL, we could popup the error. We don't need 
this long text actually 😂 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to