From 056fdec301de69e235313c0e27aadf8c769f8082 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sun, 24 Jan 2016 20:48:31 -0600 Subject: PLT-7 client side infra for loc --- web/react/pages/authorize.jsx | 75 ++++++++++++++++++++++++++------ web/react/pages/claim_account.jsx | 71 +++++++++++++++++++++++++----- web/react/pages/docs.jsx | 64 +++++++++++++++++++++++---- web/react/pages/password_reset.jsx | 71 +++++++++++++++++++++++++----- web/react/pages/signup_team.jsx | 63 ++++++++++++++++++++++++--- web/react/pages/signup_team_complete.jsx | 67 ++++++++++++++++++++++++---- web/react/pages/signup_user_complete.jsx | 73 ++++++++++++++++++++++++++----- web/react/pages/verify.jsx | 65 ++++++++++++++++++++++++--- 8 files changed, 473 insertions(+), 76 deletions(-) diff --git a/web/react/pages/authorize.jsx b/web/react/pages/authorize.jsx index 71f17d007..7474332ce 100644 --- a/web/react/pages/authorize.jsx +++ b/web/react/pages/authorize.jsx @@ -2,20 +2,69 @@ // See License.txt for license information. import Authorize from '../components/authorize.jsx'; +import * as Client from '../utils/client.jsx'; -function setupAuthorizePage(props) { +var IntlProvider = ReactIntl.IntlProvider; + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + this.props.map.Locale, + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } +} + +global.window.setup_authorize_page = function setup(props) { ReactDOM.render( - , + , document.getElementById('authorize') ); -} - -global.window.setup_authorize_page = setupAuthorizePage; +}; diff --git a/web/react/pages/claim_account.jsx b/web/react/pages/claim_account.jsx index bca203d96..7c6af73ca 100644 --- a/web/react/pages/claim_account.jsx +++ b/web/react/pages/claim_account.jsx @@ -2,18 +2,67 @@ // See License.txt for license information. import ClaimAccount from '../components/claim/claim_account.jsx'; +import * as Client from '../utils/client.jsx'; -function setupClaimAccountPage(props) { +var IntlProvider = ReactIntl.IntlProvider; + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + this.props.map.Locale, + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } +} + +global.window.setup_claim_account_page = function setup(props) { ReactDOM.render( - , + , document.getElementById('claim') ); -} - -global.window.setup_claim_account_page = setupClaimAccountPage; +}; \ No newline at end of file diff --git a/web/react/pages/docs.jsx b/web/react/pages/docs.jsx index 74d9c2d19..2f5d4db55 100644 --- a/web/react/pages/docs.jsx +++ b/web/react/pages/docs.jsx @@ -2,15 +2,63 @@ // See License.txt for license information. import Docs from '../components/docs.jsx'; +import * as Client from '../utils/client.jsx'; -function setupDocumentationPage(props) { - ReactDOM.render( - , - document.getElementById('docs') - ); +var IntlProvider = ReactIntl.IntlProvider; + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + this.props.map.Locale, + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } } global.window.mm_user = global.window.mm_user || {}; -global.window.setup_documentation_page = setupDocumentationPage; + +global.window.setup_documentation_page = function setup(props) { + ReactDOM.render( + , + document.getElementById('docs') + ); +}; diff --git a/web/react/pages/password_reset.jsx b/web/react/pages/password_reset.jsx index 4a6f1dcb0..23bbf2691 100644 --- a/web/react/pages/password_reset.jsx +++ b/web/react/pages/password_reset.jsx @@ -2,18 +2,67 @@ // See License.txt for license information. import PasswordReset from '../components/password_reset.jsx'; +import * as Client from '../utils/client.jsx'; -function setupPasswordResetPage(props) { +var IntlProvider = ReactIntl.IntlProvider; + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + this.props.map.Locale, + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } +} + +global.window.setup_password_reset_page = function setup(props) { ReactDOM.render( - , + , document.getElementById('reset') ); -} - -global.window.setup_password_reset_page = setupPasswordResetPage; +}; diff --git a/web/react/pages/signup_team.jsx b/web/react/pages/signup_team.jsx index 08ea45000..8f4f86a7c 100644 --- a/web/react/pages/signup_team.jsx +++ b/web/react/pages/signup_team.jsx @@ -2,8 +2,60 @@ // See License.txt for license information. import SignupTeam from '../components/signup_team.jsx'; +import * as Client from '../utils/client.jsx'; -function setupSignupTeamPage(props) { +var IntlProvider = ReactIntl.IntlProvider; + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired, + teams: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + this.props.map.Locale, + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } +} + +global.window.setup_signup_team_page = function setup(props) { var teams = []; for (var prop in props) { @@ -15,9 +67,10 @@ function setupSignupTeamPage(props) { } ReactDOM.render( - , + , document.getElementById('signup-team') ); -} - -global.window.setup_signup_team_page = setupSignupTeamPage; +}; \ No newline at end of file diff --git a/web/react/pages/signup_team_complete.jsx b/web/react/pages/signup_team_complete.jsx index d5ed144a1..1bee4e598 100644 --- a/web/react/pages/signup_team_complete.jsx +++ b/web/react/pages/signup_team_complete.jsx @@ -2,16 +2,65 @@ // See License.txt for license information. import SignupTeamComplete from '../components/signup_team_complete.jsx'; +import * as Client from '../utils/client.jsx'; -function setupSignupTeamCompletePage(props) { +var IntlProvider = ReactIntl.IntlProvider; + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + this.props.map.Locale, + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } +} + +global.window.setup_signup_team_complete_page = function setup(props) { ReactDOM.render( - , + , document.getElementById('signup-team-complete') ); -} - -global.window.setup_signup_team_complete_page = setupSignupTeamCompletePage; +}; \ No newline at end of file diff --git a/web/react/pages/signup_user_complete.jsx b/web/react/pages/signup_user_complete.jsx index de2c48443..6c761c1ee 100644 --- a/web/react/pages/signup_user_complete.jsx +++ b/web/react/pages/signup_user_complete.jsx @@ -2,19 +2,68 @@ // See License.txt for license information. import SignupUserComplete from '../components/signup_user_complete.jsx'; +import * as Client from '../utils/client.jsx'; -function setupSignupUserCompletePage(props) { +var IntlProvider = ReactIntl.IntlProvider; + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + this.props.map.Locale, + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } +} + +global.window.setup_signup_user_complete_page = function setup(props) { ReactDOM.render( - , + , document.getElementById('signup-user-complete') ); -} - -global.window.setup_signup_user_complete_page = setupSignupUserCompletePage; +}; \ No newline at end of file diff --git a/web/react/pages/verify.jsx b/web/react/pages/verify.jsx index d4ce4844d..2fc619e58 100644 --- a/web/react/pages/verify.jsx +++ b/web/react/pages/verify.jsx @@ -2,15 +2,66 @@ // See License.txt for license information. import EmailVerify from '../components/email_verify.jsx'; +import * as Client from '../utils/client.jsx'; -global.window.setupVerifyPage = function setupVerifyPage(props) { +var IntlProvider = ReactIntl.IntlProvider; + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + this.props.map.Locale, + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } +} + +global.window.setupVerifyPage = function setup(props) { ReactDOM.render( - , + , document.getElementById('verify') ); }; -- cgit v1.2.3-1-g7c22