Skip to content

Commit 95565eb

Browse files
committed
plugin enabled adapted namespace
1 parent 21e10e1 commit 95565eb

File tree

5 files changed

+60
-3
lines changed

5 files changed

+60
-3
lines changed

src/models/namespacePlugin.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
findNamespacePlugin,
2424
getAllNamespacePlugins,
2525
updateNamespacePluginEnabled,
26+
updateNamespacePluginEnabledByNamespace,
2627
updateNamespacePlugin,
2728
deleteNamespacePlugin,
2829
asyncNamespacePlugin,
@@ -120,6 +121,22 @@ export default {
120121
message.warn(json.message);
121122
}
122123
},
124+
*updateEnByNamespace(params, { call, put }) {
125+
const { payload, fetchValue, callback } = params;
126+
const json = yield call(updateNamespacePluginEnabledByNamespace, payload);
127+
128+
if (json.code === 200) {
129+
message.success(
130+
getIntlContent("SHENYU.COMMON.RESPONSE.UPDATE.SUCCESS"),
131+
);
132+
callback();
133+
if (fetchValue) {
134+
yield put({ type: "reload", fetchValue });
135+
}
136+
} else {
137+
message.warn(json.message);
138+
}
139+
},
123140

124141
*reload(params, { put }) {
125142
const { fetchValue } = params;

src/routes/Plugin/Common/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import Selector from "./Selector";
3434
import Rule from "./Rule";
3535
import { getCurrentLocale, getIntlContent } from "../../../utils/IntlUtils";
3636
import AuthButton from "../../../utils/AuthButton";
37-
import { getUpdateModal, updatePluginsEnabled } from "../../../utils/plugin";
37+
import { getUpdateModal } from "../../../utils/plugin";
38+
import { updateNamespacePluginsEnabledByNamespace } from "../../../utils/namespacePlugin";
3839

3940
const { Search } = Input;
4041
const { Title } = Typography;
@@ -377,8 +378,9 @@ export default class Common extends Component {
377378
: "";
378379
const plugin = this.getPlugin(plugins, pluginName);
379380
const enabled = !this.state.isPluginEnabled;
380-
updatePluginsEnabled({
381+
updateNamespacePluginsEnabledByNamespace({
381382
list: [plugin.id],
383+
namespaceId: this.props.currentNamespaceId,
382384
enabled,
383385
dispatch,
384386
callback: () => {

src/routes/System/Plugin/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export default class Plugin extends Component {
5656
constructor(props) {
5757
super(props);
5858
this.state = {
59+
namespaceId: this.props.currentNamespaceId,
5960
currentPage: 1,
6061
pageSize: 12,
6162
selectedRowKeys: [],
@@ -101,9 +102,10 @@ export default class Plugin extends Component {
101102
};
102103

103104
currentQueryPayload = (override) => {
104-
const { name, enabled, currentPage, pageSize } = this.state;
105+
const { name, namespaceId, enabled, currentPage, pageSize } = this.state;
105106
return {
106107
name,
108+
namespaceId,
107109
enabled,
108110
currentPage,
109111
pageSize,

src/services/api.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,17 @@ export async function updateNamespacePluginEnabled(params) {
12771277
},
12781278
});
12791279
}
1280+
/* updateNamespacePluginEnabledByNamespace */
1281+
export async function updateNamespacePluginEnabledByNamespace(params) {
1282+
return request(`${baseUrl}/namespacePlugin/enabledByNamespace`, {
1283+
method: `POST`,
1284+
body: {
1285+
ids: params.list,
1286+
enabled: params.enabled,
1287+
namespaceId: params.namespaceId,
1288+
},
1289+
});
1290+
}
12801291

12811292
/* updateNamespacePlugin */
12821293
export async function updateNamespacePlugin(params) {

src/utils/namespacePlugin.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,28 @@ export function updateNamespacePluginsEnabled({
9999
},
100100
});
101101
}
102+
103+
export function updateNamespacePluginsEnabledByNamespace({
104+
list,
105+
enabled,
106+
namespaceId,
107+
dispatch,
108+
fetchValue,
109+
callback,
110+
}) {
111+
dispatch({
112+
type: "namespacePlugin/updateEnByNamespace",
113+
payload: {
114+
list,
115+
enabled,
116+
namespaceId,
117+
},
118+
fetchValue,
119+
callback: () => {
120+
if (callback) {
121+
callback();
122+
}
123+
refreshAuthMenus({ dispatch });
124+
},
125+
});
126+
}

0 commit comments

Comments
 (0)