Copilot commented on code in PR #718:
URL: https://github.com/apache/shenyu-dashboard/pull/718#discussion_r4291418168


##########
src/routes/System/NamespacePlugin/AddModal.js:
##########
@@ -139,25 +152,45 @@ class AddModal extends Component {
               />,
             )}
           </FormItem>
-          {data && data.length > 0 && (
+          {configError && (
+            <FormItem
+              label={getIntlContent("SHENYU.COMMON.SETTING")}
+              {...formItemLayout}
+            >
+              {getFieldDecorator("config", {
+                initialValue: config,
+                rules: [
+                  {
+                    validator: (rule, value, callback) =>
+                      callback(
+                        parseJsonObject(value).error

Review Comment:
   Clearing the recovery textarea passes validation because 
`parseJsonObject("")` returns `{ value: undefined }` without an error. 
`handleSubmit` then submits `config: ""`, allowing the stored namespace-plugin 
configuration to be erased without correcting it to a JSON object. Require a 
defined parsed object in this validator, leaving the helper's handling of 
initially empty configurations unchanged. Add a clear-then-save regression test.



##########
src/routes/System/Plugin/AddModal.js:
##########
@@ -141,25 +153,45 @@ class AddModal extends Component {
               />,
             )}
           </FormItem>
-          {data && data.length > 0 && (
+          {configError && (
+            <FormItem
+              label={getIntlContent("SHENYU.COMMON.SETTING")}
+              {...formItemLayout}
+            >
+              {getFieldDecorator("config", {
+                initialValue: config,
+                rules: [
+                  {
+                    validator: (rule, value, callback) =>
+                      callback(
+                        parseJsonObject(value).error

Review Comment:
   Clearing the recovery textarea passes validation because 
`parseJsonObject("")` returns `{ value: undefined }` without an error. 
`handleSubmit` then submits `config: ""`, allowing the stored configuration to 
be erased without correcting it to a JSON object. Require a defined parsed 
object in this validator, leaving the helper's handling of initially empty 
configurations unchanged. Add a clear-then-save regression test.



-- 
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]

Reply via email to