Skip to content

Commit

Permalink
Proposal to make document title dynamic (#2842)
Browse files Browse the repository at this point in the history
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
edmundoa authored and bernd committed Sep 26, 2016
1 parent 430518c commit b85b9ff
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
28 changes: 28 additions & 0 deletions graylog2-web-interface/src/components/common/DocumentTitle.jsx
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;
1 change: 1 addition & 0 deletions graylog2-web-interface/src/components/common/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as ClipboardButton } from './ClipboardButton';
export { default as DataFilter } from './DataFilter';
export { default as DataTable } from './DataTable';
export { default as DatePicker } from './DatePicker';
export { default as DocumentTitle } from './DocumentTitle';
export { default as EntityList } from './EntityList';
export { default as EntityListItem } from './EntityListItem';
export { default as GridsterContainer } from './GridsterContainer';
Expand Down
26 changes: 14 additions & 12 deletions graylog2-web-interface/src/pages/NodesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@ import Reflux from 'reflux';
import StoreProvider from 'injection/StoreProvider';
const CurrentUserStore = StoreProvider.getStore('CurrentUser');

import { PageHeader } from 'components/common';
import { DocumentTitle, PageHeader } from 'components/common';
import { NodesList } from 'components/nodes';

const NodesPage = React.createClass({
mixins: [Reflux.connect(CurrentUserStore)],
render() {
return (
<div>
<PageHeader title="Nodes">
<span>This page provides a real-time overview of the nodes in your Graylog cluster.</span>
<DocumentTitle title="Nodes">
<div>
<PageHeader title="Nodes">
<span>This page provides a real-time overview of the nodes in your Graylog cluster.</span>

<span>
You can pause message processing at any time. The process buffers will not accept any new messages until
you resume it. If the message journal is enabled for a node, which it is by default, incoming messages
will be persisted to disk, even when processing is disabled.
</span>
</PageHeader>
<NodesList permissions={this.state.currentUser.permissions}/>
</div>
<span>
You can pause message processing at any time. The process buffers will not accept any new messages until
you resume it. If the message journal is enabled for a node, which it is by default, incoming messages
will be persisted to disk, even when processing is disabled.
</span>
</PageHeader>
<NodesList permissions={this.state.currentUser.permissions}/>
</div>
</DocumentTitle>
);
},
});
Expand Down

0 comments on commit b85b9ff

Please sign in to comment.