Skip to content

Commit

Permalink
Use useUserSessionTimeout in UserMenu
Browse files Browse the repository at this point in the history
This allows to simplify the UserMenu by dropping the proptypes, HOC
composition and store connection.
  • Loading branch information
bjoernricks committed Nov 8, 2019
1 parent 79f25a2 commit 73b9f28
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions gsa/src/web/components/menu/usermenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
import React from 'react';

import {connect} from 'react-redux';

import {useHistory} from 'react-router-dom';

import styled, {keyframes} from 'styled-components';
Expand All @@ -35,15 +33,12 @@ import UserIcon from 'web/components/icon/usericon';
import Divider from 'web/components/layout/divider';
import Link from 'web/components/link/link';

import compose from 'web/utils/compose';
import PropTypes from 'web/utils/proptypes';
import Theme from 'web/utils/theme';
import useGmp from 'web/utils/useGmp';
import useUserName from 'web/utils/useUserName';
import useUserSessionTimeout from 'web/utils/useUserSessionTimeout';
import useUserTimezone from 'web/utils/useUserTimezone';

import {getSessionTimeout} from 'web/store/usersettings/selectors';

const UserMenu = styled.span`
display: inline-flex;
flex-direction: column;
Expand Down Expand Up @@ -133,7 +128,8 @@ const StyledLink = styled(Link)`
}
`;

const UserMenuContainer = ({sessionTimeout}) => {
const UserMenuContainer = () => {
const sessionTimeout = useUserSessionTimeout();
const userTimezone = useUserTimezone();
const userName = useUserName();
const gmp = useGmp();
Expand Down Expand Up @@ -188,14 +184,6 @@ const UserMenuContainer = ({sessionTimeout}) => {
);
};

UserMenuContainer.propTypes = {
sessionTimeout: PropTypes.date,
};

export default compose(
connect(rootState => ({
sessionTimeout: getSessionTimeout(rootState),
})),
)(UserMenuContainer);
export default UserMenuContainer;

// vim: set ts=2 sw=2 tw=80:

0 comments on commit 73b9f28

Please sign in to comment.