This is an automated email from the ASF dual-hosted git repository.
hefengen 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 60183a3f [bugfix] fix namespace bugs 20241127 (#510)
60183a3f is described below
commit 60183a3f43c909192a46273830df0b7d4c76d90d
Author: aias00 <[email protected]>
AuthorDate: Sat Nov 30 22:57:00 2024 +0800
[bugfix] fix namespace bugs 20241127 (#510)
* [bugfix] fix namespace bugs
* fix namespace plugin bugs
* fix namespace bugs
* fix namespace selector bugs
* fix namespace plugin bugs
* fix namespace plugin delete bug
* fix lint
* fix lint
* fix lint
---
src/models/namespacePlugin.js | 5 +++--
src/routes/Home/index.js | 1 +
src/routes/Plugin/Common/SelectorCopy.js | 14 ++++++++------
src/routes/System/NamespacePlugin/index.js | 13 ++++++++-----
src/services/api.js | 10 ++++++----
src/utils/namespacePlugin.js | 3 +--
6 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/src/models/namespacePlugin.js b/src/models/namespacePlugin.js
index 9d3f5ad4..20853558 100644
--- a/src/models/namespacePlugin.js
+++ b/src/models/namespacePlugin.js
@@ -145,8 +145,9 @@ export default {
yield put({ type: "fetch", payload });
},
- *asyncAll(_, { call }) {
- const json = yield call(asyncNamespacePlugin);
+ *asyncAll(params, { call }) {
+ const { payload } = params;
+ const json = yield call(asyncNamespacePlugin, payload);
if (json.code === 200) {
message.success(getIntlContent("SHENYU.COMMON.RESPONSE.SYNC.SUCCESS"));
} else {
diff --git a/src/routes/Home/index.js b/src/routes/Home/index.js
index c50f267b..1b6bc188 100644
--- a/src/routes/Home/index.js
+++ b/src/routes/Home/index.js
@@ -96,6 +96,7 @@ export default class Home extends Component {
return (
<div style={{ display: "inline" }}>
<Tag color="geekblue">{log.operationTime}</Tag>
+ {/* eslint-disable-next-line prettier/prettier */}
<span style={textStyle}>{log.operationType}</span> by{" "}
<span style={textStyle}>{log.operator}</span>
</div>
diff --git a/src/routes/Plugin/Common/SelectorCopy.js
b/src/routes/Plugin/Common/SelectorCopy.js
index 3b42237e..959efa91 100644
--- a/src/routes/Plugin/Common/SelectorCopy.js
+++ b/src/routes/Plugin/Common/SelectorCopy.js
@@ -69,12 +69,14 @@ class SelectorCopy extends Component {
if (Object.keys(pluginMap).length) {
Object.keys(pluginMap).forEach((key) => {
const plugin = pluginList.find((v) => v.id === key);
- selectorTree.push({
- title: plugin.name,
- value: plugin.id,
- disabled: true,
- children: pluginMap[key],
- });
+ if (plugin) {
+ selectorTree.push({
+ title: plugin.name,
+ value: plugin.id,
+ disabled: true,
+ children: pluginMap[key],
+ });
+ }
});
}
this.setState({ selectorTree });
diff --git a/src/routes/System/NamespacePlugin/index.js
b/src/routes/System/NamespacePlugin/index.js
index 0cc39b63..060f991d 100644
--- a/src/routes/System/NamespacePlugin/index.js
+++ b/src/routes/System/NamespacePlugin/index.js
@@ -143,7 +143,7 @@ export default class NamespacePlugin extends Component {
editClick = (record) => {
const { dispatch, currentNamespaceId } = this.props;
getUpdateModal({
- id: record.id,
+ id: record.pluginId,
namespaceId: currentNamespaceId,
dispatch,
fetchValue: this.currentQueryPayload(),
@@ -196,7 +196,7 @@ export default class NamespacePlugin extends Component {
}
};
- // 数据状态切换
+ // change status
statusSwitch = ({ list, enabled, namespaceId, callback }) => {
const { dispatch } = this.props;
updateNamespacePluginsEnabled({
@@ -209,7 +209,7 @@ export default class NamespacePlugin extends Component {
});
};
- // 批量启用或禁用
+ // batch enable or disable
enableClick = () => {
const { dispatch, currentNamespaceId } = this.props;
const { selectedRowKeys } = this.state;
@@ -234,11 +234,12 @@ export default class NamespacePlugin extends Component {
}
};
- // 同步插件数据
+ // sync all
syncAllClick = () => {
const { dispatch } = this.props;
dispatch({
type: "namespacePlugin/asyncAll",
+ payload: { namespaceId: this.props.currentNamespaceId },
});
};
@@ -372,7 +373,7 @@ export default class NamespacePlugin extends Component {
checked={text}
onChange={(checked) => {
this.statusSwitch({
- list: [row.id],
+ list: [row.pluginId],
enabled: checked,
namespaceId: row.namespaceId,
});
@@ -436,6 +437,7 @@ export default class NamespacePlugin extends Component {
selectedRowKeys,
onChange: this.onSelectChange,
};
+
const flatList = (map, list) => {
list.forEach((element) => {
if (!element.children) {
@@ -534,6 +536,7 @@ export default class NamespacePlugin extends Component {
loading={loading}
columns={columns}
dataSource={namespacePluginList}
+ rowKey={(record) => record.pluginId}
rowSelection={rowSelection}
pagination={{
total,
diff --git a/src/services/api.js b/src/services/api.js
index 17312bf0..b014028f 100644
--- a/src/services/api.js
+++ b/src/services/api.js
@@ -1294,7 +1294,7 @@ export async function deleteNamespace(params) {
/* findNamespacePlugin */
export async function findNamespacePlugin(params) {
- return request(`${baseUrl}/namespace-plugin/${params.id}`, {
+ return request(`${baseUrl}/namespace-plugin/detail?${stringify(params)}`, {
method: `GET`,
});
}
@@ -1313,6 +1313,7 @@ export async function
updateNamespacePluginEnabled(params) {
body: {
ids: params.list,
enabled: params.enabled,
+ namespaceId: params.namespaceId,
},
});
}
@@ -1330,8 +1331,8 @@ export async function
updateNamespacePluginEnabledByNamespace(params) {
/* updateNamespacePlugin */
export async function updateNamespacePlugin(params) {
- return request(`${baseUrl}/namespace-plugin/${params.id}`, {
- method: `PUT`,
+ return request(`${baseUrl}/namespace-plugin`, {
+ method: `POST`,
body: params,
});
}
@@ -1348,8 +1349,9 @@ export async function deleteNamespacePlugin(params) {
}
// sync all plugin
-export async function asyncNamespacePlugin() {
+export async function asyncNamespacePlugin(params) {
return request(`${baseUrl}/namespace-plugin/syncPluginAll`, {
method: `POST`,
+ body: params,
});
}
diff --git a/src/utils/namespacePlugin.js b/src/utils/namespacePlugin.js
index 433ca2a3..ad7c70d1 100644
--- a/src/utils/namespacePlugin.js
+++ b/src/utils/namespacePlugin.js
@@ -30,7 +30,7 @@ export function getUpdateModal({
}) {
dispatch({
type: "namespacePlugin/fetchItem",
- payload: { id },
+ payload: { id, namespaceId },
callback: (plugin) => {
dispatch({
type: "namespacePlugin/fetchByPluginId",
@@ -50,7 +50,6 @@ export function getUpdateModal({
type: "namespacePlugin/update",
payload: {
config,
- id: plugin.id,
pluginId: plugin.pluginId,
enabled,
namespaceId,