1
1
import React , { useContext } from 'react'
2
2
import PropsTypes from 'prop-types'
3
- import { Modal , Icon } from 'patternfly- react'
3
+ import { Modal , ModalVariant , Button } from '@ patternfly/ react-core '
4
4
import { MsgContext } from '_/intl'
5
5
6
6
const btnPropType = PropsTypes . shape ( {
7
7
title : PropsTypes . string ,
8
8
onClick : PropsTypes . func ,
9
9
} )
10
10
11
- const ConfirmationModal = ( { show, title, confirm, body, subContent, onClose, extra, accessibleDescription } ) => {
11
+ const ConfirmationModal = ( { show, title, confirm, body, subContent, onClose, extra } ) => {
12
12
const { msg } = useContext ( MsgContext )
13
13
return (
14
- < Modal onHide = { onClose } show = { show } className = 'message-dialog-pf' aria-describedby = { accessibleDescription } >
15
- < Modal . Header >
16
- < button
17
- className = 'close'
18
- onClick = { onClose }
19
- >
20
- < span className = 'pficon pficon-close' title = 'Close' />
21
- </ button >
22
- < Modal . Title > { title } </ Modal . Title >
23
- </ Modal . Header >
24
- < Modal . Body >
25
- {
14
+ < Modal
15
+ title = { title }
16
+ isOpen = { show }
17
+ variant = { ModalVariant . small }
18
+ titleIconVariant = 'warning'
19
+ position = 'top'
20
+ onClose = { onClose }
21
+ actions = { [
22
+ < Button key = 'confirm' variant = { confirm . type || 'primary' } onClick = { ( ) => { confirm . onClick ( ) ; onClose ( ) } } > { confirm . title } </ Button > ,
23
+ extra && < Button key = 'extra' variant = 'secondary' onClick = { ( ) => { extra . onClick ( ) ; onClose ( ) } } > { extra . title } </ Button > ,
24
+ < Button key = 'cancel' variant = 'link' onClick = { onClose } > { msg . cancel ( ) } </ Button > ,
25
+ ] . filter ( Boolean ) }
26
+ >
27
+ {
26
28
typeof body === 'string'
27
29
? (
28
30
< >
29
- < Icon type = 'pf' name = 'warning-triangle-o' />
30
- < div id = { accessibleDescription } >
31
- < p className = 'lead' >
32
- { body }
33
- </ p >
34
- {
31
+ < p className = 'lead' >
32
+ { body }
33
+ </ p >
34
+ {
35
35
subContent && typeof subContent === 'string'
36
36
? < p > { subContent } </ p >
37
37
: subContent
38
38
}
39
- </ div >
40
39
</ >
41
40
)
42
41
: body
43
42
}
44
- </ Modal . Body >
45
- < Modal . Footer >
46
- { extra && < button className = 'btn btn-info' onClick = { ( ) => { extra . onClick ( ) ; onClose ( ) } } > { extra . title } </ button > }
47
- < button className = { `btn ${ confirm ? 'btn-default' : 'btn-info' } ` } onClick = { onClose } > { msg . cancel ( ) } </ button >
48
- { confirm && < button className = { `btn ${ confirm . type ? `btn-${ confirm . type } ` : 'btn-info' } ` } onClick = { ( ) => { confirm . onClick ( ) ; onClose ( ) } } > { confirm . title } </ button > }
49
- </ Modal . Footer >
50
43
</ Modal >
51
44
)
52
45
}
@@ -56,10 +49,9 @@ ConfirmationModal.propTypes = {
56
49
title : PropsTypes . string . isRequired ,
57
50
58
51
onClose : PropsTypes . func ,
59
- accessibleDescription : PropsTypes . string ,
60
52
confirm : PropsTypes . shape ( {
61
53
title : PropsTypes . string ,
62
- type : PropsTypes . oneOf ( [ 'primary' , 'success' , 'info' , ' warning', 'danger '] ) ,
54
+ type : PropsTypes . oneOf ( [ 'primary' | 'secondary' | 'tertiary' | 'danger' | ' warning' | 'link' | 'plain' | 'control '] ) ,
63
55
onClick : PropsTypes . func ,
64
56
} ) ,
65
57
extra : btnPropType ,
0 commit comments