This is an automated email from the ASF dual-hosted git repository.
likeguo 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 6bdd2fea Quickly switch from the `/config/plugin` page to the
`/plug/**` page (#319)
6bdd2fea is described below
commit 6bdd2fea685fcefa163cd48b4564049ad0fe7278
Author: Kerwin Bryant <[email protected]>
AuthorDate: Thu Aug 17 21:32:50 2023 +0800
Quickly switch from the `/config/plugin` page to the `/plug/**` page (#319)
---
src/layouts/BasicLayout.js | 7 +++++++
src/models/resource.js | 16 ++++++++++++++++
src/routes/System/Plugin/index.js | 28 +++++++++++++++++++++++-----
3 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js
index 31aa23db..b6bf0c8f 100644
--- a/src/layouts/BasicLayout.js
+++ b/src/layouts/BasicLayout.js
@@ -301,6 +301,13 @@ class BasicLayout extends React.PureComponent {
removeEmptyMenu(menus);
}
+ dispatch({
+ type: "resource/authorizedMenuTree",
+ payload: {
+ authMenu: menus
+ }
+ });
+
const layout = (
<Layout>
<SiderMenu
diff --git a/src/models/resource.js b/src/models/resource.js
index 4ec79f26..6cf0ff77 100644
--- a/src/models/resource.js
+++ b/src/models/resource.js
@@ -33,6 +33,7 @@ export default {
state: {
resourceList: [],
menuTree: [],
+ authMenu: [],
total: 0
},
@@ -113,6 +114,15 @@ export default {
});
}
},
+ *authorizedMenuTree(params, { put }) {
+ const { payload } = params;
+ yield put({
+ type: "saveAuthMenu",
+ payload: {
+ authMenu: payload.authMenu
+ }
+ });
+ },
},
reducers: {
@@ -128,6 +138,12 @@ export default {
...state,
menuTree: payload.menuTree
};
+ },
+ saveAuthMenu(state, { payload }) {
+ return {
+ ...state,
+ authMenu: payload.authMenu
+ };
}
}
};
diff --git a/src/routes/System/Plugin/index.js
b/src/routes/System/Plugin/index.js
index 73f1fa42..63fd7b0b 100644
--- a/src/routes/System/Plugin/index.js
+++ b/src/routes/System/Plugin/index.js
@@ -18,6 +18,7 @@
import React, { Component } from "react";
import { Table, Input, Button, message, Popconfirm, Select, Popover, Tag,
Typography } from "antd";
import { connect } from "dva";
+import { Link } from "dva/router";
import { resizableComponents } from "../../../utils/resizable";
import AddModal from "./AddModal";
import { getCurrentLocale, getIntlContent } from "../../../utils/IntlUtils";
@@ -29,8 +30,9 @@ const { Text } = Typography;
const { Option } = Select;
-@connect(({ plugin, loading, global }) => ({
+@connect(({ plugin, resource, loading, global }) => ({
plugin,
+ authMenu: resource.authMenu,
language: global.language,
loading: loading.effects["plugin/fetch"]
}))
@@ -356,8 +358,10 @@ export default class Plugin extends Component {
key: "name",
ellipsis: true,
width: 120,
- render: text => {
- return <div style={{color: "#260033","fontWeight":"bold"}}>{text
|| "----"}</div>;
+ render: (text, record) => {
+ return record.url
+ ? <Link to={record.url}><div style={{color: "#1890ff",
"fontWeight": "bold", "text-decoration-line": "underline"}}>{text ||
"----"}</div></Link>
+ : <div style={{color: "#260033", "fontWeight": "bold"}}>{text ||
"----"}</div>;
}
},
{
@@ -470,7 +474,6 @@ export default class Plugin extends Component {
</div>
</AuthButton>
</div>
-
);
}
}
@@ -479,7 +482,7 @@ export default class Plugin extends Component {
}
render() {
- const { plugin, loading } = this.props;
+ const { plugin, loading, authMenu } = this.props;
const { pluginList, total } = plugin;
const { currentPage, pageSize, selectedRowKeys, name, enabled, popup } =
this.state;
const columns = this.state.columns.map((col, index) => ({
@@ -493,6 +496,21 @@ export default class Plugin extends Component {
selectedRowKeys,
onChange: this.onSelectChange
};
+ const flatList = (map, list) => {
+ list.forEach(element => {
+ if (!element.children) {
+ map[element.id] = element;
+ } else {
+ flatList(map, element.children);
+ }
+ });
+ return map;
+ };
+ const flatAuthMenu = flatList({}, authMenu);
+
+ pluginList.forEach(p => {
+ p.url = (flatAuthMenu[p.id] ?? {}).path;
+ });
return (
<div className="plug-content-wrap">