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

Merged
merged 46 commits into from
Feb 18, 2025
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b27ae44
add permissions for user preference management, add okapiInterface
JohnC-80 Jan 27, 2025
662db88
add usePreferences hook
JohnC-80 Jan 27, 2025
92aa6e1
add AppOrderProvider context
JohnC-80 Jan 27, 2025
cab6928
implement App Reordering, refactor MainNav to functional.
JohnC-80 Jan 27, 2025
c36e6cf
Merge branch 'master' into STCOR-936
JohnC-80 Jan 27, 2025
c7bf306
recreat apps list on pathname change - fixes 'selectedApp'
JohnC-80 Jan 28, 2025
2ad7943
Merge branch 'STCOR-936' of https://github.com/folio-org/stripes-core…
JohnC-80 Jan 28, 2025
a78b938
AppOrderProvider: key query on user id
JohnC-80 Jan 28, 2025
26b3037
AppOrderProvider - key query on user id
JohnC-80 Jan 28, 2025
80f4a85
AppOrderProvider: clean comments
JohnC-80 Jan 28, 2025
23e31bd
add tests for usePreferences hook
JohnC-80 Jan 29, 2025
0c6e189
AppOrderProvider tests
JohnC-80 Jan 29, 2025
1d2a3dc
more AppOrderProvider tests
JohnC-80 Jan 30, 2025
75679bf
usePreferences clean up
JohnC-80 Jan 30, 2025
03fd9f7
AppList clean-up
JohnC-80 Jan 30, 2025
27fbb0c
Generalized perm descriptions for managing user preferences
JohnC-80 Jan 30, 2025
cde0ee5
AppOrderProvider clean-up
JohnC-80 Jan 30, 2025
de63069
clean up usePreference parameters
JohnC-80 Jan 30, 2025
3beaa16
clean up tests for usePreferences, AppOrderProvider
JohnC-80 Jan 30, 2025
844116e
Merge branch 'master' into STCOR-936
JohnC-80 Jan 30, 2025
6c8d962
use 'act' from testing-library/react
JohnC-80 Jan 30, 2025
88d5756
Merge branch 'STCOR-936' of https://github.com/folio-org/stripes-core…
JohnC-80 Jan 30, 2025
8b732b5
Merge branch 'master' into STCOR-936
JohnC-80 Jan 31, 2025
cbebda2
export AppImportProvider directly from itself rather than through Mai…
JohnC-80 Feb 3, 2025
38248a5
Merge branch 'STCOR-936' of https://github.com/folio-org/stripes-core…
JohnC-80 Feb 3, 2025
0c701c4
minor lint
JohnC-80 Feb 3, 2025
dfe2520
Merge branch 'master' into STCOR-936
JohnC-80 Feb 6, 2025
beb172f
log changes
JohnC-80 Feb 11, 2025
3083c63
add translation for Settings alt text
JohnC-80 Feb 12, 2025
6905a40
log changes
JohnC-80 Feb 12, 2025
2241218
add comments to AppOrder Provider, translate settings alt text
JohnC-80 Feb 12, 2025
0608ec1
Merge branch 'STCOR-936' of https://github.com/folio-org/stripes-core…
JohnC-80 Feb 12, 2025
29db12d
minor formatting in changelog
JohnC-80 Feb 12, 2025
c0d5296
add comments to Main Nav for updating the selectedApp on location change
JohnC-80 Feb 12, 2025
652860f
Merge branch 'master' into STCOR-936
JohnC-80 Feb 12, 2025
c07369c
App order provider - filter saved app order by perms as well
JohnC-80 Feb 12, 2025
788c5fe
Merge branch 'STCOR-936' of https://github.com/folio-org/stripes-core…
JohnC-80 Feb 12, 2025
7541f78
comment
JohnC-80 Feb 12, 2025
c1c6f43
sort 'new' apps to the end of the list
JohnC-80 Feb 12, 2025
6a4fca5
Merge branch 'master' into STCOR-936
JohnC-80 Feb 13, 2025
9274b73
minor comment adjustments
JohnC-80 Feb 13, 2025
fff58a5
Merge branch 'STCOR-936' of https://github.com/folio-org/stripes-core…
JohnC-80 Feb 13, 2025
b22c9d6
RootWithIntl: remove deprecated config constraint for rtr
JohnC-80 Feb 14, 2025
1781c0e
Merge branch 'master' into STCOR-936
JohnC-80 Feb 14, 2025
f8d4a6d
Merge branch 'master' into STCOR-936
JohnC-80 Feb 17, 2025
6531f7b
remove that silly 'Tenant settings' translation
JohnC-80 Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
recreat apps list on pathname change - fixes 'selectedApp'
  • Loading branch information
JohnC-80 committed Jan 28, 2025
commit c7bf3065f036882e619c80b3f7ae741dc7b5d37f
2 changes: 1 addition & 1 deletion src/components/MainNav/AppOrderProvider.js
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ export const AppOrderProvider = ({ children }) => {
}

return { navList, orderedApps };
}, [formatMessage, app, lastVisited, userAppList]); // omitted: stripes, pathname
}, [formatMessage, app, lastVisited, userAppList, pathname]); // omitted: stripes, pathname

const updateList = async (list) => {
// clean the 'isNew' field;
26 changes: 10 additions & 16 deletions src/components/MainNav/MainNav.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { isEqual, find } from 'lodash';
import { useIntl } from 'react-intl';
import { useLocation, useHistory } from 'react-router-dom';
@@ -14,7 +14,7 @@ import {
isQueryResourceModule,
getQueryResourceState,
} from '../../locationService';
import { logout } from '../../loginServices';

import css from './MainNav.css';
import NavButton from './NavButton';
import NavDivider from './NavDivider';
@@ -39,8 +39,8 @@ const MainNav = () => {
const history = useHistory();
const intl = useIntl();

const curModule = useRef(getCurrentModule(modules, location));
const selectedApp = useRef(apps.find(entry => entry.active)).current;
const [curModule, setCurModule] = useState(getCurrentModule(modules, location));
const [selectedApp, setSelectedApp] = useState(apps.find(entry => entry.active));
const helpUrl = useRef(stripes.config.helpUrl ?? 'https://docs.folio.org').current;

useEffect(() => {
@@ -50,14 +50,6 @@ const MainNav = () => {
const { store } = stripes;
const _unsubscribe = store.subscribe(() => {
const module = curModule;
const state = store.getState();

// If user has timed out, force them to log in again.
if (state?.okapi?.token && state.okapi.authFailure
&& find(state.okapi.authFailure, { type: 'error', code: 'user.timeout' })) {
// this.returnToLogin();
logout(state.okapi.url, store, queryClient);
}

if (module && isQueryResourceModule(module, location)) {
const { moduleName } = module;
@@ -80,11 +72,13 @@ const MainNav = () => {
}, []);

useEffect(() => {
curModule.current = getCurrentModule(modules, location);
if (curModule.current) {
updateQueryResource(location, curModule.current, stripes.store);
setSelectedApp(apps.find(entry => entry.active));
const nextCurModule = getCurrentModule(modules, location);
if (nextCurModule) {
setCurModule(getCurrentModule(modules, location));
updateQueryResource(location, nextCurModule, stripes.store);
}
}, [modules, location, stripes.store]);
}, [modules, location, stripes.store, apps]);

return (
<header className={css.navRoot} style={branding?.style?.mainNav ?? {}}>