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:
parent
e4372a4be7
commit
0847f24cf7
2 changed files with 26 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useTranslation, Trans } from 'react-i18next';
|
import { useTranslation, Trans } from 'react-i18next';
|
||||||
import { Loader } from 'semantic-ui-react';
|
import { Loader } from 'semantic-ui-react';
|
||||||
|
@ -14,9 +14,26 @@ import Background from '../Background';
|
||||||
import styles from './Core.module.scss';
|
import styles from './Core.module.scss';
|
||||||
|
|
||||||
const Core = React.memo(
|
const Core = React.memo(
|
||||||
({ isInitializing, isSocketDisconnected, currentModal, currentProject }) => {
|
({ isInitializing, isSocketDisconnected, currentModal, currentProject, currentBoard }) => {
|
||||||
const [t] = useTranslation();
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{isInitializing ? (
|
{isInitializing ? (
|
||||||
|
@ -58,12 +75,16 @@ Core.propTypes = {
|
||||||
isInitializing: PropTypes.bool.isRequired,
|
isInitializing: PropTypes.bool.isRequired,
|
||||||
isSocketDisconnected: PropTypes.bool.isRequired,
|
isSocketDisconnected: PropTypes.bool.isRequired,
|
||||||
currentModal: PropTypes.oneOf(Object.values(ModalTypes)),
|
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 = {
|
Core.defaultProps = {
|
||||||
currentModal: undefined,
|
currentModal: undefined,
|
||||||
currentProject: undefined,
|
currentProject: undefined,
|
||||||
|
currentBoard: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Core;
|
export default Core;
|
||||||
|
|
|
@ -8,11 +8,13 @@ const mapStateToProps = (state) => {
|
||||||
const isSocketDisconnected = selectors.selectIsSocketDisconnected(state);
|
const isSocketDisconnected = selectors.selectIsSocketDisconnected(state);
|
||||||
const currentModal = selectors.selectCurrentModal(state);
|
const currentModal = selectors.selectCurrentModal(state);
|
||||||
const currentProject = selectors.selectCurrentProject(state);
|
const currentProject = selectors.selectCurrentProject(state);
|
||||||
|
const currentBoard = selectors.selectCurrentBoard(state);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isSocketDisconnected,
|
isSocketDisconnected,
|
||||||
currentModal,
|
currentModal,
|
||||||
currentProject,
|
currentProject,
|
||||||
|
currentBoard,
|
||||||
isInitializing: isCoreInitializing,
|
isInitializing: isCoreInitializing,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue