Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit288ce77

Browse files
committed
Add overwrite credential in the Deploy Modal
1 parent2c21181 commit288ce77

File tree

1 file changed

+99
-2
lines changed

1 file changed

+99
-2
lines changed

‎client/packages/lowcoder/src/pages/setting/environments/components/DeployItemModal.tsx‎

Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// components/DeployItemModal.tsx
22
importReact,{useState,useEffect}from'react';
3-
import{Modal,Form,Select,Checkbox,Button,Spin,Input,Tag,Space}from'antd';
3+
import{Modal,Form,Select,Checkbox,Button,Spin,Input,Tag,Space,Alert}from'antd';
44
import{messageInstance}from'lowcoder-design/src/components/GlobalInstances';
55
import{Environment}from'../types/environment.types';
66
import{DeployableItemConfig}from'../types/deployable-item.types';
77
import{useEnvironmentContext}from'../context/EnvironmentContext';
88
import{getEnvironmentTagColor,formatEnvironmentType}from'../utils/environmentUtils';
9+
import{ExclamationCircleOutlined}from'@ant-design/icons';
910

1011
interfaceDeployItemModalProps{
1112
visible:boolean;
@@ -27,10 +28,12 @@ function DeployItemModal({
2728
const[form]=Form.useForm();
2829
const{ environments, isLoading}=useEnvironmentContext();
2930
const[deploying,setDeploying]=useState(false);
31+
const[credentialConfirmationStep,setCredentialConfirmationStep]=useState(0);// 0: not started, 1: first confirmation, 2: confirmed
3032

3133
useEffect(()=>{
3234
if(visible){
3335
form.resetFields();
36+
setCredentialConfirmationStep(0);
3437
}
3538
},[visible,form]);
3639

@@ -39,6 +42,76 @@ function DeployItemModal({
3942
(env:Environment)=>env.environmentId!==sourceEnvironment.environmentId&&env.isLicensed!==false
4043
);
4144

45+
// Handle credential checkbox change with double confirmation
46+
consthandleCredentialCheckboxChange=(checked:boolean,fieldName:string)=>{
47+
if(!checked){
48+
// If unchecking, reset confirmation and update form
49+
setCredentialConfirmationStep(0);
50+
form.setFieldsValue({[fieldName]:false});
51+
return;
52+
}
53+
54+
// First confirmation
55+
if(credentialConfirmationStep===0){
56+
Modal.confirm({
57+
title:'Overwrite Credentials Warning',
58+
icon:<ExclamationCircleOutlined/>,
59+
content:(
60+
<div>
61+
<Alert
62+
message="This action will overwrite existing credentials in the target environment."
63+
description="This is a serious operation that may affect other applications and users. Are you sure you want to proceed?"
64+
type="warning"
65+
showIcon
66+
style={{marginBottom:16}}
67+
/>
68+
</div>
69+
),
70+
okText:'Continue',
71+
cancelText:'Cancel',
72+
onOk:()=>{
73+
setCredentialConfirmationStep(1);
74+
// Show second confirmation immediately
75+
showSecondConfirmation(fieldName);
76+
},
77+
onCancel:()=>{
78+
setCredentialConfirmationStep(0);
79+
form.setFieldsValue({[fieldName]:false});
80+
}
81+
});
82+
}
83+
};
84+
85+
constshowSecondConfirmation=(fieldName:string)=>{
86+
Modal.confirm({
87+
title:'Final Confirmation Required',
88+
icon:<ExclamationCircleOutlined/>,
89+
content:(
90+
<div>
91+
<Alert
92+
message="Final Warning: Credential Overwrite"
93+
description="You are about to overwrite credentials in the target environment. This action cannot be undone and may break existing integrations. Please confirm one more time."
94+
type="error"
95+
showIcon
96+
style={{marginBottom:16}}
97+
/>
98+
<p><strong>Are you absolutely certain you want to overwrite the credentials?</strong></p>
99+
</div>
100+
),
101+
okText:'Yes, Overwrite Credentials',
102+
okType:'danger',
103+
cancelText:'Cancel',
104+
onOk:()=>{
105+
setCredentialConfirmationStep(2);
106+
form.setFieldsValue({[fieldName]:true});
107+
},
108+
onCancel:()=>{
109+
setCredentialConfirmationStep(0);
110+
form.setFieldsValue({[fieldName]:false});
111+
}
112+
});
113+
};
114+
42115
consthandleDeploy=async()=>{
43116
if(!config.deploy||!item)return;
44117

@@ -50,6 +123,12 @@ function DeployItemModal({
50123
messageInstance.error('Target environment not found');
51124
return;
52125
}
126+
127+
// Additional check for credential overwrite
128+
if(values.deployCredential&&credentialConfirmationStep!==2){
129+
messageInstance.error('Please confirm credential overwrite before deploying');
130+
return;
131+
}
53132

54133
setDeploying(true);
55134

@@ -124,14 +203,32 @@ function DeployItemModal({
124203
{config.deploy?.fields.map(field=>{
125204
switch(field.type){
126205
case'checkbox':
206+
// Special handling for credential-related checkboxes
207+
constisCredentialField=field.name==='deployCredential';
127208
return(
128209
<Form.Item
129210
key={field.name}
130211
name={field.name}
131212
valuePropName="checked"
132213
initialValue={field.defaultValue}
133214
>
134-
<Checkbox>{field.label}</Checkbox>
215+
<Checkbox
216+
onChange={(e)=>{
217+
if(isCredentialField){
218+
handleCredentialCheckboxChange(e.target.checked,field.name);
219+
}else{
220+
// For non-credential checkboxes, handle normally
221+
form.setFieldsValue({[field.name]:e.target.checked});
222+
}
223+
}}
224+
>
225+
{field.label}
226+
{isCredentialField&&credentialConfirmationStep===2&&(
227+
<Tagcolor="orange"style={{marginLeft:8}}>
228+
Confirmed
229+
</Tag>
230+
)}
231+
</Checkbox>
135232
</Form.Item>
136233
);
137234
case'select':

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp