diff --git a/client/src/components/Core/Core.jsx b/client/src/components/Core/Core.jsx index 33800427..78bcc333 100755 --- a/client/src/components/Core/Core.jsx +++ b/client/src/components/Core/Core.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import { useTranslation, Trans } from 'react-i18next'; import { Loader } from 'semantic-ui-react'; @@ -14,9 +14,26 @@ import Background from '../Background'; import styles from './Core.module.scss'; const Core = React.memo( - ({ isInitializing, isSocketDisconnected, currentModal, currentProject }) => { + ({ isInitializing, isSocketDisconnected, currentModal, currentProject, currentBoard }) => { const [t] = useTranslation(); + const defaultTitle = useRef(document.title); + + useEffect(() => { + let title; + if (currentProject) { + title = currentProject.name; + + if (currentBoard) { + title += ` | ${currentBoard.name}`; + } + } else { + title = defaultTitle.current; + } + + document.title = title; + }, [currentProject, currentBoard]); + return ( <> {isInitializing ? ( @@ -58,12 +75,16 @@ Core.propTypes = { isInitializing: PropTypes.bool.isRequired, isSocketDisconnected: PropTypes.bool.isRequired, currentModal: PropTypes.oneOf(Object.values(ModalTypes)), - currentProject: PropTypes.object, // eslint-disable-line react/forbid-prop-types + /* eslint-disable react/forbid-prop-types */ + currentProject: PropTypes.object, + currentBoard: PropTypes.object, + /* eslint-enable react/forbid-prop-types */ }; Core.defaultProps = { currentModal: undefined, currentProject: undefined, + currentBoard: undefined, }; export default Core; diff --git a/client/src/containers/CoreContainer.js b/client/src/containers/CoreContainer.js index 09ffc2c3..e65c4d98 100755 --- a/client/src/containers/CoreContainer.js +++ b/client/src/containers/CoreContainer.js @@ -8,11 +8,13 @@ const mapStateToProps = (state) => { const isSocketDisconnected = selectors.selectIsSocketDisconnected(state); const currentModal = selectors.selectCurrentModal(state); const currentProject = selectors.selectCurrentProject(state); + const currentBoard = selectors.selectCurrentBoard(state); return { isSocketDisconnected, currentModal, currentProject, + currentBoard, isInitializing: isCoreInitializing, }; };