-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposal to make document title dynamic (#2842)
Introduce a component that takes care of modifying the document title to a given value, and use it in one of the pages as an example. Refs #2834
- Loading branch information
Showing
3 changed files
with
43 additions
and
12 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
graylog2-web-interface/src/components/common/DocumentTitle.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
|
||
const DocumentTitle = React.createClass({ | ||
propTypes: { | ||
title: React.PropTypes.string.isRequired, | ||
children: React.PropTypes.oneOfType([ | ||
React.PropTypes.arrayOf(React.PropTypes.element), | ||
React.PropTypes.element, | ||
]).isRequired, | ||
}, | ||
|
||
componentDidMount() { | ||
this.originalTitle = document.title; | ||
document.title = `${document.title} - ${this.props.title}`; | ||
}, | ||
|
||
componentWillUnmount() { | ||
document.title = this.originalTitle; | ||
}, | ||
|
||
originalTitle: undefined, | ||
|
||
render() { | ||
return this.props.children; | ||
}, | ||
}); | ||
|
||
export default DocumentTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters