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-20 07:37:01 +08:00
|
|
|
makeGmailOAuthRequest,
|
2017-09-11 13:45:48 +08:00
|
|
|
buildGmailAccountFromToken,
|
2016-05-28 05:05:27 +08:00
|
|
|
buildGmailSessionKey,
|
|
|
|
buildGmailAuthURL,
|
|
|
|
} from './onboarding-helpers';
|
|
|
|
|
|
|
|
import OnboardingActions from './onboarding-actions';
|
2017-09-11 13:45:48 +08:00
|
|
|
import AccountProviders from './account-providers';
|
2016-05-28 05:05:27 +08:00
|
|
|
|
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 = {
|
2017-09-11 13:45:48 +08:00
|
|
|
account: React.PropTypes.object,
|
2016-05-28 05:05:27 +08:00
|
|
|
};
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-09-11 03:04:22 +08:00
|
|
|
onSuccess(account) {
|
2017-09-26 06:44:20 +08:00
|
|
|
OnboardingActions.finishAndAddAccount(account);
|
2016-05-28 05:05:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-09-11 13:45:48 +08:00
|
|
|
const providerConfig = AccountProviders.find(a =>
|
|
|
|
a.provider === this.props.account.provider
|
|
|
|
)
|
|
|
|
const {headerIcon} = providerConfig;
|
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-24 23:34:07 +08:00
|
|
|
serviceName="Google"
|
2017-01-19 09:44:22 +08:00
|
|
|
providerAuthPageUrl={this._gmailAuthUrl}
|
2017-01-24 23:34:07 +08:00
|
|
|
iconName={headerIcon}
|
2017-01-20 07:37:01 +08:00
|
|
|
tokenRequestPollFn={makeGmailOAuthRequest}
|
2017-09-11 13:45:48 +08:00
|
|
|
accountFromTokenFn={buildGmailAccountFromToken}
|
2016-08-26 01:44:23 +08:00
|
|
|
onSuccess={this.onSuccess}
|
2017-01-19 09:44:22 +08:00
|
|
|
onTryAgain={goBack}
|
2016-08-26 01:44:23 +08:00
|
|
|
sessionKey={this._sessionKey}
|
|
|
|
/>
|
2016-05-28 05:05:27 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|