Skip to content

Conversation

@syntrydy
Copy link
Contributor

@syntrydy syntrydy commented Dec 8, 2025

#2503
Closes #2503

Summary by CodeRabbit

  • New Features

    • Service health dashboard with per-service status badges, overall health summary, alerts, and manual refresh.
    • Enhanced MAU dashboard: summary cards, trend and token charts, token-distribution visuals, responsive layouts, and date-range presets with apply/loading states.
  • Documentation

    • Added English, Spanish, French, and Portuguese translations for MAU metrics, token labels, date presets, and health/status messaging.

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

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

coderabbitai bot commented Dec 8, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Replaces legacy JS MAU and Health UI with new TypeScript implementations: adds typed pages, components, hooks, types, utils, constants, and translations; removes old JS components; updates route wiring and exposes a theme consumer hook.

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 MAU and health/status localization keys (e.g., fields.total_mau, fields.total_tokens, fields.cc_tokens, fields.authz_code_tokens, date presets, titles.mau_dashboard, titles.token_trends, and health labels/messages like service_status_up, services_healthy_count, no_mau_data, mau_loading, vs_previous_period).
Health feature (TS)
admin-ui/plugins/admin/components/Health/HealthPage.tsx, admin-ui/plugins/admin/components/Health/components/HealthStatusBadge.tsx, admin-ui/plugins/admin/components/Health/components/ServiceStatusCard.tsx, admin-ui/plugins/admin/components/Health/hooks/{index.ts,useHealthStatus.ts}, admin-ui/plugins/admin/components/Health/types/{HealthTypes.ts,index.ts}, admin-ui/plugins/admin/components/Health/constants.ts, admin-ui/plugins/admin/components/Health/utils/{formatters.ts,index.ts}
New typed Health dashboard and pieces: HealthPage with loader/refresh and alerts; useHealthStatus hook fetching and normalizing statuses (uses STATUS_MAP, cache config); presentation components HealthStatusBadge and ServiceStatusCard; constants, types, and formatServiceName util with re-export.
MAU feature (TS)
admin-ui/plugins/admin/components/MAU/MauPage.tsx, admin-ui/plugins/admin/components/MAU/components/*, admin-ui/plugins/admin/components/MAU/hooks/{index.ts,useMauStats.ts}, admin-ui/plugins/admin/components/MAU/types/*, admin-ui/plugins/admin/components/MAU/utils/*, admin-ui/plugins/admin/components/MAU/constants.ts, admin-ui/plugins/admin/components/MAU/components/index.ts, admin-ui/plugins/admin/components/MAU/utils/index.ts
New typed MAU dashboard: MauPage with DateRangeSelector, summary cards, trend & token charts; useMauStats hook calling GetStat, transforming and augmenting data, computing summary and percent changes; utilities for date formatting/augmentation and numeric/percent formatting; chart color constants and re-exports.
Removed legacy JS components
admin-ui/plugins/admin/components/Health/HealthPage.js, admin-ui/plugins/admin/components/MAU/MauGraph.js, admin-ui/plugins/admin/components/Reports/SimpleBarChart.js
Deleted legacy JavaScript components for Health, MAU graph, and a simple bar chart.
Route & metadata
admin-ui/plugins/admin/plugin-metadata.ts
Swapped route component import and registration from MauGraph to the new MauPage (path unchanged).
Reports minor change
admin-ui/plugins/admin/components/Reports/ReportPage.tsx
Converted ReportPage from a function declaration to a typed const ReportPage: React.FC = () => { ... }.
Theme hook export
admin-ui/app/context/theme/themeContext.tsx
Added and exported useTheme() hook to consume and validate ThemeContext.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MauPage
    participant DateRangeSelector
    participant useMauStats
    participant GetStatAPI as GetStat API
    participant Augment as Data Augmentation
    participant Charts

    User->>MauPage: open page
    MauPage->>DateRangeSelector: render defaults
    User->>DateRangeSelector: select dates / apply
    DateRangeSelector->>MauPage: onApply(dateRange)
    MauPage->>useMauStats: request stats(dateRange)
    useMauStats->>GetStatAPI: call GetStat (token, params)
    GetStatAPI-->>useMauStats: return raw stats
    useMauStats->>Augment: transform & augment data
    Augment-->>useMauStats: MauStatEntry[]
    useMauStats-->>MauPage: data, summary
    MauPage->>Charts: render summary & charts
    Charts-->>User: display MAU dashboard
Loading
sequenceDiagram
    participant User
    participant HealthPage
    participant useHealthStatus
    participant GetServiceStatusAPI as GetServiceStatus API
    participant Normalizer as STATUS_MAP
    participant UI

    User->>HealthPage: open page
    HealthPage->>useHealthStatus: init (auth token)
    useHealthStatus->>GetServiceStatusAPI: fetch statuses
    GetServiceStatusAPI-->>useHealthStatus: raw service data
    useHealthStatus->>Normalizer: normalize statuses
    Normalizer-->>useHealthStatus: ServiceHealth[]
    useHealthStatus-->>HealthPage: services, healthyCount, totalCount
    HealthPage->>UI: render HealthStatusBadge, ServiceStatusCard[]
    UI-->>User: display Health dashboard
    User->>HealthPage: click refresh
    HealthPage->>useHealthStatus: refetch()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Files to scrutinize:
    • admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts — API params, select transform, augmentation, percent-change logic.
    • admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts — STATUS_MAP normalization, sorting, query select behavior.
    • MAU utils/formatters — month-range generation, edge cases (previous period zero) and number formatting.
    • Translation files — consistency of new keys across locales.

Possibly related PRs

Suggested reviewers

  • duttarnab
  • syntrydy

Poem

🐇 I hopped through locales, charts, and status lights,
Replaced old burrows with TypeScript nights.
Hooks bake data, badges blink and play,
Dates pick carrots, charts parade the day,
🥕 A twitch, a thump — the admin’s fresh bouquet.

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 directly describes the main change: migrating MAU, Reports, and Health pages to use TypeScript-generated client instead of manual types.
Linked Issues check ✅ Passed The PR successfully replaces manual types with TypeScript-generated client types on MAU, Reports, and Health pages, addressing issue #2503 requirements.
Out of Scope Changes check ✅ Passed All changes are directly related to migrating MAU, Reports, and Health pages to use TypeScript-generated client. No unrelated modifications detected.

📜 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 deea088 and ceb836c.

📒 Files selected for processing (4)
  • admin-ui/app/locales/en/translation.json (3 hunks)
  • admin-ui/app/locales/es/translation.json (3 hunks)
  • admin-ui/app/locales/fr/translation.json (3 hunks)
  • admin-ui/app/locales/pt/translation.json (3 hunks)

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 8, 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: 20

📜 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 f93f8b8.

📒 Files selected for processing (32)
  • admin-ui/app/locales/en/translation.json (4 hunks)
  • admin-ui/app/locales/es/translation.json (4 hunks)
  • admin-ui/app/locales/fr/translation.json (4 hunks)
  • admin-ui/app/locales/pt/translation.json (4 hunks)
  • admin-ui/plugins/admin/components/Health/HealthPage.js (0 hunks)
  • admin-ui/plugins/admin/components/Health/HealthPage.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Health/components/HealthStatusBadge.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Health/components/ServiceStatusCard.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Health/constants.ts (1 hunks)
  • admin-ui/plugins/admin/components/Health/hooks/index.ts (1 hunks)
  • admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts (1 hunks)
  • admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (1 hunks)
  • admin-ui/plugins/admin/components/Health/types/index.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/MauGraph.js (0 hunks)
  • admin-ui/plugins/admin/components/MAU/MauPage.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/DateRangeSelector.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/MauSummaryCards.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/MauTrendChart.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/TokenDistributionChart.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/TokenTrendChart.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/index.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/constants.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/hooks/index.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/types/index.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/utils/formatters.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/utils/index.ts (1 hunks)
  • admin-ui/plugins/admin/components/Reports/ReportPage.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Reports/SimpleBarChart.js (0 hunks)
  • admin-ui/plugins/admin/plugin-metadata.ts (2 hunks)
💤 Files with no reviewable changes (3)
  • admin-ui/plugins/admin/components/Health/HealthPage.js
  • admin-ui/plugins/admin/components/MAU/MauGraph.js
  • admin-ui/plugins/admin/components/Reports/SimpleBarChart.js
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-05T18:24:41.681Z
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2498
File: admin-ui/plugins/saml/components/SamlConfigurationForm.tsx:30-30
Timestamp: 2025-12-05T18:24:41.681Z
Learning: In the GluuFederation/flex admin-ui codebase, `SetTitle` (imported from 'Utils/SetTitle') is a custom React hook that should be called at the component's top level, not inside `useEffect` or other hooks, because it internally manages side effects for setting page titles.

Applied to files:

  • admin-ui/plugins/admin/components/Health/HealthPage.tsx
🧬 Code graph analysis (14)
admin-ui/plugins/admin/components/MAU/components/MauSummaryCards.tsx (7)
admin-ui/plugins/schema/components/types/AttributeListPage.types.ts (1)
  • ThemeState (29-31)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • MauSummary (30-37)
admin-ui/plugins/admin/components/MAU/types/index.ts (1)
  • MauSummary (5-5)
admin-ui/app/components/Card/Card.tsx (1)
  • Card (27-27)
admin-ui/plugins/admin/components/MAU/utils/formatters.ts (2)
  • formatNumber (12-20)
  • formatPercentChange (29-32)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • getChartColors (45-47)
admin-ui/plugins/admin/redux/features/mappingSlice.js (1)
  • index (47-47)
admin-ui/plugins/admin/components/Health/components/ServiceStatusCard.tsx (2)
admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (1)
  • ServiceStatusCardProps (14-19)
admin-ui/plugins/admin/components/Health/types/index.ts (1)
  • ServiceStatusCardProps (6-6)
admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts (2)
admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (3)
  • ServiceStatusValue (5-5)
  • ServiceHealth (7-12)
  • ServiceStatusResponse (25-27)
admin-ui/plugins/admin/components/Health/constants.ts (3)
  • STATUS_MAP (15-26)
  • DEFAULT_STATUS (28-28)
  • HEALTH_CACHE_CONFIG (3-6)
admin-ui/plugins/admin/components/MAU/MauPage.tsx (4)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • DEFAULT_DATE_RANGE_MONTHS (8-8)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • MauDateRange (25-28)
admin-ui/plugins/admin/components/MAU/types/index.ts (1)
  • MauDateRange (4-4)
admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts (1)
  • useMauStats (84-120)
admin-ui/plugins/admin/components/Health/HealthPage.tsx (3)
admin-ui/plugins/schema/components/types/AttributeListPage.types.ts (1)
  • ThemeState (29-31)
admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts (1)
  • useHealthStatus (70-100)
admin-ui/app/components/Card/Card.tsx (1)
  • Card (27-27)
admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (1)
admin-ui/plugins/admin/components/Health/types/index.ts (5)
  • ServiceStatusValue (4-4)
  • ServiceHealth (5-5)
  • ServiceStatusCardProps (6-6)
  • HealthStatusBadgeProps (7-7)
  • ServiceStatusResponse (8-8)
admin-ui/plugins/admin/components/MAU/utils/formatters.ts (2)
admin-ui/plugins/admin/components/MAU/utils/index.ts (4)
  • formatMonth (10-10)
  • formatNumber (11-11)
  • calculatePercentChange (12-12)
  • formatPercentChange (13-13)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • MONTH_NAMES (49-62)
admin-ui/plugins/admin/components/MAU/components/TokenTrendChart.tsx (4)
admin-ui/plugins/schema/components/types/AttributeListPage.types.ts (1)
  • ThemeState (29-31)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • MauChartProps (57-59)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • getChartColors (45-47)
admin-ui/plugins/admin/components/MAU/utils/index.ts (2)
  • formatMonth (10-10)
  • formatNumber (11-11)
admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts (4)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (4)
  • MauStatEntry (3-9)
  • RawStatEntry (11-23)
  • MauSummary (30-37)
  • MauDateRange (25-28)
admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (2)
  • transformRawStatEntry (21-31)
  • augmentMauData (43-64)
admin-ui/plugins/admin/components/MAU/utils/formatters.ts (1)
  • calculatePercentChange (22-27)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • MAU_CACHE_CONFIG (3-6)
admin-ui/plugins/admin/components/MAU/components/MauTrendChart.tsx (4)
admin-ui/plugins/schema/components/types/AttributeListPage.types.ts (1)
  • ThemeState (29-31)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • MauChartProps (57-59)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • getChartColors (45-47)
admin-ui/plugins/admin/components/MAU/utils/formatters.ts (2)
  • formatMonth (3-10)
  • formatNumber (12-20)
admin-ui/plugins/admin/components/Health/components/HealthStatusBadge.tsx (4)
admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (1)
  • HealthStatusBadgeProps (21-23)
admin-ui/plugins/admin/components/Health/types/index.ts (1)
  • HealthStatusBadgeProps (7-7)
admin-ui/plugins/admin/components/Audit/AuditListPage.js (1)
  • badgeColor (54-54)
admin-ui/plugins/admin/components/Health/constants.ts (3)
  • STATUS_BADGE_COLOR (37-42)
  • STATUS_LABEL_KEYS (30-35)
  • STATUS_COLORS (8-13)
admin-ui/plugins/admin/components/MAU/components/DateRangeSelector.tsx (3)
admin-ui/plugins/schema/components/types/AttributeListPage.types.ts (1)
  • ThemeState (29-31)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • DateRangeSelectorProps (61-70)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • DATE_PRESETS (10-14)
admin-ui/plugins/admin/components/Health/constants.ts (2)
admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (1)
  • ServiceStatusValue (5-5)
admin-ui/plugins/admin/components/Health/types/index.ts (1)
  • ServiceStatusValue (4-4)
admin-ui/plugins/admin/components/MAU/constants.ts (2)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • DateRangePreset (46-49)
admin-ui/plugins/admin/components/MAU/types/index.ts (1)
  • DateRangePreset (7-7)
🔇 Additional comments (27)
admin-ui/plugins/admin/components/Reports/ReportPage.tsx (1)

3-5: Empty component implementation.

The component returns an empty <div> with no content or functionality. This appears to be a placeholder.

Is this intentional, or is there missing implementation for the Reports page?

admin-ui/plugins/admin/components/MAU/hooks/index.ts (1)

1-1: LGTM!

Clean barrel export pattern for MAU hooks.

admin-ui/plugins/admin/components/Health/hooks/index.ts (1)

1-1: LGTM!

Clean barrel export pattern for Health hooks.

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

1-9: LGTM!

Proper barrel export consolidating Health-related types for easier consumption.

admin-ui/plugins/admin/components/Health/components/ServiceStatusCard.tsx (1)

34-48: LGTM!

The component structure and JSX rendering are clean and well-organized. The use of conditional styling for errors and the integration with HealthStatusBadge work correctly.

admin-ui/plugins/admin/plugin-metadata.ts (2)

5-5: LGTM!

Correct import update from MauGraph to MauPage aligning with the PR's objective to use TypeScript-generated client types.


143-143: LGTM!

Route component correctly updated to use MauPage instead of the old MauGraph component.

admin-ui/plugins/admin/components/MAU/components/TokenDistributionChart.tsx (2)

23-39: LGTM!

Good use of useMemo for both chartColors and data to optimize rendering performance. The data structure correctly maps summary values to chart-ready format with proper dependencies.


43-75: LGTM!

Clean conditional rendering with proper empty state handling. The chart configuration is well-structured with appropriate responsive behavior, tooltips, and legends.

admin-ui/plugins/admin/components/Health/components/HealthStatusBadge.tsx (1)

7-11: LGTM!

Clean implementation using well-defined constants for colors and labels. The component correctly leverages translations and type-safe props.

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

64-65: MAU/Health i18n keys align with new UI usage

The added actions.refresh, MAU fields.* totals/presets, health/MAU messages.*, and titles.* entries are consistent with the new MAU charts and Health page components and use correct interpolation placeholders. No issues from a UI/i18n perspective.

Also applies to: 362-369, 868-882, 1027-1030

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

171-173: Portuguese MAU/Health translations mirror EN keys and usage

The new actions.refresh, MAU fields.* totals/presets, health/MAU messages.*, and titles.* entries correctly mirror the English keys and maintain required interpolation placeholders, so they should integrate cleanly with the new MAU and Health UIs.

Also applies to: 495-502, 800-814, 939-943

admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts (1)

70-100: useHealthStatus hook wiring and transformation are appropriate

The hook correctly gates the query on authToken, applies cache settings from HEALTH_CACHE_CONFIG, shapes the raw JsonNode via select: transformServiceStatus, and memoizes computeOverallStatus(services). The returned surface (services, aggregated status/counts, loading/error flags, refetch) is well‑structured for the Health page.

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

1-5: MAU components barrel export is clean and conventional

The index file neatly re‑exports the MAU components as named exports, which simplifies imports for callers without adding runtime complexity.

admin-ui/plugins/admin/components/MAU/components/MauSummaryCards.tsx (1)

47-93: LGTM!

The MauSummaryCards component is well-structured with proper use of useMemo for chart colors, responsive grid layout, and clean separation between the card configuration and rendering logic.

admin-ui/plugins/admin/components/MAU/MauPage.tsx (3)

78-80: Verify refetch is stable or add it to dependency array consideration.

The handleApply callback depends on refetch from the query result. If refetch reference changes between renders, it could cause unnecessary re-renders of components receiving handleApply. This is typically fine with React Query's stable references, but worth noting.


84-142: LGTM!

The page structure is well-organized with proper permission gating via GluuViewWrapper, appropriate loading states, and clean conditional rendering for error/empty/data states. The responsive layout for charts is correctly implemented.


24-24: SetTitle should be called within a useEffect hook.

Calling SetTitle directly in the component body executes it on every render, which is a side effect. Move it to a useEffect to follow React best practices for side effects.

+  React.useEffect(() => {
+    SetTitle(t('titles.mau_dashboard'))
+  }, [t])
-  SetTitle(t('titles.mau_dashboard'))
⛔ Skipped due to learnings
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2498
File: admin-ui/plugins/saml/components/SamlConfigurationForm.tsx:30-30
Timestamp: 2025-12-05T18:24:41.681Z
Learning: In the GluuFederation/flex admin-ui codebase, `SetTitle` (imported from 'Utils/SetTitle') is a custom React hook that should be called at the component's top level, not inside `useEffect` or other hooks, because it internally manages side effects for setting page titles.
admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts (3)

100-110: LGTM!

The query configuration properly gates fetching with isEnabled, applies appropriate caching settings, and the select function correctly transforms and augments the API response. The closure over dateRange is safe since the query re-executes when params change.


14-23: LGTM!

The transformApiResponse function defensively handles undefined/non-array data and properly converts the generic JsonNode type to the specific RawStatEntry type using the established transformation utility.


84-120: LGTM!

The useMauStats hook provides a clean API with proper auth gating, configurable enablement, and extends the base query result with processed data and computed summary. The memoization of summary computation is appropriate.

admin-ui/plugins/admin/components/MAU/utils/index.ts (1)

1-14: LGTM!

Clean barrel file that properly consolidates utility exports from internal modules, providing a clean public API surface for MAU utilities.

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

1-11: LGTM!

Proper use of export type syntax for type-only re-exports, providing a clean public API for MAU type definitions.

admin-ui/plugins/admin/components/MAU/utils/formatters.ts (1)

12-32: Number and percent formatters look appropriate for dashboard use

formatNumber, calculatePercentChange, and formatPercentChange behave as expected for MAU/token metrics (K/M abbreviations, division‑by‑zero guard, and signed percentage output). No issues from a correctness or UX standpoint.

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

64-65: New MAU and health/status Spanish translations align with code expectations

The added keys for MAU metrics (fields.total_mau, fields.total_tokens, fields.cc_tokens, fields.authz_code_tokens, date presets) and health/status (messages.service_status_*, messages.status_*, MAU loading/empty states, dashboard titles) match the identifiers used in the new constants and components. Placeholder usage (e.g., {{healthyCount}}, {{totalCount}}) looks correct, and there are no obvious structural issues in these sections.

Also applies to: 362-369, 867-881, 1020-1023

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

174-176: French MAU and health/status translations are consistent with new feature surface

The newly added French strings for refresh, MAU totals/date presets, health status descriptions, status labels, MAU loading/empty messages, and the MAU/health dashboard titles all use keys that match the TS constants (fields.date_preset_*, messages.status_*, etc.). Interpolation variables and JSON structure look correct, so these should plug into the new UI without i18n issues.

Also applies to: 483-490, 805-819, 946-950

admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)

3-70: MAU type definitions are cohesive and align with utilities/components

The MAU interfaces cleanly model the data you transform and display (MauStatEntry vs RawStatEntry), the summary metrics, token distribution entries, and the date‑range selector props. Month encoding as a numeric YYYYMM aligns with the augmentation/formatter helpers, and the preset/date range types line up with DATE_PRESETS and the selector callbacks. No changes needed here.

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: 1

♻️ Duplicate comments (6)
admin-ui/plugins/admin/components/Health/components/HealthStatusBadge.tsx (1)

7-12: LGTM! Previous feedback addressed.

The inline style object has been properly extracted as a top-level constant DOT_STYLE, which avoids recreation on every render.

admin-ui/plugins/admin/components/MAU/components/MauSummaryCards.tsx (2)

20-43: LGTM! Previous feedback addressed.

The zero-change logic has been properly fixed. Lines 23-24 now correctly distinguish positive (change > 0) from negative (change < 0) from neutral (change === 0), and line 26 uses fa-minus for the neutral case, displaying gray color.


63-72: LGTM! Previous feedback addressed.

The token sub-category cards (cc_tokens and authz_code_tokens) no longer include the change property, preventing the display of misleading aggregate change values for individual token types.

admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts (1)

48-57: LGTM! Previous feedback addressed.

The single-entry edge case is now properly handled. When data.length === 1, the function returns the totals with mauChange: 0 and tokenChange: 0, avoiding the misleading percentage calculation that would occur with an empty first half.

admin-ui/plugins/admin/components/MAU/MauPage.tsx (1)

109-114: LGTM! Previous feedback addressed.

The error message now correctly uses 'messages.error_loading_data', which is appropriate for a data-fetching failure rather than a save operation.

admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts (1)

39-75: LGTM! Previous feedback addressed.

The computeOverallStatus function now correctly handles all status combinations:

  • Returns 'unknown' when services array is empty (lines 44-50)
  • Correctly identifies 'unknown' as the overall status when no services are down/degraded but some are unknown (lines 64-65)
  • Properly distinguishes fully healthy (healthyCount === services.length) from mixed states

This fixes the previous issue where all-unknown services would incorrectly report as 'up'.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f93f8b8 and 2e73a35.

📒 Files selected for processing (22)
  • admin-ui/app/context/theme/themeContext.tsx (2 hunks)
  • admin-ui/app/locales/en/translation.json (4 hunks)
  • admin-ui/app/locales/es/translation.json (4 hunks)
  • admin-ui/app/locales/fr/translation.json (4 hunks)
  • admin-ui/app/locales/pt/translation.json (4 hunks)
  • admin-ui/plugins/admin/components/Health/HealthPage.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Health/components/HealthStatusBadge.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Health/components/ServiceStatusCard.tsx (1 hunks)
  • admin-ui/plugins/admin/components/Health/constants.ts (1 hunks)
  • admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts (1 hunks)
  • admin-ui/plugins/admin/components/Health/utils/formatters.ts (1 hunks)
  • admin-ui/plugins/admin/components/Health/utils/index.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/MauPage.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/DateRangeSelector.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/MauSummaryCards.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/MauTrendChart.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/TokenDistributionChart.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/components/TokenTrendChart.tsx (1 hunks)
  • admin-ui/plugins/admin/components/MAU/constants.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/utils/formatters.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-10T14:18:58.310Z
Learnt from: kdhttps
Repo: GluuFederation/flex PR: 2378
File: admin-ui/plugins/admin/components/Cedarling/CedarlingConfigPage.tsx:107-109
Timestamp: 2025-11-10T14:18:58.310Z
Learning: In the Cedarling configuration page (admin-ui/plugins/admin/components/Cedarling/CedarlingConfigPage.tsx), console.error calls should be kept in catch blocks when there are multiple operations in the try block, as they help print the whole error object with details for debugging unexpected errors.

Applied to files:

  • admin-ui/plugins/admin/components/MAU/MauPage.tsx
📚 Learning: 2025-12-05T18:24:41.681Z
Learnt from: faisalsiddique4400
Repo: GluuFederation/flex PR: 2498
File: admin-ui/plugins/saml/components/SamlConfigurationForm.tsx:30-30
Timestamp: 2025-12-05T18:24:41.681Z
Learning: In the GluuFederation/flex admin-ui codebase, `SetTitle` (imported from 'Utils/SetTitle') is a custom React hook that should be called at the component's top level, not inside `useEffect` or other hooks, because it internally manages side effects for setting page titles.

Applied to files:

  • admin-ui/plugins/admin/components/Health/HealthPage.tsx
🧬 Code graph analysis (11)
admin-ui/plugins/admin/components/MAU/components/TokenDistributionChart.tsx (4)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • MauSummary (30-37)
admin-ui/app/context/theme/themeContext.tsx (1)
  • useTheme (44-50)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • getChartColors (45-46)
admin-ui/plugins/admin/components/MAU/utils/formatters.ts (1)
  • formatNumber (15-23)
admin-ui/plugins/admin/components/MAU/components/DateRangeSelector.tsx (6)
admin-ui/plugins/admin/components/MAU/types/index.ts (1)
  • DateRangeSelectorProps (10-10)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • DateRangeSelectorProps (61-70)
admin-ui/app/context/theme/themeContext.tsx (1)
  • useTheme (44-50)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • DATE_PRESETS (10-14)
admin-ui/plugins/admin/components/Audit/AuditListPage.js (2)
  • startDate (59-59)
  • endDate (60-60)
admin-ui/plugins/auth-server/components/Clients/ClientBasicPanel.js (1)
  • isLoading (56-56)
admin-ui/plugins/admin/components/MAU/utils/formatters.ts (2)
admin-ui/plugins/admin/components/MAU/utils/index.ts (4)
  • formatMonth (10-10)
  • formatNumber (11-11)
  • calculatePercentChange (12-12)
  • formatPercentChange (13-13)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • MONTH_NAMES (48-61)
admin-ui/plugins/admin/components/MAU/MauPage.tsx (4)
admin-ui/plugins/admin/components/MAU/constants.ts (1)
  • DEFAULT_DATE_RANGE_MONTHS (8-8)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • MauDateRange (25-28)
admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts (1)
  • useMauStats (95-131)
admin-ui/app/components/Card/Card.tsx (1)
  • Card (27-27)
admin-ui/plugins/admin/components/Health/components/HealthStatusBadge.tsx (2)
admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (1)
  • HealthStatusBadgeProps (21-23)
admin-ui/plugins/admin/components/Health/constants.ts (3)
  • STATUS_BADGE_COLOR (37-42)
  • STATUS_LABEL_KEYS (30-35)
  • STATUS_COLORS (8-13)
admin-ui/plugins/admin/components/MAU/constants.ts (2)
admin-ui/plugins/admin/components/MAU/types/index.ts (1)
  • DateRangePreset (7-7)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • DateRangePreset (46-49)
admin-ui/plugins/admin/components/Health/HealthPage.tsx (2)
admin-ui/app/context/theme/themeContext.tsx (1)
  • useTheme (44-50)
admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts (1)
  • useHealthStatus (77-107)
admin-ui/plugins/admin/components/Health/constants.ts (2)
admin-ui/plugins/admin/components/Health/types/index.ts (1)
  • ServiceStatusValue (4-4)
admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (1)
  • ServiceStatusValue (5-5)
admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (2)
admin-ui/plugins/admin/components/MAU/types/index.ts (2)
  • RawStatEntry (3-3)
  • MauStatEntry (2-2)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (2)
  • RawStatEntry (11-23)
  • MauStatEntry (3-9)
admin-ui/plugins/admin/components/Health/components/ServiceStatusCard.tsx (2)
admin-ui/plugins/admin/components/Health/types/HealthTypes.ts (2)
  • ServiceHealth (7-12)
  • ServiceStatusCardProps (14-19)
admin-ui/plugins/admin/components/Health/utils/formatters.ts (1)
  • formatServiceName (1-6)
admin-ui/plugins/admin/components/MAU/components/MauTrendChart.tsx (3)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
  • MauChartProps (57-59)
admin-ui/app/context/theme/themeContext.tsx (1)
  • useTheme (44-50)
admin-ui/plugins/admin/components/MAU/utils/formatters.ts (2)
  • formatMonth (3-13)
  • formatNumber (15-23)
🔇 Additional comments (19)
admin-ui/app/context/theme/themeContext.tsx (1)

44-50: useTheme hook cleanly encapsulates ThemeContext access

Wrapping useContext(ThemeContext) with a typed hook and an explicit provider check is a good improvement and removes the need for unsafe casts in consumers.

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

171-172: PT translations correctly mirror new MAU and Health keys

The added Portuguese strings for refresh, MAU/token metrics, service health messages, and MAU-related titles are consistent with the English keys and keep placeholder syntax intact.

Also applies to: 495-502, 800-815, 940-944

admin-ui/plugins/admin/components/MAU/constants.ts (1)

3-61: MAU cache, presets, and theming constants are coherent and type-safe

Cache timings, date presets, theme color mapping, getChartColors fallback, and MONTH_NAMES all align with the MAU types and formatter usage; this centralization should make the MAU charts easier to maintain.

admin-ui/plugins/admin/components/Health/utils/index.ts (1)

1-1: Re-export of formatServiceName is appropriate

Barrel-exporting the formatter keeps the Health utils API tidy and consistent with other modules.

admin-ui/plugins/admin/components/MAU/components/TokenDistributionChart.tsx (1)

14-69: TokenDistributionChart logic and theming integration look solid

The chart correctly derives its segments from MauSummary, uses the theme-aware getChartColors(state.theme), falls back to a translated “no data” state when totalTokens is zero, and wires labels to the new i18n keys (fields.cc_tokens, fields.authz_code_tokens, titles.token_distribution, messages.no_mau_data) as expected.

admin-ui/plugins/admin/components/MAU/components/MauTrendChart.tsx (1)

18-53: MauTrendChart data shaping and themed rendering are correct

The component cleanly augments input data with monthLabel, formats values with formatNumber, uses the translated labels (titles.mau_trend, fields.monthly_active_users), and pulls colors from getChartColors(state.theme) via the new useTheme hook; overall the implementation looks correct and maintainable.

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

64-65: MAU and Health i18n keys look consistent with new UI usage; verify cross-locale coverage

The added MAU/Health keys (actions.refresh, fields.date_preset_*, token counters, messages for service status/MAU loading, and new titles) align with the new MAU and Health components and appear well named and phrased.

To ensure all locales stay in sync, verify that the following keys exist in each translation file (en, es, fr, pt):

  • Fields: cc_tokens, authz_code_tokens, date_preset_3m, date_preset_6m, date_preset_1y, date_preset_custom, total_mau, total_tokens
  • Messages: service_status_up, service_status_down, service_status_degraded, service_status_unknown, services_healthy_count, error_fetching_health_status, no_services_found, status_online, status_offline, status_degraded, status_unknown, no_mau_data, error_loading_data, mau_loading, vs_previous_period
  • Titles: mau_dashboard, mau_trend, token_distribution, token_trends
  • Actions: refresh
admin-ui/plugins/admin/components/Health/components/HealthStatusBadge.tsx (1)

19-76: LGTM!

The component correctly uses the useTheme() hook and properly transforms data for the stacked area chart. The translation keys and color mappings are consistent with the MAU constants.

admin-ui/plugins/admin/components/MAU/components/DateRangeSelector.tsx (1)

12-79: LGTM!

The date range selector is well-implemented with proper theme integration, preset handling, and loading state management. The Material-UI DatePicker components are correctly configured with the Dayjs adapter.

admin-ui/plugins/admin/components/Health/HealthPage.tsx (1)

12-85: LGTM!

The HealthPage component is well-structured:

  • SetTitle is correctly called at the top level
  • Theme integration via useTheme() and getThemeColor is proper
  • The useHealthStatus hook provides clean data access with loading/error states
  • Refresh functionality with loading indicator is correctly implemented
  • Conditional rendering for loading, error, and empty states is appropriate
admin-ui/plugins/admin/components/MAU/hooks/useMauStats.ts (1)

95-131: LGTM!

The hook is well-structured:

  • Properly gates the query with auth token and date range validation
  • Applies appropriate cache configuration
  • Uses a select transformer to shape the data
  • Computes the summary via useMemo for efficiency
  • Returns a clean API with all necessary loading/error states
admin-ui/plugins/admin/components/MAU/MauPage.tsx (1)

22-143: LGTM!

The MauPage component is well-implemented:

  • SetTitle is correctly called at the top level
  • Cedarling permission checks are properly integrated
  • Date range state management with presets is well-structured
  • Event handlers use useCallback for optimization
  • Conditional rendering for loading, error, and empty states is appropriate
  • Component composition with MAU charts and summaries is clean
admin-ui/plugins/admin/components/Health/hooks/useHealthStatus.ts (1)

77-107: LGTM!

The hook is well-structured:

  • Properly gates the query with auth token validation
  • Applies appropriate cache configuration via HEALTH_CACHE_CONFIG
  • Uses a select transformer to normalize and sort service data
  • Computes overall metrics via useMemo for efficiency
  • Returns a comprehensive API with all necessary query states and actions
admin-ui/plugins/admin/components/Health/components/ServiceStatusCard.tsx (1)

1-47: ServiceStatusCard helper + component look correct and aligned with health types/constants

getStatusMessage cleanly covers all status cases with i18n keys and falls back to service.error; the component uses formatServiceName, HealthStatusBadge, and themeColors.background as expected, with safe conditional styling on errors. No issues spotted.

admin-ui/plugins/admin/components/MAU/utils/formatters.ts (1)

1-35: MAU formatting helpers are robust and side‑effect free

formatMonth now correctly validates the MM portion and falls back to the original string on invalid months; formatNumber, calculatePercentChange, and formatPercentChange behave consistently and are suitable for MAU displays. No changes requested.

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

64-66: Spanish MAU/health translation keys are consistent with usage

New actions.refresh, MAU field labels, health/MAU messages.* (including services_healthy_count with correct {{healthyCount}} / {{totalCount}} placeholders), and MAU-related titles align with the component and constant keys added elsewhere. No structural or placeholder issues found.

Also applies to: 362-369, 867-882, 1021-1024

admin-ui/plugins/admin/components/Health/constants.ts (1)

1-42: Health status configuration and mappings are type‑safe and coherent

Cache timings are reasonable, STATUS_MAP correctly uses satisfies Record<string, ServiceStatusValue> for type safety, and colors/label keys/badge colors cover all ServiceStatusValue variants consistently. Looks good.

admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (1)

1-65: MAU data augmentation correctly bounds data to the selected month range

generateMonthRange, transformRawStatEntry, and createEmptyStatEntry are straightforward; augmentMauData now filters to the requested [startDate, endDate] month set and fills missing months with empty entries while preserving existing data within range. Input arrays are not mutated. No changes requested.

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

174-175: French MAU/health translations align with the new UI and constants

Added actions.refresh, MAU metric/date-preset field labels, health/MAU messages.* (including status and services_healthy_count placeholders), and MAU dashboard titles all match the keys used by Health/MAU components and STATUS_LABEL_KEYS. No structural issues identified.

Also applies to: 483-490, 805-820, 947-951

Copy link
Contributor

@duttarnab duttarnab left a comment

Choose a reason for hiding this comment

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

  1. MAU page data does not matches with the dashboard
image image

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: 1

♻️ Duplicate comments (1)
admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (1)

43-65: LGTM! Data augmentation correctly filters and fills gaps.

The function properly handles both empty and populated data cases. Notably, line 56 filters the input data to only include months within the requested range (monthSet.has(entry.month)), which addresses the concern raised in the previous review about bounding the series to the selected date range. The logic correctly fills gaps with empty entries and returns a sorted, continuous monthly series.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41e1339 and 8f95b74.

📒 Files selected for processing (2)
  • admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1 hunks)
  • admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (1)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (2)
  • RawStatEntry (11-23)
  • MauStatEntry (3-9)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)
admin-ui/plugins/admin/components/MAU/types/index.ts (9)
  • MauStatEntry (2-2)
  • RawStatEntry (3-3)
  • MauDateRange (4-4)
  • MauSummary (5-5)
  • MauSummaryCardProps (6-6)
  • DateRangePreset (7-7)
  • TokenDistributionData (8-8)
  • MauChartProps (9-9)
  • DateRangeSelectorProps (10-10)
🔇 Additional comments (4)
admin-ui/plugins/admin/components/MAU/types/MauTypes.ts (1)

1-70: LGTM! Well-structured TypeScript type definitions.

The MAU type definitions are comprehensive and well-organized. The interfaces properly distinguish between API response shapes (RawStatEntry with optional fields) and internal data models (MauStatEntry with required fields), use Dayjs consistently for date handling, and provide appropriate prop types for UI components. The type design supports type safety throughout the MAU feature implementation.

admin-ui/plugins/admin/components/MAU/utils/dataAugmentation.ts (3)

4-6: LGTM! Clean date formatting utility.

The function correctly formats Dayjs dates to YYYYMM string format for API compatibility.


8-19: LGTM! Correct month range generation.

The function properly generates an inclusive array of month numbers in YYYYMM format. The use of startOf('month') ensures consistent month boundaries, and the loop condition correctly includes both start and end months.


33-41: LGTM! Clean empty entry factory.

The function correctly creates zero-filled MAU stat entries for gap filling.

Resolved conflicts in fr and pt translation files by keeping both
service/MAU translations from HEAD and audit translations from main.
@moabu moabu merged commit d6f81fc into main Dec 11, 2025
4 of 5 checks passed
@moabu moabu deleted the admin-ui-2503 branch December 11, 2025 11:27
@sonarqubecloud
Copy link

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 MAU, Reports and Heath pages

4 participants