From 779e5e84e37278b8f3255a1061f2137f5b6a3a7d Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Tue, 16 Aug 2016 12:37:35 +0200
Subject: refactor file up and download

---
 web/src/js/components/Header/FileMenu.jsx | 32 +++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

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

diff --git a/web/src/js/components/Header/FileMenu.jsx b/web/src/js/components/Header/FileMenu.jsx
index d3786475..392cc163 100644
--- a/web/src/js/components/Header/FileMenu.jsx
+++ b/web/src/js/components/Header/FileMenu.jsx
@@ -1,10 +1,19 @@
-import React, { Component } from 'react'
+import React, { Component, PropTypes } from 'react'
 import { connect } from 'react-redux'
 import classnames from 'classnames'
+import FileChooser from '../common/FileChooser'
 import * as flowsActions from '../../ducks/flows'
 
+
+
 class FileMenu extends Component {
 
+    static propTypes = {
+        clearFlows: PropTypes.func.isRequired,
+        loadFlows: PropTypes.func.isRequired,
+        saveFlows: PropTypes.func.isRequired
+    }
+
     constructor(props, context) {
         super(props, context)
         this.state = { show: false }
@@ -45,12 +54,8 @@ class FileMenu extends Component {
         this.fileInput.click()
     }
 
-    onOpenFile(e) {
-        e.preventDefault()
-        if (e.target.files.length > 0) {
-            this.props.loadFlows(e.target.files[0])
-            this.fileInput.value = ''
-        }
+    onOpenFile(file) {
+        this.props.loadFlows(file)
     }
 
     onSaveClick(e) {
@@ -70,15 +75,10 @@ class FileMenu extends Component {
                         </a>
                     </li>
                     <li>
-                        <a href="#" onClick={this.onOpenClick}>
-                            <i className="fa fa-fw fa-folder-open"></i>
-                            Open...
-                        </a>
-                        <input
-                            ref={ref => this.fileInput = ref}
-                            className="hidden"
-                            type="file"
-                            onChange={this.onOpenFile}
+                        <FileChooser
+                            icon="fa-folder-open"
+                            text="Open..."
+                            onOpenFile={this.onOpenFile}
                         />
                     </li>
                     <li>
-- 
cgit v1.2.3

