Mailspring/app/internal_packages/onboarding/lib/onboarding-root.jsx
Ben Gotow ae72cf1c65 Bump to React 16.2 now that the old composer is gone 🎉
commit 3c10d22199ea6428a6b45c6361d281b1d281ef4f
Author: Ben Gotow <ben@foundry376.com>
Date:   Fri Jan 19 08:10:43 2018 -0800

    Small fixes

commit e7d4ba85eb011a6fd58b57e079bf3a19c19126d8
Author: Ben Gotow <ben@foundry376.com>
Date:   Thu Jan 18 23:47:03 2018 -0800

    Rewrite UnsafeComponent using Error Boundaries

commit aa772694fdee6c57887b75b3abb2e654e146fab5
Author: Ben Gotow <ben@foundry376.com>
Date:   Thu Jan 18 23:15:53 2018 -0800

    Remove GeneratedForm

commit f9ea4296f07d446f942dfc2532deea37db43ddac
Author: Ben Gotow <ben@foundry376.com>
Date:   Thu Jan 18 23:08:45 2018 -0800

    Fully remove calendar related dead code and spec_disabled

    It’s making it hard to see what I need to edit and what I don’t care about

commit 6192ce6073244bc66b7908b66b5033d34e947efb
Author: Ben Gotow <ben@foundry376.com>
Date:   Thu Jan 18 23:08:16 2018 -0800

    Bump to React 16.2 🎉
2018-01-22 22:18:46 -08:00

88 lines
2.6 KiB
JavaScript

import React from 'react';
import { CSSTransitionGroup } from 'react-transition-group';
import OnboardingStore from './onboarding-store';
import PageTopBar from './page-top-bar';
import WelcomePage from './page-welcome';
import TutorialPage from './page-tutorial';
import AuthenticatePage from './page-authenticate';
import AccountChoosePage from './page-account-choose';
import AccountSettingsPage from './page-account-settings';
import AccountSettingsPageGmail from './page-account-settings-gmail';
import AccountSettingsPageIMAP from './page-account-settings-imap';
import AccountOnboardingSuccess from './page-account-onboarding-success';
import InitialPreferencesPage from './page-initial-preferences';
import InitialSubscriptionPage from './page-initial-subscription';
const PageComponents = {
welcome: WelcomePage,
tutorial: TutorialPage,
authenticate: AuthenticatePage,
'account-choose': AccountChoosePage,
'account-settings': AccountSettingsPage,
'account-settings-gmail': AccountSettingsPageGmail,
'account-settings-imap': AccountSettingsPageIMAP,
'account-onboarding-success': AccountOnboardingSuccess,
'initial-preferences': InitialPreferencesPage,
'initial-subscription': InitialSubscriptionPage,
};
export default class OnboardingRoot extends React.Component {
static displayName = 'OnboardingRoot';
static containerRequired = false;
constructor(props) {
super(props);
this.state = this._getStateFromStore();
}
componentDidMount() {
this.unsubscribe = OnboardingStore.listen(this._onStateChanged, this);
AppEnv.center();
AppEnv.displayWindow();
}
componentWillUnmount() {
if (this.unsubscribe) {
this.unsubscribe();
}
}
_getStateFromStore = () => {
return {
page: OnboardingStore.page(),
pageDepth: OnboardingStore.pageDepth(),
account: OnboardingStore.account(),
};
};
_onStateChanged = () => {
this.setState(this._getStateFromStore());
};
render() {
const Component = PageComponents[this.state.page];
if (!Component) {
throw new Error(`Cannot find component for page: ${this.state.page}`);
}
return (
<div className="page-frame">
<PageTopBar
pageDepth={this.state.pageDepth}
allowMoveBack={!['initial-preferences', 'account-choose'].includes(this.state.page)}
/>
<CSSTransitionGroup
transitionName="alpha-fade"
transitionLeaveTimeout={150}
transitionEnterTimeout={150}
>
<div key={this.state.page} className="page-container">
<Component account={this.state.account} />
</div>
</CSSTransitionGroup>
</div>
);
}
}