Skip to content

fix(usage-logs, users): 修复日志列样式和用户组选择器问题 - #5120

Open
GnezIew wants to merge 1 commit into
QuantumNous:mainfrom
GnezIew:feat-lazy-load-groups
Open

GnezIew wants to merge 1 commit into
QuantumNous:mainfrom
GnezIew:feat-lazy-load-groups

Conversation

@GnezIew

@GnezIew GnezIew commented May 26, 2026 •

Copy link
Copy Markdown
Contributor
  • 为使用日志公共列的样式添加undefined兜底值'neutral',避免样式渲染报错
  • 优化用户编辑抽屉的群组查询逻辑,改为打开选择器时再拉取数据,修复选项不显示问题

⚠️ 提交说明 / PR Notice

Important

  • 给管理员用户模块中编辑用户分组,增加了点击分组获取实时分组列表功能

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
管理员用户模块中,编辑用户时的「分组」下拉选择器在抽屉打开时即自动请求 /api/group 接口获取分组列表。现在改为 仅在用户点击展开下拉列表时 才发起请求,通过 Select 组件的 onOpenChange 回调,在 isOpen === true 时触发 refetch() ,收起时不调用。同时修正了接口地址去掉尾部多余的 / 。

附带修复了一个与本需求无关的 TypeScript 编译错误:日志列表 timing 列中 frtVariant 可能为 null ,作为 timingBgMap 索引会导致类型报错,补充了 'neutral' fallback。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • [✅] ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • [✅] ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • [✅] 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • [✅] 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • [✅] Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • [✅] 变更理解: 我已理解这些更改的工作原理及可能影响。
  • [✅] 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • [✅] 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • [✅] 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
e84133679c0e7ded17eb95c77519c0de

Summary by CodeRabbit

  • Bug Fixes

    • Fixed styling inconsistency in the Timing column's first-response-time badge when variant data is unavailable.
  • Improvements

    • Groups list now loads on-demand when opening the group selection dropdown, improving initial performance.

Review Change Stack

- 为使用日志公共列的样式添加undefined兜底值'neutral',避免样式渲染报错
- 优化用户编辑抽屉的群组查询逻辑,改为打开选择器时再拉取数据,修复选项不显示问题
@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4c5415d5-c8c0-481c-b7d1-8faa67ab7201

📥 Commits

Reviewing files that changed from the base of the PR and between 65f8afe and 39e84e7.

📒 Files selected for processing (2)
  • web/default/src/features/usage-logs/components/columns/common-logs-columns.tsx
  • web/default/src/features/users/components/users-mutate-drawer.tsx

Walkthrough

Two independent improvements: a defensive styling fallback for timing badges with missing variants, and a lazy-loading refactor that fetches user groups only when the dropdown is opened instead of on component mount.

Changes

UI improvements and data fetching optimization

Layer / File(s) Summary
Timing badge fallback styling
web/default/src/features/usage-logs/components/columns/common-logs-columns.tsx
Stream first-response-time badge now uses neutral as fallback in the className lookup when frtVariant is null or undefined.
Lazy-load groups on demand
web/default/src/features/users/components/users-mutate-drawer.tsx
Groups query starts disabled and derives from query result; refetch() is triggered when the Group Select dropdown opens to load groups on demand.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit sees two tiny fixes blend,
one styling badge that needs defend,
another query waits on user's call—
lazy loads when dropdowns sprawl! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is in Chinese and uses technical terms, but it references fixing issues in 'usage-logs' and 'users' components which directly matches the two files changed in this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant