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/09/03 06:11:29 UTC

[apisix-dashboard] branch master updated: fix: no response when clicking [createNew] button in create route resultView (#426)

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

juzhiyuan 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 476a2cb  fix: no response when clicking [createNew] button in create route resultView (#426)
476a2cb is described below

commit 476a2cbf39916e7888d4f1281cefdc87d6726431
Author: liuxiran <be...@126.com>
AuthorDate: Thu Sep 3 14:11:18 2020 +0800

    fix: no response when clicking [createNew] button in create route resultView (#426)
---
 src/pages/Route/Create.tsx                         | 20 +++++++++-----
 .../Route/components/ResultView/ResultView.tsx     | 31 ++++++++++------------
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/src/pages/Route/Create.tsx b/src/pages/Route/Create.tsx
index 51ee1c0..39be889 100644
--- a/src/pages/Route/Create.tsx
+++ b/src/pages/Route/Create.tsx
@@ -17,7 +17,7 @@
 import React, { useState, useEffect } from 'react';
 import { Card, Steps, Form } from 'antd';
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import { useIntl } from 'umi';
+import { history, useIntl } from 'umi';
 
 import ActionBar from '@/components/ActionBar';
 import { transformer as chartTransformer } from '@api7-dashboard/pluginchart';
@@ -86,7 +86,6 @@ const Page: React.FC<Props> = (props) => {
     step2Data,
     step3Data,
   };
-
   const setupRoute = (rid: number) =>
     fetchItem(rid).then((data) => {
       form1.setFieldsValue(data.step1Data);
@@ -120,8 +119,9 @@ const Page: React.FC<Props> = (props) => {
     setStep1Data(DEFAULT_STEP_1_DATA);
     setStep2Data(DEFAULT_STEP_2_DATA);
     setStep3Data(DEFAULT_STEP_3_DATA);
-    form1.resetFields();
-    form2.resetFields();
+
+    form1.setFieldsValue(DEFAULT_STEP_1_DATA);
+    form2.setFieldsValue(DEFAULT_STEP_2_DATA);
     setStep(1);
   };
 
@@ -187,9 +187,17 @@ const Page: React.FC<Props> = (props) => {
     }
 
     if (step === 5) {
-      return <ResultView onReset={onReset} />;
+      return (
+        <ResultView
+          createNew={() => {
+            if (props.route.path.indexOf('edit') !== -1) {
+              return history.replace('/routes/create');
+            }
+            return onReset();
+          }}
+        />
+      );
     }
-
     return null;
   };
 
diff --git a/src/pages/Route/components/ResultView/ResultView.tsx b/src/pages/Route/components/ResultView/ResultView.tsx
index 3346e2c..9013656 100644
--- a/src/pages/Route/components/ResultView/ResultView.tsx
+++ b/src/pages/Route/components/ResultView/ResultView.tsx
@@ -19,28 +19,25 @@ import { Result, Button } from 'antd';
 import { history, useIntl } from 'umi';
 
 type Props = {
-  onReset?(): void;
+  createNew(): void;
 };
 
-const ResultView: React.FC<Props> = () => {
-
+const ResultView: React.FC<Props> = (props) => {
   const { formatMessage } = useIntl();
-
-  return(
+  return (
     <Result
-    status="success"
-    title={formatMessage({ id: 'route.result.submit.success' })}
-    extra={[
-      <Button type="primary" key="goto-list" onClick={() => history.replace('/routes/list')}>
-        {formatMessage({ id: 'route.result.return.list' })}
-      </Button>,
-      <Button key="create-new" onClick={() => history.replace('/routes/create')}>
-        {formatMessage({ id: 'route.result.create' })}
-      </Button>,
-    ]}
-  />
+      status="success"
+      title={formatMessage({ id: 'route.result.submit.success' })}
+      extra={[
+        <Button type="primary" key="goto-list" onClick={() => history.replace('/routes/list')}>
+          {formatMessage({ id: 'route.result.return.list' })}
+        </Button>,
+        <Button key="create-new" onClick={() => props.createNew()}>
+          {formatMessage({ id: 'route.result.create' })}
+        </Button>,
+      ]}
+    />
   );
-  
 };
 
 export default ResultView;