2016-05-28 05:05:27 +08:00
|
|
|
import React from 'react';
|
2016-08-26 01:44:23 +08:00
|
|
|
import {OAuthSignInPage} from 'nylas-component-kit';
|
2016-05-28 05:05:27 +08:00
|
|
|
|
|
|
|
import {
|
2017-01-19 09:44:22 +08:00
|
|
|
tokenRequestPollForGmail,
|
|
|
|
authIMAPForGmail,
|
2016-05-28 05:05:27 +08:00
|
|
|
buildGmailSessionKey,
|
|
|
|
buildGmailAuthURL,
|
|
|
|
} from './onboarding-helpers';
|
|
|
|
|
|
|
|
import OnboardingActions from './onboarding-actions';
|
|
|
|
import AccountTypes from './account-types';
|
|
|
|
|
2016-07-27 06:55:31 +08:00
|
|
|
|
2016-05-28 05:05:27 +08:00
|
|
|
export default class AccountSettingsPageGmail extends React.Component {
|
|
|
|
static displayName = "AccountSettingsPageGmail";
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
accountInfo: React.PropTypes.object,
|
|
|
|
};
|
|
|
|
|
2016-07-27 06:55:31 +08:00
|
|
|
constructor() {
|
|
|
|
super()
|
2016-05-28 05:05:27 +08:00
|
|
|
this._sessionKey = buildGmailSessionKey();
|
2016-07-27 06:55:31 +08:00
|
|
|
this._gmailAuthUrl = buildGmailAuthURL(this._sessionKey)
|
2016-05-28 05:05:27 +08:00
|
|
|
}
|
|
|
|
|
2016-08-26 01:44:23 +08:00
|
|
|
onSuccess(account) {
|
2016-12-02 05:34:39 +08:00
|
|
|
OnboardingActions.accountJSONReceived(account, account.localToken, account.cloudToken);
|
2016-05-28 05:05:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {accountInfo} = this.props;
|
|
|
|
const iconName = AccountTypes.find(a => a.type === accountInfo.type).headerIcon;
|
2017-01-19 09:44:22 +08:00
|
|
|
const goBack = () => OnboardingActions.moveToPreviousPage()
|
2016-05-28 05:05:27 +08:00
|
|
|
|
|
|
|
return (
|
2016-08-26 01:44:23 +08:00
|
|
|
<OAuthSignInPage
|
2017-01-19 09:44:22 +08:00
|
|
|
providerAuthPageUrl={this._gmailAuthUrl}
|
2016-08-26 01:44:23 +08:00
|
|
|
iconName={iconName}
|
2017-01-19 09:44:22 +08:00
|
|
|
tokenRequestPollFn={tokenRequestPollForGmail}
|
|
|
|
accountFromTokenFn={authIMAPForGmail}
|
2016-08-26 01:44:23 +08:00
|
|
|
onSuccess={this.onSuccess}
|
2017-01-19 09:44:22 +08:00
|
|
|
onTryAgain={goBack}
|
|
|
|
serviceName="Google"
|
2016-08-26 01:44:23 +08:00
|
|
|
sessionKey={this._sessionKey}
|
|
|
|
/>
|
2016-05-28 05:05:27 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|