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 6a598dbf plugin enabled adapted namespace (#506)
6a598dbf is described below
commit 6a598dbf91f1ba74d81a570b609f46dce9f566f0
Author: aias00 <[email protected]>
AuthorDate: Tue Nov 19 15:37:21 2024 +0800
plugin enabled adapted namespace (#506)
---
src/models/namespacePlugin.js | 17 +++++++++++++++++
src/routes/Plugin/Common/index.js | 6 ++++--
src/routes/System/Plugin/index.js | 4 +++-
src/services/api.js | 11 +++++++++++
src/utils/namespacePlugin.js | 25 +++++++++++++++++++++++++
5 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/src/models/namespacePlugin.js b/src/models/namespacePlugin.js
index 9d349886..9d3f5ad4 100644
--- a/src/models/namespacePlugin.js
+++ b/src/models/namespacePlugin.js
@@ -23,6 +23,7 @@ import {
findNamespacePlugin,
getAllNamespacePlugins,
updateNamespacePluginEnabled,
+ updateNamespacePluginEnabledByNamespace,
updateNamespacePlugin,
deleteNamespacePlugin,
asyncNamespacePlugin,
@@ -120,6 +121,22 @@ export default {
message.warn(json.message);
}
},
+ *updateEnByNamespace(params, { call, put }) {
+ const { payload, fetchValue, callback } = params;
+ const json = yield call(updateNamespacePluginEnabledByNamespace,
payload);
+
+ if (json.code === 200) {
+ message.success(
+ getIntlContent("SHENYU.COMMON.RESPONSE.UPDATE.SUCCESS"),
+ );
+ callback();
+ if (fetchValue) {
+ yield put({ type: "reload", fetchValue });
+ }
+ } else {
+ message.warn(json.message);
+ }
+ },
*reload(params, { put }) {
const { fetchValue } = params;
diff --git a/src/routes/Plugin/Common/index.js
b/src/routes/Plugin/Common/index.js
index f73cdc86..37b85ecb 100755
--- a/src/routes/Plugin/Common/index.js
+++ b/src/routes/Plugin/Common/index.js
@@ -34,7 +34,8 @@ import Selector from "./Selector";
import Rule from "./Rule";
import { getCurrentLocale, getIntlContent } from "../../../utils/IntlUtils";
import AuthButton from "../../../utils/AuthButton";
-import { getUpdateModal, updatePluginsEnabled } from "../../../utils/plugin";
+import { getUpdateModal } from "../../../utils/plugin";
+import { updateNamespacePluginsEnabledByNamespace } from
"../../../utils/namespacePlugin";
const { Search } = Input;
const { Title } = Typography;
@@ -377,8 +378,9 @@ export default class Common extends Component {
: "";
const plugin = this.getPlugin(plugins, pluginName);
const enabled = !this.state.isPluginEnabled;
- updatePluginsEnabled({
+ updateNamespacePluginsEnabledByNamespace({
list: [plugin.id],
+ namespaceId: this.props.currentNamespaceId,
enabled,
dispatch,
callback: () => {
diff --git a/src/routes/System/Plugin/index.js
b/src/routes/System/Plugin/index.js
index 6202fc88..1a490b6a 100644
--- a/src/routes/System/Plugin/index.js
+++ b/src/routes/System/Plugin/index.js
@@ -56,6 +56,7 @@ export default class Plugin extends Component {
constructor(props) {
super(props);
this.state = {
+ namespaceId: this.props.currentNamespaceId,
currentPage: 1,
pageSize: 12,
selectedRowKeys: [],
@@ -101,9 +102,10 @@ export default class Plugin extends Component {
};
currentQueryPayload = (override) => {
- const { name, enabled, currentPage, pageSize } = this.state;
+ const { name, namespaceId, enabled, currentPage, pageSize } = this.state;
return {
name,
+ namespaceId,
enabled,
currentPage,
pageSize,
diff --git a/src/services/api.js b/src/services/api.js
index 64116d8e..6de72a7f 100644
--- a/src/services/api.js
+++ b/src/services/api.js
@@ -1287,6 +1287,17 @@ export async function
updateNamespacePluginEnabled(params) {
},
});
}
+/* updateNamespacePluginEnabledByNamespace */
+export async function updateNamespacePluginEnabledByNamespace(params) {
+ return request(`${baseUrl}/namespacePlugin/enabledByNamespace`, {
+ method: `POST`,
+ body: {
+ ids: params.list,
+ enabled: params.enabled,
+ namespaceId: params.namespaceId,
+ },
+ });
+}
/* updateNamespacePlugin */
export async function updateNamespacePlugin(params) {
diff --git a/src/utils/namespacePlugin.js b/src/utils/namespacePlugin.js
index fc701e47..433ca2a3 100644
--- a/src/utils/namespacePlugin.js
+++ b/src/utils/namespacePlugin.js
@@ -99,3 +99,28 @@ export function updateNamespacePluginsEnabled({
},
});
}
+
+export function updateNamespacePluginsEnabledByNamespace({
+ list,
+ enabled,
+ namespaceId,
+ dispatch,
+ fetchValue,
+ callback,
+}) {
+ dispatch({
+ type: "namespacePlugin/updateEnByNamespace",
+ payload: {
+ list,
+ enabled,
+ namespaceId,
+ },
+ fetchValue,
+ callback: () => {
+ if (callback) {
+ callback();
+ }
+ refreshAuthMenus({ dispatch });
+ },
+ });
+}