feat(web): open user editor from user and log tables#3411
feat(web): open user editor from user and log tables#3411MisonL wants to merge 6 commits intoQuantumNous:mainfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughReplaces the read-only user-info modal with an editable user panel across task-logs, usage-logs, and users tables. Callback renamed from Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant Table as Table (columns)
participant Hook as Hook (useLogsData / useTaskLogsData)
participant Modal as EditUserModal
participant API as API
User->>Table: click username/avatar
Table->>Hook: openEditUserPanel(userId)
Hook-->>Table: set editingUser, showEditUser = true
Hook->>Modal: visible=true, editingUser.id
Modal->>API: fetch user data (loadUser)
API-->>Modal: return user data
Modal->>User: render editable user form
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/src/components/table/task-logs/index.jsx`:
- Around line 55-60: Editing a user triggers taskLogsData.refresh which
currently reloads page 1; when rendering EditUserModal pass a refresh handler
that preserves the current page instead of the default reset—e.g., wire
EditUserModal's refresh prop to a wrapper that calls taskLogsData.refresh with
the current page (or call a new taskLogsData.refreshCurrentPage helper exposed
by useTaskLogsData) so saving in EditUserModal (editingUser / showEditUser)
reloads the same page rather than jumping back to page one.
In `@web/src/components/table/task-logs/TaskLogsColumnDefs.jsx`:
- Around line 304-325: The click handler currently calls event.stopPropagation()
unconditionally in handleOpen, preventing row clicks even when the user panel
shouldn’t open; update handleOpen (or the onClick props on Avatar and
Typography.Text) so that either (a) handleOpen returns immediately if !canOpen
and only calls event.stopPropagation() when canOpen is true, or (b) only attach
onClick handlers when canOpen is true; locate handleOpen, canOpen,
openEditUserPanel(record.user_id), Avatar and Typography.Text in
TaskLogsColumnDefs.jsx to make the change.
In `@web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx`:
- Around line 579-601: The cell click handler handleOpen always calls
event.stopPropagation(), preventing row clicks from propagating for deleted
users; update handleOpen (used by Avatar and Typography.Text) to only call
event.stopPropagation() when canOpen is true (i.e., record.user_id exists) and
otherwise allow the event to bubble so row expansion works; keep the early
return for the non-openable case and still call
openEditUserPanel(record.user_id) when canOpen.
In `@web/src/components/table/users/modals/EditUserModal.jsx`:
- Around line 118-145: The initialize function can leave stale form values when
loadUser fails or returns success: false; ensure the form is cleared to initial
state before attempting to load a different user and also on any
non-success/failure path by calling
formApiRef.current?.setValues(getInitValues()) (or a shallow reset using
getInitValues() merged with the new currentUserId if needed) immediately prior
to calling loadUser and again in the !success and catch branches; update
initialize and its error/non-success handling so form state is reset reliably
(references: initialize, loadUser, formApiRef, setValues, getInitValues,
currentUserId).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9891a950-b41a-4197-a359-730ae925eb74
📒 Files selected for processing (14)
web/src/components/table/task-logs/TaskLogsColumnDefs.jsxweb/src/components/table/task-logs/TaskLogsTable.jsxweb/src/components/table/task-logs/index.jsxweb/src/components/table/task-logs/modals/ColumnSelectorModal.jsxweb/src/components/table/usage-logs/UsageLogsColumnDefs.jsxweb/src/components/table/usage-logs/UsageLogsTable.jsxweb/src/components/table/usage-logs/index.jsxweb/src/components/table/usage-logs/modals/ColumnSelectorModal.jsxweb/src/components/table/usage-logs/modals/UserInfoModal.jsxweb/src/components/table/users/UsersColumnDefs.jsxweb/src/components/table/users/UsersTable.jsxweb/src/components/table/users/modals/EditUserModal.jsxweb/src/hooks/task-logs/useTaskLogsData.jsweb/src/hooks/usage-logs/useUsageLogsData.jsx
💤 Files with no reviewable changes (1)
- web/src/components/table/usage-logs/modals/UserInfoModal.jsx
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/src/components/table/users/modals/EditUserModal.jsx`:
- Around line 107-111: The problem is that loadUser() is called after
fetchGroups() completes even if the target changed, and loadUser() immediately
sets loading which can leave the modal stuck; fix by short-circuiting stale
calls: when starting initialize()/fetchGroups() create an abort token or a local
"currentRequestId" (or use a mounted boolean) and check it before calling
loadUser(currentUserId) and before setting state inside loadUser; update
loadUser and initialize to accept or reference that token and bail early
(return) if the token indicates the request is no longer current so stale
responses never flip loading/state for a newer target.
In `@web/src/hooks/usage-logs/useUsageLogsData.jsx`:
- Around line 776-780: The refresh helper currently always calls handleEyeClick
which reopens stats; change refresh to accept an optional flag (e.g.,
refreshStats = true) and only call handleEyeClick when refreshStats is true,
keeping setActivePage and await loadLogs(page, pageSize) unchanged; update the
EditUserModal.submit call site to invoke refresh(page, { refreshStats: false }
or refresh(page, false) depending on your chosen param shape so saving a user
only refreshes the table and does not open stats.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 66d796aa-31b3-4958-86b0-73d29bfac73a
📒 Files selected for processing (7)
web/src/components/table/task-logs/TaskLogsColumnDefs.jsxweb/src/components/table/task-logs/index.jsxweb/src/components/table/usage-logs/UsageLogsColumnDefs.jsxweb/src/components/table/usage-logs/index.jsxweb/src/components/table/users/modals/EditUserModal.jsxweb/src/hooks/task-logs/useTaskLogsData.jsweb/src/hooks/usage-logs/useUsageLogsData.jsx
✅ Files skipped from review due to trivial changes (2)
- web/src/components/table/task-logs/index.jsx
- web/src/components/table/usage-logs/index.jsx
🚧 Files skipped from review as they are similar to previous changes (3)
- web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx
- web/src/components/table/task-logs/TaskLogsColumnDefs.jsx
- web/src/hooks/task-logs/useTaskLogsData.js
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/src/hooks/usage-logs/useUsageLogsData.jsx`:
- Around line 333-335: The current validation uses a falsy check on userId which
incorrectly rejects numeric zero; update the check in useUsageLogsData.jsx
(where userId is validated) to only treat null or undefined as missing rather
than any falsy value — replace the '!userId' condition with a
null/undefined-specific check so valid IDs like 0 are allowed, and keep the
existing showError(t('用户信息缺失')) and early return behavior unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2b71684f-dd92-4132-9184-3a53dbd9817b
📒 Files selected for processing (2)
web/src/components/table/usage-logs/index.jsxweb/src/hooks/usage-logs/useUsageLogsData.jsx
CodeRabbit follow-up fixes已补充修复 usage logs 中的 refresh 行为:
已验证:
commit: |
CodeRabbit follow-up fixes补充处理了新增的
已验证:
commit: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/src/hooks/usage-logs/useUsageLogsData.jsx`:
- Around line 776-779: The change made `refresh(page = activePage, ...)` causes
calls to refresh() (e.g., from UsageLogsFilters.jsx filter reset) to inherit the
current activePage instead of resetting to page 1; revert to a
backward-compatible behavior by changing the refresh signature to treat an
omitted page as request to reset to page 1 (for example use page = undefined or
no default and inside refresh set page = (page === undefined ? 1 : page)),
update logic in the refresh function (useUsageLogsData.jsx -> refresh) to set
page to 1 when page is undefined, and keep calls that pass an explicit page
unaffected.
- Around line 329-339: openEditUserPanel correctly passes id: 0 but
EditUserModal determines edit mode using Boolean(userId), which treats 0 as
false; update the modal's edit detection (in EditUserModal.jsx around the
component's mode logic) to check for id !== null && id !== undefined (or use
typeof id !== 'undefined' && id !== null) instead of Boolean(userId), or
alternatively accept an explicit flag (e.g., isEdit) from setEditingUser —
adjust the code path that reads the prop (userId / editingUser.id) so a valid id
of 0 is recognized as edit mode.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5f50f45d-00a5-4bd1-813b-16e9a6d25446
📒 Files selected for processing (1)
web/src/hooks/usage-logs/useUsageLogsData.jsx
CodeRabbit follow-up fixes补充收口了这轮新增的两个 follow-up 问题:
已验证:
commit: |
ac584df to
ea7a437
Compare
📝 变更描述 / Description
/api/user/self请求或覆盖目标用户数据。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
git diff --checkbunx eslint src/components/table/users/UsersColumnDefs.jsx src/components/table/users/UsersTable.jsx src/components/table/users/modals/EditUserModal.jsx src/hooks/usage-logs/useUsageLogsData.jsx src/components/table/usage-logs/UsageLogsTable.jsx src/components/table/usage-logs/UsageLogsColumnDefs.jsx src/components/table/usage-logs/index.jsx src/hooks/task-logs/useTaskLogsData.js src/components/table/task-logs/TaskLogsTable.jsx src/components/table/task-logs/TaskLogsColumnDefs.jsx src/components/table/task-logs/index.jsxbun run build