Copilot commented on code in PR #1477:
URL: https://github.com/apache/dubbo-admin/pull/1477#discussion_r3524278201
##########
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:
When `configVersion !== 'v3.0'`, `getRoutingRuleDetail()` returns early
without persisting the fetched `conditions` into `TAB_STATE.conditionRule`.
Since `routeList` is not rebuilt, `mergeConditions()` later returns `[]`, and
saving from this form view can unintentionally wipe the rule's existing
conditions.
##########
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:
`updateRoutingRule()` always sends `conditions: mergeConditions()`. If the
rule uses an unsupported `configVersion` (e.g. v3.1), the form intentionally
skips parsing and `routeList` stays at its default empty selection state, so
`mergeConditions()` becomes `[]` and the update request will delete all
existing conditions.
--
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]