Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STCOR-936 - implement App-reordering, user preference management in stripes-core. #1584

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

JohnC-80
Copy link
Contributor

@JohnC-80 JohnC-80 commented Jan 27, 2025

STCOR-936

This PR Implements 2 things -

  1. A centralized mechanism for managing user preferences and interacting with mod-settings.
  2. A context that reads/writes a persisted user preference for the order of application icons in the main navigation of the UI.

1 is fairly straightforward. A hook - usePreferences - that accepts an object of options with the key and scope of a user preference. It will automatically apply the logged in user's id as well as maintain the id of an existing preference in its internal state. As per typical, it try/catches the requests. TODO: Better error handling than console.log.

usePreferences supplies methods getPreference, setPreference, and deletePreference.

getPreference/setPreference queries the preferences with the userId, scope, and key. If the preference is found, it will grab the id and store that in local state to use when setPreference is called. If a preference is not found, then the id remains null and when setPreference is called, a new preference is created according to mod-settings' API. deletePreference removes the preference and resets the found preference id if there is any.

2 involved setting up a context with a Provider - AppOrderProvider- that wraps the FOLIO UI at a high level - outside of the main navigation and around the ui-module container. It access the user preference and provides an ordered list of apps filtered by user permissions (named apps). It also provides the persisted preference value - an array containing objects with app information - only name as well as an isNew field if a platform app does not have a corresponding list order value.

The app list -building logic was lifted from MainNav.js and <MainNav> refactored as a functional component, trading out HOC's for hooks. One detail that's subject to further inspection is line 58 where it uses logout instead of an apparently undefined returnToLogin function.

ResizeContainer and AppListDropdown were two components that had to be touched as they were forcing alphabetical order of the list - switching from Object.keys to using the order of the array of apps/preference.

Still Remaining:

  • Tests!

Copy link

github-actions bot commented Jan 27, 2025

Bigtest Unit Test Results

189 tests  ±0   184 ✅ ±0   6s ⏱️ ±0s
  1 suites ±0     5 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit dfe2520. ± Comparison against base commit 7f5344a.

This pull request removes 5 and adds 3 tests. Note that renamed tests count towards both.
      equal to check email label in english translation
      equal to check email precautions label in english translation
      equal to sent email precautions label in english translation
Chrome_132_0_0_0_(Linux_x86_64).Forgot username/password status test check email status page tests ‑ Forgot username/password status test check email status page tests should have the header with an appropriate text content
Chrome_132_0_0_0_(Linux_x86_64).Forgot username/password status test check email status page tests ‑ Forgot username/password status test check email status page tests should have the paragraph with an appropriate text content
Chrome_132_0_0_0_(Linux_x86_64).Forgot username/password status test check email status page tests ‑ Forgot username/password status test check email status page tests should have the header with an appropriate text content
      equal to check email label in english translation
Chrome_132_0_0_0_(Linux_x86_64).Forgot username/password status test check email status page tests ‑ Forgot username/password status test check email status page tests should have the paragraph with an appropriate text content
      equal to check email precautions label in english translation
Chrome_132_0_0_0_(Linux_x86_64).Forgot username/password status test check email status page tests ‑ Forgot username/password status test check email status page tests should have the paragraph with an appropriate text content
      equal to sent email precautions label in english translation

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jan 27, 2025

Jest Unit Test Results

  1 files  ± 0   64 suites  +2   1m 32s ⏱️ -1s
379 tests +15  379 ✅ +15  0 💤 ±0  0 ❌ ±0 
383 runs  +16  383 ✅ +16  0 💤 ±0  0 ❌ ±0 

Results for commit dfe2520. ± Comparison against base commit 7f5344a.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@MikeTaylor MikeTaylor left a comment

Choose a reason for hiding this comment

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

I've not read every line of this, but it looks good.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/components/MainNav/AppList/AppList.js Outdated Show resolved Hide resolved
src/components/MainNav/AppOrderProvider.js Show resolved Hide resolved
src/components/MainNav/AppOrderProvider.js Outdated Show resolved Hide resolved
src/hooks/usePreferences.js Show resolved Hide resolved
src/hooks/usePreferences.js Outdated Show resolved Hide resolved
src/hooks/usePreferences.js Show resolved Hide resolved
src/hooks/usePreferences.js Outdated Show resolved Hide resolved
src/hooks/usePreferences.js Show resolved Hide resolved
@JohnC-80 JohnC-80 marked this pull request as ready for review February 3, 2025 16:05
@JohnC-80 JohnC-80 requested a review from a team as a code owner February 3, 2025 16:05
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.

3 participants