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

baoyuan 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 7b8d9c5b3 fix: adapt APISIX plugin disabled (#2717)
7b8d9c5b3 is described below

commit 7b8d9c5b30a8eae2ca038b99cf2a3c36cdca2ddc
Author: Baoyuan <[email protected]>
AuthorDate: Fri Jan 20 09:02:44 2023 +0800

    fix: adapt APISIX plugin disabled (#2717)
---
 web/.eslintrc.js                           |  1 +
 web/src/components/Plugin/PluginDetail.tsx |  6 ++++--
 web/src/components/Plugin/PluginPage.tsx   | 10 +++++-----
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/web/.eslintrc.js b/web/.eslintrc.js
index 36fbf31f6..2f2bd7682 100644
--- a/web/.eslintrc.js
+++ b/web/.eslintrc.js
@@ -33,6 +33,7 @@ module.exports = {
     'import/order': 'off',
     'simple-import-sort/imports': 'error',
     'simple-import-sort/exports': 'error',
+    'no-underscore-dangle': 'off',
   },
   settings: {
     'import/resolver': {
diff --git a/web/src/components/Plugin/PluginDetail.tsx 
b/web/src/components/Plugin/PluginDetail.tsx
index 8fc98acd7..0e0fc8f96 100644
--- a/web/src/components/Plugin/PluginDetail.tsx
+++ b/web/src/components/Plugin/PluginDetail.tsx
@@ -181,7 +181,7 @@ const PluginDetail: React.FC<Props> = ({
 
   useEffect(() => {
     form.setFieldsValue({
-      disable: isEnabled ? true : initialData[name] && 
!initialData[name].disable,
+      disable: isEnabled ? true : initialData[name] && 
!initialData[name]._meta.disable,
       scope: 'global',
     });
     if (PLUGIN_UI_LIST.includes(name)) {
@@ -415,7 +415,9 @@ const PluginDetail: React.FC<Props> = ({
           name="disable"
         >
           <Switch
-            defaultChecked={isEnabled ? true : initialData[name] && 
!initialData[name].disable}
+            defaultChecked={
+              isEnabled ? true : initialData[name] && 
!initialData[name]._meta.disable
+            }
             disabled={readonly || isEnabled}
           />
         </Form.Item>
diff --git a/web/src/components/Plugin/PluginPage.tsx 
b/web/src/components/Plugin/PluginPage.tsx
index 62460cf1e..5c843f3c3 100644
--- a/web/src/components/Plugin/PluginPage.tsx
+++ b/web/src/components/Plugin/PluginPage.tsx
@@ -101,7 +101,7 @@ const PluginPage: React.FC<Props> = ({
 
   useEffect(() => {
     const openPluginList = pluginList.filter(
-      (item) => initialData[item.name] && !initialData[item.name].disable,
+      (item) => initialData[item.name] && 
!initialData[item.name]._meta.disable,
     );
     setPlugins(initialData);
     setEnablePluginsList(openPluginList);
@@ -244,16 +244,16 @@ const PluginPage: React.FC<Props> = ({
                   actions={[
                     <Button
                       type={
-                        initialData[item.name] && 
!initialData[item.name].disable
+                        initialData[item.name] && 
!initialData[item.name]._meta.disable
                           ? 'primary'
                           : 'default'
                       }
-                      danger={initialData[item.name] && 
!initialData[item.name].disable}
+                      danger={initialData[item.name] && 
!initialData[item.name]._meta.disable}
                       onClick={() => {
                         setName(item.name);
                       }}
                     >
-                      {initialData[item.name] && 
!initialData[item.name].disable
+                      {initialData[item.name] && 
!initialData[item.name]._meta.disable
                         ? formatMessage({ id: 'component.plugin.disable' })
                         : formatMessage({ id: 'component.plugin.enable' })}
                     </Button>,
@@ -315,7 +315,7 @@ const PluginPage: React.FC<Props> = ({
       onChange={({ monacoData, formData, shouldDelete }) => {
         let newPlugins = {
           ...initialData,
-          [name]: { ...monacoData, disable: !formData.disable },
+          [name]: { ...monacoData, _meta: { disable: !formData.disable } },
         };
         let handleType = 'edit';
         if (shouldDelete === true) {

Reply via email to