diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-07-25 17:03:50 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-07-25 17:03:50 -0700 |
commit | 70dbd1b32d13d30e15c03ee91b0fab7bfdf429b3 (patch) | |
tree | 8c15d471934ac4b2c898725a2929f30f8dc7f9dd /web/src/js/components/ContentView.jsx | |
parent | 79ebcb046e8669f80357a6c3046ec76c6adf49be (diff) | |
download | mitmproxy-70dbd1b32d13d30e15c03ee91b0fab7bfdf429b3.tar.gz mitmproxy-70dbd1b32d13d30e15c03ee91b0fab7bfdf429b3.tar.bz2 mitmproxy-70dbd1b32d13d30e15c03ee91b0fab7bfdf429b3.zip |
web: refactor ContentLoader
Diffstat (limited to 'web/src/js/components/ContentView.jsx')
-rw-r--r-- | web/src/js/components/ContentView.jsx | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/web/src/js/components/ContentView.jsx b/web/src/js/components/ContentView.jsx index 80dec0f4..9ec0266b 100644 --- a/web/src/js/components/ContentView.jsx +++ b/web/src/js/components/ContentView.jsx @@ -1,10 +1,11 @@ import React, { Component, PropTypes } from 'react' import { connect } from 'react-redux' -import { MessageUtils } from '../flow/utils.js' import * as ContentViews from './ContentView/ContentViews' import * as MetaViews from './ContentView/MetaViews' -import ContentLoader from './ContentView/ContentLoader' import ViewSelector from './ContentView/ViewSelector' +import UploadContentButton from './ContentView/UploadContentButton' +import DownloadContentButton from './ContentView/DownloadContentButton' + import { setContentView, displayLarge, updateEdit } from '../ducks/ui/flow' ContentView.propTypes = { @@ -18,7 +19,7 @@ ContentView.propTypes = { ContentView.isContentTooLarge = msg => msg.contentLength > 1024 * 1024 * (ContentViews.ViewImage.matches(msg) ? 10 : 0.2) function ContentView(props) { - const { flow, message, contentView, selectView, displayLarge, setDisplayLarge, uploadContent, onContentChange, content, readonly } = props + const { flow, message, contentView, selectView, displayLarge, setDisplayLarge, uploadContent, onContentChange, readonly } = props if (message.contentLength === 0) { return <MetaViews.ContentEmpty {...props}/> @@ -35,34 +36,14 @@ function ContentView(props) { const View = ContentViews[contentView] return ( <div> - {View.textView ? ( - <ContentLoader flow={flow} readonly={readonly} message={message}> - <View readonly={readonly} onChange={onContentChange} content="" /> - </ContentLoader> - ) : ( - <View flow={flow} readonly={readonly} onChange={onContentChange} content={content} message={message} /> - )} + <View flow={flow} message={message} readonly={readonly} onChange={onContentChange}/> + <div className="view-options text-center"> <ViewSelector onSelectView={selectView} active={View} message={message}/> - <a className="btn btn-default btn-xs" - href={MessageUtils.getContentURL(flow, message)} - title="Download the content of the flow."> - <i className="fa fa-download"/> - </a> + <DownloadContentButton flow={flow} message={message}/> - <a className="btn btn-default btn-xs" - onClick={() => ContentView.fileInput.click()} - title="Upload a file to replace the content." - > - <i className="fa fa-upload"/> - </a> - <input - ref={ref => ContentView.fileInput = ref} - className="hidden" - type="file" - onChange={e => {if(e.target.files.length > 0) uploadContent(e.target.files[0])}} - /> + <UploadContentButton uploadContent={uploadContent}/> </div> </div> ) |