Vulcan/packages/nova-base-components/lib/common/App.jsx

51 lines
1.3 KiB
React
Raw Normal View History

import React, { PropTypes, Component } from 'react';
2016-06-09 17:42:20 +09:00
import {IntlProvider, intlShape} from 'react-intl';
2016-05-22 15:23:30 +09:00
import { AppComposer } from "meteor/nova:core";
class App extends Component {
2016-03-24 18:17:35 +09:00
2016-06-09 17:42:20 +09:00
getLocale() {
return Telescope.settings.get("locale", "en_US");
}
getChildContext() {
2016-06-09 17:42:20 +09:00
const intlProvider = new IntlProvider({locale: this.getLocale()}, Telescope.strings[this.getLocale()]);
const {intl} = intlProvider.getChildContext();
2016-03-24 18:17:35 +09:00
return {
currentUser: this.props.currentUser,
2016-06-09 17:42:20 +09:00
currentRoute: this.props.currentRoute,
intl: intl
2016-03-24 18:17:35 +09:00
};
}
render() {
2016-06-09 17:42:20 +09:00
if (this.props.ready) {
2016-06-09 17:42:20 +09:00
return (
<IntlProvider locale={this.getLocale()} messages={Telescope.strings[this.getLocale()]}>
<Telescope.components.Layout currentUser={this.props.currentUser}>{this.props.content}</Telescope.components.Layout>
</IntlProvider>
)
2016-02-16 15:08:30 +09:00
} else {
return <Telescope.components.AppLoading />
2016-02-16 15:08:30 +09:00
}
}
}
App.propTypes = {
ready: React.PropTypes.bool,
currentUser: React.PropTypes.object,
currentRoute: React.PropTypes.object
}
App.childContextTypes = {
currentUser: React.PropTypes.object,
2016-06-09 17:42:20 +09:00
currentRoute: React.PropTypes.object,
intl: intlShape
}
2016-03-27 16:32:29 +09:00
module.exports = AppComposer(App);
export default AppComposer(App);