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 all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* Include optional okapi interfaces, `consortia`, `roles`, `users-keycloak`. Refs STCOR-889.
* useUserTenantPermissions hook - provide `isFetched` property. Refs STCOR-890.
* Reword error message "Error: server is forbidden, unreachable or down. VPN issue?". Refs STCOR-893.
* Move session timeout banner to the bottom of the page. Refs STCOR-883.


## [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
6 changes: 6 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ 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';
import { eventsPortal } from './constants';

const StrictWrapper = ({ children }) => {
if (config.disableStrictMode) {
Expand Down Expand Up @@ -58,6 +60,10 @@ export default class StripesCore extends Component {

return (
<StrictWrapper>
<div
id={eventsPortal}
className={css.eventsContainer}
/>
<Root
store={this.store}
epics={this.epics}
Expand Down
14 changes: 0 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@folio/stripes-components';

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

/**
* FixedLengthSessionWarning
Expand Down Expand Up @@ -48,7 +49,7 @@ const FixedLengthSessionWarning = () => {
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>;
};

export default FixedLengthSessionWarning;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import PropTypes from 'prop-types';
import createInactivityTimer from 'inactivity-timer';
import ms from 'ms';
Expand All @@ -15,6 +16,7 @@ import {
} from '../Root/constants';
import { toggleRtrModal } from '../../okapiActions';
import FixedLengthSessionWarning from './FixedLengthSessionWarning';
import { eventsPortal } from '../../constants';

//
// event listeners
Expand Down Expand Up @@ -278,7 +280,7 @@ const SessionEventContainer = ({ history }) => {
renderList.push(<FixedLengthSessionWarning key="FixedLengthSessionWarning" />);
}

return renderList.length ? renderList : null;
return renderList.length ? createPortal(renderList, document.getElementById(eventsPortal)) : null;
};

SessionEventContainer.propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { RTR_TIMEOUT_EVENT } from '../Root/constants';

import { toggleRtrModal } from '../../okapiActions';
import { eventsPortal } from '../../constants';

jest.mock('./KeepWorkingModal', () => (() => <div>KeepWorkingModal</div>));
jest.mock('../../loginServices');
Expand All @@ -37,6 +38,11 @@ const stripes = {
};

describe('SessionEventContainer', () => {
beforeAll(() => {
const eventsPortalElement = document.createElement('div');
eventsPortalElement.id = eventsPortal;
document.body.appendChild(eventsPortalElement);
});
it('Renders nothing if useSecureTokens is false', async () => {
const insecureStripes = {
config: {
Expand Down
Empty file.
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);
}
3 changes: 3 additions & 0 deletions src/constants/eventsPortal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const EVENTS_PORTAL = 'events-portal';

export default EVENTS_PORTAL;
1 change: 1 addition & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export { default as ssoErrorCodes } from './ssoErrorCodes';
export { default as defaultErrors } from './defaultErrors';
export { default as packageName } from './packageName';
export { default as delimiters } from './delimiters';
export { default as eventsPortal } from './eventsPortal';
Loading