PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0-beta1
Elementor Website Builder – more than just a page builder v3.8.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 All 457 releases
elementor / app / assets / js / organisms / error-boundary.js

error-boundary.js in Elementor Website Builder – more than just a page builder 3.8.0-beta1, at app/assets/js/organisms/error-boundary.js

59 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import Dialog from 'elementor-app/ui/dialog/dialog';
2
3 // In the current time there is no solution to use "getDerivedStateFromError" static method with functional component
4 // That is why this component is a class component.
5 // @link https://reactjs.org/docs/hooks-faq.html#do-hooks-cover-all-use-cases-for-classes
6 export default class ErrorBoundary extends React.Component {
7 static propTypes = {
8 children: PropTypes.any,
9 title: PropTypes.string,
10 text: PropTypes.string,
11 learnMoreUrl: PropTypes.string,
12 };
13
14 static defaultProps = {
15 title: __( 'App could not be loaded', 'elementor' ),
16 text: __( 'We’re sorry, but something went wrong. Click on ‘Learn more’ and follow each of the steps to quickly solve it.', 'elementor' ),
17 learnMoreUrl: 'https://go.elementor.com/app-general-load-issue/',
18 };
19
20 constructor( props ) {
21 super( props );
22
23 this.state = {
24 hasError: null,
25 };
26 }
27
28 static getDerivedStateFromError() {
29 return { hasError: true };
30 }
31
32 goBack() {
33 // If the app was opened inside an iframe, it will close it,
34 // if not, it will redirect to the last location.
35 if ( window.top !== window.self ) {
36 window.top.$e.run( 'app/close' );
37 }
38
39 window.location = elementorAppConfig.return_url;
40 }
41
42 render() {
43 if ( this.state.hasError ) {
44 return <Dialog
45 title={ this.props.title }
46 text={ this.props.text }
47 approveButtonUrl={ this.props.learnMoreUrl }
48 approveButtonColor="link"
49 approveButtonTarget="_blank"
50 approveButtonText={ __( 'Learn More', 'elementor' ) }
51 dismissButtonText={ __( 'Go Back', 'elementor' ) }
52 dismissButtonOnClick={ this.goBack }
53 />;
54 }
55
56 return this.props.children;
57 }
58 }
59