Pārlūkot izejas kodu

Add an error page for app config (window.CONFIG) not being loaded

Kailash Nadh 6 gadi atpakaļ
vecāks
revīzija
c3d1813695
2 mainītis faili ar 17 papildinājumiem un 3 dzēšanām
  1. 11 1
      frontend/my/src/App.js
  2. 6 2
      frontend/my/src/index.css

+ 11 - 1
frontend/my/src/App.js

@@ -1,7 +1,7 @@
 import React from 'react'
 import React from 'react'
 import Utils from './utils'
 import Utils from './utils'
 import { BrowserRouter } from 'react-router-dom'
 import { BrowserRouter } from 'react-router-dom'
-import { notification } from "antd"
+import { Icon, notification } from "antd"
 import axios from 'axios'
 import axios from 'axios'
 import qs from 'qs'
 import qs from 'qs'
 
 
@@ -121,6 +121,16 @@ class App extends React.PureComponent {
     }
     }
 
 
     render() {
     render() {
+        if(!window.CONFIG) {
+            return(
+                <div className="broken">
+                    <h1><Icon type="frown" /> Something's not right</h1>
+                    <p>The app configuration could not be loaded.
+                        Please ensure that the app is running and then refresh this page.</p>
+                </div>
+            )
+        }
+
         return (
         return (
             <BrowserRouter>
             <BrowserRouter>
                 <Layout
                 <Layout

+ 6 - 2
frontend/my/src/index.css

@@ -36,6 +36,10 @@ hr {
   color: #999;
   color: #999;
 }
 }
 
 
+.hidden {
+  display: none;
+}
+
 /* Layout */
 /* Layout */
 body {
 body {
   margin: 0;
   margin: 0;
@@ -65,8 +69,8 @@ body {
   width: 20px;
   width: 20px;
 }
 }
 
 
-.hidden {
-  display: none;
+.broken {
+  margin: 100px;
 }
 }
 
 
 /* Form */
 /* Form */