You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2020/06/03 10:10:53 UTC

[incubator-apisix-dashboard] branch next updated (fe91088 -> 996e04a)

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

juzhiyuan pushed a change to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git.


    from fe91088  feat: added API (#237)
     new 4cf0ce7  fix some actions
     new 996e04a  fix

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/components/PluginModal/index.tsx                |  2 ++
 .../Routes/components/Step1/MatchingRulesView.tsx   |  2 ++
 .../Routes/components/Step1/RequestConfigView.tsx   | 21 +++++++++++----------
 .../components/Step2/HttpHeaderRewriteView.tsx      |  2 ++
 .../Routes/components/Step2/RequestRewriteView.tsx  | 14 +++++++-------
 src/pages/Routes/constants.ts                       |  6 +++---
 src/pages/Routes/service.ts                         |  5 ++++-
 src/pages/Routes/transform.ts                       | 15 +++++++++------
 src/pages/Routes/typing.d.ts                        |  4 ++--
 9 files changed, 42 insertions(+), 29 deletions(-)


[incubator-apisix-dashboard] 02/02: fix

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git

commit 996e04a9ed02251ff8ca01f62fd8393deeb01246
Author: juzhiyuan <jj...@gmail.com>
AuthorDate: Wed Jun 3 18:10:17 2020 +0800

    fix
---
 src/pages/Routes/components/Step1/RequestConfigView.tsx  |  6 +++---
 src/pages/Routes/components/Step2/RequestRewriteView.tsx |  6 +++---
 src/pages/Routes/constants.ts                            |  4 ++--
 src/pages/Routes/service.ts                              |  5 ++++-
 src/pages/Routes/transform.ts                            | 15 +++++++++------
 src/pages/Routes/typing.d.ts                             |  4 ++--
 6 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/src/pages/Routes/components/Step1/RequestConfigView.tsx b/src/pages/Routes/components/Step1/RequestConfigView.tsx
index cae126f..e3670eb 100644
--- a/src/pages/Routes/components/Step1/RequestConfigView.tsx
+++ b/src/pages/Routes/components/Step1/RequestConfigView.tsx
@@ -18,7 +18,7 @@ const RequestConfigView: React.FC<Props> = ({ data, disabled, onChange }) => {
   const { protocols } = data.step1Data;
 
   const onProtocolChange = (e: CheckboxValueType[]) => {
-    if (!e.includes('HTTP') && !e.includes('HTTPS')) return;
+    if (!e.includes('http') && !e.includes('https')) return;
     onChange({ ...data.step1Data, protocols: e });
   };
 
@@ -98,7 +98,7 @@ const RequestConfigView: React.FC<Props> = ({ data, disabled, onChange }) => {
                 )}
               </Form.Item>
             ))}
-            {fields.length === 0 && <span>无</span>}
+            {fields.length === 0 && disabled && <span>无</span>}
             {!disabled && (
               <Form.Item>
                 <Button
@@ -122,7 +122,7 @@ const RequestConfigView: React.FC<Props> = ({ data, disabled, onChange }) => {
       <Form.Item label="协议" name="protocols" rules={[{ required: true, message: '请勾选协议' }]}>
         <Checkbox.Group
           disabled={disabled}
-          options={['HTTP', 'HTTPS']}
+          options={['http', 'https']}
           value={protocols}
           onChange={onProtocolChange}
         />
diff --git a/src/pages/Routes/components/Step2/RequestRewriteView.tsx b/src/pages/Routes/components/Step2/RequestRewriteView.tsx
index ca04444..dc31a1c 100644
--- a/src/pages/Routes/components/Step2/RequestRewriteView.tsx
+++ b/src/pages/Routes/components/Step2/RequestRewriteView.tsx
@@ -105,9 +105,9 @@ const RequestRewriteView: React.FC<Props> = ({ data, form, disabled, onChange })
           rules={[{ required: true, message: '请勾选协议' }]}
         >
           <Radio.Group onChange={onProtocolChange} name="upstreamProtocol" disabled={disabled}>
-            <Radio value="originalRequest">原始请求</Radio>
-            <Radio value="HTTP">HTTP</Radio>
-            <Radio value="HTTPS">HTTPS</Radio>
+            <Radio value="original">原始请求</Radio>
+            <Radio value="http">HTTP</Radio>
+            <Radio value="https">HTTPS</Radio>
           </Radio.Group>
         </Form.Item>
         {renderUpstreamMeta()}
diff --git a/src/pages/Routes/constants.ts b/src/pages/Routes/constants.ts
index 294ebb6..0f87b3d 100644
--- a/src/pages/Routes/constants.ts
+++ b/src/pages/Routes/constants.ts
@@ -26,7 +26,7 @@ export const FORM_ITEM_WITHOUT_LABEL = {
 
 export const DEFAULT_STEP_1_DATA: RouteModule.Step1Data = {
   name: '',
-  protocols: ['HTTP', 'HTTPS'],
+  protocols: ['http', 'https'],
   websocket: false,
   hosts: [''],
   paths: [],
@@ -35,7 +35,7 @@ export const DEFAULT_STEP_1_DATA: RouteModule.Step1Data = {
 };
 
 export const DEFAULT_STEP_2_DATA: RouteModule.Step2Data = {
-  upstreamProtocol: 'originalRequest',
+  upstreamProtocol: 'original',
   upstreamHostList: [{ host: '', port: 80, weight: 0 }],
   upstreamHeaderList: [],
   upstreamPath: '',
diff --git a/src/pages/Routes/service.ts b/src/pages/Routes/service.ts
index be34816..e4427ba 100644
--- a/src/pages/Routes/service.ts
+++ b/src/pages/Routes/service.ts
@@ -3,7 +3,10 @@ import { request } from 'umi';
 import { transformStepData } from './transform';
 
 export const createRoute = (data: Pick<RouteModule.Data, 'data'>) => {
-  return request('/workspaces/default/routes', { data: transformStepData(data) });
+  return request('/workspaces/default/routes', {
+    method: 'POST',
+    data: transformStepData(data),
+  });
 };
 
 export const updateRoute = () => {};
diff --git a/src/pages/Routes/transform.ts b/src/pages/Routes/transform.ts
index dbaa55f..ee3896f 100644
--- a/src/pages/Routes/transform.ts
+++ b/src/pages/Routes/transform.ts
@@ -13,12 +13,17 @@ export const transformStepData = ({
     upstream_header[header.header_name] = header.header_value;
   });
 
-  let data: RouteModule.Body = {
+  let { protocols } = step1Data;
+  if (step1Data.websocket) {
+    protocols = protocols.concat('websocket');
+  }
+
+  const data: RouteModule.Body = {
     ...step1Data,
     ...step2Data,
     ...step3Data,
     priority: 0,
-    protocols: step1Data.protocols.concat(step1Data.websocket ? 'websocket' : []),
+    protocols,
     uris: step1Data.paths,
     redirect: {
       redirect_to_https: true,
@@ -49,7 +54,7 @@ export const transformStepData = ({
     },
   };
 
-  data = omit(data, [
+  return omit(data, [
     'advancedMatchingRules',
     'upstreamProtocol',
     'upstreamHostList',
@@ -57,7 +62,5 @@ export const transformStepData = ({
     'upstreamHeaderList',
     'websocket',
     'timeout',
-  ]) as RouteModule.Body;
-
-  return data;
+  ]);
 };
diff --git a/src/pages/Routes/typing.d.ts b/src/pages/Routes/typing.d.ts
index f8229b3..1bb29e3 100644
--- a/src/pages/Routes/typing.d.ts
+++ b/src/pages/Routes/typing.d.ts
@@ -10,7 +10,7 @@ declare namespace RouteModule {
   }
 
   type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'OPTIONS' | 'PATCH';
-  type RequestProtocol = 'HTTPS' | 'HTTP' | 'websocket';
+  type RequestProtocol = 'https' | 'http' | 'websocket';
 
   type Step1Data = {
     name: string;
@@ -54,7 +54,7 @@ declare namespace RouteModule {
   }
 
   type Step2Data = {
-    upstreamProtocol: 'HTTP' | 'HTTPS' | 'originalRequest';
+    upstreamProtocol: 'http' | 'https' | 'original';
     upstreamHostList: UpstreamHost[];
     upstreamPath: string;
     upstreamHeaderList: UpstreamHeader[];


[incubator-apisix-dashboard] 01/02: fix some actions

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git

commit 4cf0ce706a21ea618a2a97cb9f32902b8d25d83c
Author: juzhiyuan <jj...@gmail.com>
AuthorDate: Wed Jun 3 17:55:32 2020 +0800

    fix some actions
---
 src/components/PluginModal/index.tsx                    |  2 ++
 src/pages/Routes/components/Step1/MatchingRulesView.tsx |  2 ++
 src/pages/Routes/components/Step1/RequestConfigView.tsx | 17 +++++++++--------
 .../Routes/components/Step2/HttpHeaderRewriteView.tsx   |  2 ++
 .../Routes/components/Step2/RequestRewriteView.tsx      |  8 ++++----
 src/pages/Routes/constants.ts                           |  2 +-
 6 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/components/PluginModal/index.tsx b/src/components/PluginModal/index.tsx
index 25347d1..9f4882c 100644
--- a/src/components/PluginModal/index.tsx
+++ b/src/components/PluginModal/index.tsx
@@ -21,6 +21,8 @@ const PluginModal: React.FC<Props> = (props) => {
       destroyOnClose
       visible={visible}
       title={`${useIntl().formatMessage({ id: 'component.global.edit.plugin' })} ${name}`}
+      okText="确定"
+      cancelText="取消"
     >
       <PluginForm form={form} {...props} />
     </Modal>
diff --git a/src/pages/Routes/components/Step1/MatchingRulesView.tsx b/src/pages/Routes/components/Step1/MatchingRulesView.tsx
index ee13c2a..dc0522b 100644
--- a/src/pages/Routes/components/Step1/MatchingRulesView.tsx
+++ b/src/pages/Routes/components/Step1/MatchingRulesView.tsx
@@ -99,6 +99,8 @@ const MatchingRulesView: React.FC<Props> = ({ data, disabled, onChange }) => {
           setVisible(false);
           modalForm.resetFields();
         }}
+        okText="确定"
+        cancelText="取消"
         destroyOnClose
       >
         <Form form={modalForm} labelCol={{ span: 4 }} wrapperCol={{ span: 20 }}>
diff --git a/src/pages/Routes/components/Step1/RequestConfigView.tsx b/src/pages/Routes/components/Step1/RequestConfigView.tsx
index a52e647..cae126f 100644
--- a/src/pages/Routes/components/Step1/RequestConfigView.tsx
+++ b/src/pages/Routes/components/Step1/RequestConfigView.tsx
@@ -59,8 +59,8 @@ const RequestConfigView: React.FC<Props> = ({ data, disabled, onChange }) => {
                 ) : null}
               </Form.Item>
             ))}
-            <Form.Item {...FORM_ITEM_WITHOUT_LABEL}>
-              {!disabled && (
+            {!disabled && (
+              <Form.Item {...FORM_ITEM_WITHOUT_LABEL}>
                 <Button
                   type="dashed"
                   onClick={() => {
@@ -69,8 +69,8 @@ const RequestConfigView: React.FC<Props> = ({ data, disabled, onChange }) => {
                 >
                   <PlusOutlined /> 增加
                 </Button>
-              )}
-            </Form.Item>
+              </Form.Item>
+            )}
           </div>
         );
       }}
@@ -98,8 +98,9 @@ const RequestConfigView: React.FC<Props> = ({ data, disabled, onChange }) => {
                 )}
               </Form.Item>
             ))}
-            <Form.Item>
-              {!disabled && (
+            {fields.length === 0 && <span>无</span>}
+            {!disabled && (
+              <Form.Item>
                 <Button
                   type="dashed"
                   onClick={() => {
@@ -108,8 +109,8 @@ const RequestConfigView: React.FC<Props> = ({ data, disabled, onChange }) => {
                 >
                   <PlusOutlined /> 增加
                 </Button>
-              )}
-            </Form.Item>
+              </Form.Item>
+            )}
           </div>
         );
       }}
diff --git a/src/pages/Routes/components/Step2/HttpHeaderRewriteView.tsx b/src/pages/Routes/components/Step2/HttpHeaderRewriteView.tsx
index 3baff95..fa41e81 100644
--- a/src/pages/Routes/components/Step2/HttpHeaderRewriteView.tsx
+++ b/src/pages/Routes/components/Step2/HttpHeaderRewriteView.tsx
@@ -95,6 +95,8 @@ const HttpHeaderRewriteView: React.FC<Props> = ({ data, disabled, onChange }) =>
           setVisible(false);
           modalForm.resetFields();
         }}
+        okText="确定"
+        cancelText="取消"
         destroyOnClose
       >
         <Form form={modalForm} labelCol={{ span: 4 }} wrapperCol={{ span: 20 }}>
diff --git a/src/pages/Routes/components/Step2/RequestRewriteView.tsx b/src/pages/Routes/components/Step2/RequestRewriteView.tsx
index 4e338e5..ca04444 100644
--- a/src/pages/Routes/components/Step2/RequestRewriteView.tsx
+++ b/src/pages/Routes/components/Step2/RequestRewriteView.tsx
@@ -71,8 +71,8 @@ const RequestRewriteView: React.FC<Props> = ({ data, form, disabled, onChange })
               </Row>
             </Form.Item>
           ))}
-          <Form.Item {...FORM_ITEM_WITHOUT_LABEL}>
-            {!disabled && (
+          {!disabled && (
+            <Form.Item {...FORM_ITEM_WITHOUT_LABEL}>
               <Button
                 type="dashed"
                 onClick={() => {
@@ -81,8 +81,8 @@ const RequestRewriteView: React.FC<Props> = ({ data, form, disabled, onChange })
               >
                 <PlusOutlined /> 增加
               </Button>
-            )}
-          </Form.Item>
+            </Form.Item>
+          )}
         </>
       )}
     </Form.List>
diff --git a/src/pages/Routes/constants.ts b/src/pages/Routes/constants.ts
index 6ccce6a..294ebb6 100644
--- a/src/pages/Routes/constants.ts
+++ b/src/pages/Routes/constants.ts
@@ -36,7 +36,7 @@ export const DEFAULT_STEP_1_DATA: RouteModule.Step1Data = {
 
 export const DEFAULT_STEP_2_DATA: RouteModule.Step2Data = {
   upstreamProtocol: 'originalRequest',
-  upstreamHostList: [{ host: '', port: 0, weight: 0 }],
+  upstreamHostList: [{ host: '', port: 80, weight: 0 }],
   upstreamHeaderList: [],
   upstreamPath: '',
   timeout: {