Skip to content

Commit bf81496

Browse files
authored
feat(web): add confirm update env modal (#806)
1 parent 0472a65 commit bf81496

File tree

5 files changed

+28
-16
lines changed

5 files changed

+28
-16
lines changed

web/public/locales/en/translation.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@
137137
"Expire": "Expiration",
138138
"Setting": "Setting",
139139
"SystemSetting": "Application Settings",
140-
"UserSetting": "User Settings"
140+
"UserSetting": "User Settings",
141+
"UpdateConfirm": "Update env will restart application, are you sure?"
141142
},
142143
"StoragePanel": {
143144
"All": "Total Capacity",
@@ -231,4 +232,4 @@
231232
"Bucket": {
232233
"StatusTip": "External access needs to set the bucket permission to readonly"
233234
}
234-
}
235+
}

web/public/locales/zh-CN/translation.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@
125125
"AppEnv": "环境变量",
126126
"AddAppEnv": "新增环境变量",
127127
"Expire": "过期时间",
128-
"UserSetting": "用户设置"
128+
"UserSetting": "用户设置",
129+
"UpdateConfirm": "更新环境变量将重新启动应用,是否继续?"
129130
},
130131
"StoragePanel": {
131132
"CreateBucket": "创建 Bucket",
@@ -232,4 +233,4 @@
232233
"Bucket": {
233234
"StatusTip": "外部访问需要将 bucket 权限设置为 readonly"
234235
}
235-
}
236+
}

web/public/locales/zh/translation.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@
137137
"Expire": "过期时间",
138138
"Setting": "设置",
139139
"SystemSetting": "应用设置",
140-
"UserSetting": "用户设置"
140+
"UserSetting": "用户设置",
141+
"UpdateConfirm": "更新环境变量将重新启动应用,是否继续?"
141142
},
142143
"StoragePanel": {
143144
"All": "总容量",
@@ -231,4 +232,4 @@
231232
"Bucket": {
232233
"StatusTip": "外部访问需要将 bucket 权限设置为 readonly"
233234
}
234-
}
235+
}

web/src/components/ConfirmButton/index.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ interface ConfirmButtonProps {
1717
onSuccessAction: () => void;
1818
headerText: string;
1919
bodyText: string;
20-
20+
confirmButtonText?: string;
2121
children: React.ReactElement;
2222
}
2323

24-
const ConfirmButton = ({ onSuccessAction, headerText, bodyText, children }: ConfirmButtonProps) => {
24+
const ConfirmButton = ({
25+
onSuccessAction,
26+
headerText,
27+
bodyText,
28+
confirmButtonText,
29+
children,
30+
}: ConfirmButtonProps) => {
2531
const { isOpen, onOpen, onClose } = useDisclosure();
2632
const cancelRef = React.useRef<any>();
2733

@@ -52,7 +58,9 @@ const ConfirmButton = ({ onSuccessAction, headerText, bodyText, children }: Conf
5258

5359
<AlertDialogFooter>
5460
<Button colorScheme={"red"} onClick={onSubmit}>
55-
{t("Delete")}
61+
{confirmButtonText && confirmButtonText.length !== 0
62+
? confirmButtonText
63+
: t("Delete")}
5664
</Button>
5765
</AlertDialogFooter>
5866
</AlertDialogContent>

web/src/pages/app/setting/AppEnvList/index.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Button } from "@chakra-ui/react";
22
import { t } from "i18next";
33

4+
import ConfirmButton from "@/components/ConfirmButton";
45
import EditableTable from "@/components/EditableTable";
56
import { isExitInList } from "@/utils/format";
67

@@ -74,17 +75,17 @@ const AppEnvList = (props: { onClose?: () => {} }) => {
7475
onDelete={(data) => delEnvironmentMutation.mutateAsync({ name: data })}
7576
onCreate={(data) => addEnvironmentMutation.mutateAsync(data)}
7677
/>
77-
<Button
78-
className="w-28 h-8 self-end mt-4"
79-
type="submit"
80-
variant={"secondary"}
81-
onClick={() => {
78+
<ConfirmButton
79+
onSuccessAction={() => {
8280
globalStore.restartCurrentApp();
8381
props.onClose && props.onClose();
8482
}}
83+
headerText={String(t("Update"))}
84+
bodyText={String(t("SettingPanel.UpdateConfirm"))}
85+
confirmButtonText={String(t("Update"))}
8586
>
86-
{t("Update")}
87-
</Button>
87+
<Button className="w-28 h-8 self-end mt-4">{t("Update")}</Button>
88+
</ConfirmButton>
8889
</div>
8990
</>
9091
);

0 commit comments

Comments
 (0)