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-883: fixed-length session timeout banner may scroll off-screen or otherwise be hidden #1540

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Add `nl` (Dutch, Flemish) to the supported locales. Refs STCOR-878.
* Include optional okapi interfaces, `consortia`, `roles`, `users-keycloak`. Refs STCOR-889.
* useUserTenantPermissions hook - provide `isFetched` property. Refs STCOR-890.
* Move session timout banner to the bottom of the page. Refs STCOR-883.
aidynoJ marked this conversation as resolved.
Show resolved Hide resolved

## [10.1.1](https://github.com/folio-org/stripes-core/tree/v10.1.1) (2024-03-25)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.1.0...v10.1.1)
Expand Down
11 changes: 10 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import configureLogger from './configureLogger';
import configureStore from './configureStore';
import gatherActions from './gatherActions';
import { destroyStore } from './mainActions';
import css from './components/SessionEventContainer/style.css';

import Root from './components/Root';

Expand Down Expand Up @@ -37,7 +38,11 @@ export default class StripesCore extends Component {
const parsedTenant = storedTenant ? JSON.parse(storedTenant) : undefined;

const okapi = (typeof okapiConfig === 'object' && Object.keys(okapiConfig).length > 0)
? { ...okapiConfig, tenant: parsedTenant?.tenantName || okapiConfig.tenant, clientId: parsedTenant?.clientId || okapiConfig.clientId } : { withoutOkapi: true };
? {
...okapiConfig,
tenant: parsedTenant?.tenantName || okapiConfig.tenant,
clientId: parsedTenant?.clientId || okapiConfig.clientId
} : { withoutOkapi: true };

const initialState = merge({}, { okapi }, props.initialState);

Expand All @@ -58,6 +63,10 @@ export default class StripesCore extends Component {

return (
<StrictWrapper>
<div
id="events-portal"
aidynoJ marked this conversation as resolved.
Show resolved Hide resolved
className={css.eventsContainer}
/>
<Root
store={this.store}
epics={this.epics}
Expand Down
11 changes: 8 additions & 3 deletions src/RootWithIntl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from 'react';
import PropTypes from 'prop-types';
import { createPortal } from 'react-dom';
import {
Router,
Switch,
Expand Down Expand Up @@ -62,7 +63,7 @@ const RootWithIntl = ({ stripes, token = '', isAuthenticated = false, disableAut
>
<Provider store={connectedStripes.store}>
<Router history={history}>
{ isAuthenticated || token || disableAuth ?
{isAuthenticated || token || disableAuth ?
<>
<MainContainer>
<AppCtxMenuProvider>
Expand All @@ -72,10 +73,14 @@ const RootWithIntl = ({ stripes, token = '', isAuthenticated = false, disableAut
event={events.LOGIN}
stripes={connectedStripes}
/>
{ (typeof connectedStripes.okapi !== 'object' || connectedStripes.discovery.isFinished) && (
{(typeof connectedStripes.okapi !== 'object' || connectedStripes.discovery.isFinished) && (
<ModuleContainer id="content">
<OverlayContainer />
{connectedStripes.config.useSecureTokens && <SessionEventContainer history={history} queryClient={queryClient} />}
{connectedStripes.config.useSecureTokens &&
createPortal(<SessionEventContainer
history={history}
/>,
document.getElementById('events-portal'))}
aidynoJ marked this conversation as resolved.
Show resolved Hide resolved
aidynoJ marked this conversation as resolved.
Show resolved Hide resolved
<Switch>
<TitledRoute
name="home"
Expand Down
19 changes: 5 additions & 14 deletions src/RootWithIntl.test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
/* shhhh, eslint, it's ok. we need "unused" imports for mocks */
/* eslint-disable no-unused-vars */

import { render, screen } from '@folio/jest-config-stripes/testing-library/react';
import { Router as DefaultRouter } from 'react-router-dom';
import { createMemoryHistory } from 'history';

import AuthnLogin from './components/AuthnLogin';
import {
Login,
MainNav,
MainContainer,
ModuleContainer,
OverlayContainer,
StaleBundleWarning,
SessionEventContainer,
} from './components';

import RootWithIntl from './RootWithIntl';
import Stripes from './Stripes';

Expand Down Expand Up @@ -54,6 +40,11 @@ const store = {
};

describe('RootWithIntl', () => {
beforeAll(() => {
const eventsPortal = document.createElement('div');
eventsPortal.id = 'events-portal';
document.body.appendChild(eventsPortal);
});
it('renders login without one of (isAuthenticated, token, disableAuth)', async () => {
const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, discovery: { isFinished: false } });
await render(<Harness><RootWithIntl stripes={stripes} history={defaultHistory} isAuthenticated={false} /></Harness>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
} from '@folio/stripes-components';

import { useStripes } from '../../StripesContext';
import css from './style.css';

/**
* FixedLengthSessionWarning
Expand Down Expand Up @@ -48,7 +49,9 @@
return '00:00';
};

return <MessageBanner type="warning" show><FormattedMessage id="stripes-core.rtr.fixedLengthSession.timeRemaining" /> {timestampFormatter()}</MessageBanner>;
return <MessageBanner show contentClassName={css.fixedSessionBanner}><FormattedMessage
id="stripes-core.rtr.fixedLengthSession.timeRemaining"
/> {timestampFormatter()}</MessageBanner>;

Check failure on line 54 in src/components/SessionEventContainer/FixedLengthSessionWarning.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Closing tag of a multiline JSX expression must be on its own line

Check failure on line 54 in src/components/SessionEventContainer/FixedLengthSessionWarning.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Closing tag of a multiline JSX expression must be on its own line
};

export default FixedLengthSessionWarning;
14 changes: 14 additions & 0 deletions src/components/SessionEventContainer/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import '@folio/stripes-components/lib/variables.css';

.eventsContainer {
position: absolute;
bottom: 0;
z-index: 100000;
left: 50%;
transform: translate(-50%);
border: none
}

.fixedSessionBanner {
background-color: var(--warn);
}
Loading