2017-01-24 20:29:25 +00:00
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
import InlineSVG from 'react-inlinesvg';
|
|
|
|
import { Link } from 'react-router';
|
|
|
|
|
2017-02-22 19:29:35 +00:00
|
|
|
const exitUrl = require('../../../images/exit.svg');
|
|
|
|
|
2017-01-24 20:29:25 +00:00
|
|
|
class ErrorModal extends React.Component {
|
|
|
|
componentDidMount() {
|
2017-02-22 19:29:35 +00:00
|
|
|
this.errorModal.focus();
|
2017-01-24 20:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
forceAuthentication() {
|
|
|
|
return (
|
|
|
|
<p>
|
|
|
|
In order to save sketches, you must be logged in. Please
|
|
|
|
<Link to="/login" onClick={this.props.closeModal}>Login</Link>
|
|
|
|
or
|
|
|
|
<Link to="/signup" onClick={this.props.closeModal}>Sign Up</Link>.
|
|
|
|
</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
staleSession() {
|
|
|
|
return (
|
|
|
|
<p>
|
2017-02-22 19:29:35 +00:00
|
|
|
It looks like you've been logged out. Please
|
2017-01-24 20:29:25 +00:00
|
|
|
<Link to="/login" onClick={this.props.closeModal}>log in</Link>.
|
|
|
|
</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
staleProject() {
|
|
|
|
return (
|
|
|
|
<p>
|
|
|
|
The project you have attempted to save is out of date. Please refresh the page.
|
|
|
|
</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2017-02-22 19:29:35 +00:00
|
|
|
<section className="error-modal" ref={(element) => { this.errorModal = element; }} tabIndex="0">
|
2017-01-24 20:29:25 +00:00
|
|
|
<header className="error-modal__header">
|
|
|
|
<h2 className="error-modal__title">Error</h2>
|
|
|
|
<button className="error-modal__exit-button" onClick={this.props.closeModal}>
|
|
|
|
<InlineSVG src={exitUrl} alt="Close Error Modal" />
|
|
|
|
</button>
|
|
|
|
</header>
|
|
|
|
<div className="error-modal__content">
|
|
|
|
{(() => { // eslint-disable-line
|
|
|
|
if (this.props.type === 'forceAuthentication') {
|
|
|
|
return this.forceAuthentication();
|
|
|
|
} else if (this.props.type === 'staleSession') {
|
|
|
|
return this.staleSession();
|
|
|
|
} else if (this.props.type === 'staleProject') {
|
|
|
|
return this.staleProject();
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ErrorModal.propTypes = {
|
2017-02-22 19:29:35 +00:00
|
|
|
type: PropTypes.string.isRequired,
|
2017-01-24 20:29:25 +00:00
|
|
|
closeModal: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ErrorModal;
|