Close new file modal on enter, update upload limit selector to handle undefined case
This commit is contained in:
parent
a6f59fd309
commit
c29e4a1c52
4 changed files with 13 additions and 18 deletions
|
@ -3,7 +3,7 @@ import objectID from 'bson-objectid';
|
||||||
import blobUtil from 'blob-util';
|
import blobUtil from 'blob-util';
|
||||||
import { reset } from 'redux-form';
|
import { reset } from 'redux-form';
|
||||||
import * as ActionTypes from '../../../constants';
|
import * as ActionTypes from '../../../constants';
|
||||||
import { setUnsavedChanges } from './ide';
|
import { setUnsavedChanges, closeNewFolderModal, closeNewFileModal } from './ide';
|
||||||
import { setProjectSavedTime } from './project';
|
import { setProjectSavedTime } from './project';
|
||||||
|
|
||||||
const __process = (typeof global !== 'undefined' ? global : window).process;
|
const __process = (typeof global !== 'undefined' ? global : window).process;
|
||||||
|
@ -58,6 +58,7 @@ export function createFile(formProps) {
|
||||||
parentId
|
parentId
|
||||||
});
|
});
|
||||||
dispatch(setProjectSavedTime(response.data.project.updatedAt));
|
dispatch(setProjectSavedTime(response.data.project.updatedAt));
|
||||||
|
dispatch(closeNewFileModal());
|
||||||
dispatch(reset('new-file'));
|
dispatch(reset('new-file'));
|
||||||
// dispatch({
|
// dispatch({
|
||||||
// type: ActionTypes.HIDE_MODAL
|
// type: ActionTypes.HIDE_MODAL
|
||||||
|
@ -85,6 +86,7 @@ export function createFile(formProps) {
|
||||||
// type: ActionTypes.HIDE_MODAL
|
// type: ActionTypes.HIDE_MODAL
|
||||||
// });
|
// });
|
||||||
dispatch(setUnsavedChanges(true));
|
dispatch(setUnsavedChanges(true));
|
||||||
|
dispatch(closeNewFileModal());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -109,9 +111,7 @@ export function createFolder(formProps) {
|
||||||
parentId
|
parentId
|
||||||
});
|
});
|
||||||
dispatch(setProjectSavedTime(response.data.project.updatedAt));
|
dispatch(setProjectSavedTime(response.data.project.updatedAt));
|
||||||
dispatch({
|
dispatch(closeNewFolderModal());
|
||||||
type: ActionTypes.CLOSE_NEW_FOLDER_MODAL
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(response => dispatch({
|
.catch(response => dispatch({
|
||||||
type: ActionTypes.ERROR,
|
type: ActionTypes.ERROR,
|
||||||
|
@ -130,9 +130,7 @@ export function createFolder(formProps) {
|
||||||
fileType: 'folder',
|
fileType: 'folder',
|
||||||
children: []
|
children: []
|
||||||
});
|
});
|
||||||
dispatch({
|
dispatch(closeNewFolderModal());
|
||||||
type: ActionTypes.CLOSE_NEW_FOLDER_MODAL
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { bindActionCreators, compose } from 'redux';
|
||||||
import { reduxForm } from 'redux-form';
|
import { reduxForm } from 'redux-form';
|
||||||
import InlineSVG from 'react-inlinesvg';
|
import InlineSVG from 'react-inlinesvg';
|
||||||
import NewFileForm from './NewFileForm';
|
import NewFileForm from './NewFileForm';
|
||||||
import { getCanUploadMedia, getreachedTotalSizeLimit } from '../selectors/users';
|
|
||||||
import { closeNewFileModal } from '../actions/ide';
|
import { closeNewFileModal } from '../actions/ide';
|
||||||
import { createFile } from '../actions/files';
|
import { createFile } from '../actions/files';
|
||||||
import { CREATE_FILE_REGEX } from '../../../../server/utils/fileUtils';
|
import { CREATE_FILE_REGEX } from '../../../../server/utils/fileUtils';
|
||||||
|
@ -67,11 +66,8 @@ function validate(formProps) {
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps() {
|
||||||
return {
|
return {};
|
||||||
canUploadMedia: getCanUploadMedia(state),
|
|
||||||
reachedTotalSizeLimit: getreachedTotalSizeLimit(state)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps(dispatch) {
|
function mapDispatchToProps(dispatch) {
|
||||||
|
|
|
@ -20,9 +20,7 @@ class NewFolderForm extends React.Component {
|
||||||
<form
|
<form
|
||||||
className="new-folder-form"
|
className="new-folder-form"
|
||||||
onSubmit={(data) => {
|
onSubmit={(data) => {
|
||||||
if (handleSubmit(this.createFolder)(data)) {
|
handleSubmit(this.createFolder)(data);
|
||||||
this.props.closeModal();
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="new-folder-form__input-wrapper">
|
<div className="new-folder-form__input-wrapper">
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { createSelector } from 'reselect';
|
||||||
const __process = (typeof global !== 'undefined' ? global : window).process;
|
const __process = (typeof global !== 'undefined' ? global : window).process;
|
||||||
const getAuthenticated = state => state.user.authenticated;
|
const getAuthenticated = state => state.user.authenticated;
|
||||||
const getTotalSize = state => state.user.totalSize;
|
const getTotalSize = state => state.user.totalSize;
|
||||||
|
const getAssetsTotalSize = state => state.assets.totalSize;
|
||||||
const limit = __process.env.UPLOAD_LIMIT || 250000000;
|
const limit = __process.env.UPLOAD_LIMIT || 250000000;
|
||||||
|
|
||||||
export const getCanUploadMedia = createSelector(
|
export const getCanUploadMedia = createSelector(
|
||||||
|
@ -19,8 +20,10 @@ export const getCanUploadMedia = createSelector(
|
||||||
|
|
||||||
export const getreachedTotalSizeLimit = createSelector(
|
export const getreachedTotalSizeLimit = createSelector(
|
||||||
getTotalSize,
|
getTotalSize,
|
||||||
(totalSize) => {
|
getAssetsTotalSize,
|
||||||
if (totalSize > limit) return true;
|
(totalSize, assetsTotalSize) => {
|
||||||
|
const currentSize = totalSize || assetsTotalSize;
|
||||||
|
if (currentSize && currentSize > limit) return true;
|
||||||
// if (totalSize > 1000) return true;
|
// if (totalSize > 1000) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue