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

nuoyan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 7fb3d0fc Feat/plugin permission resource button (#243)
7fb3d0fc is described below

commit 7fb3d0fcdb86e99ccf65dc1ac44c3d87cf768d98
Author: ZongZi <[email protected]>
AuthorDate: Thu Sep 22 17:23:49 2022 +0800

    Feat/plugin permission resource button (#243)
    
    * feat: update i18n json file
    
    * feat: update button of plugin table
    
    Co-authored-by: Leridy_Lei <[email protected]>
---
 public/favicon.ico                  | Bin 4286 -> 4286 bytes
 src/locales/en-US.json              |   1 +
 src/locales/zh-CN.json              |   1 +
 src/models/plugin.js                |  16 ++++++++++-
 src/models/pluginHandle.js          |   2 +-
 src/routes/System/Plugin/index.js   |  53 ++++++++++++++++++++++++++++--------
 src/routes/System/Plugin/index.less |   8 ++++++
 src/services/api.js                 |  11 ++++++++
 8 files changed, 79 insertions(+), 13 deletions(-)

diff --git a/public/favicon.ico b/public/favicon.ico
index b6e72f03..124d5ca2 100644
Binary files a/public/favicon.ico and b/public/favicon.ico differ
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index 66510475..21de8336 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -267,6 +267,7 @@
   "SHENYU.BUTTON.SYSTEM.SYNCHRONIZE": "synchronize",
   "SHENYU.BUTTON.SYSTEM.ENABLE": "enable",
   "SHENYU.BUTTON.SYSTEM.EDITRESOURCEDETAILS": "editDetails",
+  "SHENYU.BUTTON.SYSTEM.RESOURCE": "resource",
   "SHENYU.BUTTON.DATA.PERMISSION.CONFIG": "ConfigureDataPermission",
   "SHENYU.MESSAGE.SESSION.INVALID": "Session is invalid",
   "SHENYU.MESSAGE.SESSION.RELOGIN": "Please login in again",
diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json
index 65471128..a904e198 100644
--- a/src/locales/zh-CN.json
+++ b/src/locales/zh-CN.json
@@ -259,6 +259,7 @@
   "SHENYU.BUTTON.SYSTEM.SYNCHRONIZE": "同步",
   "SHENYU.BUTTON.SYSTEM.ENABLE": "启用",
   "SHENYU.BUTTON.SYSTEM.EDITRESOURCEDETAILS": "编辑详情",
+  "SHENYU.BUTTON.SYSTEM.RESOURCE": "资源",
   "SHENYU.BUTTON.DATA.PERMISSION.CONFIG": "配置数据权限",
   "SHENYU.MESSAGE.SESSION.INVALID": "会话超时",
   "SHENYU.MESSAGE.SESSION.RELOGIN": "会话超时,请重新登录",
diff --git a/src/models/plugin.js b/src/models/plugin.js
index 92fa0db3..6ba9d291 100644
--- a/src/models/plugin.js
+++ b/src/models/plugin.js
@@ -24,7 +24,7 @@ import {
   addPlugin,
   asyncPlugin,
   updatepluginEnabled,
-  fetchPluginHandleByPluginId
+  fetchPluginHandleByPluginId, addPluginResource
 } from "../services/api";
 import {getIntlContent} from "../utils/IntlUtils";
 
@@ -120,12 +120,14 @@ export default {
         message.warn(json.message)
       }
     },
+
     *reload(params, { put }) {
       const { fetchValue } = params;
       const { name, currentPage, pageSize } = fetchValue;
       const payload = { name, currentPage, pageSize };
       yield put({ type: "fetch", payload });
     },
+
     *asyncAll(_, { call }) {
       const json = yield call(asyncPlugin);
       if (json.code === 200) {
@@ -134,6 +136,7 @@ export default {
         message.warn(json.message);
       }
     },
+
     * fetchByPluginId(params, {call}) {
       const {payload,callback} = params;
       const json = yield call(fetchPluginHandleByPluginId, payload);
@@ -142,6 +145,17 @@ export default {
       }
     },
 
+    * createPluginResource(params, {call}) {
+      const {payload, callback} = params;
+      const json = yield call(addPluginResource, payload);
+      if (json.code === 200) {
+        message.success(getIntlContent("SHENYU.COMMON.RESPONSE.ADD.SUCCESS"));
+        callback(json)
+      } else {
+        message.warn(json.message.split(":")[1]);
+      }
+    }
+
   },
 
   reducers: {
diff --git a/src/models/pluginHandle.js b/src/models/pluginHandle.js
index 2fd9e81e..b168a6a9 100644
--- a/src/models/pluginHandle.js
+++ b/src/models/pluginHandle.js
@@ -102,7 +102,7 @@ export default {
       }
     },
 
-    *fetchByPluginId(params, { call }) {
+    * fetchByPluginId(params, { call }) {
       const { payload } = params;
       let handle = payload.handle;
       let callback = payload.callBack;
diff --git a/src/routes/System/Plugin/index.js 
b/src/routes/System/Plugin/index.js
index feeb49b4..7fb65c1d 100644
--- a/src/routes/System/Plugin/index.js
+++ b/src/routes/System/Plugin/index.js
@@ -23,6 +23,7 @@ import AddModal from "./AddModal";
 import { getCurrentLocale, getIntlContent } from "../../../utils/IntlUtils";
 import AuthButton from "../../../utils/AuthButton";
 import { resetAuthMenuCache } from "../../../utils/AuthRoute";
+import styles from "./index.less";
 
 const { Text } = Typography;
 
@@ -182,6 +183,23 @@ export default class Plugin extends Component {
     });
   };
 
+  resourceClick = (record) => {
+    // code here...
+    const { dispatch } = this.props;
+    const {name, role, sort, config, id, enabled} = record;
+    dispatch({
+      type: "plugin/createPluginResource",
+      payload: {
+        name,
+        role,
+        sort,
+        config,
+        id,
+        enabled
+      },
+    });
+  };
+
   searchOnchange = e => {
     this.setState({ name:e.target.value}, this.query);
   };
@@ -437,20 +455,33 @@ export default class Plugin extends Component {
           dataIndex: "time",
           key: "time",
           ellipsis: true,
-          width: 80,
+          width: 160,
           fixed: "right",
           render: (text, record) => {
             return (
-              <AuthButton perms="system:plugin:edit">
-                <div
-                  className="edit"
-                  onClick={() => {
-                    this.editClick(record);
-                  }}
-                >
-                  {getIntlContent("SHENYU.SYSTEM.EDITOR")}
-                </div>
-              </AuthButton>
+              <div className={styles.optionParts}>
+                <AuthButton perms="system:plugin:edit">
+                  <div
+                    className="edit"
+                    onClick={() => {
+                      this.editClick(record);
+                    }}
+                  >
+                    {getIntlContent("SHENYU.SYSTEM.EDITOR")}
+                  </div>
+                </AuthButton>
+                <AuthButton perms="system:plugin:resource">
+                  <div
+                    className="edit"
+                    onClick={() => {
+                      this.resourceClick(record);
+                    }}
+                  >
+                    {getIntlContent("SHENYU.BUTTON.SYSTEM.RESOURCE")}
+                  </div>
+                </AuthButton>
+              </div>
+
             );
           }
         }
diff --git a/src/routes/System/Plugin/index.less 
b/src/routes/System/Plugin/index.less
new file mode 100644
index 00000000..2c7960d8
--- /dev/null
+++ b/src/routes/System/Plugin/index.less
@@ -0,0 +1,8 @@
+.optionParts {
+  display: flex;
+  justify-content: center;
+
+  div:first-child {
+    margin-right: 16px;
+  }
+}
diff --git a/src/services/api.js b/src/services/api.js
index f79bb22e..59088490 100644
--- a/src/services/api.js
+++ b/src/services/api.js
@@ -523,6 +523,17 @@ export function fetchPluginHandleByPluginId(params) {
   );
 }
 
+// create plugin resource
+export function addPluginResource(params) {
+  return request(
+    `${baseUrl}/plugin/createPluginResource/${params.id}`,
+    {
+      method: `PUT`,
+      body: params
+    },
+  );
+}
+
 // fetch dict list
 export async function fetchShenYuDicts(params) {
   return request(`${baseUrl}/shenyu-dict?${stringify(params)}`, {

Reply via email to