LiteSun commented on a change in pull request #1764:
URL: https://github.com/apache/apisix-dashboard/pull/1764#discussion_r613049577



##########
File path: web/cypress/fixtures/selector.json
##########
@@ -85,7 +74,6 @@
   "pageTwoActived": ".ant-pagination-item-2.ant-pagination-item-active",
   "selectDropdown": ".ant-select-dropdown",
   "codeMirrorMode": "[data-cy='code-mirror-mode']",
-  "selectJSON":".ant-select-dropdown [label=JSON]",
-
+  "selectJSON": ".ant-select-dropdown [label=JSON]",
   "deleteAlert": ".ant-modal-body"
-}
+}

Review comment:
       new line please.

##########
File path: web/src/components/Upstream/UpstreamForm.tsx
##########
@@ -86,14 +87,18 @@ const UpstreamForm: React.FC<Props> = forwardRef(
         if (required) {
           requestAnimationFrame(() => {
             form.resetFields();
-            form.setFieldsValue(DEFAULT_UPSTREAM);
             setHiddenForm(false);
           });
         }
       } else {
         if (upstream_id) {
           requestAnimationFrame(() => {
-            form.setFieldsValue(list.find((item) => item.id === upstream_id));
+            const targetData = list.find((item) => item.id === upstream_id) as 
UpstreamComponent.ResponseData
+            if (targetData) {
+              
form.setFieldsValue(transformUpstreamDataFromRequest(targetData));
+            } else {
+              // TODO: 提示 upstream_id 找不到想要的数据

Review comment:
       remove Chinese comment.

##########
File path: web/src/components/Upstream/components/TLS.tsx
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 { Form, Row, Col, Select, FormInstance, Input } from 'antd'
+import { useIntl } from 'umi'
+
+type Props = {
+  form: FormInstance;
+  readonly?: boolean;
+}
+
+const TLSComponent: React.FC<Props> = ({ form, readonly }) => {
+  const { formatMessage } = useIntl()
+
+  return (
+    <React.Fragment>
+      <Form.Item
+        label={formatMessage({ id: 'component.upstream.fields.tls' })}
+        tooltip={formatMessage({ id: 'component.upstream.fields.tls.tooltip' 
})}
+        style={{ marginBottom: 0 }}
+      >
+        <Row>
+          <Col span={5}>
+            <Form.Item
+              name={["custom", "tls"]}
+              initialValue="disable"
+            >
+              <Select disabled={readonly}>
+                {
+                  ["disable", "enable"].map(item => (
+                    <Select.Option value={item} key={item}>
+                      {formatMessage({ id: `component.global.${item}` })}
+                    </Select.Option>
+                  ))
+                }
+              </Select>
+            </Form.Item>
+          </Col>
+        </Row>
+      </Form.Item>
+      <Form.Item
+        noStyle
+        shouldUpdate={(prev, next) => {
+          return prev.custom.tls !== next.custom.tls
+        }}
+      >
+        {
+          () => {
+            if (form.getFieldValue(["custom", "tls"]) === 'enable') {
+              return (
+                <React.Fragment>
+                  <Form.Item
+                    label={formatMessage({ id: 
'component.upstream.fields.tls.client_cert' })}
+                    name={["tls", "client_cert"]}
+                    required
+                    rules={[{ required: true, message: "" }, { max: 64 * 1024 
}, { min: 128 }]}
+                  >
+                    <Input.TextArea disabled={readonly} minLength={128} 
maxLength={64 * 1024} rows={5} placeholder="请输入客户端证书" />
+                  </Form.Item>
+                  <Form.Item
+                    label={formatMessage({ id: 
'component.upstream.fields.tls.client_key' })}
+                    name={["tls", "client_key"]}
+                    required
+                    rules={[{ required: true, message: "" }, { max: 64 * 1024 
}, { min: 128 }]}
+                  >
+                    <Input.TextArea disabled={readonly} minLength={128} 
maxLength={64 * 1024} rows={5} placeholder="请输入客户端私钥" />

Review comment:
       ditto

##########
File path: web/src/components/Upstream/components/TLS.tsx
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 { Form, Row, Col, Select, FormInstance, Input } from 'antd'
+import { useIntl } from 'umi'
+
+type Props = {
+  form: FormInstance;
+  readonly?: boolean;
+}
+
+const TLSComponent: React.FC<Props> = ({ form, readonly }) => {
+  const { formatMessage } = useIntl()
+
+  return (
+    <React.Fragment>
+      <Form.Item
+        label={formatMessage({ id: 'component.upstream.fields.tls' })}
+        tooltip={formatMessage({ id: 'component.upstream.fields.tls.tooltip' 
})}
+        style={{ marginBottom: 0 }}
+      >
+        <Row>
+          <Col span={5}>
+            <Form.Item
+              name={["custom", "tls"]}
+              initialValue="disable"
+            >
+              <Select disabled={readonly}>
+                {
+                  ["disable", "enable"].map(item => (
+                    <Select.Option value={item} key={item}>
+                      {formatMessage({ id: `component.global.${item}` })}
+                    </Select.Option>
+                  ))
+                }
+              </Select>
+            </Form.Item>
+          </Col>
+        </Row>
+      </Form.Item>
+      <Form.Item
+        noStyle
+        shouldUpdate={(prev, next) => {
+          return prev.custom.tls !== next.custom.tls
+        }}
+      >
+        {
+          () => {
+            if (form.getFieldValue(["custom", "tls"]) === 'enable') {
+              return (
+                <React.Fragment>
+                  <Form.Item
+                    label={formatMessage({ id: 
'component.upstream.fields.tls.client_cert' })}
+                    name={["tls", "client_cert"]}
+                    required
+                    rules={[{ required: true, message: "" }, { max: 64 * 1024 
}, { min: 128 }]}
+                  >
+                    <Input.TextArea disabled={readonly} minLength={128} 
maxLength={64 * 1024} rows={5} placeholder="请输入客户端证书" />

Review comment:
       ditto

##########
File path: web/src/components/Upstream/components/passive-check/Type.tsx
##########
@@ -15,43 +15,55 @@
  * limitations under the License.
  */
 import React from 'react'
-import { Form, Select } from 'antd'
+import { Form, Select, Row, Col } from 'antd'
+import { useIntl } from 'umi'
 
 type Props = {
   readonly?: boolean
 }
 
-const PassiveCheckTypeComponent: React.FC<Props> = ({ readonly }) => {
-  const options = [
-    {
-      label: "HTTP",
-      value: "http"
-    }, {
-      label: "HTTPs",
-      value: "https"
-    }, {
-      label: "TCP",
-      value: "tcp"
-    }
-  ]
+const options = [
+  {
+    label: "HTTP",
+    value: "http"
+  }, {
+    label: "HTTPs",
+    value: "https"
+  }, {
+    label: "TCP",
+    value: "tcp"
+  }
+]
+
+const ActiveCheckTypeComponent: React.FC<Props> = ({ readonly }) => {
+  const { formatMessage } = useIntl()
 
   return (
     <Form.Item
-      label="Type"
-      name={['checks', 'passive', 'type']}
-      rules={[{ required: true }]}
+      label={formatMessage({ id: 
'component.upstream.fields.checks.active.type' })}
+      style={{ marginBottom: 0 }}
+      tooltip={formatMessage({ id: 
'component.upstream.fields.checks.active.type.tooltip' })}
     >
-      <Select disabled={readonly}>
-        {options.map(item => {
-          return (
-            <Select.Option value={item.value} key={item.value}>
-              {item.label}
-            </Select.Option>
-          );
-        })}
-      </Select>
+      <Row>
+        <Col span={5}>
+          <Form.Item
+            name={['checks', 'passive', 'type']}
+            initialValue="http"
+          >
+            <Select disabled={readonly}>
+              {options.map(item => {
+                return (
+                  <Select.Option value={item.value} key={item.value}>
+                    {item.label}
+                  </Select.Option>
+                );
+              })}
+            </Select>
+          </Form.Item>
+        </Col>
+      </Row>
     </Form.Item>
   )
 }
 
-export default PassiveCheckTypeComponent
+export default ActiveCheckTypeComponent

Review comment:
       wrong name.




-- 
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