@@ -6,7 +6,8 @@ import { Environment } from '../types/environment.types';
6
6
import { DeployableItemConfig } from '../types/deployable-item.types' ;
7
7
import { useEnvironmentContext } from '../context/EnvironmentContext' ;
8
8
import { getEnvironmentTagColor , formatEnvironmentType } from '../utils/environmentUtils' ;
9
- import { ExclamationCircleOutlined , WarningOutlined } from '@ant-design/icons' ;
9
+ import { ExclamationCircleOutlined } from '@ant-design/icons' ;
10
+ import { showFirstCredentialOverwriteConfirm , showSecondCredentialOverwriteConfirm } from './credentialConfirmations' ;
10
11
11
12
interface DeployItemModalProps {
12
13
visible :boolean ;
@@ -53,58 +54,20 @@ function DeployItemModal({
53
54
54
55
// First confirmation
55
56
if ( credentialConfirmationStep === 0 ) {
56
- Modal . confirm ( {
57
- title :(
58
- < div style = { { display :'flex' , alignItems :'center' , color :'#ff7a00' } } >
59
- < WarningOutlined style = { { marginRight :8 , fontSize :'18px' } } />
60
- < span style = { { fontSize :'16px' , fontWeight :'600' } } > Overwrite Credentials Warning</ span >
61
- </ div >
62
- ) ,
63
- icon :null ,
64
- content :(
65
- < div style = { { padding :'16px 0' } } >
66
- < Alert
67
- message = "This action will overwrite existing credentials in the target environment."
68
- description = {
69
- < div style = { { marginTop :'8px' } } >
70
- < p style = { { margin :0 , fontWeight :'500' } } >
71
- This is a serious operation that may affect other applications and users.
72
- </ p >
73
- < p style = { { margin :'8px 0 0 0' , color :'#8c8c8c' } } >
74
- Are you sure you want to proceed?
75
- </ p >
76
- </ div >
77
- }
78
- type = "warning"
79
- showIcon
80
- style = { {
81
- marginBottom :0 ,
82
- border :'1px solid #fff2e8' ,
83
- borderRadius :'8px'
84
- } }
85
- />
86
- </ div >
87
- ) ,
88
- okText :'Continue' ,
89
- cancelText :'Cancel' ,
90
- okButtonProps :{
91
- style :{
92
- backgroundColor :'#ff7a00' ,
93
- borderColor :'#ff7a00' ,
94
- fontWeight :'500'
95
- }
96
- } ,
97
- cancelButtonProps :{
98
- style :{
99
- fontWeight :'500'
100
- }
101
- } ,
102
- width :520 ,
103
- centered :false ,
57
+ showFirstCredentialOverwriteConfirm ( {
104
58
onOk :( ) => {
105
59
setCredentialConfirmationStep ( 1 ) ;
106
60
// Show second confirmation immediately
107
- showSecondConfirmation ( fieldName ) ;
61
+ showSecondCredentialOverwriteConfirm ( {
62
+ onOk :( ) => {
63
+ setCredentialConfirmationStep ( 2 ) ;
64
+ form . setFieldsValue ( { [ fieldName ] :true } ) ;
65
+ } ,
66
+ onCancel :( ) => {
67
+ setCredentialConfirmationStep ( 0 ) ;
68
+ form . setFieldsValue ( { [ fieldName ] :false } ) ;
69
+ }
70
+ } ) ;
108
71
} ,
109
72
onCancel :( ) => {
110
73
setCredentialConfirmationStep ( 0 ) ;
@@ -114,81 +77,6 @@ function DeployItemModal({
114
77
}
115
78
} ;
116
79
117
- const showSecondConfirmation = ( fieldName :string ) => {
118
- Modal . confirm ( {
119
- title :(
120
- < div style = { { display :'flex' , alignItems :'center' , color :'#ff4d4f' } } >
121
- < ExclamationCircleOutlined style = { { marginRight :8 , fontSize :'18px' } } />
122
- < span style = { { fontSize :'16px' , fontWeight :'600' } } > Final Confirmation Required</ span >
123
- </ div >
124
- ) ,
125
- icon :null ,
126
- content :(
127
- < div style = { { padding :'16px 0' } } >
128
- < Alert
129
- message = "Final Warning: Credential Overwrite"
130
- description = {
131
- < div style = { { marginTop :'8px' } } >
132
- < p style = { { margin :0 , fontWeight :'500' } } >
133
- You are about to overwrite credentials in the target environment.
134
- This action cannot be undone and may break existing integrations.
135
- </ p >
136
- < p style = { { margin :'8px 0 0 0' , color :'#8c8c8c' } } >
137
- Please confirm one more time.
138
- </ p >
139
- </ div >
140
- }
141
- type = "error"
142
- showIcon
143
- style = { {
144
- marginBottom :16 ,
145
- border :'1px solid #ffebee' ,
146
- borderRadius :'8px'
147
- } }
148
- />
149
- < div style = { {
150
- padding :'12px 16px' ,
151
- backgroundColor :'#fff2f0' ,
152
- borderRadius :'8px' ,
153
- border :'1px solid #ffccc7'
154
- } } >
155
- < p style = { {
156
- margin :0 ,
157
- fontWeight :'600' ,
158
- color :'#cf1322' ,
159
- fontSize :'14px'
160
- } } >
161
- Are you absolutely certain you want to overwrite the credentials?
162
- </ p >
163
- </ div >
164
- </ div >
165
- ) ,
166
- okText :'Yes, Overwrite Credentials' ,
167
- okType :'danger' ,
168
- cancelText :'Cancel' ,
169
- okButtonProps :{
170
- style :{
171
- fontWeight :'500'
172
- }
173
- } ,
174
- cancelButtonProps :{
175
- style :{
176
- fontWeight :'500'
177
- }
178
- } ,
179
- width :520 ,
180
- centered :false ,
181
- onOk :( ) => {
182
- setCredentialConfirmationStep ( 2 ) ;
183
- form . setFieldsValue ( { [ fieldName ] :true } ) ;
184
- } ,
185
- onCancel :( ) => {
186
- setCredentialConfirmationStep ( 0 ) ;
187
- form . setFieldsValue ( { [ fieldName ] :false } ) ;
188
- }
189
- } ) ;
190
- } ;
191
-
192
80
const handleDeploy = async ( ) => {
193
81
if ( ! config . deploy || ! item ) return ;
194
82
@@ -346,7 +234,7 @@ function DeployItemModal({
346
234
return null ;
347
235
}
348
236
} ) }
349
-
237
+
350
238
< Form . Item >
351
239
< Button type = "default" onClick = { onClose } style = { { marginRight :8 } } >
352
240
Cancel