import React, { Component } from 'react' import classnames from 'classnames' import { FlowActions } from '../../actions.js' export default class FileMenu extends Component { constructor(props, context) { super(props, context) this.state = { show: false } this.close = this.close.bind(this) this.onFileClick = this.onFileClick.bind(this) this.onNewClick = this.onNewClick.bind(this) this.onOpenClick = this.onOpenClick.bind(this) this.onOpenFile = this.onOpenFile.bind(this) this.onSaveClick = this.onSaveClick.bind(this) } close() { this.setState({ show: false }) document.removeEventListener('click', this.close) } onFileClick(e) { e.preventDefault() if (this.state.show) { return } document.addEventListener('click', this.close) this.setState({ show: true }) } onNewClick(e) { e.preventDefault() if (confirm('Delete all flows?')) { FlowActions.clear() } } onOpenClick(e) { e.preventDefault() this.fileInput.click() } onOpenFile(e) { e.preventDefault() if (e.target.files.length > 0) { FlowActions.upload(e.target.files[0]) this.fileInput.value = '' } } onSaveClick(e) { e.preventDefault() FlowActions.download() } render() { return (
mitmproxy
) } }