[apisix-dashboard] branch master updated: feat: added new plugin dependency (#475)

2020-09-15 Thread juzhiyuan
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 c81f0b9  feat: added new plugin dependency (#475)
c81f0b9 is described below

commit c81f0b94fac96264fd34ba7fa943a4b80d45fe02
Author: 琚致远 
AuthorDate: Wed Sep 16 11:22:46 2020 +0800

feat: added new plugin dependency (#475)

* feat: added new plugin dependency

* feat: omit shadow var

* feat: omit shadow var
---
 package.json   |  8 ++--
 src/pages/Route/Create.tsx | 15 +++
 .../Route/components/CreateStep4/CreateStep4.tsx   |  2 +-
 src/pages/Route/components/Step1/index.tsx |  2 +-
 src/pages/Route/components/Step3/index.tsx | 22 ++---
 yarn.lock  | 52 ++
 6 files changed, 59 insertions(+), 42 deletions(-)

diff --git a/package.json b/package.json
index 7f3f1bb..0860c8a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "apisix-dashboard",
-  "version": "1.5.3",
+  "version": "1.5.4",
   "private": true,
   "description": "Dashboard for Apache APISIX",
   "scripts": {
@@ -54,9 +54,9 @@
 "@ant-design/icons": "^4.0.0",
 "@ant-design/pro-layout": "^6.0.0",
 "@ant-design/pro-table": "2.6.3",
-"@api7-dashboard/plugin": "^1.0.3",
-"@api7-dashboard/pluginchart": "^1.0.9",
-"@api7-dashboard/ui": "^1.0.0",
+"@api7-dashboard/plugin": "^1.0.4",
+"@api7-dashboard/pluginchart": "^1.0.11",
+"@api7-dashboard/ui": "^1.0.3",
 "@rjsf/antd": "2.2.0",
 "@rjsf/core": "2.2.0",
 "antd": "^4.4.0",
diff --git a/src/pages/Route/Create.tsx b/src/pages/Route/Create.tsx
index fc767d2..40c6365 100644
--- a/src/pages/Route/Create.tsx
+++ b/src/pages/Route/Create.tsx
@@ -187,15 +187,10 @@ const Page: React.FC = (props) => {
 if (step === 3) {
   return (
  {
-if (mode === 'NORMAL') {
-  setStep3Data({ plugins: data, script: {} });
-  setChart(INIT_CHART);
-} else {
-  setChart(data);
-}
+  data={step3Data}
+  onChange={({ plugins, script = INIT_CHART }) => {
+setStep3Data({ plugins, script });
+setChart(script);
   }}
 />
   );
@@ -234,7 +229,7 @@ const Page: React.FC = (props) => {
 };
 
 const savePlugins = () => {
-  if (Object.keys(chart.nodes).length) {
+  if (Object.keys(chart.nodes || {}).length) {
 const transformChart = chartTransformer(chart);
 setStep3Data({ script: { ...transformChart, chart }, plugins: {} });
   } else {
diff --git a/src/pages/Route/components/CreateStep4/CreateStep4.tsx 
b/src/pages/Route/components/CreateStep4/CreateStep4.tsx
index ad47fc1..1d6928a 100644
--- a/src/pages/Route/components/CreateStep4/CreateStep4.tsx
+++ b/src/pages/Route/components/CreateStep4/CreateStep4.tsx
@@ -47,7 +47,7 @@ const CreateStep4: React.FC = ({ form1, form2, 
redirect, ...rest }) => {
   
   {formatMessage({ id: 
'route.create.plugin.configuration' })}
   {Boolean(Object.keys(plugins).length !== 0) && (
-
+
   )}
   {Boolean(Object.keys(script).length !== 0) && (
  = (props) => {
diff --git a/src/pages/Route/components/Step3/index.tsx 
b/src/pages/Route/components/Step3/index.tsx
index 0b872e9..ae6a606 100644
--- a/src/pages/Route/components/Step3/index.tsx
+++ b/src/pages/Route/components/Step3/index.tsx
@@ -18,13 +18,17 @@ import React, { useState } from 'react';
 import { Radio, Tooltip } from 'antd';
 import { QuestionCircleOutlined } from '@ant-design/icons';
 import { isChrome } from 'react-device-detect';
+
 import { PluginPage, PluginPageType } from '@api7-dashboard/plugin';
 import PluginOrchestration from '@api7-dashboard/pluginchart';
 
 type Props = {
-  data: PluginPageType.PluginData;
-  onChange(data: PluginPageType.PluginData): void;
-  readonly: boolean;
+  data: {
+plugins: PluginPageType.FinalData;
+script: Record;
+  };
+  onChange(data: { plugins: PluginPageType.FinalData; script: any }): void;
+  readonly?: boolean;
 };
 
 type Mode = 'NORMAL' | 'DRAW';
@@ -33,7 +37,7 @@ const Page: React.FC = ({ data, onChange, readonly = 
false }) => {
   const { plugins = {}, script = {} } = data;
 
   // NOTE: Currently only compatible with chrome
-  const type = Object.keys(script).length === 0 || !isChrome ? 'NORMAL' : 
'DRAW';
+  const type = Object.keys(script || {}).length === 0 || !isChrome ? 'NORMAL' 
: 'DRAW';
   const [mode, setMode] = useState(type);
 
   return (
@@ -44,6 +48,7 @@ const Page: React.FC = ({ data, onChange, readonly = 
false }) => {
   onChange={(e) => {
 setMode(e.target.value);
   }}
+  sty

[apisix-dashboard] branch master updated: feat: added new plugin dependency (#475)

2020-09-15 Thread juzhiyuan
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 c81f0b9  feat: added new plugin dependency (#475)
c81f0b9 is described below

commit c81f0b94fac96264fd34ba7fa943a4b80d45fe02
Author: 琚致远 
AuthorDate: Wed Sep 16 11:22:46 2020 +0800

feat: added new plugin dependency (#475)

* feat: added new plugin dependency

* feat: omit shadow var

* feat: omit shadow var
---
 package.json   |  8 ++--
 src/pages/Route/Create.tsx | 15 +++
 .../Route/components/CreateStep4/CreateStep4.tsx   |  2 +-
 src/pages/Route/components/Step1/index.tsx |  2 +-
 src/pages/Route/components/Step3/index.tsx | 22 ++---
 yarn.lock  | 52 ++
 6 files changed, 59 insertions(+), 42 deletions(-)

diff --git a/package.json b/package.json
index 7f3f1bb..0860c8a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "apisix-dashboard",
-  "version": "1.5.3",
+  "version": "1.5.4",
   "private": true,
   "description": "Dashboard for Apache APISIX",
   "scripts": {
@@ -54,9 +54,9 @@
 "@ant-design/icons": "^4.0.0",
 "@ant-design/pro-layout": "^6.0.0",
 "@ant-design/pro-table": "2.6.3",
-"@api7-dashboard/plugin": "^1.0.3",
-"@api7-dashboard/pluginchart": "^1.0.9",
-"@api7-dashboard/ui": "^1.0.0",
+"@api7-dashboard/plugin": "^1.0.4",
+"@api7-dashboard/pluginchart": "^1.0.11",
+"@api7-dashboard/ui": "^1.0.3",
 "@rjsf/antd": "2.2.0",
 "@rjsf/core": "2.2.0",
 "antd": "^4.4.0",
diff --git a/src/pages/Route/Create.tsx b/src/pages/Route/Create.tsx
index fc767d2..40c6365 100644
--- a/src/pages/Route/Create.tsx
+++ b/src/pages/Route/Create.tsx
@@ -187,15 +187,10 @@ const Page: React.FC = (props) => {
 if (step === 3) {
   return (
  {
-if (mode === 'NORMAL') {
-  setStep3Data({ plugins: data, script: {} });
-  setChart(INIT_CHART);
-} else {
-  setChart(data);
-}
+  data={step3Data}
+  onChange={({ plugins, script = INIT_CHART }) => {
+setStep3Data({ plugins, script });
+setChart(script);
   }}
 />
   );
@@ -234,7 +229,7 @@ const Page: React.FC = (props) => {
 };
 
 const savePlugins = () => {
-  if (Object.keys(chart.nodes).length) {
+  if (Object.keys(chart.nodes || {}).length) {
 const transformChart = chartTransformer(chart);
 setStep3Data({ script: { ...transformChart, chart }, plugins: {} });
   } else {
diff --git a/src/pages/Route/components/CreateStep4/CreateStep4.tsx 
b/src/pages/Route/components/CreateStep4/CreateStep4.tsx
index ad47fc1..1d6928a 100644
--- a/src/pages/Route/components/CreateStep4/CreateStep4.tsx
+++ b/src/pages/Route/components/CreateStep4/CreateStep4.tsx
@@ -47,7 +47,7 @@ const CreateStep4: React.FC = ({ form1, form2, 
redirect, ...rest }) => {
   
   {formatMessage({ id: 
'route.create.plugin.configuration' })}
   {Boolean(Object.keys(plugins).length !== 0) && (
-
+
   )}
   {Boolean(Object.keys(script).length !== 0) && (
  = (props) => {
diff --git a/src/pages/Route/components/Step3/index.tsx 
b/src/pages/Route/components/Step3/index.tsx
index 0b872e9..ae6a606 100644
--- a/src/pages/Route/components/Step3/index.tsx
+++ b/src/pages/Route/components/Step3/index.tsx
@@ -18,13 +18,17 @@ import React, { useState } from 'react';
 import { Radio, Tooltip } from 'antd';
 import { QuestionCircleOutlined } from '@ant-design/icons';
 import { isChrome } from 'react-device-detect';
+
 import { PluginPage, PluginPageType } from '@api7-dashboard/plugin';
 import PluginOrchestration from '@api7-dashboard/pluginchart';
 
 type Props = {
-  data: PluginPageType.PluginData;
-  onChange(data: PluginPageType.PluginData): void;
-  readonly: boolean;
+  data: {
+plugins: PluginPageType.FinalData;
+script: Record;
+  };
+  onChange(data: { plugins: PluginPageType.FinalData; script: any }): void;
+  readonly?: boolean;
 };
 
 type Mode = 'NORMAL' | 'DRAW';
@@ -33,7 +37,7 @@ const Page: React.FC = ({ data, onChange, readonly = 
false }) => {
   const { plugins = {}, script = {} } = data;
 
   // NOTE: Currently only compatible with chrome
-  const type = Object.keys(script).length === 0 || !isChrome ? 'NORMAL' : 
'DRAW';
+  const type = Object.keys(script || {}).length === 0 || !isChrome ? 'NORMAL' 
: 'DRAW';
   const [mode, setMode] = useState(type);
 
   return (
@@ -44,6 +48,7 @@ const Page: React.FC = ({ data, onChange, readonly = 
false }) => {
   onChange={(e) => {
 setMode(e.target.value);
   }}
+  sty