remove lastFileUpload field

This commit is contained in:
Clemens 2016-07-25 09:05:24 +02:00
parent f578bf5122
commit 0aedea6e60
5 changed files with 10 additions and 24 deletions

View File

@ -18,7 +18,7 @@ ContentView.propTypes = {
ContentView.isContentTooLarge = msg => msg.contentLength > 1024 * 1024 * (ContentViews.ViewImage.matches(msg) ? 10 : 0.2) ContentView.isContentTooLarge = msg => msg.contentLength > 1024 * 1024 * (ContentViews.ViewImage.matches(msg) ? 10 : 0.2)
function ContentView(props) { function ContentView(props) {
const { flow, message, contentView, selectView, displayLarge, setDisplayLarge, lastFileUpload, uploadContent, onContentChange, content, readonly } = props const { flow, message, contentView, selectView, displayLarge, setDisplayLarge, uploadContent, onContentChange, content, readonly } = props
if (message.contentLength === 0) { if (message.contentLength === 0) {
return <MetaViews.ContentEmpty {...props}/> return <MetaViews.ContentEmpty {...props}/>
@ -36,11 +36,11 @@ function ContentView(props) {
return ( return (
<div> <div>
{View.textView ? ( {View.textView ? (
<ContentLoader flow={flow} lastFileUpload={lastFileUpload} readonly={readonly} message={message}> <ContentLoader flow={flow} readonly={readonly} message={message}>
<View readonly={readonly} onChange={onContentChange} content="" /> <View readonly={readonly} onChange={onContentChange} content="" />
</ContentLoader> </ContentLoader>
) : ( ) : (
<View flow={flow} lastFileUpload={lastFileUpload} readonly={readonly} content={content} message={message} /> <View flow={flow} readonly={readonly} content={content} message={message} />
)} )}
<div className="view-options text-center"> <div className="view-options text-center">
<ViewSelector onSelectView={selectView} active={View} message={message}/> <ViewSelector onSelectView={selectView} active={View} message={message}/>
@ -72,11 +72,10 @@ export default connect(
state => ({ state => ({
contentView: state.ui.flow.contentView, contentView: state.ui.flow.contentView,
displayLarge: state.ui.flow.displayLarge, displayLarge: state.ui.flow.displayLarge,
lastFileUpload: state.ui.flow.lastFileUpload
}), }),
{ {
selectView: setContentView, selectView: setContentView,
displayLarge, displayLarge,
updateEdit, updateEdit
} }
)(ContentView) )(ContentView)

View File

@ -60,10 +60,10 @@ ViewAuto.propTypes = {
flow: React.PropTypes.object.isRequired, flow: React.PropTypes.object.isRequired,
} }
export function ViewAuto({ message, flow, readonly, lastFileUpload }) { export function ViewAuto({ message, flow, readonly }) {
const View = ViewAuto.findView(message) const View = ViewAuto.findView(message)
if (View.textView) { if (View.textView) {
return <ContentLoader message={message} lastFileUpload={lastFileUpload} flow={flow}><View readonly={readonly} content="" /></ContentLoader> return <ContentLoader message={message} flow={flow}><View readonly={readonly} content="" /></ContentLoader>
} else { } else {
return <View readonly={readonly} message={message} flow={flow} /> return <View readonly={readonly} message={message} flow={flow} />
} }

View File

@ -9,7 +9,8 @@ import ValidateEditor from '../ValueEditor/ValidateEditor'
import ValueEditor from '../ValueEditor/ValueEditor' import ValueEditor from '../ValueEditor/ValueEditor'
import Headers from './Headers' import Headers from './Headers'
import { startEdit, updateEdit, uploadContent } from '../../ducks/ui/flow' import { startEdit, updateEdit } from '../../ducks/ui/flow'
import * as FlowActions from '../../ducks/flows'
import ToggleEdit from './ToggleEdit' import ToggleEdit from './ToggleEdit'
function RequestLine({ flow, readonly, updateFlow }) { function RequestLine({ flow, readonly, updateFlow }) {
@ -73,7 +74,7 @@ const Message = connect(
}), }),
{ {
updateFlow: updateEdit, updateFlow: updateEdit,
uploadContent: uploadContent uploadContent: FlowActions.uploadContent
} }
) )

View File

@ -112,7 +112,7 @@ export function update(flow, data) {
return dispatch => fetchApi.put(`/flows/${flow.id}`, data) return dispatch => fetchApi.put(`/flows/${flow.id}`, data)
} }
export function updateContent(flow, file, type) { export function uploadContent(flow, file, type) {
const body = new FormData() const body = new FormData()
if (typeof file !== File) if (typeof file !== File)
file = new Blob([file], {type: 'plain/text'}) file = new Blob([file], {type: 'plain/text'})

View File

@ -16,7 +16,6 @@ const defaultState = {
displayLarge: false, displayLarge: false,
modifiedFlow: false, modifiedFlow: false,
contentView: 'ViewAuto', contentView: 'ViewAuto',
lastFileUpload: false,
tab: 'request', tab: 'request',
} }
@ -42,12 +41,6 @@ export default function reducer(state = defaultState, action) {
modifiedFlow: false modifiedFlow: false
} }
case UPLOAD_CONTENT:
return {
... state,
lastFileUpload: new Date()
}
case flowsActions.SELECT: case flowsActions.SELECT:
return { return {
...state, ...state,
@ -98,13 +91,6 @@ export function updateEdit(update) {
return { type: UPDATE_EDIT, update } return { type: UPDATE_EDIT, update }
} }
export function uploadContent(flow, content, type){
return (dispatch) => {
dispatch(flowsActions.updateContent(flow, content, type))
dispatch({ type: UPLOAD_CONTENT })
}
}
export function stopEdit(flow, modified_flow) { export function stopEdit(flow, modified_flow) {
let diff = getDiff(flow, modified_flow) let diff = getDiff(flow, modified_flow)
return (dispatch) => { return (dispatch) => {