Skip to content

UIIN-3585: Improve usage of GET /users-keycloak/_self requests in Inventory app#2968

Open
OleksandrHladchenko1 wants to merge 4 commits intomasterfrom
UIIN-3585
Open

UIIN-3585: Improve usage of GET /users-keycloak/_self requests in Inventory app#2968
OleksandrHladchenko1 wants to merge 4 commits intomasterfrom
UIIN-3585

Conversation

@OleksandrHladchenko1
Copy link
Contributor

@OleksandrHladchenko1 OleksandrHladchenko1 commented Feb 3, 2026

Purpose

  • This pull request optimizes the performance of the Inventory app by reducing unnecessary API requests to /users-keycloak/_self. The changes implement lazy loading of user tenant permissions and improve the lifecycle management of API calls.

Approach

  • Removed: useState hook and getUserTenantsPermissions() call
    • Eliminated the practice of fetching all tenant permissions at once on component mount
    • These permissions were being fetched regardless of whether they were actually needed
  • Removed: userTenantPermissions prop passed to MemberTenantHoldings
    • Permissions are now fetched per-tenant on demand
    • Refactored component props: Removed userTenantPermissions prop
  • Added lazy-loaded permissions:
    • Integrated useUserTenantPermissions hook to fetch permissions only when accordion is opened
    • Permissions are now fetched conditionally based on accordion state
  • Enhanced accordion state management:
    • Replaced useControlledAccordion with useHoldingsFromStorage for persistent accordion state
    • Added explicit open and onToggle props to Accordion component
    • Accordion state is now saved to sessionStorage
  • Added query client cleanup:
    • Implemented useQueryClient to cancel ongoing queries when accordion is closed
    • Reduces memory usage and prevents unnecessary background requests
  • Improved loading states:
    • Combined isLoading and isUserTenantPermissionsLoading to properly handle loading during permission fetching

Benefits:

  • Permissions are fetched only when needed (when user opens accordion)
  • Prevents multiple simultaneous permission requests
  • Queries are cancelled when accordions are closed to save resources
  • Accordion state is persistent across navigation

Refs

UIIN-3585

Screenshots

Inventory.-.UIIN-3585.-.FOLIO.-.Google.Chrome.2026-02-03.19-26-30.mp4

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Jest Unit Test Results

    1 files  ±0    321 suites  ±0   10m 13s ⏱️ -5s
1 431 tests ±0  1 412 ✅ ±0  19 💤 ±0  0 ❌ ±0 
1 445 runs  ±0  1 426 ✅ ±0  19 💤 ±0  0 ❌ ±0 

Results for commit 9e14ff5. ± Comparison against base commit 2cd96a1.

♻️ This comment has been updated with latest results.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 5, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants