From 8f1b763082d0d00bee0b1e97f9c8bfb740083c63 Mon Sep 17 00:00:00 2001
From: Maximilian Hils <git@maximilianhils.com>
Date: Wed, 26 Apr 2017 17:51:33 +0200
Subject: [web] add connection indicator

---
 .../js/components/Header/ConnectionIndicator.jsx   | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 web/src/js/components/Header/ConnectionIndicator.jsx

(limited to 'web/src/js/components/Header/ConnectionIndicator.jsx')

diff --git a/web/src/js/components/Header/ConnectionIndicator.jsx b/web/src/js/components/Header/ConnectionIndicator.jsx
new file mode 100644
index 00000000..e8feb20e
--- /dev/null
+++ b/web/src/js/components/Header/ConnectionIndicator.jsx
@@ -0,0 +1,29 @@
+import React, { PropTypes } from "react"
+import { connect } from "react-redux"
+import classnames from "classnames"
+import {ConnectionState} from "../../ducks/connection"
+
+
+ConnectionIndicator.propTypes = {
+    state: PropTypes.symbol.isRequired,
+    message: PropTypes.string,
+
+}
+function ConnectionIndicator({ state, message }) {
+    switch(state){
+        case ConnectionState.INIT:
+            return <span className="connection-indicator init">connecting…</span>;
+        case ConnectionState.FETCHING:
+            return <span className="connection-indicator fetching">fetching data…</span>;
+        case ConnectionState.ESTABLISHED:
+            return <span className="connection-indicator established">connected</span>;
+        case ConnectionState.ERROR:
+            return <span className="connection-indicator error" title={message}>connection lost</span>;
+        case ConnectionState.OFFLINE:
+            return <span className="connection-indicator offline">offline</span>;
+    }
+}
+
+export default connect(
+    state => state.connection,
+)(ConnectionIndicator)
-- 
cgit v1.2.3


From 97a00728a85a32ca6a8e98a991f6dcf28809e73b Mon Sep 17 00:00:00 2001
From: Maximilian Hils <git@maximilianhils.com>
Date: Sat, 29 Apr 2017 19:43:59 +0200
Subject: [web] add connection tests

---
 web/src/js/components/Header/ConnectionIndicator.jsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'web/src/js/components/Header/ConnectionIndicator.jsx')

diff --git a/web/src/js/components/Header/ConnectionIndicator.jsx b/web/src/js/components/Header/ConnectionIndicator.jsx
index e8feb20e..1ee42e25 100644
--- a/web/src/js/components/Header/ConnectionIndicator.jsx
+++ b/web/src/js/components/Header/ConnectionIndicator.jsx
@@ -1,7 +1,7 @@
-import React, { PropTypes } from "react"
+import React from "react"
+import PropTypes from "prop-types"
 import { connect } from "react-redux"
-import classnames from "classnames"
-import {ConnectionState} from "../../ducks/connection"
+import { ConnectionState } from "../../ducks/connection"
 
 
 ConnectionIndicator.propTypes = {
@@ -10,7 +10,7 @@ ConnectionIndicator.propTypes = {
 
 }
 function ConnectionIndicator({ state, message }) {
-    switch(state){
+    switch (state) {
         case ConnectionState.INIT:
             return <span className="connection-indicator init">connecting…</span>;
         case ConnectionState.FETCHING:
@@ -18,7 +18,8 @@ function ConnectionIndicator({ state, message }) {
         case ConnectionState.ESTABLISHED:
             return <span className="connection-indicator established">connected</span>;
         case ConnectionState.ERROR:
-            return <span className="connection-indicator error" title={message}>connection lost</span>;
+            return <span className="connection-indicator error"
+                         title={message}>connection lost</span>;
         case ConnectionState.OFFLINE:
             return <span className="connection-indicator offline">offline</span>;
     }
-- 
cgit v1.2.3

