Close new file modal on enter, update upload limit selector to handle undefined case

This commit is contained in:
Cassie Tarakajian 2020-03-24 18:07:58 -04:00
parent a6f59fd309
commit c29e4a1c52
4 changed files with 13 additions and 18 deletions

View file

@ -3,7 +3,7 @@ import objectID from 'bson-objectid';
import blobUtil from 'blob-util';
import { reset } from 'redux-form';
import * as ActionTypes from '../../../constants';
import { setUnsavedChanges } from './ide';
import { setUnsavedChanges, closeNewFolderModal, closeNewFileModal } from './ide';
import { setProjectSavedTime } from './project';
const __process = (typeof global !== 'undefined' ? global : window).process;
@ -58,6 +58,7 @@ export function createFile(formProps) {
parentId
});
dispatch(setProjectSavedTime(response.data.project.updatedAt));
dispatch(closeNewFileModal());
dispatch(reset('new-file'));
// dispatch({
// type: ActionTypes.HIDE_MODAL
@ -85,6 +86,7 @@ export function createFile(formProps) {
// type: ActionTypes.HIDE_MODAL
// });
dispatch(setUnsavedChanges(true));
dispatch(closeNewFileModal());
}
};
}
@ -109,9 +111,7 @@ export function createFolder(formProps) {
parentId
});
dispatch(setProjectSavedTime(response.data.project.updatedAt));
dispatch({
type: ActionTypes.CLOSE_NEW_FOLDER_MODAL
});
dispatch(closeNewFolderModal());
})
.catch(response => dispatch({
type: ActionTypes.ERROR,
@ -130,9 +130,7 @@ export function createFolder(formProps) {
fileType: 'folder',
children: []
});
dispatch({
type: ActionTypes.CLOSE_NEW_FOLDER_MODAL
});
dispatch(closeNewFolderModal());
}
};
}

View file

@ -5,7 +5,6 @@ import { bindActionCreators, compose } from 'redux';
import { reduxForm } from 'redux-form';
import InlineSVG from 'react-inlinesvg';
import NewFileForm from './NewFileForm';
import { getCanUploadMedia, getreachedTotalSizeLimit } from '../selectors/users';
import { closeNewFileModal } from '../actions/ide';
import { createFile } from '../actions/files';
import { CREATE_FILE_REGEX } from '../../../../server/utils/fileUtils';
@ -67,11 +66,8 @@ function validate(formProps) {
return errors;
}
function mapStateToProps(state) {
return {
canUploadMedia: getCanUploadMedia(state),
reachedTotalSizeLimit: getreachedTotalSizeLimit(state)
};
function mapStateToProps() {
return {};
}
function mapDispatchToProps(dispatch) {

View file

@ -20,9 +20,7 @@ class NewFolderForm extends React.Component {
<form
className="new-folder-form"
onSubmit={(data) => {
if (handleSubmit(this.createFolder)(data)) {
this.props.closeModal();
}
handleSubmit(this.createFolder)(data);
}}
>
<div className="new-folder-form__input-wrapper">

View file

@ -3,6 +3,7 @@ import { createSelector } from 'reselect';
const __process = (typeof global !== 'undefined' ? global : window).process;
const getAuthenticated = state => state.user.authenticated;
const getTotalSize = state => state.user.totalSize;
const getAssetsTotalSize = state => state.assets.totalSize;
const limit = __process.env.UPLOAD_LIMIT || 250000000;
export const getCanUploadMedia = createSelector(
@ -19,8 +20,10 @@ export const getCanUploadMedia = createSelector(
export const getreachedTotalSizeLimit = createSelector(
getTotalSize,
(totalSize) => {
if (totalSize > limit) return true;
getAssetsTotalSize,
(totalSize, assetsTotalSize) => {
const currentSize = totalSize || assetsTotalSize;
if (currentSize && currentSize > limit) return true;
// if (totalSize > 1000) return true;
return false;
}