2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-11-22 18:14:51 -05:00
|
|
|
import Events from "meteor/nova:events";
|
|
|
|
import Users from 'meteor/nova:users';
|
2016-03-17 18:08:03 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-06-09 20:45:58 +09:00
|
|
|
import { IntlProvider, intlShape} from 'react-intl';
|
2016-11-22 18:14:51 -05:00
|
|
|
import { graphql } from 'react-apollo';
|
|
|
|
import gql from 'graphql-tag';
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
class App extends Component {
|
2016-03-24 18:17:35 +09:00
|
|
|
|
2016-06-09 17:42:20 +09:00
|
|
|
getLocale() {
|
2016-06-09 20:45:58 +09:00
|
|
|
return Telescope.settings.get("locale", "en");
|
2016-06-09 17:42:20 +09:00
|
|
|
}
|
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
getChildContext() {
|
2016-06-09 17:42:20 +09:00
|
|
|
|
2016-06-09 20:45:58 +09:00
|
|
|
const messages = Telescope.strings[this.getLocale()] || {};
|
|
|
|
const intlProvider = new IntlProvider({locale: this.getLocale()}, messages);
|
|
|
|
|
2016-06-09 17:42:20 +09:00
|
|
|
const {intl} = intlProvider.getChildContext();
|
|
|
|
|
2016-03-24 18:17:35 +09:00
|
|
|
return {
|
2016-11-10 22:18:36 +01:00
|
|
|
currentUser: this.props.currentUser,
|
2016-10-31 16:19:37 +01:00
|
|
|
actions: {call: Meteor.call},
|
2016-11-11 11:23:39 +01:00
|
|
|
events: Events,
|
2016-06-09 17:42:20 +09:00
|
|
|
intl: intl
|
2016-03-24 18:17:35 +09:00
|
|
|
};
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
2016-02-14 12:27:20 +09:00
|
|
|
|
|
|
|
render() {
|
2016-06-16 10:43:25 +09:00
|
|
|
return (
|
|
|
|
<IntlProvider locale={this.getLocale()} messages={Telescope.strings[this.getLocale()]}>
|
|
|
|
{
|
2016-11-10 17:26:55 +09:00
|
|
|
this.props.loading ?
|
|
|
|
<Telescope.components.AppLoading /> :
|
2016-10-14 08:47:18 +02:00
|
|
|
<Telescope.components.Layout>{this.props.children}</Telescope.components.Layout>
|
2016-06-16 10:43:25 +09:00
|
|
|
}
|
|
|
|
</IntlProvider>
|
|
|
|
)
|
2016-02-14 12:27:20 +09:00
|
|
|
}
|
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
App.propTypes = {
|
2016-11-10 17:26:55 +09:00
|
|
|
loading: React.PropTypes.bool,
|
2016-03-27 13:04:21 +09:00
|
|
|
currentUser: React.PropTypes.object,
|
2016-06-14 22:36:54 +02:00
|
|
|
actions: React.PropTypes.object,
|
|
|
|
events: React.PropTypes.object,
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
App.childContextTypes = {
|
|
|
|
currentUser: React.PropTypes.object,
|
2016-06-14 22:36:54 +02:00
|
|
|
actions: React.PropTypes.object,
|
2016-06-14 17:03:35 +09:00
|
|
|
events: React.PropTypes.object,
|
2016-11-03 14:39:27 +09:00
|
|
|
intl: intlShape,
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
2016-02-16 15:40:37 +09:00
|
|
|
|
2016-11-22 18:14:51 -05:00
|
|
|
// we are not "forced" to use the containers helpers to run specific queries like `getCurrentUser` which doesn't take any argument
|
|
|
|
const currentUserContainer = graphql(
|
|
|
|
gql`query getCurrentUser {
|
|
|
|
currentUser {
|
|
|
|
_id
|
|
|
|
username
|
|
|
|
createdAt
|
|
|
|
isAdmin
|
|
|
|
__bio
|
|
|
|
__commentCount
|
|
|
|
__displayName
|
|
|
|
__downvotedComments {
|
|
|
|
itemId
|
|
|
|
power
|
|
|
|
votedAt
|
|
|
|
}
|
|
|
|
__downvotedPosts {
|
|
|
|
itemId
|
|
|
|
power
|
|
|
|
votedAt
|
|
|
|
}
|
|
|
|
__email
|
|
|
|
__emailHash
|
|
|
|
__groups
|
|
|
|
__htmlBio
|
|
|
|
__karma
|
|
|
|
__newsletter_subscribeToNewsletter
|
|
|
|
#__notifications_users
|
|
|
|
#__notifications_posts
|
|
|
|
__postCount
|
|
|
|
__slug
|
|
|
|
__twitterUsername
|
|
|
|
__upvotedComments {
|
|
|
|
itemId
|
|
|
|
power
|
|
|
|
votedAt
|
|
|
|
}
|
|
|
|
__upvotedPosts {
|
|
|
|
itemId
|
|
|
|
power
|
|
|
|
votedAt
|
|
|
|
}
|
|
|
|
__website
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
props(props) {
|
|
|
|
const {data: {loading, currentUser}} = props;
|
|
|
|
return {
|
|
|
|
loading,
|
|
|
|
currentUser,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
Telescope.registerComponent('App', App, currentUserContainer);
|