Skip to content

Commit c4397fa

Browse files
committed
fix(traffic): preserve priority/force/configVersion on rule edit forms
The §9.4 smoke drill expectation "after rollback, the rule should look the same on UI refresh" exposed a pre-existing edit-form regression: rollback was correct at the ledger and ZK levels, but the edit form silently dropped `priority`, `force`, and (for condition routes) `configVersion` because they were neither rendered in the GET response nor re-sent on save. This is not caused by versioning, but a true round-trip is the first flow that forces every field through the loop. Adds the missing fields to ConditionRuleResp / TagRuleResp on the backend, and reads/writes them in updateByFormView.vue on the frontend so a "save → rollback → reload" cycle is now lossless.
1 parent 3e29abd commit c4397fa

4 files changed

Lines changed: 56 additions & 9 deletions

File tree

pkg/console/model/condition_rule.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ type ConditionRuleResp struct {
5252
Conditions []string `json:"conditions"`
5353
ConfigVersion string `json:"configVersion"`
5454
Enabled bool `json:"enabled"`
55+
Force bool `json:"force"`
5556
Key string `json:"key"`
57+
Priority int32 `json:"priority"`
5658
Runtime bool `json:"runtime"`
5759
Scope string `json:"scope"`
5860
}
@@ -246,7 +248,9 @@ func GenConditionRuleToResp(data *meshproto.ConditionRoute) *CommonResp {
246248
Conditions: data.Conditions,
247249
ConfigVersion: data.ConfigVersion,
248250
Enabled: data.Enabled,
251+
Force: data.Force,
249252
Key: data.Key,
253+
Priority: data.Priority,
250254
Runtime: data.Runtime,
251255
Scope: data.Scope,
252256
})

pkg/console/model/tag_rule.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ type TagRuleSearchResp struct {
3131
type TagRuleResp struct {
3232
ConfigVersion string `json:"configVersion"`
3333
Enabled bool `json:"enabled"`
34+
Force bool `json:"force"`
3435
Key string `json:"key"`
36+
Priority int32 `json:"priority"`
3537
Runtime bool `json:"runtime"`
3638
Scope string `json:"scope"`
3739
Tags []RespTagElement `json:"tags"`
@@ -50,7 +52,9 @@ func GenTagRouteResp(pb *meshproto.TagRoute) *CommonResp {
5052
return NewSuccessResp(TagRuleResp{
5153
ConfigVersion: pb.ConfigVersion,
5254
Enabled: pb.Enabled,
55+
Force: pb.Force,
5356
Key: pb.Key,
57+
Priority: pb.Priority,
5458
Runtime: pb.Runtime,
5559
Scope: constants.ScopeApplication,
5660
Tags: tagToRespTagElement(pb.Tags),

ui-vue3/src/views/traffic/routingRule/tabs/updateByFormView.vue

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,20 @@ const {
181181
182182
onMounted(async () => {
183183
if (!isNil(TAB_STATE.conditionRule)) {
184-
const { enabled = true, key, scope, runtime = true, conditions } = TAB_STATE.conditionRule
184+
const {
185+
configVersion,
186+
priority,
187+
enabled = true,
188+
force = false,
189+
key,
190+
scope,
191+
runtime = true,
192+
conditions
193+
} = TAB_STATE.conditionRule
194+
baseInfo.configVersion = configVersion
195+
baseInfo.priority = priority
185196
baseInfo.enable = enabled
197+
baseInfo.faultTolerantProtection = force
186198
baseInfo.objectOfAction = key
187199
baseInfo.ruleGranularity = scope
188200
baseInfo.runtime = runtime
@@ -248,6 +260,7 @@ const baseInfo = reactive({
248260
faultTolerantProtection: false,
249261
runtime: true,
250262
priority: null,
263+
configVersion: '',
251264
group: ''
252265
})
253266
@@ -300,16 +313,18 @@ async function getRoutingRuleDetail() {
300313
// console.log(res)
301314
if (res?.code === HTTP_STATUS.SUCCESS) {
302315
console.log('res', res.data)
303-
const { conditions, configVersion, enabled, force, key, runtime, scope } = res.data || {}
316+
const { conditions, configVersion, priority, enabled, force, key, runtime, scope } =
317+
res.data || {}
304318
baseInfo.ruleGranularity = scope
305319
baseInfo.objectOfAction = key
306320
baseInfo.enable = enabled
307321
baseInfo.faultTolerantProtection = force
308322
baseInfo.runtime = runtime
309323
baseInfo.configVersion = configVersion
324+
baseInfo.priority = priority
310325
311326
// format conditions data
312-
if (configVersion == 'v3.0' && conditions && conditions.length > 0) {
327+
if (conditions && conditions.length > 0) {
313328
// Clear and rebuild routeList based on conditions
314329
routeList.value = []
315330
conditions.forEach((item, index) => {
@@ -336,10 +351,19 @@ const updateRoutingRule = async () => {
336351
loading.value = true
337352
try {
338353
const { ruleName } = route.params
339-
const { version, ruleGranularity, objectOfAction, enable, faultTolerantProtection, runtime } =
340-
baseInfo
354+
const {
355+
version,
356+
ruleGranularity,
357+
objectOfAction,
358+
enable,
359+
faultTolerantProtection,
360+
runtime,
361+
priority,
362+
configVersion
363+
} = baseInfo
341364
const data = {
342-
configVersion: 'v3.0',
365+
configVersion: configVersion || 'v3.0',
366+
priority,
343367
scope: ruleGranularity,
344368
key: objectOfAction,
345369
enabled: enable,

ui-vue3/src/views/traffic/tagRule/tabs/updateByFormView.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,20 @@ const router = useRouter()
251251
252252
onMounted(async () => {
253253
if (!isNil(TAB_STATE.tagRule)) {
254-
const { enabled = true, key, scope, runtime = true, tags } = TAB_STATE.tagRule
254+
const {
255+
configVersion,
256+
priority,
257+
enabled = true,
258+
force = false,
259+
key,
260+
scope,
261+
runtime = true,
262+
tags
263+
} = TAB_STATE.tagRule
264+
baseInfo.configVersion = configVersion
265+
baseInfo.priority = priority
255266
baseInfo.enable = enabled
267+
baseInfo.faultTolerantProtection = force
256268
baseInfo.objectOfAction = key
257269
baseInfo.ruleGranularity = scope
258270
baseInfo.runtime = runtime
@@ -565,10 +577,11 @@ const deleteTagItem = (tagItemIndex: number) => {
565577
const getTagRuleDetail = async () => {
566578
const res = await getTagRuleDetailAPI(route.params?.ruleName as string)
567579
if (res.code === HTTP_STATUS.SUCCESS) {
568-
const { configVersion, enabled, key, runtime, scope, tags } = res.data || {}
580+
const { configVersion, priority, enabled, force, key, runtime, scope, tags } = res.data || {}
569581
baseInfo.configVersion = configVersion
582+
baseInfo.priority = priority
570583
baseInfo.enable = enabled
571-
// baseInfo.faultTolerantProtection =
584+
baseInfo.faultTolerantProtection = force
572585
baseInfo.runtime = runtime
573586
baseInfo.ruleGranularity = scope
574587
baseInfo.objectOfAction = key
@@ -618,7 +631,9 @@ const updateTagRule = async () => {
618631
configVersion,
619632
scope: ruleGranularity,
620633
key: objectOfAction,
634+
priority,
621635
enabled: enable,
636+
force: faultTolerantProtection,
622637
runtime,
623638
tags: []
624639
}

0 commit comments

Comments
 (0)