diff --git a/client/modules/IDE/actions/uploader.js b/client/modules/IDE/actions/uploader.js index f2f12585..602ac3e5 100644 --- a/client/modules/IDE/actions/uploader.js +++ b/client/modules/IDE/actions/uploader.js @@ -66,11 +66,11 @@ export function dropzoneAcceptCallback(userId, file, done) { done(); }) .catch((response) => { - file.custom_status = 'rejected'; // eslint-disable-line - if (response.data.responseText && response.data.responseText.message) { + file.custom_status = 'rejected'; // eslint-disable-line + if (response.data && response.data.responseText && response.data.responseText.message) { done(response.data.responseText.message); } - done('error preparing the upload'); + done('Error: Reached upload limit.'); }); } }; diff --git a/client/modules/IDE/components/NewFileForm.jsx b/client/modules/IDE/components/NewFileForm.jsx index d0a6b8ab..926a9925 100644 --- a/client/modules/IDE/components/NewFileForm.jsx +++ b/client/modules/IDE/components/NewFileForm.jsx @@ -22,16 +22,18 @@ class NewFileForm extends React.Component { handleSubmit(this.createFile)(data); }} > - - { this.fileName = element; }} - /> - +
{ - `You have reached the size limit for the number of files you can upload to your account. + `Error: You cannot upload any more files. You have reached the total size limit of 250MB. If you would like to upload more, please remove the ones you aren't using anymore by - looking through your ` + in your ` } assets {'.'} diff --git a/client/modules/IDE/selectors/users.js b/client/modules/IDE/selectors/users.js index 7a2a9a1b..c656e283 100644 --- a/client/modules/IDE/selectors/users.js +++ b/client/modules/IDE/selectors/users.js @@ -1,7 +1,9 @@ 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 limit = __process.env.UPLOAD_LIMIT || 250000000; export const getCanUploadMedia = createSelector( getAuthenticated, @@ -10,7 +12,7 @@ export const getCanUploadMedia = createSelector( if (!authenticated) return false; // eventually do the same thing for verified when // email verification actually works - if (totalSize > 250000000) return false; + if (totalSize > limit) return false; return true; } ); @@ -18,8 +20,8 @@ export const getCanUploadMedia = createSelector( export const getreachedTotalSizeLimit = createSelector( getTotalSize, (totalSize) => { - if (totalSize > 250000000) return true; - //if (totalSize > 1000) return true; + if (totalSize > limit) return true; + // if (totalSize > 1000) return true; return false; } ); diff --git a/client/styles/components/_modal.scss b/client/styles/components/_modal.scss index b7b56f78..752b4434 100644 --- a/client/styles/components/_modal.scss +++ b/client/styles/components/_modal.scss @@ -10,7 +10,7 @@ .modal-content { @extend %modal; min-height: #{150 / $base-font-size}rem; - width: #{700 / $base-font-size}rem; + width: #{500 / $base-font-size}rem; padding: #{20 / $base-font-size}rem; .modal--reduced & { //min-height: #{150 / $base-font-size}rem; @@ -32,9 +32,8 @@ margin-bottom: #{20 / $base-font-size}rem; } -.new-file-form, .new-file-folder { +.new-folder-form__input-wrapper, .new-file-form__input-wrapper { display: flex; - flex-wrap: wrap; } .new-file-form__name-label, .new-folder-form__name-label { @@ -43,6 +42,7 @@ .new-file-form__name-input, .new-folder-form__name-input { margin-right: #{10 / $base-font-size}rem; + flex: 1; } .modal__divider { diff --git a/server/controllers/aws.controller.js b/server/controllers/aws.controller.js index b4976a50..92564ec4 100644 --- a/server/controllers/aws.controller.js +++ b/server/controllers/aws.controller.js @@ -73,6 +73,11 @@ export function deleteObjectFromS3(req, res) { } export function signS3(req, res) { + const limit = process.env.UPLOAD_LIMIT || 250000000; + if (req.user.totalSize > limit) { + res.status(403).send({message: 'user has uploaded the maximum size of assets.'}); + return; + } const fileExtension = getExtension(req.body.name); const filename = uuid.v4() + fileExtension; const acl = 'public-read'; diff --git a/server/views/index.js b/server/views/index.js index d8848351..156fcfdc 100644 --- a/server/views/index.js +++ b/server/views/index.js @@ -31,6 +31,7 @@ export function renderIndex() { window.process.env.EXAMPLES_ENABLED = ${process.env.EXAMPLES_ENABLED === 'false' ? false : true}; window.process.env.UI_ACCESS_TOKEN_ENABLED = ${process.env.UI_ACCESS_TOKEN_ENABLED === 'false' ? false : true}; window.process.env.UI_COLLECTIONS_ENABLED = ${process.env.UI_COLLECTIONS_ENABLED === 'false' ? false : true}; + window.process.env.UPLOAD_LIMIT = ${process.env.UPLOAD_LIMIT === 'false' ? false : true};