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/01 05:27:30 UTC

[incubator-apisix-dashboard] 01/01: feat: update Plugin

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

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

commit 513cb55924521991c7dedc00d274bb9c3f7b49b8
Author: juzhiyuan <jj...@gmail.com>
AuthorDate: Mon Jun 1 13:27:02 2020 +0800

    feat: update Plugin
---
 src/pages/Routes/Create.tsx                             | 7 +------
 src/pages/Routes/components/CreateStep3/CreateStep3.tsx | 8 ++++++--
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/pages/Routes/Create.tsx b/src/pages/Routes/Create.tsx
index f007825..ee6559f 100644
--- a/src/pages/Routes/Create.tsx
+++ b/src/pages/Routes/Create.tsx
@@ -45,12 +45,7 @@ const Create: React.FC = () => {
           />
         );
       case 2:
-        return (
-          <CreateStep3
-            data={data}
-            onChange={(params: RouteModule.Step3Data) => setStep3Data({ ...step3Data, ...params })}
-          />
-        );
+        return <CreateStep3 data={data} onChange={setStep3Data} />;
       default:
         return null;
     }
diff --git a/src/pages/Routes/components/CreateStep3/CreateStep3.tsx b/src/pages/Routes/components/CreateStep3/CreateStep3.tsx
index 52b95a7..c2bed02 100644
--- a/src/pages/Routes/components/CreateStep3/CreateStep3.tsx
+++ b/src/pages/Routes/components/CreateStep3/CreateStep3.tsx
@@ -1,5 +1,6 @@
 import React, { useState, useEffect } from 'react';
 import { SettingOutlined, LinkOutlined } from '@ant-design/icons';
+import { omit, merge } from 'lodash';
 
 import { pluginList } from '@/components/PluginForm';
 import PanelSection from '../PanelSection';
@@ -15,7 +16,7 @@ const sectionStyle = {
   gridColumnGap: 10,
 };
 
-const CreateStep3: React.FC<Props> = ({ data }) => {
+const CreateStep3: React.FC<Props> = ({ data, onChange }) => {
   // NOTE: Plugin in blacklist WILL NOT be shown on Step3.
   const pluginBlackList = ['redirect'];
 
@@ -79,9 +80,12 @@ const CreateStep3: React.FC<Props> = ({ data }) => {
         onInactive={(name: string) => {
           setActiveList(activeList.filter((item) => item.name !== name));
           setInactiveList(inactiveList.concat({ name }));
+          onChange(omit({ ...data.step3Data }, `plugins.${currentPlugin}`));
           setCurrentPlugin(undefined);
         }}
-        onFinish={(value) => console.log('plugin data:', value)}
+        onFinish={(value) => {
+          onChange(merge(data.step3Data, { plugins: { [currentPlugin as string]: value } }));
+        }}
       />
     </>
   );