@@ -9,17 +9,17 @@ import messages from './messages';
9
9
import { useUploadConfirmModalHooks } from './hooks' ;
10
10
11
11
const UploadConfirmModal = ( {
12
- open, files , closeHandler, uploadHandler,
12
+ open, file , closeHandler, uploadHandler,
13
13
} ) => {
14
14
const { formatMessage } = useIntl ( ) ;
15
15
16
16
const {
17
- errors ,
17
+ shouldShowError ,
18
18
exitHandler,
19
19
confirmUploadClickHandler,
20
20
onFileDescriptionChange,
21
21
} = useUploadConfirmModalHooks ( {
22
- files ,
22
+ file ,
23
23
closeHandler,
24
24
uploadHandler,
25
25
} ) ;
@@ -30,6 +30,7 @@ const UploadConfirmModal = ({
30
30
title = { formatMessage ( messages . uploadFileModalTitle ) }
31
31
hasCloseButton = { false }
32
32
onClose = { exitHandler }
33
+ isBlocking
33
34
>
34
35
< ModalDialog . Header >
35
36
< ModalDialog . Title >
@@ -39,28 +40,26 @@ const UploadConfirmModal = ({
39
40
40
41
< ModalDialog . Body >
41
42
< div >
42
- { files . map ( ( file , i ) => (
43
- // note: we only support one file
44
- // eslint-disable-next-line react/no-array-index-key
45
- < Form . Group key = { i } >
43
+ { file && (
44
+ < Form . Group >
46
45
< FormLabel >
47
46
< strong >
48
47
{ formatMessage ( messages . uploadFileDescriptionFieldLabel ) }
49
48
</ strong >
50
49
< span className = "file-name-ellipsis" > { file . name } </ span >
51
50
</ FormLabel >
52
51
< Form . Control
53
- isInvalid = { errors [ i ] }
54
- name = { ` file-${ i } - description` }
52
+ isInvalid = { shouldShowError }
53
+ name = " file-description"
55
54
onChange = { onFileDescriptionChange }
56
55
/>
57
- { errors [ i ] && (
56
+ { shouldShowError && (
58
57
< Form . Control . Feedback type = "invalid" >
59
- { errors [ i ] && formatMessage ( messages . fileDescriptionMissingError ) }
58
+ formatMessage(messages.fileDescriptionMissingError)
60
59
</ Form . Control . Feedback >
61
60
) }
62
61
</ Form . Group >
63
- ) ) }
62
+ ) }
64
63
</ div >
65
64
</ ModalDialog . Body >
66
65
< ModalDialog . Footer >
@@ -79,18 +78,15 @@ const UploadConfirmModal = ({
79
78
80
79
UploadConfirmModal . defaultProps = {
81
80
open : false ,
82
- files : [ ] ,
83
81
closeHandler : ( ) => { } ,
84
82
uploadHandler : ( ) => { } ,
85
83
} ;
86
84
UploadConfirmModal . propTypes = {
87
85
open : PropTypes . bool ,
88
- files : PropTypes . arrayOf (
89
- PropTypes . shape ( {
90
- name : PropTypes . string ,
91
- description : PropTypes . string ,
92
- } ) ,
93
- ) ,
86
+ file : PropTypes . shape ( {
87
+ name : PropTypes . string ,
88
+ description : PropTypes . string ,
89
+ } ) . isRequired ,
94
90
closeHandler : PropTypes . func ,
95
91
uploadHandler : PropTypes . func ,
96
92
} ;
0 commit comments