feat(config): add payload disable controls to the visual editor#209
feat(config): add payload disable controls to the visual editor#209xwil1 wants to merge 2 commits intorouter-for-me:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to disable specific payload rules and parameters within the visual configuration editor. Key changes include updates to the data models and YAML serialization/deserialization logic to support a disabled-params field, alongside UI enhancements such as disabled state styling, toggle buttons, and status badges. The PR also prevents switching to the source tab when validation errors exist and adds comprehensive tests for the new functionality. Review feedback focuses on reducing CSS duplication by consolidating identical badge styles.
| .payloadParamStateBadge { | ||
| display: inline-flex; | ||
| align-items: center; | ||
| min-height: 24px; | ||
| padding: 0 10px; | ||
| border-radius: 999px; | ||
| border: 1px solid var(--warning-border); | ||
| background: var(--warning-bg); | ||
| color: var(--warning-text); | ||
| font-size: 11px; | ||
| font-weight: 700; | ||
| letter-spacing: 0.04em; | ||
| } |
| > | ||
| {itemDisabled ? ( | ||
| <div className={styles.payloadParamStateRow}> | ||
| <span className={styles.payloadParamStateBadge}> |
| > | ||
| {paramDisabled ? ( | ||
| <div className={styles.payloadParamStateRow}> | ||
| <span className={styles.payloadParamStateBadge}> |
Expose persisted disable toggles for payload rules, params, and filter entries so iterative payload debugging can happen without repeatedly deleting and rebuilding test rules in YAML.
4e25170 to
bdbbbd1
Compare
LTbinglingfeng
left a comment
There was a problem hiding this comment.
这版我先给 Request changes,有一个我认为会影响该功能目标的阻塞点。
src/pages/ConfigPage.tsx现在在切换到sourcetab 时,只要存在 payload 校验错误就直接拦截;同时src/hooks/useVisualConfig.ts的hasPayloadParamValidationErrors()仍然把 disabled rule / disabled param 里的非法值当成阻塞错误。
这和 PR 描述里的目标不一致。这个 PR 的核心卖点是“把实验性 payload 规则保留在 YAML 里,但临时禁用,不需要反复删除/重建”。按现在的实现,用户一旦把一个未完成或暂时无效的参数标成 disabled,仍然会被卡住:既不能正常走可视化保存,也不能切回 source tab 手工修 YAML。实际体验上相当于“看起来支持 disabled,实际上 disabled 仍然不能脱离校验约束”。
我建议至少保证其中一条成立:
- disabled 项不参与这类前端阻塞校验;或
- 即使继续校验,也不要阻止用户切回
sourcetab 进行手工修复。
如果后端语义明确要求 disabled 项也必须始终合法,那也建议把前端文案和交互重新收紧,不然当前行为和这个 PR 的功能描述是冲突的。
其余像样式复用/测试接线之类的问题我认为都不是这轮的主要 blocker,先把这个行为语义理顺更重要。
|
@LTbinglingfeng 感谢指出,这个 blocker 已在 这次按你建议走了“disabled 项不参与前端阻塞校验”这条语义:
已复核:
另外后端 PR |
Summary
Backend dependency
The matching backend support has already been submitted in router-for-me/CLIProxyAPI#2741.
This UI change can wait for backend feedback first if you prefer to review the behavior end-to-end after the backend shape is confirmed.
Why
The backend now supports keeping experimental payload rules in YAML while temporarily ignoring them. This frontend PR exposes that workflow directly in the management UI so debugging no longer requires repeatedly deleting and rebuilding test rules.
UI changes
启用/禁用)Local validation
npm run type-checknpm run buildsrc/hooks/useVisualConfig.test.ts