aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/components/common
diff options
context:
space:
mode:
authorClemens <cle1000.cb@gmail.com>2016-08-16 12:37:35 +0200
committerClemens <cle1000.cb@gmail.com>2016-08-16 12:37:35 +0200
commit779e5e84e37278b8f3255a1061f2137f5b6a3a7d (patch)
treefe91c08c5cdf87bfb99cf3cfe6bfcf3a7e67e933 /web/src/js/components/common
parent57fafd3281af7a35f8e650fa9fb2cf5af70995f0 (diff)
downloadmitmproxy-779e5e84e37278b8f3255a1061f2137f5b6a3a7d.tar.gz
mitmproxy-779e5e84e37278b8f3255a1061f2137f5b6a3a7d.tar.bz2
mitmproxy-779e5e84e37278b8f3255a1061f2137f5b6a3a7d.zip
refactor file up and download
Diffstat (limited to 'web/src/js/components/common')
-rw-r--r--web/src/js/components/common/FileChooser.jsx27
1 files changed, 27 insertions, 0 deletions
diff --git a/web/src/js/components/common/FileChooser.jsx b/web/src/js/components/common/FileChooser.jsx
new file mode 100644
index 00000000..d8a80ad7
--- /dev/null
+++ b/web/src/js/components/common/FileChooser.jsx
@@ -0,0 +1,27 @@
+import React, { PropTypes } from 'react'
+
+FileChooser.propTypes = {
+ icon: PropTypes.string,
+ text: PropTypes.string,
+ className: PropTypes.string,
+ title: PropTypes.string,
+ onOpenFile: PropTypes.func.isRequired
+}
+
+export default function FileChooser({ icon, text, className, title, onOpenFile }) {
+ let fileInput;
+ return (
+ <a onClick={() => fileInput.click()}
+ className={className}
+ title={title}>
+ <i className={'fa fa-fw ' + icon}></i>
+ {text}
+ <input
+ ref={ref => fileInput = ref}
+ className="hidden"
+ type="file"
+ onChange={e => { e.preventDefault(); if(e.target.files.length > 0) onOpenFile(e.target.files[0]); fileInput = "";}}
+ />
+ </a>
+ )
+}