17
17
import { useState } from 'react'
18
18
19
19
import {
20
- Button ,
21
- ButtonVariantType ,
22
20
ClipboardButton ,
23
- ComponentSizeType ,
24
21
copyToClipboard ,
25
- VisibleModal ,
22
+ GenericModal ,
23
+ InfoBlock ,
24
+ stopPropagation ,
26
25
} from '@devtron-labs/devtron-fe-common-lib'
27
26
28
- import { ReactComponent as Close } from '../../../../assets/icons/ic-close.svg'
29
- import { ReactComponent as Key } from '../../../../assets/icons/ic-key-bulb.svg'
30
- import { ReactComponent as Success } from '../../../../assets/icons/ic-success-outline.svg'
31
27
import { GenerateTokenModalType } from './apiToken.type'
32
28
33
- const GenerateModal = ( { close, token, reload, redirectToTokenList, isRegenerationModal } : GenerateTokenModalType ) => {
29
+ const GenerateModal = ( {
30
+ close,
31
+ token,
32
+ reload,
33
+ redirectToTokenList,
34
+ isRegenerationModal,
35
+ open,
36
+ } : GenerateTokenModalType ) => {
34
37
const [ copyToClipboardPromise , setCopyToClipboardPromise ] = useState < ReturnType < typeof copyToClipboard > > ( null )
35
38
const modelType = isRegenerationModal ? 'regenerated' : 'generated'
36
39
const handleCloseButton = ( ) => {
@@ -40,45 +43,43 @@ const GenerateModal = ({ close, token, reload, redirectToTokenList, isRegenerati
40
43
}
41
44
42
45
const handleCopyToClipboard = async ( e ?: React . MouseEvent ) => {
43
- e ?. stopPropagation ( )
44
-
46
+ stopPropagation ( e )
45
47
setCopyToClipboardPromise ( copyToClipboard ( token ) )
46
48
}
47
49
48
50
return (
49
- < VisibleModal className = "generate-token-modal" >
50
- < div className = "modal__body w-600 pl-20 pr-20 pt-20 pb-20 flex column dc__gap-16" >
51
- < button
52
- type = "button"
53
- data-testid = { `${ modelType } -token-modal-close` }
54
- className = "w-100 flex right dc__transparent"
55
- onClick = { handleCloseButton }
56
- aria-label = "Close modal"
57
- >
58
- < Close className = "icon-dim-24" />
59
- </ button >
60
- < Success className = "dc__vertical-align-middle" />
51
+ < GenericModal
52
+ name = "create-ci-cd-pipeline-modal"
53
+ open = { open }
54
+ width = { 600 }
55
+ onClose = { handleCloseButton }
56
+ onEscape = { handleCloseButton }
57
+ >
58
+ < GenericModal . Header title = { `API Token ${ modelType } ` } />
59
+ < GenericModal . Body >
60
+ < div className = "flexbox-col dc__gap-20 p-20" >
61
+ < div >
62
+ < h4 className = "m-0" > Copy and store this token safely, you won’t be able to view it again.</ h4 >
63
+ < p className = "cn-7 fs-12 lh-1-5 m-0" >
64
+ You can regenerate a token anytime. If you do, remember to update any scripts or
65
+ applications using the old token.
66
+ </ p >
67
+ </ div >
61
68
62
- < h2 className = "modal__title fs-16" > API token { modelType } </ h2 >
63
- < div
64
- className = "flex top left bcg-1 br-4 eg-2 bw-1 pl-16 pr-16 pt-10 pb-10 dc__break-word"
65
- style = { { width : '560px' } }
66
- >
67
- < Key className = "api-token-icon icon-dim-20 mr-10" />
68
- < span data-testid = { `${ modelType } -token` } className = "api-token-text cn-9 fs-14" >
69
- { token }
70
- </ span >
69
+ < InfoBlock description = { token } variant = "success" />
71
70
</ div >
72
- < Button
73
- dataTestId = "copy-token"
74
- variant = { ButtonVariantType . primary }
75
- size = { ComponentSizeType . large }
76
- onClick = { handleCopyToClipboard }
77
- startIcon = { < ClipboardButton content = { token } copyToClipboardPromise = { copyToClipboardPromise } /> }
78
- text = "Copy token"
79
- />
80
- </ div >
81
- </ VisibleModal >
71
+ </ GenericModal . Body >
72
+ < GenericModal . Footer
73
+ buttonConfig = { {
74
+ primaryButton : {
75
+ dataTestId : 'copy-token' ,
76
+ startIcon : < ClipboardButton content = { token } copyToClipboardPromise = { copyToClipboardPromise } /> ,
77
+ text : 'Copy token' ,
78
+ onClick : handleCopyToClipboard ,
79
+ } ,
80
+ } }
81
+ />
82
+ </ GenericModal >
82
83
)
83
84
}
84
85
0 commit comments