Skip to content

[CSM Portal] profile platform roles, drop unused dashboard-API flag, fix stale-chunk reload guard, silent re-auth before sign-in redirect - #1185

Merged
cloby99 merged 4 commits into
wso2-open-operations:mainfrom
rksk:csm-profile-platform-roles
Jul 21, 2026
Merged

[CSM Portal] profile platform roles, drop unused dashboard-API flag, fix stale-chunk reload guard, silent re-auth before sign-in redirect#1185
cloby99 merged 4 commits into
wso2-open-operations:mainfrom
rksk:csm-profile-platform-roles

Conversation

@rksk

@rksk rksk commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Purpose

Four small, independent CSM Portal frontend fixes:

  1. The profile modal listed the Asgardeo ID token's groups claim under a "Groups" heading, but this platform authorizes off its own data, not IdP claims — Asgardeo groups aren't a reliable role list.
  2. The dashboard page carried a CSM_DASHBOARD_API_IMPLEMENTED flag and matching fetch-disable plumbing for a backend endpoint (GET /csm/dashboard) that doesn't exist yet, which added complexity without any current benefit.
  3. The stale-chunk auto-reload guard (added to recover a tab that's been open across a deploy) was set once and never cleared, so it only auto-recovered the first stale-chunk failure a tab ever hit in its lifetime — any later one (e.g. after a subsequent deploy, hours into the same open tab) silently did nothing instead of reloading.
  4. When the refresh token is dead, useAuthApiClient immediately redirected the whole tab to a full sign-in, discarding any in-progress work (an open comment draft, an unsaved dialog) even when the user's underlying IdP session was still alive.

Goals

  1. Show the platform roles array already returned by GET /users/me, rendered the same way CsmUsersPage already displays a user's roles.
  2. Remove the unused fetch hook, flag, and related props entirely. This can be reintroduced in one PR once the backend ships the endpoint.
  3. Re-arm the reload guard after a clean mount so a distinct, later stale-chunk failure still gets one auto-reload instead of being silently swallowed for the rest of the tab's session.
  4. Try a silent, hidden-iframe re-authentication before falling back to the hard redirect, so a still-alive IdP session recovers the token without losing in-progress work.

Approach

  • UserProfileModal.tsx: switched the "Groups" section to read platform roles from /users/me instead of the Asgardeo ID token's groups claim.
  • Removed useGetCsmDashboard.ts (the disabled fetch hook), the CSM_DASHBOARD_API_IMPLEMENTED flag in CsmDashboardPage.tsx, and the now-unused engineer/isError props in AbtDashboardHeader.tsx (which now shows a static "Engineer overview" label). Removed the now-unused CsmDashboardEngineer/CsmAbtDashboardData types.
  • main.tsx: hoisted the RELOAD_GUARD_KEY sessionStorage key to module scope and added a 10s post-mount setTimeout that clears it, so a mount that stays up long enough to prove it's healthy (not the same failure looping) re-arms the guard for the next distinct failure.
  • useAuthApiClient.ts: on a still-unauthenticated retry, call signInSilently() (hidden iframe) before redirectToSignIn(). Single-flighted via a module-scoped silentSignInInFlight promise, same pattern as the existing signInInFlight guard, so concurrent requests hitting the dead token at once await one shared attempt. On success, the original request is retried once more; if it still fails with a token-expired error (e.g. a race with a session that expires a moment later), it falls through to the existing hard redirect.

User stories

N/A

Release note

  • Profile modal now shows platform roles instead of Asgardeo IdP groups.
  • Removed dead dashboard-API-flag plumbing pending the backend endpoint.
  • Fixed the stale-chunk auto-reload so it recovers every deploy a long-lived tab crosses, not just the first.
  • A dead refresh token now tries a silent re-authentication before bouncing the tab to a full sign-in redirect, preserving in-progress work when the IdP session is still alive.

Documentation

N/A — internal FE cleanup, no user-facing docs impact.

Training

N/A

Certification

N/A — no exam-relevant changes.

Automation tests

  • Unit tests: existing suite run (pnpm test); no new failures introduced (3 pre-existing failing files unrelated to this change, verified against main).
  • Integration tests: N/A

Security checks

Samples

N/A

Related PRs

None

Migrations (if applicable)

N/A

Test environment

Local pnpm build / pnpm lint / pnpm test on macOS (Darwin), Node/pnpm toolchain per repo package.json.

Learning

N/A

rksk added 2 commits July 20, 2026 23:28
The dashboard-data flag and its enable/disable plumbing added complexity
for a backend endpoint that does not exist yet. Removed the fetch hook,
the flag, and the engineer/isError props entirely; the header now shows
a static "Engineer overview" label. This code can be reintroduced once
the backend ships GET /csm/dashboard.
…sgardeo groups

The profile modal listed the Asgardeo ID token's `groups` claim under a
"Groups" heading, but this platform authorizes off its own data, not IdP
claims — Asgardeo groups aren't a reliable role list. Switched to the
`roles` array already returned by GET /users/me, rendered the same way
CsmUsersPage already displays a user's roles.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The profile modal now displays user roles with loading and overflow handling. The CSM dashboard removes page-level ABT data fetching, engineer/error header props, and related dashboard data types and hook files.

Changes

User profile roles

Layer / File(s) Summary
Role chip rendering
apps/csm-portal/webapp/src/components/header/UserProfileModal.tsx
Replaces group display with a loading-aware Roles section that shows limited role chips and a +N more overflow chip.

Dashboard data decoupling

Layer / File(s) Summary
Dashboard header contract
apps/csm-portal/webapp/src/features/csm-dashboard/components/AbtDashboardHeader.tsx
Removes engineer and error props and replaces engineer-specific status content with a static “Engineer overview” subtitle.
Dashboard page wiring
apps/csm-portal/webapp/src/features/csm-dashboard/pages/CsmDashboardPage.tsx, apps/csm-portal/webapp/src/features/csm-dashboard/api/useGetCsmDashboard.ts, apps/csm-portal/webapp/src/features/csm-dashboard/types/abtDashboard.ts
Removes page-level dashboard fetching and deletes the associated dashboard hook and data interfaces.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: Type/Improvement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions stale-chunk reload and silent re-auth, but those changes aren't in the PR; it should describe the role update and dashboard cleanup only. Retitle the PR to match the actual changes, focusing on profile roles and dashboard API cleanup only.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description covers the required template sections and gives enough detail on the role and dashboard cleanup changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

The chunk-reload guard was set once and never cleared, so it only
auto-recovered the first stale-deploy chunk failure a tab ever hit;
any later one (e.g. after a subsequent deploy, hours into the same
open tab) silently did nothing instead of reloading. Clear the guard
10s after a clean mount so a later, distinct failure still gets one
auto-reload.
@rksk rksk changed the title [CSM Portal] profile platform roles + drop unused dashboard-API flag [CSM Portal] profile platform roles, drop unused dashboard-API flag, fix stale-chunk reload guard Jul 20, 2026
…edirect

When the refresh token is dead, useAuthApiClient immediately redirected the
whole tab to sign-in, discarding any in-progress work (an open comment
draft, an unsaved dialog). Try a hidden-iframe silent re-authentication
first: if the IdP session is still alive it mints a fresh token with no
visible navigation, so only a genuinely dead IdP session falls through to
the hard redirect.
@rksk rksk changed the title [CSM Portal] profile platform roles, drop unused dashboard-API flag, fix stale-chunk reload guard [CSM Portal] profile platform roles, drop unused dashboard-API flag, fix stale-chunk reload guard, silent re-auth before sign-in redirect Jul 20, 2026
@rksk
rksk requested a review from Rashmika998 July 21, 2026 04:09
@cloby99
cloby99 merged commit a79f9f4 into wso2-open-operations:main Jul 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants