Skip to content

Commit c29e4a1

Browse files
committed
Close new file modal on enter, update upload limit selector to handle undefined case
1 parent a6f59fd commit c29e4a1

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

client/modules/IDE/actions/files.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import objectID from 'bson-objectid';
33
import blobUtil from 'blob-util';
44
import { reset } from 'redux-form';
55
import * as ActionTypes from '../../../constants';
6-
import { setUnsavedChanges } from './ide';
6+
import { setUnsavedChanges, closeNewFolderModal, closeNewFileModal } from './ide';
77
import { setProjectSavedTime } from './project';
88

99
const __process = (typeof global !== 'undefined' ? global : window).process;
@@ -58,6 +58,7 @@ export function createFile(formProps) {
5858
parentId
5959
});
6060
dispatch(setProjectSavedTime(response.data.project.updatedAt));
61+
dispatch(closeNewFileModal());
6162
dispatch(reset('new-file'));
6263
// dispatch({
6364
// type: ActionTypes.HIDE_MODAL
@@ -85,6 +86,7 @@ export function createFile(formProps) {
8586
// type: ActionTypes.HIDE_MODAL
8687
// });
8788
dispatch(setUnsavedChanges(true));
89+
dispatch(closeNewFileModal());
8890
}
8991
};
9092
}
@@ -109,9 +111,7 @@ export function createFolder(formProps) {
109111
parentId
110112
});
111113
dispatch(setProjectSavedTime(response.data.project.updatedAt));
112-
dispatch({
113-
type: ActionTypes.CLOSE_NEW_FOLDER_MODAL
114-
});
114+
dispatch(closeNewFolderModal());
115115
})
116116
.catch(response => dispatch({
117117
type: ActionTypes.ERROR,
@@ -130,9 +130,7 @@ export function createFolder(formProps) {
130130
fileType: 'folder',
131131
children: []
132132
});
133-
dispatch({
134-
type: ActionTypes.CLOSE_NEW_FOLDER_MODAL
135-
});
133+
dispatch(closeNewFolderModal());
136134
}
137135
};
138136
}

client/modules/IDE/components/NewFileModal.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { bindActionCreators, compose } from 'redux';
55
import { reduxForm } from 'redux-form';
66
import InlineSVG from 'react-inlinesvg';
77
import NewFileForm from './NewFileForm';
8-
import { getCanUploadMedia, getreachedTotalSizeLimit } from '../selectors/users';
98
import { closeNewFileModal } from '../actions/ide';
109
import { createFile } from '../actions/files';
1110
import { CREATE_FILE_REGEX } from '../../../../server/utils/fileUtils';
@@ -67,11 +66,8 @@ function validate(formProps) {
6766
return errors;
6867
}
6968

70-
function mapStateToProps(state) {
71-
return {
72-
canUploadMedia: getCanUploadMedia(state),
73-
reachedTotalSizeLimit: getreachedTotalSizeLimit(state)
74-
};
69+
function mapStateToProps() {
70+
return {};
7571
}
7672

7773
function mapDispatchToProps(dispatch) {

client/modules/IDE/components/NewFolderForm.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class NewFolderForm extends React.Component {
2020
<form
2121
className="new-folder-form"
2222
onSubmit={(data) => {
23-
if (handleSubmit(this.createFolder)(data)) {
24-
this.props.closeModal();
25-
}
23+
handleSubmit(this.createFolder)(data);
2624
}}
2725
>
2826
<div className="new-folder-form__input-wrapper">

client/modules/IDE/selectors/users.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createSelector } from 'reselect';
33
const __process = (typeof global !== 'undefined' ? global : window).process;
44
const getAuthenticated = state => state.user.authenticated;
55
const getTotalSize = state => state.user.totalSize;
6+
const getAssetsTotalSize = state => state.assets.totalSize;
67
const limit = __process.env.UPLOAD_LIMIT || 250000000;
78

89
export const getCanUploadMedia = createSelector(
@@ -19,8 +20,10 @@ export const getCanUploadMedia = createSelector(
1920

2021
export const getreachedTotalSizeLimit = createSelector(
2122
getTotalSize,
22-
(totalSize) => {
23-
if (totalSize > limit) return true;
23+
getAssetsTotalSize,
24+
(totalSize, assetsTotalSize) => {
25+
const currentSize = totalSize || assetsTotalSize;
26+
if (currentSize && currentSize > limit) return true;
2427
// if (totalSize > 1000) return true;
2528
return false;
2629
}

0 commit comments

Comments
 (0)