From 59fe175ede253230959689337949cffe3bbdc29e Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Thu, 26 Sep 2019 15:06:43 -0400 Subject: [PATCH] Fix merge conflict for cherry picking 11833e9880257fe8164331689f77f8aa11df6a2a --- client/modules/IDE/actions/uploader.js | 6 ++--- client/modules/IDE/components/NewFileForm.jsx | 22 ++++++++++--------- .../modules/IDE/components/NewFolderForm.jsx | 22 ++++++++++--------- .../modules/IDE/components/NewFolderModal.jsx | 2 +- client/modules/IDE/components/Sidebar.jsx | 2 +- .../IDE/components/UploadFileModal.jsx | 4 ++-- client/modules/IDE/selectors/users.js | 8 ++++--- client/styles/components/_modal.scss | 6 ++--- server/controllers/aws.controller.js | 5 +++++ server/views/index.js | 1 + 10 files changed, 45 insertions(+), 33 deletions(-) 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; }} - /> - +
+ + { this.fileName = element; }} + /> + +
{name.touched && name.error && {name.error}} ); diff --git a/client/modules/IDE/components/NewFolderForm.jsx b/client/modules/IDE/components/NewFolderForm.jsx index 3490de64..92b91442 100644 --- a/client/modules/IDE/components/NewFolderForm.jsx +++ b/client/modules/IDE/components/NewFolderForm.jsx @@ -25,16 +25,18 @@ class NewFolderForm extends React.Component { } }} > - - { this.fileName = element; }} - {...domOnlyProps(name)} - /> - +
+ + { this.fileName = element; }} + {...domOnlyProps(name)} + /> + +
{name.touched && name.error && {name.error}} ); diff --git a/client/modules/IDE/components/NewFolderModal.jsx b/client/modules/IDE/components/NewFolderModal.jsx index 60483ce8..4af43a89 100644 --- a/client/modules/IDE/components/NewFolderModal.jsx +++ b/client/modules/IDE/components/NewFolderModal.jsx @@ -16,7 +16,7 @@ class NewFolderModal extends React.Component {
{ this.newFolderModal = element; }} >
-

Add Folder

+

Create Folder

diff --git a/client/modules/IDE/components/Sidebar.jsx b/client/modules/IDE/components/Sidebar.jsx index f6a5bdd1..61c61515 100644 --- a/client/modules/IDE/components/Sidebar.jsx +++ b/client/modules/IDE/components/Sidebar.jsx @@ -97,7 +97,7 @@ class Sidebar extends React.Component { onBlur={this.onBlurComponent} onFocus={this.onFocusComponent} > - Add folder + Create folder
  • diff --git a/client/modules/IDE/components/UploadFileModal.jsx b/client/modules/IDE/components/UploadFileModal.jsx index 3e335fc0..9385d6aa 100644 --- a/client/modules/IDE/components/UploadFileModal.jsx +++ b/client/modules/IDE/components/UploadFileModal.jsx @@ -36,9 +36,9 @@ class UploadFileModal extends React.Component { { this.props.reachedTotalSizeLimit &&

    { - `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};