From 48728af43ad746d70ef3e251dc28b75028dea1e6 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Tue, 19 Jul 2016 12:23:20 +0200
Subject: moved flow editor state to redux

---
 .../js/components/FlowView/FlowEditorButton.jsx    | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 web/src/js/components/FlowView/FlowEditorButton.jsx

(limited to 'web/src/js/components/FlowView/FlowEditorButton.jsx')

diff --git a/web/src/js/components/FlowView/FlowEditorButton.jsx b/web/src/js/components/FlowView/FlowEditorButton.jsx
new file mode 100644
index 00000000..e9c75535
--- /dev/null
+++ b/web/src/js/components/FlowView/FlowEditorButton.jsx
@@ -0,0 +1,48 @@
+import React, { PropTypes, Component } from 'react'
+import { connect } from 'react-redux'
+
+import {closeFlowEditor} from '../../ducks/ui.js'
+import {openFlowEditor} from '../../ducks/ui.js'
+
+// FlowEditorButton.propTypes = {
+//     isFlowEditorOpen: PropTypes.bool.isRequired,
+//     content: PropTypes.string.isRequired,
+//     onContentChange: PropTypes.func.isRequired
+// }
+
+class FlowEditorButton extends Component{
+     static propTypes = {
+        isFlowEditorOpen: PropTypes.bool.isRequired,
+        content: PropTypes.string.isRequired,
+        onContentChange: PropTypes.func.isRequired
+     }
+
+    render(){
+        let { isFlowEditorOpen, closeFlowEditor, openFlowEditor,  onContentChange, content } = this.props
+        return (
+            <div className="edit-flow-container">
+                {isFlowEditorOpen ?
+                    <a className="edit-flow" onClick={() => {onContentChange(content); closeFlowEditor()}}>
+                        <i className="fa fa-check"/>
+                    </a>
+                    :
+                    <a  className="edit-flow" onClick={() => openFlowEditor()}>
+                        <i className="fa fa-pencil"/>
+                    </a>
+                }
+            </div>
+        )
+    }
+}
+
+export default connect(
+    state => ({
+        isFlowEditorOpen: state.ui.isFlowEditorOpen,
+        content: state.flows.modifiedFlow.content
+    }),
+    {
+        closeFlowEditor,
+        openFlowEditor
+
+    }
+)(FlowEditorButton)
-- 
cgit v1.2.3

