Skip to content

Commit

Permalink
Merge branch 'master' into STCOR-846
Browse files Browse the repository at this point in the history
  • Loading branch information
zburke authored May 29, 2024
2 parents 08d7aca + 2b86b9e commit b5be7a0
Show file tree
Hide file tree
Showing 72 changed files with 2,449 additions and 961 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
* Provide `useUserTenantPermissions` hook. Refs STCOR-830.
* Load DayJS locale data as part of `loginServices`. STCOR-771.
* Turn on `<StrictMode>`; ignore it with `stripes.config.js` `disableStrictMode: true`. Refs STCOR-841.
* Make branding optional. Refs STCOR-847.
* Idle-session timeout and "Keep working?" modal. Refs STCOR-776.
* Implement password validation for Login Page. Refs STCOR-741.
* Avoid deprecated `defaultProps` for functional components. Refs STCOR-844..
* Update session data with values from `_self` request on reload. Refs STCOR-846.

## [10.1.0](https://github.com/folio-org/stripes-core/tree/v10.1.0) (2024-03-13)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.0.3...v10.1.0)
## [10.1.0](https://github.com/folio-org/stripes-core/tree/v10.1.0) (2024-03-12)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.0.0...v10.1.0)

* Provide optional tenant argument to `useOkapiKy` hook. Refs STCOR-747.
* Avoid private path when import `validateUser` function. Refs STCOR-749.
* Ensure `<AppIcon>` is not cut off when app name is long. Refs STCOR-752.
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@
"graphql": "^16.0.0",
"history": "^4.6.3",
"hoist-non-react-statics": "^3.3.0",
"inactivity-timer": "^1.0.0",
"jwt-decode": "^3.1.2",
"ky": "^0.23.0",
"localforage": "^1.5.6",
"lodash": "^4.17.21",
"moment-timezone": "^0.5.14",
"ms": "^2.1.3",
"prop-types": "^15.5.10",
"query-string": "^7.1.2",
"react-cookie": "^4.0.3",
Expand Down
278 changes: 141 additions & 137 deletions src/RootWithIntl.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import { useState } from 'react';
import PropTypes from 'prop-types';
import {
Router,
Switch,
} from 'react-router-dom';

import { Provider } from 'react-redux';
import { CookiesProvider } from 'react-cookie';

Expand All @@ -27,155 +26,160 @@ import {
HandlerManager,
TitleManager,
Login,
Logout,
LogoutTimeout,
OverlayContainer,
CreateResetPassword,
CheckEmailStatusPage,
ForgotPasswordCtrl,
ForgotUserNameCtrl,
AppCtxMenuProvider,
SessionEventContainer,
} from './components';
import StaleBundleWarning from './components/StaleBundleWarning';
import { StripesContext } from './StripesContext';
import { CalloutContext } from './CalloutContext';

class RootWithIntl extends React.Component {
static propTypes = {
stripes: PropTypes.shape({
config: PropTypes.object,
epics: PropTypes.object,
logger: PropTypes.object.isRequired,
clone: PropTypes.func.isRequired,
}).isRequired,
token: PropTypes.string,
isAuthenticated: PropTypes.bool,
disableAuth: PropTypes.bool.isRequired,
history: PropTypes.shape({}),
};
const RootWithIntl = ({ stripes, token = '', isAuthenticated = false, disableAuth, history = {} }) => {
const connect = connectFor('@folio/core', stripes.epics, stripes.logger);
const connectedStripes = stripes.clone({ connect });

static defaultProps = {
token: '',
isAuthenticated: false,
history: {},
const [callout, setCallout] = useState(null);
const setCalloutDomRef = (ref) => {
setCallout(ref);
};

state = { callout: null };

setCalloutRef = (ref) => {
this.setState({
callout: ref,
});
}
return (
<StripesContext.Provider value={connectedStripes}>
<CalloutContext.Provider value={callout}>
<ModuleTranslator>
<TitleManager>
<HotKeys
keyMap={connectedStripes.bindings}
noWrapper
>
<Provider store={connectedStripes.store}>
<Router history={history}>
{ isAuthenticated || token || disableAuth ?
<>
<MainContainer>
<AppCtxMenuProvider>
<MainNav stripes={connectedStripes} />
{typeof connectedStripes?.config?.staleBundleWarning === 'object' && <StaleBundleWarning />}
<HandlerManager
event={events.LOGIN}
stripes={connectedStripes}
/>
{ (connectedStripes.okapi !== 'object' || connectedStripes.discovery.isFinished) && (
<ModuleContainer id="content">
<OverlayContainer />
{connectedStripes.config.useSecureTokens && <SessionEventContainer history={history} />}
<Switch>
<TitledRoute
name="home"
path="/"
key="root"
exact
component={<Front stripes={connectedStripes} />}
/>
<TitledRoute
name="ssoRedirect"
path="/sso-landing"
key="sso-landing"
component={<SSORedirect stripes={connectedStripes} />}
/>
<TitledRoute
name="logoutTimeout"
path="/logout-timeout"
component={<LogoutTimeout />}
/>
<TitledRoute
name="settings"
path="/settings"
component={<Settings stripes={connectedStripes} />}
/>
<TitledRoute
name="logout"
path="/logout"
component={<Logout history={history} />}
/>
<ModuleRoutes stripes={connectedStripes} />
</Switch>
</ModuleContainer>
)}
</AppCtxMenuProvider>
</MainContainer>
<Callout ref={setCalloutDomRef} />
</> :
<Switch>
{/* The ? after :token makes that part of the path optional, so that token may optionally
be passed in via URL parameter to avoid length restrictions */}
<TitledRoute
name="CreateResetPassword"
path="/reset-password/:token?"
component={<CreateResetPassword stripes={connectedStripes} />}
/>
<TitledRoute
name="ssoLanding"
exact
path="/sso-landing"
component={<CookiesProvider><SSOLanding stripes={connectedStripes} /></CookiesProvider>}
key="sso-landing"
/>
<TitledRoute
name="forgotPassword"
path="/forgot-password"
component={<ForgotPasswordCtrl stripes={connectedStripes} />}
/>
<TitledRoute
name="forgotUsername"
path="/forgot-username"
component={<ForgotUserNameCtrl stripes={connectedStripes} />}
/>
<TitledRoute
name="checkEmail"
path="/check-email"
component={<CheckEmailStatusPage />}
/>
<TitledRoute
name="logoutTimeout"
path="/logout-timeout"
component={<LogoutTimeout />}
/>
<TitledRoute
name="login"
component={
<Login
autoLogin={connectedStripes.config.autoLogin}
stripes={connectedStripes}
/>}
/>
</Switch>
}
</Router>
</Provider>
</HotKeys>
</TitleManager>
</ModuleTranslator>
</CalloutContext.Provider>
</StripesContext.Provider>
);
};

render() {
const {
token,
isAuthenticated,
disableAuth,
history,
} = this.props;

const connect = connectFor('@folio/core', this.props.stripes.epics, this.props.stripes.logger);
const stripes = this.props.stripes.clone({ connect });

return (
<StripesContext.Provider value={stripes}>
<CalloutContext.Provider value={this.state.callout}>
<ModuleTranslator>
<TitleManager>
<HotKeys
keyMap={stripes.bindings}
noWrapper
>
<Provider store={stripes.store}>
<Router history={history}>
{ isAuthenticated || token || disableAuth ?
<>
<MainContainer>
<AppCtxMenuProvider>
<MainNav stripes={stripes} />
{typeof stripes?.config?.staleBundleWarning === 'object' && <StaleBundleWarning />}
<HandlerManager
event={events.LOGIN}
stripes={stripes}
/>
{ (stripes.okapi !== 'object' || stripes.discovery.isFinished) && (
<ModuleContainer id="content">
<OverlayContainer />
<Switch>
<TitledRoute
name="home"
path="/"
key="root"
exact
component={<Front stripes={stripes} />}
/>
<TitledRoute
name="ssoRedirect"
path="/sso-landing"
key="sso-landing"
component={<SSORedirect stripes={stripes} />}
/>
<TitledRoute
name="settings"
path="/settings"
component={<Settings stripes={stripes} />}
/>
<ModuleRoutes stripes={stripes} />
</Switch>
</ModuleContainer>
)}
</AppCtxMenuProvider>
</MainContainer>
<Callout ref={this.setCalloutRef} />
</> :
<Switch>
<TitledRoute
name="CreateResetPassword"
path="/reset-password/:token"
component={<CreateResetPassword stripes={stripes} />}
/>
<TitledRoute
name="ssoLanding"
exact
path="/sso-landing"
component={<CookiesProvider><SSOLanding stripes={stripes} /></CookiesProvider>}
key="sso-landing"
/>
<TitledRoute
name="forgotPassword"
path="/forgot-password"
component={<ForgotPasswordCtrl stripes={stripes} />}
/>
<TitledRoute
name="forgotUsername"
path="/forgot-username"
component={<ForgotUserNameCtrl stripes={stripes} />}
/>
<TitledRoute
name="checkEmail"
path="/check-email"
component={<CheckEmailStatusPage />}
/>
<TitledRoute
name="login"
component={
<Login
autoLogin={stripes.config.autoLogin}
stripes={stripes}
/>
}
/>
</Switch>
}
</Router>
</Provider>
</HotKeys>
</TitleManager>
</ModuleTranslator>
</CalloutContext.Provider>
</StripesContext.Provider>
);
}
}
RootWithIntl.propTypes = {
stripes: PropTypes.shape({
clone: PropTypes.func.isRequired,
config: PropTypes.object,
epics: PropTypes.object,
logger: PropTypes.object.isRequired,
okapi: PropTypes.object.isRequired,
store: PropTypes.object.isRequired
}).isRequired,
token: PropTypes.string,
isAuthenticated: PropTypes.bool,
disableAuth: PropTypes.bool.isRequired,
history: PropTypes.shape({}),
};

export default RootWithIntl;

18 changes: 5 additions & 13 deletions src/components/AppIcon/AppIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ import { withStripes } from '../../StripesContext';
import css from './AppIcon.css';

const AppIcon = ({
iconAlignment,
iconAriaHidden,
size,
iconAlignment = 'center',
iconAriaHidden = true,
size = 'medium',
icon,
alt,
src,
style,
children,
className,
tag,
tag = 'span',
app,
iconKey,
iconKey = 'app',
iconClassName,
stripes,
}) => {
Expand Down Expand Up @@ -137,12 +137,4 @@ AppIcon.propTypes = {
tag: PropTypes.string,
};

AppIcon.defaultProps = {
iconAlignment: 'center',
iconAriaHidden: true,
iconKey: 'app',
size: 'medium',
tag: 'span',
};

export default withStripes(AppIcon);
3 changes: 2 additions & 1 deletion src/components/Login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Login extends Component {
const buttonLabel = submissionStatus ? 'loggingIn' : 'login';
return (
<main>
<div className={styles.wrapper} style={branding.style?.login ?? {}}>
<div className={styles.wrapper} style={branding?.style?.login ?? {}}>
<div className={styles.container}>
<Row center="xs">
<Col xs={6}>
Expand Down Expand Up @@ -160,6 +160,7 @@ class Login extends Component {
validationEnabled={false}
hasClearIcon={false}
autoComplete="current-password"
required
/>
</Col>
</Row>
Expand Down
Loading

0 comments on commit b5be7a0

Please sign in to comment.