Mailspring/packages/client-app/internal_packages/onboarding/lib/page-authenticate.jsx
Evan Morikawa 4904a9ae85 [client-app] Updates to feature limiting
This is a squash of a bunch of commits releated to feature limiting.
Includes making the upgrade path seamless by accessing billing through a
WebView and making sure that the feature is enabled after upgrading, or
canceled if the upgrade path is stopped by the user in any way.

Included diffs
---------------
Differential Revision: https://phab.nylas.com/D4078
Differential Revision: https://phab.nylas.com/D4136
Differential Revision: https://phab.nylas.com/D4137
Differential Revision: https://phab.nylas.com/D4143
Differential Revision: https://phab.nylas.com/D4147
Differential Revision: https://phab.nylas.com/D4171
Differential Revision: https://phab.nylas.com/D4173
2017-04-05 16:02:53 -07:00

45 lines
1.4 KiB
JavaScript

import React from 'react';
import {IdentityStore} from 'nylas-exports';
import {Webview} from 'nylas-component-kit';
import OnboardingActions from './onboarding-actions';
export default class AuthenticatePage extends React.Component {
static displayName = "AuthenticatePage";
static propTypes = {
accountInfo: React.PropTypes.object,
};
_src() {
const n1Version = NylasEnv.getVersion();
return `${IdentityStore.URLRoot}/onboarding?utm_medium=N1&utm_source=OnboardingPage&N1_version=${n1Version}&client_edition=basic`
}
_onDidFinishLoad = (webview) => {
const receiveUserInfo = `
var a = document.querySelector('#pro-account');
result = a ? a.innerText : null;
`;
webview.executeJavaScript(receiveUserInfo, false, (result) => {
this.setState({ready: true, webviewLoading: false});
if (result !== null) {
OnboardingActions.authenticationJSONReceived(JSON.parse(result));
}
});
const openExternalLink = `
var el = document.querySelector('.open-external');
if (el) {el.addEventListener('click', function(event) {console.log(this.href); event.preventDefault(); return false;})}
`;
webview.executeJavaScript(openExternalLink);
}
render() {
return (
<div className="page authenticate">
<Webview src={this._src()} onDidFinishLoad={this._onDidFinishLoad} />
</div>
);
}
}