User last activity
Requested in https://github.com/tolgee/tolgee-platform/issues/2973.
Based on https://github.com/tolgee/tolgee-platform/pull/3238.
Summary by CodeRabbit
-
New Features
- Users list now shows formatted "last activity" with a compact two-column user item and action area.
-
Documentation
- Development guide refined for clarity, formatting, examples and authentication snippets.
-
Chores
- Public user schemas and API responses migrated to an administration-focused user model.
- Administration endpoints now require stricter super-admin access.
- Public LLM prompt endpoint and related schemas removed.
-
Tests
- E2E helpers updated and a test added to verify user last-activity display and date forcing.
Walkthrough
Renames admin user models/assemblers to administration-specific types, adds lastActivity through repository/service/controller/DTOs and frontend schemas, removes a public LLM prompt endpoint and related schemas, refactors admin UI list rendering, and updates E2E tests to assert lastActivity.
Changes
| Cohort / File(s) | Summary |
|---|---|
Model & HATEOAS backend/api/src/main/kotlin/io/tolgee/hateoas/userAccount/UserAccountAdministrationModel.kt, backend/api/src/main/kotlin/io/tolgee/hateoas/userAccount/UserAccountAdministrationModelAssembler.kt, backend/api/src/main/kotlin/io/tolgee/hateoas/userAccount/UserAccountModelAssembler.kt |
Introduced UserAccountAdministrationModel (adds lastActivity) and UserAccountAdministrationModelAssembler (maps UserAccountAdministrationView → model using AvatarService); removed legacy UserAccountModelAssembler. |
DTO & Repository backend/data/src/main/kotlin/io/tolgee/dtos/queryResults/UserAccountAdministrationView.kt, backend/data/src/main/kotlin/io/tolgee/repository/UserAccountRepository.kt |
Added UserAccountAdministrationView (includes lastActivity); findAllWithDisabledPaged now returns Page<UserAccountAdministrationView> and SQL/query produces lastActivity. |
Service & Controller backend/data/src/main/kotlin/io/tolgee/service/security/UserAccountService.kt, backend/api/src/main/kotlin/io/tolgee/api/v2/controllers/administration/AdministrationController.kt |
Service signature updated to use administration view; controller uses administration assemblers/types, returns PagedModel<UserAccountAdministrationModel>, and endpoints gained @RequiresSuperAuthentication where applicable; minor textual fixes. |
Frontend schemas & UI webapp/src/service/apiSchema.generated.ts, webapp/src/websocket-client/WebsocketClient.ts, webapp/src/component/security/UserMenu/MenuHeader.tsx, webapp/src/views/administration/components/*, webapp/src/views/administration/AdministrationUsers.tsx |
Replaced UserAccountModel usages with UserAccountAdministrationModel (schema now includes lastActivity); removed LLM prompt endpoint and schemas (LlmMessage, LlmParams, PromptResult); websocket actor.data switched to SimpleUserAccountModel; admin UI refactored to use AdministrationUserItem. |
E2E tests & helpers e2e/cypress/common/administration.ts, e2e/cypress/e2e/administration/*.ts, e2e/cypress/support/dataCyType.d.ts |
Split/renamed navigation helpers (visitAdministration → visitAdministrationOrganizations, added visitAdministrationUsers), added administration-user-activity data-cy literal, updated selectors, and added test asserting user's lastActivity after forced-date activity. |
Tests backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/administration/AdministrationControllerTest.kt |
Added cleanup for forced date and a test verifying lastActivity is returned and updated after creating project activity. |
Docs DEVELOPMENT.md |
Documentation-only editorial and formatting updates; added examples and minor clarifications. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant Client
participant Controller as AdministrationController
participant Service as UserAccountService
participant Repo as UserAccountRepository
participant Assembler as UserAccountAdministrationModelAssembler
Client->>Controller: GET /v2/administration/users
Controller->>Service: findAllWithDisabledPaged(pageable, search)
Service->>Repo: findAllWithDisabledPaged(pageable, search)
Repo-->>Service: Page<UserAccountAdministrationView> (includes lastActivity)
Service-->>Controller: Page<UserAccountAdministrationView>
Controller->>Assembler: toModel(view) for each item
Assembler-->>Controller: UserAccountAdministrationModel (avatar links, lastActivity)
Controller-->>Client: PagedModel<UserAccountAdministrationModel>
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
- Pay extra attention to:
- Repository query CTE/join producing
lastActivity(correctness, indices, performance). - Assembler mapping (avatar links, nullable role defaulting,
lastActivitypropagation). - Frontend generated types and websocket payload typing changes.
- E2E date-forcing and timing around
lastActivityassertions.
- Repository query CTE/join producing
Possibly related PRs
- tolgee/tolgee-platform#3248 — Modifies AdministrationController and user-account model/assembler logic; closely related to controller/model renames and admin flows.
- tolgee/tolgee-platform#3228 — Overlaps user-account representation and frontend schema/component changes for user models.
Suggested reviewers
- JanCizmar
- ZuzanaOdstrcilova
Poem
🐰 I hopped through lines of code tonight,
I stamped the clock to mark who’s bright.
Admin lists now show the last small race,
Old prompts gone, new timestamps in place.
Hop, review, and nibble on the trace!
Pre-merge checks and finishing touches
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly and concisely summarizes the primary change: implementing user last activity tracking and display throughout the administration interface. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between bcc8011ee4c06d1a05f310399c6fc53403040fc9 and 56ee88f7bdac79ce8d1d0c3f02ad9fb59350aea5.
📒 Files selected for processing (1)
backend/data/src/main/kotlin/io/tolgee/repository/UserAccountRepository.kt(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-07T14:36:39.331Z
Learnt from: Anty0
Repo: tolgee/tolgee-platform PR: 3263
File: backend/data/src/main/kotlin/io/tolgee/service/organization/OrganizationRoleService.kt:279-290
Timestamp: 2025-10-07T14:36:39.331Z
Learning: In OrganizationRoleService in backend/data/src/main/kotlin/io/tolgee/service/organization/OrganizationRoleService.kt, the `removeOrDeactivateUser` method intentionally has two distinct paths: if a user can be removed, it calls `removeUserForReal` (which removes organization roles, project permissions, and evicts caches); if a user is managed by the organization and cannot be removed, it calls `userAccountService.disable(userId)` without any cleanup. This design is intentional—disabling should be reversible so the user stays unmodified (keeping their organization roles and project permissions intact), allowing them to be re-enabled if they return to the organization.
Applied to files:
backend/data/src/main/kotlin/io/tolgee/repository/UserAccountRepository.kt
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 @coderabbitai help to get the list of available commands and usage tips.
The pitch for the missing feature was created: #3304
Once implemented, this PR can be merged.
This PR is stale because it has been open for 30 days with no activity.