Copilot commented on code in PR #660:
URL: https://github.com/apache/shenyu-dashboard/pull/660#discussion_r4093939349
##########
src/models/global.js:
##########
@@ -207,9 +225,14 @@ export default {
},
saveCurrentNamespaceId(state, { payload }) {
window.sessionStorage.setItem("currentNamespaceId", payload);
+ if (state.currentNamespaceId === payload) {
+ return state;
+ }
return {
...state,
currentNamespaceId: payload,
+ plugins: [],
Review Comment:
The namespace guard was added only to `fetchPlugins`;
`fetchPluginsByNamespace` still writes its explicit-namespace response into the
shared `global.plugins` state without checking the currently selected
namespace. `DataPermModal` uses that effect for its own local namespace, so a
delayed response can repopulate this cleared state with plugins from another
namespace and make shared consumers display the wrong data. Apply the same
response check or keep that modal's plugin list out of global state.
##########
src/routes/System/NamespacePlugin/AddModal.js:
##########
@@ -65,28 +69,24 @@ class AddModal extends Component {
};
handleSubmit = (e) => {
- const { form, handleOk, id = "", data } = this.props;
+ const {
+ form,
+ handleOk,
+ id = "",
+ data,
+ config: originalConfig,
+ } = this.props;
const { jsonKey, jsonValue } = this.state;
e.preventDefault();
form.validateFieldsAndScroll((err, values) => {
if (!err) {
- let { name, enabled, config, sort } = values;
- if (data && data.length > 0) {
- config = {};
- data.forEach((item) => {
- let fieldName = `__${item.field}__`;
- if (values[fieldName]) {
- config[item.field] = values[fieldName];
- }
- });
- if (data.some((i) => i.dataType === 4)) {
- config[jsonKey] = jsonValue;
- }
- config = JSON.stringify(config);
- if (config === "{}") {
- config = "";
- }
- }
+ const { name, enabled, sort } = values;
+ const config = serializePluginConfig({
+ fields: data,
+ values,
+ config: originalConfig,
+ jsonValues: jsonKey ? { [jsonKey]: jsonValue } : {},
Review Comment:
This always submits `jsonValue` for the JSON field, including when the
editor was untouched. `parseJson` initializes that state with
`config[fieldName] || {}`, so an existing `null`, `false`, or `0` is converted
to `{}` and an edit/save changes the stored configuration. Preserve the raw
falsy value or only include `jsonValues` after an actual JSON edit.
##########
src/utils/AuthRoute.js:
##########
@@ -28,6 +28,7 @@ const notCheckRouteUrl = ["/", "/home"];
// menuItem cache
let menuCache = [];
+let menuCacheSource;
Review Comment:
The new source marker only scopes `menuCache`; `getAuthMenus` still reuses
`authMenusCache` keyed only by locale. After a namespace switch clears
permissions, `getAuthMenus(..., beginCache=true)` can therefore return the
previous namespace's sidebar, and if the permission request rejects the
callback that calls `resetAuthMenuCache` never runs. Scope or invalidate
`authMenusCache` with the current permission tree/namespace as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]