fix(web/default): api-info save silently fails when color is invalid or result unchecked - #4823
Conversation
Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR adds slate as a valid console color in validation logic and refactors the API settings save handler to conditionally reset state based on mutation success, removing its success toast notification in favor of error-only toast behavior. ChangesSettings Updates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Calcium-Ion
left a comment
There was a problem hiding this comment.
Approving. Two correct fixes:
handleSaveAllnow checksresult.successfrommutateAsyncbefore clearing dirty state and showing the success toast, so backend{ success: false, ... }responses no longer silently look successful.- Backend
setting/console_setting/validation.gogainsslateinvalidColors, matching the frontend color options (also added in #4824).
Recommend landing after #4824 so the frontend and backend slate additions ship together.
…uantumNous#4823) Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
…uantumNous#4823) Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
Sync upstream QuantumNous/new-api, backend parts only: - QuantumNous#4871 (b397c58): add register_enabled/password_register_enabled to GetStatus so the login page can react to admin registration toggle - QuantumNous#4823 (032993e): add "slate" to validColors so it is not rejected Skipped the web/default (new UI) frontend parts of both commits.
…uantumNous#4823) Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
…uantumNous#4823) Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
…uantumNous#4823) Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
问题描述
系统管理 → 内容 → API 地址页面,添加条目后点击「保存设置」,提示保存成功,但刷新页面后新添加的条目消失。
根本原因
问题一:前端不检查后端返回值
handleSaveAll使用mutateAsync但不检查返回的success字段:当后端返回
{ success: false, message: ... }时(HTTP 200),mutateAsync不会 throw,catch 块不触发,用户看到保存成功但数据实际未写入。问题二:
slate颜色不在后端白名单前端颜色选项包含
slate,但后端validColors白名单不包含slate,导致选择slate颜色时后端校验失败返回success: false,触发上述问题一。修复方案
handleSaveAll检查result.success,只有成功时才清除hasChanges标记(错误提示已由useUpdateOption的onSuccess统一处理)validColors白名单加入slate,与前端颜色选项保持一致影响范围
Signed-off-by: Micah-Zheng 102610064+Micah-Zheng@users.noreply.github.com
Summary by CodeRabbit
New Features
Bug Fixes