Skip to content

Commit d2a6ddc

Browse files
committed
fix(ui): version-conflict on add + drop double-confirm on rollback
dynamicConfig save dispatched the add branch through .then/.catch while the update branch used await + notifyRuleVersionError. The add branch printed 'e.msg' (undefined; the field is e.message) and never surfaced VERSION_CONFLICT / VERSION_LEDGER_PENDING — the request.ts interceptor silently swallows those codes since the unified handler is supposed to take them. Switch the add branch to await + try/catch so the outer notifyRuleVersionError catches conflicts on add too. Also remove the popconfirm around the history-drawer Rollback button. The parent panel already opens a Rollback modal where the user supplies the required reason; the popconfirm asked "确认回滚到 该版本?" before the reason form, splitting confirmation across two prompts. The disabled state for delete/current versions is preserved.
1 parent d498de1 commit d2a6ddc

3 files changed

Lines changed: 17 additions & 29 deletions

File tree

ui-vue3/src/views/traffic/_shared/RuleHistoryDrawer.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@
5454
<a-space>
5555
<a-button type="link" @click="$emit('view-json', item)">查看</a-button>
5656
<a-button type="link" @click="$emit('diff-current', item)">对比当前</a-button>
57-
<a-popconfirm
58-
v-if="canRollback(item)"
59-
title="确认回滚到该版本?"
60-
@confirm="$emit('rollback', item)"
57+
<a-button
58+
type="link"
59+
:disabled="!canRollback(item)"
60+
@click="canRollback(item) && $emit('rollback', item)"
61+
>回滚</a-button
6162
>
62-
<a-button type="link">回滚</a-button>
63-
</a-popconfirm>
64-
<a-button v-else type="link" disabled>回滚</a-button>
6563
</a-space>
6664
</div>
6765
</a-timeline-item>

ui-vue3/src/views/traffic/dynamicConfig/tabs/YAMLView.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,14 @@ async function saveConfig() {
172172
let data = yaml.load(YAMLValue.value)
173173
try {
174174
if (viewData.isAdd === true) {
175-
addConfiguratorDetail({ name: viewData.basicInfo.key + '.configurators' }, data, {
175+
await addConfiguratorDetail({ name: viewData.basicInfo.key + '.configurators' }, data, {
176176
expectedVersionId: currentVersionId.value
177177
})
178-
.then((res) => {
179-
TAB_STATE.dynamicConfigForm.data = null
180-
nextTick(() => {
181-
router.replace('/traffic/dynamicConfig')
182-
message.success('config add success')
183-
})
184-
})
185-
.catch((e) => {
186-
message.error('添加失败: ' + e.msg)
187-
})
178+
TAB_STATE.dynamicConfigForm.data = null
179+
nextTick(() => {
180+
router.replace('/traffic/dynamicConfig')
181+
message.success('config add success')
182+
})
188183
return
189184
}
190185
await saveConfiguratorDetail({ name: pathId.value }, data, {

ui-vue3/src/views/traffic/dynamicConfig/tabs/formView.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -629,19 +629,14 @@ async function saveConfig() {
629629
try {
630630
let data = formViewEdit.toApiInput(true)
631631
if (formViewData.isAdd === true) {
632-
addConfiguratorDetail({ name: formViewEdit.basicInfo.key + '.configurators' }, data, {
632+
await addConfiguratorDetail({ name: formViewEdit.basicInfo.key + '.configurators' }, data, {
633633
expectedVersionId: currentVersionId.value
634634
})
635-
.then((res) => {
636-
TAB_STATE.dynamicConfigForm.data = null
637-
nextTick(() => {
638-
router.replace('/traffic/dynamicConfig')
639-
message.success('config add success')
640-
})
641-
})
642-
.catch((e) => {
643-
message.error('添加失败: ' + e.msg)
644-
})
635+
TAB_STATE.dynamicConfigForm.data = null
636+
nextTick(() => {
637+
router.replace('/traffic/dynamicConfig')
638+
message.success('config add success')
639+
})
645640
return
646641
}
647642
await saveConfiguratorDetail({ name: pathId.value }, data, {

0 commit comments

Comments
 (0)