aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/components/common/FileChooser.jsx
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-08-22 20:52:03 -0700
committerGitHub <noreply@github.com>2016-08-22 20:52:03 -0700
commit53ccbaf4f50d6876e1f4d44acdac2268b3d75233 (patch)
tree80b8037a85bf3d46e7a64782aa0539ee04be3a46 /web/src/js/components/common/FileChooser.jsx
parent62ab2f2fd5188f31e99560dce788ba85c2933a1a (diff)
parenteddc4243791c2c2b1a91c1d8ae49b830206bc6df (diff)
downloadmitmproxy-53ccbaf4f50d6876e1f4d44acdac2268b3d75233.tar.gz
mitmproxy-53ccbaf4f50d6876e1f4d44acdac2268b3d75233.tar.bz2
mitmproxy-53ccbaf4f50d6876e1f4d44acdac2268b3d75233.zip
Merge pull request #1489 from mitmproxy/web_refactor
Web refactor
Diffstat (limited to 'web/src/js/components/common/FileChooser.jsx')
-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..d59d2d6d
--- /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 href='#' 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>
+ )
+}