chore(admin-ui): redundant dependencies and unscanned dead test code#2875
chore(admin-ui): redundant dependencies and unscanned dead test code#2875faisalsiddique4400 wants to merge 12 commits into
Conversation
…ion + single-source action catalog (#2872) Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
…2874) Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
|
Warning Review limit reached
More reviews will be available in 40 minutes and 4 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRemoves runtime PropTypes and several unused dependencies; expands Knip to scan tests; adds local hooks/utilities (useFileDrop, useIdleTimer, readZip, decodeJwt) with tests; replaces react-dropzone/react-idle-timer/react-tooltip/jszip/jwt-decode usages with local implementations and updates styles/config. ChangesDependency cleanup and test export fixes
Local hooks, utilities, UI replacements, and tests
Sequence Diagram (file-drop → ZIP parsing flow): sequenceDiagram
participant User
participant AgamaFlows
participant useFileDrop
participant readZip
participant ZipEntry
User->>AgamaFlows: drop ZIP file
AgamaFlows->>useFileDrop: onDrop(file)
useFileDrop-->>AgamaFlows: accepted File[]
AgamaFlows->>readZip: readZip(file)
readZip->>ZipEntry: enumerate entries
AgamaFlows->>ZipEntry: zipEntry.text() (JSON)
ZipEntry-->>AgamaFlows: entry text
AgamaFlows->>AgamaFlows: parse JSON, extract project
Estimated code review effort 🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@admin-ui/app/routes/Apps/Gluu/GluuSessionTimeout.tsx`:
- Around line 110-119: The idle timer is left running even when the user is
logged out; update the code so the timer and its listeners are disabled when
isAuthenticated is false. Either pass an "enabled"/"active" flag to useIdleTimer
(if supported) or only initialize/use the hook when isAuthenticated is true;
alternatively, call the hook's stop/pause API (or cleanup) in a useEffect
cleanup when isAuthenticated becomes false. Ensure you still call reset() when
sessionTimeout or isAuthenticated changes (keep the existing useEffect) but add
logic to stop the timer/listeners in the not-authenticated branch and re-enable
them when isAuthenticated becomes true; reference useIdleTimer, reset,
useEffect, onIdle, isAuthenticated, and sessionTimeout when making the change.
In `@admin-ui/app/routes/Apps/Gluu/GluuTooltip.tsx`:
- Around line 48-71: The current GluuTooltip component installs four global
document listeners inside its useEffect causing O(N) listeners; replace this
with a shared tooltip manager: create a module-level TooltipManager that keeps a
registry keyed by doc_entry and exposes addListener(doc_entry, callback) and
removeListener(doc_entry, callback); move the resolveAnchor/show/hide logic into
the manager so it registers the four document events once and delegates to the
matching registry entries, and update GluuTooltip's useEffect to call
TooltipManager.addListener(doc_entry, setAnchorEl) on mount and
TooltipManager.removeListener(doc_entry, setAnchorEl) on unmount (keeping
resolveAnchor and doc_entry matching logic in the manager).
- Line 89: The tooltip container div rendered in GluuTooltip (the element with
data-testid={doc_entry}, className={classes.tooltip}, style={tooltipStyle})
lacks an accessibility role; update that div to include role="tooltip" so
role-based queries (e.g., screen.getByRole('tooltip') used in
GluuTooltip.test.tsx) can find it and improve accessibility.
In `@admin-ui/app/utils/zip.ts`:
- Around line 64-80: The text() reader currently decompresses data without
checking the uncompressed size; read the uncompressed size from the central
directory entry (4 bytes little-endian at cursor + 24) and validate it against a
safe limit (e.g., const MAX_UNCOMPRESSED_SIZE = 100 * 1024 * 1024) before
returning or calling inflateRaw/decoder.decode; if the uncompressed size exceeds
the limit, throw an error mentioning the entry name. Apply this check for both
COMPRESSION_STORED and COMPRESSION_DEFLATE paths (use view.getUint32(...) to
obtain the uncompressed size) so inflateRaw/decoder.decode and any stored reads
never expand beyond the allowed size.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7dea9b4e-f0ec-4500-be84-4957330d090d
📒 Files selected for processing (24)
admin-ui/app/constants/ui.tsadmin-ui/app/hooks/__tests__/useFileDrop.test.tsxadmin-ui/app/hooks/__tests__/useIdleTimer.test.tsadmin-ui/app/hooks/useFileDrop.tsadmin-ui/app/hooks/useIdleTimer.tsadmin-ui/app/routes/Apps/Gluu/GluuSessionTimeout.tsxadmin-ui/app/routes/Apps/Gluu/GluuTooltip.tsxadmin-ui/app/routes/Apps/Gluu/GluuUploadFile.tsxadmin-ui/app/routes/Apps/Gluu/Tests/GluuTooltip.test.tsxadmin-ui/app/routes/Apps/Gluu/styles/GluuTooltip.style.tsadmin-ui/app/routes/Apps/Gluu/types/GluuComponentPropsTypes.tsadmin-ui/app/styles/plugins/plugins.scssadmin-ui/app/utils/AppAuthProvider.tsxadmin-ui/app/utils/UploadSSA.tsxadmin-ui/app/utils/__tests__/jwtDecode.test.tsadmin-ui/app/utils/__tests__/zip.test.tsadmin-ui/app/utils/jwtDecode.tsadmin-ui/app/utils/regex.tsadmin-ui/app/utils/zip.tsadmin-ui/jest.config.tsadmin-ui/jest/setup.tsadmin-ui/package.jsonadmin-ui/plugins/auth-server/components/Authentication/AgamaFlows/AgamaFlows.tsxadmin-ui/vite.config.ts
💤 Files with no reviewable changes (2)
- admin-ui/app/styles/plugins/plugins.scss
- admin-ui/package.json
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@admin-ui/app/routes/Apps/Gluu/GluuTooltip.tsx`:
- Around line 49-52: The effect registering tooltipManager.addListener for
doc_entry doesn't clear the current anchorEl when doc_entry changes, so update
the cleanup callback inside the useEffect (the function that currently calls
tooltipManager.removeListener(doc_entry, setAnchorEl)) to also reset the anchor
element by calling setAnchorEl(null); keep the existing removeListener call and
ensure this change occurs inside the same cleanup function returned from the
useEffect that depends on doc_entry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 659b8a1c-27a7-4323-b3f1-d9d769a7faa6
📒 Files selected for processing (4)
admin-ui/app/routes/Apps/Gluu/GluuSessionTimeout.tsxadmin-ui/app/routes/Apps/Gluu/GluuTooltip.tsxadmin-ui/app/utils/tooltipManager.tsadmin-ui/app/utils/zip.ts
Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
|



chore(admin-ui): redundant dependencies and unscanned dead test code (#2874)
Summary
Maintenance cleanup of the Admin UI dependency manifest and test-code analysis
coverage. Removes redundant direct dependencies, reimplements a few heavier
libraries in-house using native browser APIs or already-bundled components,
expands Knip to scan test files, and removes dead test code.
Behavior-equivalent: the reimplemented surfaces are interactive (file upload,
tooltips, session timeout, auth decode, Agama zip import), so they are covered by
unit tests and need a manual pass. This is not a no-op cleanup.
Fix Summary
Redundant dependencies removed:
query-string-> nativeURLSearchParamsreact-responsive-> existing MUIuseMediaQueryprop-types-> TypeScript compile-time checking (runtime PropTypes blocks removed)react-router->react-router-dom(standardized router imports)redux-> transitive via@reduxjs/toolkit+react-reduxDependencies reimplemented in-house (behavior-equivalent):
jwt-decode->app/utils/jwtDecode.ts(decode-only, base64url + TextDecoder)react-dropzone->app/hooks/useFileDrop.ts(GluuUploadFile, UploadSSA, AgamaFlows)jszip->app/utils/zip.tsreadZip(DecompressionStream + central-directory parse)react-idle-timer->app/hooks/useIdleTimer.ts(GluuSessionTimeout)react-tooltip-> MUIPopper(GluuTooltip) with a sharedtooltipManagerKnip:
__tests__ignore; registeredjest.requireActualhelpersso they aren't false-flagged; removed dead test fixtures, helpers, and exports
surfaced by the expanded scan.
Bundle impact
Production JS (gzipped): 1.415 MB -> 1.351 MB (~64 KB smaller). Largest single
win: the Agama project route drops ~28 KB gzip (jszip -> native zip reader).
How to test (manual QA)
No code knowledge needed. Each area was reworked under the hood and should behave
exactly as before. Log in to the Admin UI first.
Session timeout
refresh. While logged out, no timeout dialog should ever appear.
File uploads (drag-drop + click to browse)
box and also click to browse. Remove it, then re-add the same file.
.cjarfile.file", upload an
.xmlthen a.json; a.txtshould be rejected..jwtfile is accepted.the file name shows after selecting; wrong file types are not accepted.
Agama project import (zip)
.gamaproject zip -> the Project Name field auto-fills frominside the zip. Upload a matching
.sha256sum-> "SHA256 verified" shows.Login and profile
including any accented characters.
Field help tooltips
Add): hover a help icon -> bubble appears with its arrow; move away -> it
hides. Tab to a field -> tooltip shows on focus. Recheck in dark mode
(bubble stays readable).
page no tooltip stays stuck on screen.
Tabbed pages (tab highlight + switching)
tab highlight, and panel switch together; reload on a tab -> same tab stays
selected.
Metrics: click through their tabs -> they switch correctly, no crash.
Upload box appearance
(border, text, spacing). A global dropzone stylesheet was dropped.
Also touched (confirm pages open with no console errors): Assets edit, Webhooks
edit, the main layout / sidebar, and removable input rows on SSA / user-claim
forms.
Verification
npm run check:all(lint + type-check + markdown): passnpm run test:all(1236 tests / 155 suites): passnpm run knip(test files now in scope): cleanTicket
Closes: #2874