-
Notifications
You must be signed in to change notification settings - Fork 26
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
base: master
Are you sure you want to change the base?
Conversation
Bigtest Unit Test Results189 tests ±0 184 ✅ ±0 6s ⏱️ ±0s 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.
♻️ This comment has been updated with latest results. |
There was a problem hiding this 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.
…into STCOR-936
…into STCOR-936
|
STCOR-936
This PR Implements 2 things -
mod-settings
.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 thanconsole.log
.usePreferences
supplies methodsgetPreference
,setPreference
, anddeletePreference
.getPreference/setPreference
queries the preferences with theuserId
,scope
, andkey
. If the preference is found, it will grab the id and store that in local state to use whensetPreference
is called. If a preference is not found, then theid
remainsnull
and whensetPreference
is called, a new preference is created according tomod-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 (namedapps
). It also provides the persisted preference value - an array containing objects with app information - onlyname
as well as anisNew
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 useslogout
instead of an apparently undefinedreturnToLogin
function.ResizeContainer
andAppListDropdown
were two components that had to be touched as they were forcing alphabetical order of the list - switching fromObject.keys
to using the order of the array of apps/preference.Still Remaining: