Skip to content

Conversation

@syntrydy
Copy link
Contributor

@syntrydy syntrydy commented Dec 9, 2025

#2508
Closes #2508

Summary by CodeRabbit

  • New Features
    • Rebuilt Audit Logs page with search, pattern/date-range filters, page-size controls, refresh action, and clearer loading/empty/error states.
  • Localization
    • Added/enhanced English, Spanish, French, and Portuguese UI strings for audit messages, pagination, refresh, and date-validation feedback.
  • Refactor
    • Replaced legacy audit wiring with a consolidated, type-safe UI implementation and streamlined data handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@syntrydy syntrydy self-assigned this Dec 9, 2025
@syntrydy syntrydy requested a review from duttarnab as a code owner December 9, 2025 03:25
@syntrydy syntrydy added comp-admin-ui Component affected by issue or PR comp-docker-admin-ui Component affected by issue or PR labels Dec 9, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 9, 2025

📝 Walkthrough

Walkthrough

Replaces the JS/Redux audit implementation with a TypeScript hook-based AuditListPage: removes audit Redux slice, saga, and API wrapper; adds a TSX AuditListPage, type definitions, and new localization keys across en/es/fr/pt locales.

Changes

Cohort / File(s) Summary
Translations
admin-ui/app/locales/en/translation.json, admin-ui/app/locales/es/translation.json, admin-ui/app/locales/fr/translation.json, admin-ui/app/locales/pt/translation.json
Added audit-related UI keys (e.g., actions.refresh, actions.add_custom_attributes, fields.log_entry, fields.page_size, and multiple messages.* like error_loading_data, try_again_later, no_data, adjust_filters, audit_description, showing_entries, start_date_after_end, both_dates_required).
Redux removal
admin-ui/app/redux/reducers/index.ts, admin-ui/plugins/admin/plugin-metadata.ts, admin-ui/plugins/admin/redux/api/AuditApi.js, admin-ui/plugins/admin/redux/features/auditSlice.js, admin-ui/plugins/admin/redux/sagas/AuditSaga.js
Deleted the audit Redux slice, saga, and API wrapper; removed imports/registrations of auditReducer and auditSaga from reducers and plugin metadata.
Component migration & types
admin-ui/plugins/admin/components/Audit/AuditListPage.js (deleted), admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (added), admin-ui/plugins/admin/components/Audit/types/index.ts (added)
Removed JS AuditListPage and added a TypeScript AuditListPage using hook-based data fetching, pagination, date/filter validation, loading/empty/error states, and MaterialTable rendering; introduced AuditRow and AuditSearchProps TypeScript interfaces.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant UI as AuditListPage (TSX)
    participant Hook as useGetAuditData (TS hook / Generated client)
    participant Server as Audit Data API
    Note over UI,Hook: User enters filters / triggers search
    UI->>Hook: request audit data (pattern,start,end,limit,offset,token)
    Hook->>Server: GET /audit-data (with token)
    alt 200 OK
        Server-->>Hook: audit entries + totals
        Hook-->>UI: parsed response
        UI->>UI: render table, update pagination
    else 401 / token expired
        Server-->>Hook: 401
        Hook->>Hook: refresh token (internal helper)
        Hook->>Server: retry GET with refreshed token
        Server-->>Hook: audit entries
        Hook-->>UI: parsed response
    else Error
        Server-->>Hook: error
        Hook-->>UI: error -> show error message
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30–40 minutes

  • Areas needing extra attention:
    • New AuditListPage.tsx: data-fetch logic, pagination and query param construction, date validation and UI states.
    • Removed saga/slice/api: search for residual references elsewhere in codebase.
    • Type definitions: ensure compatibility with generated TypeScript client responses and hooks.
    • Translation keys: verify interpolation placeholders and pluralization where used.

Possibly related issues

  • #2508: Matches objective — replaces hand-written JS types and Redux artifacts for Audit pages with TypeScript-generated client and removes redux/api/features/saga.
  • GluuFederation/flex#2501: Similar refactor pattern removing Redux API/features/sagas and migrating to TypeScript-generated components/types; likely related effort.

Possibly related PRs

  • GluuFederation/flex#2412: Also removes legacy Redux API/feature/saga modules and replaces JS UI/clients with TypeScript-based hooks/components — strong code-level relation.

Suggested reviewers

  • duttarnab
  • moabu

Poem

🐰 New hooks hop in with gentle cheer,
Old sagas wandered out of here.
Translations sprout in every tongue,
Types keep logs from hopping wrong,
A tidy burrow for audit cheer! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: migrating Audit pages to use TypeScript-generated client instead of manual types.
Linked Issues check ✅ Passed The PR successfully addresses both objectives from #2508: replaced manual types with TypeScript-generated client types and removed Redux code (api, features, saga folders).
Out of Scope Changes check ✅ Passed All changes align with the stated objectives. Translation file updates support the new UI implementation, and the AuditListPage rewrite uses the new client architecture.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch admin-ui-2508

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5b0552 and 0e08eb5.

📒 Files selected for processing (4)
  • admin-ui/app/locales/fr/translation.json (4 hunks)
  • admin-ui/app/locales/pt/translation.json (4 hunks)
  • admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Audit/types/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-07T12:55:26.241Z
Learnt from: kdhttps
Repo: GluuFederation/flex PR: 2378
File: admin-ui/plugins/admin/components/Cedarling/CedarlingConfigPage.tsx:93-104
Timestamp: 2025-11-07T12:55:26.241Z
Learning: In the Cedarling configuration feature (admin-ui/plugins/admin/components/Cedarling/CedarlingConfigPage.tsx), the sync role to scopes mappings operation depends on the `auiPolicyStoreUrl`. The backend fetches content from this URL and syncs roles based on the response. Therefore, the audit log for the sync operation should include the `auiPolicyStoreUrl` in its payload to provide proper audit context.

Applied to files:

  • admin-ui/plugins/admin/components/Audit/AuditListPage.tsx
  • admin-ui/plugins/admin/components/Audit/types/index.ts
📚 Learning: 2025-11-26T12:25:34.923Z
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2475
File: admin-ui/plugins/auth-server/components/Clients/ClientDetailPage.js:111-216
Timestamp: 2025-11-26T12:25:34.923Z
Learning: In the admin-ui codebase, avoid suggesting comments for small functionalities or straightforward layout decisions in smaller components. Comments should be reserved for more complex or non-obvious logic.

Applied to files:

  • admin-ui/plugins/admin/components/Audit/AuditListPage.tsx
🔇 Additional comments (4)
admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (1)

298-315: Search filter logic, query param construction, and row parsing look solid

  • Date/pattern validation in filters/isSearchDisabled is consistent with the UI messages for invalid ranges and single-date cases.
  • buildQueryParams correctly builds GetAuditDataParams for pattern-only and date-range searches and is reused across search, paging, and page-size changes.
  • auditRows pre-parses timestamp and content from the raw log string once, and the table render uses those fields instead of re-running the regex.

No functional issues spotted in these areas.

Also applies to: 338-364, 441-456, 463-507

admin-ui/app/locales/pt/translation.json (1)

124-174: Portuguese audit translations align with new UI keys

The added actions, fields.log_entry / fields.page_size, and messages.* entries cover all strings used by the new Audit page and are correctly placed under the messages namespace (not titles). JSON structure looks valid.

Also applies to: 664-668, 795-803

admin-ui/app/locales/fr/translation.json (1)

126-176: French audit translations are complete and correctly namespaced

New actions, fields, and messages entries for the Audit page are present, linguistically consistent, and match the keys referenced in the component. This also resolves the earlier gap for actions.add_custom_attributes.

Also applies to: 671-673, 800-808

admin-ui/plugins/admin/components/Audit/types/index.ts (1)

1-22: Audit TypeScript interfaces match current usage

AuditRow and AuditSearchProps exactly mirror how AuditListPage and AuditSearch construct and consume data/props (including timestamp and content now being populated). No adjustments needed.


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.

@mo-auto mo-auto added the kind-bug Issue or PR is a bug in existing functionality label Dec 9, 2025
@syntrydy syntrydy changed the title fix(admin-ui): Use typescript generated client on Audit pages #2508 fix(admin-ui): Use typescript generated client on Audit pages Dec 9, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bc7864 and c84cf3a.

📒 Files selected for processing (12)
  • admin-ui/app/locales/en/translation.json (6 hunks)
  • admin-ui/app/locales/es/translation.json (6 hunks)
  • admin-ui/app/locales/fr/translation.json (3 hunks)
  • admin-ui/app/locales/pt/translation.json (3 hunks)
  • admin-ui/app/redux/reducers/index.ts (0 hunks)
  • admin-ui/plugins/admin/components/Audit/AuditListPage.js (0 hunks)
  • admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Audit/types/index.ts (1 hunks)
  • admin-ui/plugins/admin/plugin-metadata.ts (1 hunks)
  • admin-ui/plugins/admin/redux/api/AuditApi.js (0 hunks)
  • admin-ui/plugins/admin/redux/features/auditSlice.js (0 hunks)
  • admin-ui/plugins/admin/redux/sagas/AuditSaga.js (0 hunks)
💤 Files with no reviewable changes (5)
  • admin-ui/plugins/admin/components/Audit/AuditListPage.js
  • admin-ui/plugins/admin/redux/api/AuditApi.js
  • admin-ui/plugins/admin/redux/sagas/AuditSaga.js
  • admin-ui/plugins/admin/redux/features/auditSlice.js
  • admin-ui/app/redux/reducers/index.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-07T12:55:26.241Z
Learnt from: kdhttps
Repo: GluuFederation/flex PR: 2378
File: admin-ui/plugins/admin/components/Cedarling/CedarlingConfigPage.tsx:93-104
Timestamp: 2025-11-07T12:55:26.241Z
Learning: In the Cedarling configuration feature (admin-ui/plugins/admin/components/Cedarling/CedarlingConfigPage.tsx), the sync role to scopes mappings operation depends on the `auiPolicyStoreUrl`. The backend fetches content from this URL and syncs roles based on the response. Therefore, the audit log for the sync operation should include the `auiPolicyStoreUrl` in its payload to provide proper audit context.

Applied to files:

  • admin-ui/plugins/admin/components/Audit/AuditListPage.tsx
🧬 Code graph analysis (1)
admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (2)
admin-ui/app/customColors.ts (1)
  • customColors (4-25)
admin-ui/plugins/admin/components/Audit/types/index.ts (2)
  • AuditSearchProps (11-24)
  • AuditRow (3-9)
🔇 Additional comments (6)
admin-ui/plugins/admin/plugin-metadata.ts (2)

200-205: Route configuration correctly preserved.

The AuditListPage route remains properly configured with appropriate permissions and resource keys. This is correct since the PR refactors the implementation from Redux to TypeScript hooks while preserving the feature.


207-216: LGTM! Clean removal of audit Redux infrastructure.

The audit reducer and saga have been correctly removed from the plugin configuration. The remaining reducers and sagas for other features are properly configured. The removed Redux files (auditSlice.js and AuditSaga.js) are deleted from the codebase, and the new AuditListPage is properly using the JansConfigApi instead of Redux infrastructure.

admin-ui/app/locales/es/translation.json (1)

64-65: Translation keys appropriately added to support audit feature.

All new entries follow the existing structure and are semantically correct for the audit pages' functional needs (pagination, date validation, filtering guidance, error handling). Spanish translations maintain proper grammar and preserve template placeholders for dynamic values.

Also applies to: 170-170, 180-180, 779-780, 801-803, 829-830, 834-834

admin-ui/app/locales/en/translation.json (2)

64-65: English translation keys are appropriate and consistent with Spanish equivalents.

All new additions match the structure and intent of the Spanish translations. Messages use clear, idiomatic English suitable for the audit feature. Template placeholders are preserved correctly.

Also applies to: 170-170, 180-180, 779-780, 801-801, 803-803, 829-830, 834-834


1-1: Note: French (fr) and Portuguese (pt) translation files not provided.

The enriched summary indicates that French and Portuguese locales also received similar additions for audit feature support. Consider verifying those files separately to ensure consistency across all four supported locales (en, es, fr, pt).

admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (1)

1-124: Overall audit list implementation is clean and correctly wired to the TS client.

The page composes filters, data fetching (useGetAuditData), and server‑side pagination coherently:

  • Query params are centralized in queryParams and always built via buildQueryParams, avoiding ad‑hoc URL construction.
  • Date handling with Dayjs and the helper predicates (hasBothDates, isStartAfterEnd, isValidDate, dateConverter) is clear and keeps the search-disable logic readable.
  • The AuditSearch subcomponent keeps the main page lean and encapsulates keyboard handling, page-size select, and refresh/search controls.
  • MaterialTable is used as a presentational shell over an already paginated dataset (auditRows), with a custom Pagination component that drives server‑side pagination via onPageChange / onRowsPerPageChange.

No blocking correctness, performance, or concurrency issues stand out here.

Also applies to: 164-383, 397-595

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (1)

535-549: Excellent! Validation messages address previous review feedback.

The validation messages for both isStartAfterEnd and hasOnlyOneDate are now properly displayed, addressing the concern raised in the previous review about the Search button being silently disabled. Users now receive clear feedback about why they cannot search.

admin-ui/plugins/admin/components/Audit/types/index.ts (1)

1-20: LGTM! Clean and minimal type definitions.

The type definitions are well-structured and all fields are actively used in AuditListPage.tsx:

  • AuditRow fields (id, serial, log) are all consumed by the table component
  • AuditSearchProps accurately reflects the search component's interface
  • Proper use of Dayjs types for date handling

Note: The previous review's concern about unused timestamp and content fields does not apply to the current code, as these fields are not present in the interface.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c84cf3a and e5b0552.

📒 Files selected for processing (6)
  • admin-ui/app/locales/en/translation.json (6 hunks)
  • admin-ui/app/locales/es/translation.json (6 hunks)
  • admin-ui/app/locales/fr/translation.json (3 hunks)
  • admin-ui/app/locales/pt/translation.json (3 hunks)
  • admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Audit/types/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-07T12:55:26.241Z
Learnt from: kdhttps
Repo: GluuFederation/flex PR: 2378
File: admin-ui/plugins/admin/components/Cedarling/CedarlingConfigPage.tsx:93-104
Timestamp: 2025-11-07T12:55:26.241Z
Learning: In the Cedarling configuration feature (admin-ui/plugins/admin/components/Cedarling/CedarlingConfigPage.tsx), the sync role to scopes mappings operation depends on the `auiPolicyStoreUrl`. The backend fetches content from this URL and syncs roles based on the response. Therefore, the audit log for the sync operation should include the `auiPolicyStoreUrl` in its payload to provide proper audit context.

Applied to files:

  • admin-ui/plugins/admin/components/Audit/AuditListPage.tsx
  • admin-ui/app/locales/fr/translation.json
  • admin-ui/plugins/admin/components/Audit/types/index.ts
📚 Learning: 2025-11-26T12:25:34.923Z
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2475
File: admin-ui/plugins/auth-server/components/Clients/ClientDetailPage.js:111-216
Timestamp: 2025-11-26T12:25:34.923Z
Learning: In the admin-ui codebase, avoid suggesting comments for small functionalities or straightforward layout decisions in smaller components. Comments should be reserved for more complex or non-obvious logic.

Applied to files:

  • admin-ui/plugins/admin/components/Audit/AuditListPage.tsx
🔇 Additional comments (16)
admin-ui/app/locales/en/translation.json (3)

64-65: New action keys look good.

The add_custom_attributes and refresh keys are clearly defined and ready for UI consumption.


170-170: Field keys for pagination and audit UI are correctly placed.

log_entry and page_size sit appropriately in the fields section alongside related metadata keys.

Also applies to: 180-180


779-781: Audit messages are now correctly placed in messages section.

The migration from the problematic titles section (flagged in past review) to the correct messages section is confirmed. All audit-related keys (showing_entries, start_date_after_end, both_dates_required, adjust_filters, audit_description, error_loading_data, try_again_later, no_data) are now properly co-located where the UI component will look them up. Template variable syntax ({{start}}, {{end}}, {{total}}) is consistent and correct.

Also applies to: 802-807

admin-ui/app/locales/fr/translation.json (2)

671-672: Field keys for audit UI properly translated.

The log_entry and page_size keys are correctly added to the French fields section with appropriate translations that align with the English versions.


800-807: Audit messages correctly repositioned and fully translated.

This confirms that the past review issue—audit messages placed under titles instead of messages—has been resolved. All eight audit-related keys are now in the correct messages section with complete French translations. Template variables are consistent with English ({{start}}, {{end}}, {{total}}), and the message copy is idiomatic French (e.g., "Affichage de {{start}} à {{end}} sur {{total}} entrées" accurately mirrors the pagination layout).

admin-ui/app/locales/pt/translation.json (2)

794-802: Audit i18n keys correctly positioned in messages namespace.

The namespace correction from the previous review has been applied: all audit-related i18n keys (error_loading_data, try_again_later, no_data, adjust_filters, audit_description, showing_entries, start_date_after_end, both_dates_required) are now correctly placed in the messages section, aligning with the audit UI component expectations (messages.* references).


171-172: Action and field i18n keys added appropriately.

New keys—refresh action and log_entry/page_size field labels—have been added with semantically correct Portuguese translations and are positioned in the appropriate sections.

Also applies to: 665-667

admin-ui/app/locales/es/translation.json (2)

779-803: Verify audit key consistency: "no_data" vs "no_data_found" naming divergence.

Seven of eight audit message keys are present in the Spanish messages section. However, the Portuguese file includes a no_data key (line 797 in pt file), but the Spanish file appears to use no_data_found (line 861) instead. If the audit UI component references messages.no_data, the Spanish locale will show a missing translation or fall back to the key name.

Confirm whether:

  1. Spanish should also have a no_data key (aligned with Portuguese), or
  2. The audit UI intentionally uses a different key name in different locales (inconsistent), or
  3. "no_data_found" is intentionally substituted for "no_data"

Also applies to: 830-831


64-65: Action and field i18n keys correctly added to Spanish locale.

New keys (refresh, log_entry, page_size) are present with appropriate Spanish translations and correct section placement, consistent with the Portuguese file structure.

Also applies to: 170-170, 180-180

admin-ui/plugins/admin/components/Audit/AuditListPage.tsx (7)

1-114: LGTM! Clean imports and well-structured component definitions.

The imports, constants, and LoadingSkeleton component are well-organized and appropriate for the functionality. The use of MUI components, dayjs for date handling, and Material Table is consistent with the rest of the codebase.


116-151: LGTM! Well-implemented empty and error states.

The EmptyState and ErrorState components provide clear user feedback with appropriate icons and messages. The ErrorState's retry functionality is a good UX pattern.


153-271: LGTM! Well-designed search component with good UX.

The AuditSearch component includes thoughtful features like Enter-key search, animated refresh button, and proper disabled states. The keyboard accessibility is a good addition.


273-336: LGTM! Sound validation and query construction logic.

The state management and filter validation logic is well-implemented:

  • Properly handles pattern-only searches
  • Requires both dates for date-range filtering
  • Validates start date before end date
  • The buildQueryParams function correctly builds API parameters based on current filters

338-364: LGTM! Properly memoized event handlers.

All event handlers are correctly implemented with appropriate useCallback dependencies. The logic properly resets pagination when changing page size and rebuilds query parameters as needed.


459-505: LGTM! Well-configured MaterialTable with proper pagination.

The MaterialTable implementation is solid:

  • Custom pagination component correctly wired to state
  • PAGE_SIZE_OPTIONS properly used for rows-per-page dropdown
  • Styling is consistent with theme colors
  • Conditional row striping improves readability

508-570: LGTM! Complete and well-structured main render.

The main component render includes:

  • Clear page title and description
  • Search component with proper props
  • Validation feedback messages
  • Data table with appropriate states
  • Entry count display

The component provides a complete and user-friendly audit log viewing experience.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

@moabu moabu merged commit 28dbf28 into main Dec 10, 2025
9 checks passed
@moabu moabu deleted the admin-ui-2508 branch December 10, 2025 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-admin-ui Component affected by issue or PR comp-docker-admin-ui Component affected by issue or PR kind-bug Issue or PR is a bug in existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(admin-ui): Use typescript generated client on Audit pages

4 participants