mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Add document title management for the ascribe app
This commit is contained in:
parent
d6b7060f39
commit
66dbf3da71
@ -23,6 +23,7 @@ import GlobalNotificationActions from '../../actions/global_notification_actions
|
|||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../../utils/dom_utils';
|
||||||
import { mergeOptions, truncateTextAtCharIndex } from '../../utils/general_utils';
|
import { mergeOptions, truncateTextAtCharIndex } from '../../utils/general_utils';
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +87,8 @@ let ContractSettings = React.createClass({
|
|||||||
let privateContracts = this.getPrivateContracts();
|
let privateContracts = this.getPrivateContracts();
|
||||||
let createPublicContractForm = null;
|
let createPublicContractForm = null;
|
||||||
|
|
||||||
|
setDocumentTitle(getLangText('Contracts settings'));
|
||||||
|
|
||||||
if(publicContracts.length === 0) {
|
if(publicContracts.length === 0) {
|
||||||
createPublicContractForm = (
|
createPublicContractForm = (
|
||||||
<CreateContractForm
|
<CreateContractForm
|
||||||
|
@ -15,6 +15,8 @@ import APISettings from './api_settings';
|
|||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
|
||||||
import { mergeOptions } from '../../utils/general_utils';
|
import { mergeOptions } from '../../utils/general_utils';
|
||||||
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../../utils/dom_utils';
|
||||||
|
|
||||||
|
|
||||||
let SettingsContainer = React.createClass({
|
let SettingsContainer = React.createClass({
|
||||||
@ -53,6 +55,8 @@ let SettingsContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
setDocumentTitle(getLangText('Account settings'));
|
||||||
|
|
||||||
if (this.state.currentUser && this.state.currentUser.username) {
|
if (this.state.currentUser && this.state.currentUser.username) {
|
||||||
return (
|
return (
|
||||||
<div className="settings-container">
|
<div className="settings-container">
|
||||||
|
@ -11,10 +11,13 @@ import InputTextAreaToggable from './ascribe_forms/input_textarea_toggable';
|
|||||||
|
|
||||||
import ApiUrls from '../constants/api_urls';
|
import ApiUrls from '../constants/api_urls';
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
|
|
||||||
|
|
||||||
let CoaVerifyContainer = React.createClass({
|
let CoaVerifyContainer = React.createClass({
|
||||||
render() {
|
render() {
|
||||||
|
setDocumentTitle(getLangText('Verify your Certificate of Authenticity'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-login-wrapper">
|
<div className="ascribe-login-wrapper">
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -6,6 +6,7 @@ import { Link } from 'react-router';
|
|||||||
import LoginForm from './ascribe_forms/form_login';
|
import LoginForm from './ascribe_forms/form_login';
|
||||||
|
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
|
|
||||||
|
|
||||||
let LoginContainer = React.createClass({
|
let LoginContainer = React.createClass({
|
||||||
@ -26,6 +27,8 @@ let LoginContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
setDocumentTitle(getLangText('Log in'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-login-wrapper">
|
<div className="ascribe-login-wrapper">
|
||||||
<LoginForm
|
<LoginForm
|
||||||
|
@ -6,6 +6,9 @@ import { History } from 'react-router';
|
|||||||
import UserActions from '../actions/user_actions';
|
import UserActions from '../actions/user_actions';
|
||||||
import { alt, altWhitelabel, altUser, altThirdParty } from '../alt';
|
import { alt, altWhitelabel, altUser, altThirdParty } from '../alt';
|
||||||
|
|
||||||
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
|
|
||||||
|
|
||||||
let LogoutContainer = React.createClass({
|
let LogoutContainer = React.createClass({
|
||||||
|
|
||||||
@ -22,6 +25,8 @@ let LogoutContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
setDocumentTitle(getLangText('Log out'));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import ApiUrls from '../constants/api_urls';
|
|||||||
import GlobalNotificationModel from '../models/global_notification_model';
|
import GlobalNotificationModel from '../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../actions/global_notification_actions';
|
import GlobalNotificationActions from '../actions/global_notification_actions';
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
|
|
||||||
|
|
||||||
let PasswordResetContainer = React.createClass({
|
let PasswordResetContainer = React.createClass({
|
||||||
@ -75,6 +76,8 @@ let PasswordRequestResetForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
setDocumentTitle(getLangText('Reset your password'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
ref="form"
|
ref="form"
|
||||||
|
@ -24,6 +24,7 @@ import AppConstants from '../constants/application_constants';
|
|||||||
|
|
||||||
import { mergeOptions } from '../utils/general_utils';
|
import { mergeOptions } from '../utils/general_utils';
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
|
|
||||||
|
|
||||||
let PieceList = React.createClass({
|
let PieceList = React.createClass({
|
||||||
@ -153,6 +154,8 @@ let PieceList = React.createClass({
|
|||||||
let loadingElement = (<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />);
|
let loadingElement = (<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />);
|
||||||
let AccordionListItemType = this.props.accordionListItemType;
|
let AccordionListItemType = this.props.accordionListItemType;
|
||||||
|
|
||||||
|
setDocumentTitle(getLangText('Collection'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PieceListToolbar
|
<PieceListToolbar
|
||||||
|
@ -22,6 +22,7 @@ import RegisterPieceForm from './ascribe_forms/form_register_piece';
|
|||||||
|
|
||||||
import { mergeOptions } from '../utils/general_utils';
|
import { mergeOptions } from '../utils/general_utils';
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
|
|
||||||
|
|
||||||
let RegisterPiece = React.createClass( {
|
let RegisterPiece = React.createClass( {
|
||||||
@ -115,6 +116,8 @@ let RegisterPiece = React.createClass( {
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
setDocumentTitle(getLangText('Register a new piece'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className="no-margin">
|
<Row className="no-margin">
|
||||||
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
||||||
|
@ -6,6 +6,7 @@ import { Link } from 'react-router';
|
|||||||
import SignupForm from './ascribe_forms/form_signup';
|
import SignupForm from './ascribe_forms/form_signup';
|
||||||
|
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
import { setDocumentTitle } from '../utils/dom_utils';
|
||||||
|
|
||||||
|
|
||||||
let SignupContainer = React.createClass({
|
let SignupContainer = React.createClass({
|
||||||
@ -28,6 +29,8 @@ let SignupContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
setDocumentTitle(getLangText('Sign up'));
|
||||||
|
|
||||||
if (this.state.submitted){
|
if (this.state.submitted){
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-login-wrapper">
|
<div className="ascribe-login-wrapper">
|
||||||
|
30
js/utils/dom_utils.js
Normal file
30
js/utils/dom_utils.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of unread notifications in the title.
|
||||||
|
*
|
||||||
|
* @return {int} the number of unread notifications
|
||||||
|
*/
|
||||||
|
export function getUnreadCount() {
|
||||||
|
const match = document.title.match(/^\((\d+)\)/);
|
||||||
|
return match ? match[1] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the title in the browser window while keeping the unread notification count (if any).
|
||||||
|
*
|
||||||
|
* @return {string} the new document title
|
||||||
|
*/
|
||||||
|
export function setDocumentTitle(title) {
|
||||||
|
const count = getUnreadCount();
|
||||||
|
let newTitle = title;
|
||||||
|
|
||||||
|
if (count) {
|
||||||
|
newTitle = `(${count}) ` + newTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.title = newTitle;
|
||||||
|
return newTitle;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user