2016-05-28 05:05:27 +08:00
|
|
|
import React from 'react';
|
|
|
|
import {Actions, IdentityStore} from 'nylas-exports';
|
|
|
|
import {RetinaImg} from 'nylas-component-kit';
|
|
|
|
import {shell} from 'electron';
|
|
|
|
|
|
|
|
class OpenIdentityPageButton extends React.Component {
|
|
|
|
static propTypes = {
|
|
|
|
path: React.PropTypes.string,
|
|
|
|
label: React.PropTypes.string,
|
2016-06-08 03:53:05 +08:00
|
|
|
source: React.PropTypes.string,
|
|
|
|
campaign: React.PropTypes.string,
|
2016-05-28 05:05:27 +08:00
|
|
|
img: React.PropTypes.string,
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
_onClick = () => {
|
2016-06-08 03:53:05 +08:00
|
|
|
this.setState({loading: true});
|
|
|
|
IdentityStore.fetchSingleSignOnURL(this.props.path, {
|
|
|
|
source: this.props.source,
|
|
|
|
campaign: this.props.campaign,
|
|
|
|
content: this.props.label,
|
|
|
|
}).then((url) => {
|
2016-05-28 05:05:27 +08:00
|
|
|
this.setState({loading: false});
|
|
|
|
shell.openExternal(url);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
if (this.state.loading) {
|
|
|
|
return (
|
|
|
|
<div className="btn btn-disabled">
|
|
|
|
<RetinaImg name="sending-spinner.gif" width={15} height={15} mode={RetinaImg.Mode.ContentPreserve} />
|
|
|
|
{this.props.label}…
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (this.props.img) {
|
|
|
|
return (
|
|
|
|
<div className="btn" onClick={this._onClick}>
|
|
|
|
<RetinaImg name={this.props.img} mode={RetinaImg.Mode.ContentPreserve} />
|
|
|
|
{this.props.label}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div className="btn" onClick={this._onClick}>{this.props.label}</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PreferencesIdentity extends React.Component {
|
|
|
|
static displayName = 'PreferencesIdentity';
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.state = this.getStateFromStores();
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.unsubscribe = IdentityStore.listen(() => {
|
|
|
|
this.setState(this.getStateFromStores());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
this.unsubscribe();
|
|
|
|
}
|
|
|
|
|
|
|
|
getStateFromStores() {
|
|
|
|
return {
|
2016-06-03 09:56:03 +08:00
|
|
|
identity: IdentityStore.identity() || {},
|
2016-05-28 05:05:27 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-01-15 09:40:54 +08:00
|
|
|
const {identity} = this.state;
|
2016-06-03 09:56:03 +08:00
|
|
|
const {firstname, lastname, email} = identity;
|
|
|
|
|
2017-01-15 09:40:54 +08:00
|
|
|
const logout = () => Actions.logoutNylasIdentity()
|
|
|
|
const learnMore = () => shell.openExternal("https://nylas.com/nylas-pro")
|
2016-06-14 03:06:37 +08:00
|
|
|
|
2016-05-28 05:05:27 +08:00
|
|
|
return (
|
|
|
|
<div className="container-identity">
|
2016-06-14 03:06:37 +08:00
|
|
|
<div className="id-header">
|
|
|
|
Nylas ID:
|
|
|
|
</div>
|
2016-05-28 05:05:27 +08:00
|
|
|
<div className="identity-content-box">
|
|
|
|
<div className="row info-row">
|
|
|
|
<div className="logo">
|
|
|
|
<RetinaImg
|
|
|
|
name="prefs-identity-nylas-logo.png"
|
|
|
|
mode={RetinaImg.Mode.ContentPreserve}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="identity-info">
|
|
|
|
<div className="name">{firstname} {lastname}</div>
|
|
|
|
<div className="email">{email}</div>
|
|
|
|
<div className="identity-actions">
|
2016-06-08 03:53:05 +08:00
|
|
|
<OpenIdentityPageButton label="Account Details" path="/dashboard" source="Preferences" campaign="Dashboard" />
|
2017-01-15 09:40:54 +08:00
|
|
|
<OpenIdentityPageButton label="Upgrade to Nylas Pro" path="/dashboard?upgrade_to_pro=true" source="Preferences" campaign="Dashboard" />
|
|
|
|
<div className="btn" onClick={logout}>Sign Out</div>
|
2016-05-28 05:05:27 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-01-15 09:40:54 +08:00
|
|
|
|
|
|
|
<div className="row payment-row">
|
|
|
|
<div>
|
|
|
|
You are using Nylas Mail Basic. Upgrade to Nylas Pro to unlock a more powerful email experience.
|
|
|
|
</div>
|
|
|
|
<div className="btn" onClick={learnMore}>Learn More about Nylas Pro</div>
|
|
|
|
</div>
|
2016-05-28 05:05:27 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PreferencesIdentity;
|