Skip to content

Commit

Permalink
STCOR-883: create events portal constant, move createPortal to Sessio…
Browse files Browse the repository at this point in the history
…nEventsContainer
  • Loading branch information
aidynoJ committed Oct 9, 2024
1 parent 9451f98 commit 79f0cdb
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* 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 timout banner to the bottom of the page. Refs STCOR-883.
* 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)
Expand Down
3 changes: 2 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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 @@ -64,7 +65,7 @@ export default class StripesCore extends Component {
return (
<StrictWrapper>
<div
id="events-portal"
id={eventsPortal}
className={css.eventsContainer}
/>
<Root
Expand Down
7 changes: 1 addition & 6 deletions src/RootWithIntl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState } from 'react';
import PropTypes from 'prop-types';
import { createPortal } from 'react-dom';
import {
Router,
Switch,
Expand Down Expand Up @@ -76,11 +75,7 @@ const RootWithIntl = ({ stripes, token = '', isAuthenticated = false, disableAut
{(typeof connectedStripes.okapi !== 'object' || connectedStripes.discovery.isFinished) && (
<ModuleContainer id="content">
<OverlayContainer />
{connectedStripes.config.useSecureTokens &&
createPortal(<SessionEventContainer
history={history}
/>,
document.getElementById('events-portal'))}
<SessionEventContainer history={history} />
<Switch>
<TitledRoute
name="home"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ const FixedLengthSessionWarning = () => {
return '00:00';
};

return <MessageBanner show contentClassName={css.fixedSessionBanner}><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
Empty file.
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';

0 comments on commit 79f0cdb

Please sign in to comment.