1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

feat: Display current project and board in page title

This commit is contained in:
Maksim Eltyshev 2023-02-20 11:41:22 +01:00
parent e4372a4be7
commit 0847f24cf7
2 changed files with 26 additions and 3 deletions

View file

@ -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;

View file

@ -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,
};
};