mochengqian commented on code in PR #1477:
URL: https://github.com/apache/dubbo-admin/pull/1477#discussion_r3524418309


##########
ui-vue3/src/views/traffic/routingRule/tabs/updateByFormView.vue:
##########
@@ -287,20 +277,26 @@ watch(
 
 // Get condition routing details
 async function getRoutingRuleDetail() {
-  let res = await getConditionRuleDetailAPI(<string>route.params?.ruleName)
-  // console.log(res)
+  let res = await getConditionRuleDetailAPI(route.params?.ruleName as string)
   if (res?.code === HTTP_STATUS.SUCCESS) {
-    console.log('res', res.data)
-    const { conditions, configVersion, enabled, force, key, runtime, scope } = 
res?.data
+    const { conditions, configVersion, priority, enabled, force, key, runtime, 
scope } =
+      res.data || {}
     baseInfo.ruleGranularity = scope
     baseInfo.objectOfAction = key
     baseInfo.enable = enabled
     baseInfo.faultTolerantProtection = force
     baseInfo.runtime = runtime
     baseInfo.configVersion = configVersion
+    baseInfo.priority = priority
 
     //   format conditions data
-    if (configVersion == 'v3.0' && conditions && conditions.length > 0) {
+    if (conditions && conditions.length > 0) {
+      if (configVersion !== 'v3.0') {
+        console.warn(
+          `skip condition route form parsing for unsupported configVersion: 
${configVersion}`
+        )
+        return
+      }
       // Clear and rebuild routeList based on conditions

Review Comment:
   Fixed. The form now stashes the raw fetched conditions in 
`originalConditions` and tracks whether it could parse them via 
`conditionsEditable`. On save, `updateRoutingRule()` sends `conditionsEditable 
? mergeConditions() : originalConditions`, so a rule with an unsupported 
`configVersion` (e.g. v3.1) round-trips its existing conditions untouched 
instead of being wiped with `[]`. Covered by a strengthened assertion in 
`updateByFormView.spec.ts` that verifies the original conditions are preserved 
through the v3.1 edit round-trip.



##########
ui-vue3/src/views/traffic/routingRule/tabs/updateByFormView.vue:
##########
@@ -327,25 +323,33 @@ const updateRoutingRule = async () => {
   loading.value = true
   try {
     const { ruleName } = route.params
-    const { version, ruleGranularity, objectOfAction, enable, 
faultTolerantProtection, runtime } =
-      baseInfo
+    const {
+      ruleGranularity,
+      objectOfAction,
+      enable,
+      faultTolerantProtection,
+      runtime,
+      priority,
+      configVersion
+    } = baseInfo
     const data = {
-      configVersion: 'v3.0',
+      configVersion: configVersion || 'v3.0',
+      priority,
       scope: ruleGranularity,
       key: objectOfAction,
       enabled: enable,
       force: faultTolerantProtection,
       runtime,
       conditions: mergeConditions()

Review Comment:
   Fixed. The form now stashes the raw fetched conditions in 
`originalConditions` and tracks whether it could parse them via 
`conditionsEditable`. On save, `updateRoutingRule()` sends `conditionsEditable 
? mergeConditions() : originalConditions`, so a rule with an unsupported 
`configVersion` (e.g. v3.1) round-trips its existing conditions untouched 
instead of being wiped with `[]`. Covered by a strengthened assertion in 
`updateByFormView.spec.ts` that verifies the original conditions are preserved 
through the v3.1 edit round-trip.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to