-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STCOR-936 - implement App-reordering, user preference management in s…
…tripes-core. (#1584) ## [STCOR-936](https://folio-org.atlassian.net/browse/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: - [x] Tests!
- Loading branch information
Showing
15 changed files
with
946 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.