@@ -2,7 +2,7 @@ import React from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import filesize from 'filesize' ;
4
4
5
- import { DataTable , Dropzone } from '@openedx/paragon' ;
5
+ import { DataTable , Dropzone , Form } from '@openedx/paragon' ;
6
6
import { useIntl } from '@edx/frontend-platform/i18n' ;
7
7
8
8
import { nullMethod } from 'utils' ;
@@ -35,6 +35,7 @@ const FileUpload = ({
35
35
onDeletedFile,
36
36
defaultCollapsePreview,
37
37
hideHeader,
38
+ isInValid,
38
39
} ) => {
39
40
const { formatMessage } = useIntl ( ) ;
40
41
const {
@@ -47,7 +48,7 @@ const FileUpload = ({
47
48
const viewStep = useViewStep ( ) ;
48
49
const activeStepName = useActiveStepName ( ) ;
49
50
const {
50
- enabled, fileUploadLimit, allowedExtensions, maxFileSize,
51
+ enabled, fileUploadLimit, allowedExtensions, maxFileSize, required ,
51
52
} = useFileUploadConfig ( ) || { } ;
52
53
53
54
if ( ! enabled || viewStep === stepNames . studentTraining ) {
@@ -78,7 +79,7 @@ const FileUpload = ({
78
79
79
80
return (
80
81
< div >
81
- { ! hideHeader && < h3 > { formatMessage ( messages . fileUploadTitle ) } </ h3 > }
82
+ { ! hideHeader && < h3 > { formatMessage ( messages . fileUploadTitle ) } { required && < span > (required) </ span > } </ h3 > }
82
83
{ uploadedFiles . length > 0 && isReadOnly && (
83
84
< FilePreview defaultCollapsePreview = { defaultCollapsePreview } />
84
85
) }
@@ -93,15 +94,17 @@ const FileUpload = ({
93
94
columns = { columns }
94
95
/>
95
96
{ ! isReadOnly && fileUploadLimit > uploadedFiles . length && (
96
- < Dropzone
97
- multiple
98
- onProcessUpload = { onProcessUpload }
99
- progressVariant = "bar"
100
- accept = { {
101
- '*' : ( allowedExtensions || [ ] ) . map ( ( ext ) => `.${ ext } ` ) ,
102
- } }
103
- maxSize = { maxFileSize }
104
- />
97
+ < Form . Group isInValid >
98
+ < Dropzone
99
+ onProcessUpload = { onProcessUpload }
100
+ progressVariant = "bar"
101
+ accept = { {
102
+ '*' : ( allowedExtensions || [ ] ) . map ( ( ext ) => `.${ ext } ` ) ,
103
+ } }
104
+ maxSize = { maxFileSize }
105
+ />
106
+ { isInValid && < Form . Control . Feedback type = "invalid" > { formatMessage ( messages . required ) } </ Form . Control . Feedback > }
107
+ </ Form . Group >
105
108
) }
106
109
{ ! isReadOnly && isModalOpen && (
107
110
< UploadConfirmModal
@@ -122,6 +125,7 @@ FileUpload.defaultProps = {
122
125
onDeletedFile : nullMethod ,
123
126
defaultCollapsePreview : false ,
124
127
hideHeader : false ,
128
+ isInValid : false ,
125
129
} ;
126
130
FileUpload . propTypes = {
127
131
isReadOnly : PropTypes . bool ,
@@ -137,6 +141,7 @@ FileUpload.propTypes = {
137
141
onDeletedFile : PropTypes . func ,
138
142
defaultCollapsePreview : PropTypes . bool ,
139
143
hideHeader : PropTypes . bool ,
144
+ isInValid : PropTypes . bool ,
140
145
} ;
141
146
142
147
export default FileUpload ;
0 commit comments