Skip to content

(feat) AUDIT-36: add esm-audit-log-app with Carbon DataTable, filters and pagination#267

Open
AshThe25 wants to merge 3 commits into
openmrs:mainfrom
AshThe25:feat/AUDIT-36-audit-log-workspace
Open

(feat) AUDIT-36: add esm-audit-log-app with Carbon DataTable, filters and pagination#267
AshThe25 wants to merge 3 commits into
openmrs:mainfrom
AshThe25:feat/AUDIT-36-audit-log-workspace

Conversation

@AshThe25
Copy link
Copy Markdown

@AshThe25 AshThe25 commented Apr 19, 2026

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. Ensure your PR title includes a conventional commit label (such as feat, fix, or chore, among others). See existing PR titles for inspiration.

If applicable

  • My work includes tests or is validated by existing tests.

Summary

Adds esm-audit-log-app — a new O3 workspace package providing an Audit Log dashboard for OpenMRS administrators.

Features:

  • Carbon DataTable with sortable columns: Date & Time, User, Action, Object Type, Object ID, Child Logs
  • Filter panel: user UUID, action (CREATED/UPDATED/DELETED), start/end date via DatePicker
  • Server-side pagination with configurable page sizes (10/25/50)
  • Action tags colour-coded with Carbon Tag (green/blue/red)
  • Detail modal (AUDIT-45): clicking any row opens a Carbon Modal showing field-level changes (old/new values) and child log entries
  • SWR-based data fetching via useAuditLogs and useAuditLogDetail hooks
  • Lazy-loaded detail modal to keep initial bundle size small

Backend dependency: openmrs-module-auditlog PRs #17 (list endpoint) and #28 (detail endpoint)

Screenshots

N/A — requires running auditlog module backend

Related Issue

https://issues.openmrs.org/browse/AUDIT-36

Other

N/A

@AshThe25
Copy link
Copy Markdown
Author

Backend REST endpoint that powers this workspace:
openmrs/openmrs-module-auditlog#17

@praneeth622
Copy link
Copy Markdown

Nice clean structure. One thing worth confirming: the useSWR key is a URL string, so changing startIndex or limit triggers a fresh fetch as expected, but does the backend cache control header play well with SWR revalidation on focus?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thought: if filters.userUuid is pasted with trailing whitespace the REST call will 404. A .trim() before params.set('user', ...) would save users from a confusing empty result.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — added .trim() on userUuid before setting the URL param.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small UX points on the filters reset flow:

  • handleClearFilters resets page to 1 but does not reset pageSize, which feels inconsistent.
  • DEFAULT_FILTERS uses empty strings for dates, but DatePicker passes undefined when cleared. Worth aligning to avoid a stale "" value sticking in the URL params.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both fixed — handleClearFilters now resets pageSize back to the default alongside page, and changed startDate/endDate type to string|undefined to align with what DatePicker passes when cleared.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filter-by-user takes a raw UUID which is tough for non-admin users. A downstream improvement could be a UserSelect component wired to the existing users REST endpoint, keeping UUID under the hood

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — a UserSelect component would be a good improvement. I've noted it as a follow-up since it would require wiring to the users REST endpoint. Happy to tackle it as a separate PR if that works.

@AshThe25 AshThe25 requested a review from praneeth622 April 20, 2026 17:25
@AshThe25 AshThe25 force-pushed the feat/AUDIT-36-audit-log-workspace branch from efd3e26 to 5fc1d1f Compare April 20, 2026 18:06
@AshThe25 AshThe25 changed the title feat(AUDIT-36): add esm-audit-log-app package with Carbon DataTable a… (feat) AUDIT-36: add esm-audit-log-app with Carbon DataTable, filters and pagination Apr 20, 2026
@AshThe25
Copy link
Copy Markdown
Author

@praneeth622 Good catch. SWR's default revalidateOnFocus will re-fetch the current URL when the window regains focus. The auditlog REST endpoint doesn't set any Cache-Control headers today, so the browser won't cache the response and SWR will always hit the server on revalidation — which is the correct behaviour for an audit log dashboard (you want fresh data after switching tabs).

If we wanted to suppress unnecessary revalidation we could pass { revalidateOnFocus: false } to useSWR, but for an admin tool that's used infrequently I think the default is fine. Happy to add that option if you think it's worth it.

…, pagination and detail modal

Adds a new esm-audit-log-app workspace package for OpenMRS administrators.

- Carbon DataTable with sortable columns: Date/Time, User, Action, Object Type, Object ID, Child Logs
- Filter panel: user UUID, action (CREATED/UPDATED/DELETED), start/end date via DatePicker
- Server-side pagination with configurable page sizes (10/25/50)
- Action tags colour-coded with Carbon Tag (green/blue/red)
- Detail modal (AUDIT-45): clicking any row opens a Modal with field-level changes and child log entries
- SWR-based data fetching via useAuditLogs and useAuditLogDetail hooks
- Lazy-loaded detail modal to keep initial bundle size small

Depends on openmrs-module-auditlog PRs openmrs#17 and openmrs#28.
@AshThe25 AshThe25 force-pushed the feat/AUDIT-36-audit-log-workspace branch from 52a4bbe to 9027226 Compare April 21, 2026 03:06
@AshThe25
Copy link
Copy Markdown
Author

@praneeth622 squashed down to a single clean commit now — let me know if anything else needs addressing before this can move forward.

@praneeth622
Copy link
Copy Markdown

@AshThe25 thanks for the turnaround. All three inline threads look resolved on my end. The .trim(), the clear-filters pageSize reset, and the string|undefined date typing all match what I had in mind. On the SWR question, agreed that the default revalidateOnFocus is the right call for an audit surface where fresh-on-focus is actually desirable. UserSelect as a follow-up PR sounds good. Nothing else pending from me.

@AshThe25
Copy link
Copy Markdown
Author

@jayasanka all of @praneeth622's review comments have been resolved — .trim() on userUuid, pageSize reset on clear-filters, and string|undefined date typing are all in. Single clean commit. Would you be able to take a look when you get a chance?

@AshThe25
Copy link
Copy Markdown
Author

@AshThe25 thanks for the turnaround. All three inline threads look resolved on my end. The .trim(), the clear-filters pageSize reset, and the string|undefined date typing all match what I had in mind. On the SWR question, agreed that the default revalidateOnFocus is the right call for an audit surface where fresh-on-focus is actually desirable. UserSelect as a follow-up PR sounds good. Nothing else pending from me.

will be greatful if u assist then to merge it up

@AshThe25
Copy link
Copy Markdown
Author

@jayasanka all of @praneeth622's review comments are resolved and he's cleared everything on his end. Would you be able to take a look when you get a chance?

@AshThe25
Copy link
Copy Markdown
Author

@denniskigen would you be able to take a look at this when you get a chance? All of @praneeth622's review comments have been resolved.

@AshThe25 AshThe25 force-pushed the feat/AUDIT-36-audit-log-workspace branch from cc1d299 to 9027226 Compare April 21, 2026 18:15
@AshThe25
Copy link
Copy Markdown
Author

@denniskigen now that #725 and #729 are in, wanted to flag #267 again — this is the audit log frontend app that the form-engine work feeds into. @praneeth622 has cleared all review comments. Would appreciate a look when you get a chance.

@AshThe25
Copy link
Copy Markdown
Author

@denniskigen would love your review on this when you get a chance! This adds the full Audit Log frontend app to esm-admin-tools — Carbon DataTable with filters, pagination, and workspace integration. All of @praneeth622's review comments have been resolved. Happy to address any feedback. Thanks!

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.

2 participants