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,
source: React.PropTypes.string,
campaign: React.PropTypes.string,
img: React.PropTypes.string,
}
constructor(props) {
super(props);
this.state = {
loading: false,
};
}
_onClick = () => {
this.setState({loading: true});
IdentityStore.fetchSingleSignOnURL(this.props.path, {
source: this.props.source,
campaign: this.props.campaign,
content: this.props.label,
}).then((url) => {
this.setState({loading: false});
shell.openExternal(url);
});
}
render() {
if (this.state.loading) {
return (
{this.props.label}…
);
}
if (this.props.img) {
return (
{this.props.label}
)
}
return (
{this.props.label}
);
}
}
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 {
identity: IdentityStore.identity() || {},
};
}
render() {
const {identity} = this.state;
const {firstname, lastname, email} = identity;
const logout = () => Actions.logoutNylasIdentity()
const learnMore = () => shell.openExternal("https://nylas.com/nylas-pro")
return (
Nylas ID:
{firstname} {lastname}
{email}
You are using Nylas Mail Basic. Upgrade to Nylas Pro to unlock a more powerful email experience.
Learn More about Nylas Pro
);
}
}
export default PreferencesIdentity;