2017-12-12 19:53:04 +01:00
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* OverlayBlocker
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
|
import PropTypes from 'prop-types';
|
2018-01-12 12:51:39 +01:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
import cn from 'classnames';
|
2017-12-12 19:53:04 +01:00
|
|
|
|
|
|
|
|
import styles from './styles.scss';
|
|
|
|
|
|
|
|
|
|
class OverlayBlocker extends React.Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
2019-01-24 18:24:24 +01:00
|
|
|
|
2017-12-12 19:53:04 +01:00
|
|
|
this.overlayContainer = document.createElement('div');
|
2019-01-24 18:24:24 +01:00
|
|
|
|
2017-12-12 19:53:04 +01:00
|
|
|
document.body.appendChild(this.overlayContainer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
document.body.removeChild(this.overlayContainer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2019-01-24 18:24:24 +01:00
|
|
|
const { title, description, icon } = this.props;
|
|
|
|
|
|
2018-01-12 12:51:39 +01:00
|
|
|
const content = this.props.children ? (
|
|
|
|
|
this.props.children
|
|
|
|
|
) : (
|
|
|
|
|
<div className={styles.container}>
|
|
|
|
|
<div className={styles.icoContainer}>
|
2019-01-24 18:24:24 +01:00
|
|
|
<i className={icon} />
|
2018-01-12 12:51:39 +01:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<h4>
|
2019-01-24 18:24:24 +01:00
|
|
|
<FormattedMessage id={title} />
|
2018-01-12 12:51:39 +01:00
|
|
|
</h4>
|
|
|
|
|
<p>
|
2019-01-24 18:24:24 +01:00
|
|
|
<FormattedMessage id={description} />
|
2018-01-12 12:51:39 +01:00
|
|
|
</p>
|
|
|
|
|
<div className={styles.buttonContainer}>
|
2018-01-12 17:53:48 +01:00
|
|
|
<a className={cn(styles.primary, 'btn')} href="https://strapi.io/documentation/configurations/configurations.html#server" target="_blank">Read the documentation</a>
|
2018-01-12 12:51:39 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
2017-12-12 19:53:04 +01:00
|
|
|
if (this.props.isOpen) {
|
|
|
|
|
return ReactDOM.createPortal(
|
|
|
|
|
<div className={styles.overlay}>
|
|
|
|
|
<div>
|
2018-01-12 12:51:39 +01:00
|
|
|
{content}
|
2017-12-12 19:53:04 +01:00
|
|
|
</div>
|
|
|
|
|
</div>,
|
|
|
|
|
this.overlayContainer
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OverlayBlocker.defaultProps = {
|
|
|
|
|
children: '',
|
2019-01-24 18:24:24 +01:00
|
|
|
description: 'components.OverlayBlocker.description',
|
|
|
|
|
icon: 'fa fa-refresh',
|
2017-12-12 19:53:04 +01:00
|
|
|
isOpen: false,
|
2019-01-24 18:24:24 +01:00
|
|
|
title: 'components.OverlayBlocker.title',
|
2017-12-12 19:53:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OverlayBlocker.propTypes = {
|
|
|
|
|
children: PropTypes.node,
|
2019-01-24 18:24:24 +01:00
|
|
|
description: PropTypes.string,
|
|
|
|
|
icon: PropTypes.string,
|
2017-12-12 19:53:04 +01:00
|
|
|
isOpen: PropTypes.bool,
|
2019-01-24 18:24:24 +01:00
|
|
|
title: PropTypes.string,
|
2017-12-12 19:53:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default OverlayBlocker;
|