Skip to content

Commit

Permalink
fix: [AXIMST-510] there is no message if a user upload a large file
Browse files Browse the repository at this point in the history
  • Loading branch information
monteri committed Feb 22, 2024
1 parent 5697088 commit be93e22
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ export const COURSE_BLOCK_NAMES = /** @type {const} */ ({
component: { id: 'component', name: 'Component' },
});

export const UPLOAD_FILE_MAX_SIZE = 100 * 1024 * 1024; // 100mb
export const UPLOAD_FILE_MAX_SIZE = 20 * 1000 * 1000; // 20mb
4 changes: 2 additions & 2 deletions src/files-and-videos/files-page/FilesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import { getFileSizeToClosestByte } from '../../utils';
import FileThumbnail from './FileThumbnail';
import FileInfoModalSidebar from './FileInfoModalSidebar';
import { UPLOAD_FILE_MAX_SIZE } from '../../constants';

const FilesPage = ({
courseId,
Expand Down Expand Up @@ -81,7 +82,6 @@ const FilesPage = ({
usageErrorMessages: errorMessages.usageMetrics,
fileType: 'file',
};
const maxFileSize = 20 * 1048576;

const activeColumn = {
id: 'activeStatus',
Expand Down Expand Up @@ -195,7 +195,7 @@ const FilesPage = ({
handleErrorReset,
handleFileOrder,
tableColumns,
maxFileSize,
UPLOAD_FILE_MAX_SIZE,
thumbnailPreview,
infoModalSidebar,
files: assets,
Expand Down
5 changes: 3 additions & 2 deletions src/generic/modal-dropzone/ModalDropzone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { FileUpload as FileUploadIcon } from '@edx/paragon/icons';

import useModalDropzone from './useModalDropzone';
import messages from './messages';
import { UPLOAD_FILE_MAX_SIZE } from '../../constants';

const ModalDropzone = ({
fileTypes,
Expand All @@ -27,7 +28,7 @@ const ModalDropzone = ({
onCancel,
onChange,
onSavingStatus,
maxSize,
maxSize = UPLOAD_FILE_MAX_SIZE,
}) => {
const {
intl,
Expand Down Expand Up @@ -120,7 +121,7 @@ ModalDropzone.defaultProps = {
imageHelpText: '',
previewComponent: null,
imageDropzoneText: '',
maxSize: Infinity,
maxSize: UPLOAD_FILE_MAX_SIZE,
};

ModalDropzone.propTypes = {
Expand Down
7 changes: 4 additions & 3 deletions src/generic/modal-dropzone/useModalDropzone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ const useModalDropzone = ({
if (url) {
onChange(url);
onSavingStatus({ status: RequestStatus.SUCCESSFUL });
setDisabledUploadBtn(true);
setUploadProgress(0);
setPreviewUrl(null);

setTimeout(() => {
onClose();
}, 1000);
}
} catch (error) {
onSavingStatus({ status: RequestStatus.FAILED });
} finally {
setDisabledUploadBtn(true);
setUploadProgress(0);
setPreviewUrl(null);
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/textbooks/textbook-form/TextbookForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import FormikControl from '../../generic/FormikControl';
import PromptIfDirty from '../../generic/PromptIfDirty';
import ModalDropzone from '../../generic/modal-dropzone/ModalDropzone';
import { useModel } from '../../generic/model-store';
import { UPLOAD_FILE_MAX_SIZE } from '../../constants';
import textbookFormValidationSchema from './validations';
import messages from './messages';

Expand Down Expand Up @@ -166,7 +165,6 @@ const TextbookForm = ({
previewComponent={(
<Icon src={PdfIcon} className="modal-preview-icon" />
)}
maxSize={UPLOAD_FILE_MAX_SIZE}
/>
<PromptIfDirty dirty={dirty} />
</>
Expand Down

0 comments on commit be93e22

Please sign in to comment.