Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): add confirm update env modal #806

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
"Expire": "Expiration",
"Setting": "Setting",
"SystemSetting": "Application Settings",
"UserSetting": "User Settings"
"UserSetting": "User Settings",
"UpdateConfirm": "Update env will restart application, are you sure?"
},
"StoragePanel": {
"All": "Total Capacity",
Expand Down Expand Up @@ -230,4 +231,4 @@
"Bucket": {
"StatusTip": "External access needs to set the bucket permission to readonly"
}
}
}
5 changes: 3 additions & 2 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
"AppEnv": "环境变量",
"AddAppEnv": "新增环境变量",
"Expire": "过期时间",
"UserSetting": "用户设置"
"UserSetting": "用户设置",
"UpdateConfirm": "更新环境变量将重新启动应用,是否继续?"
},
"StoragePanel": {
"CreateBucket": "创建 Bucket",
Expand Down Expand Up @@ -231,4 +232,4 @@
"Bucket": {
"StatusTip": "外部访问需要将 bucket 权限设置为 readonly"
}
}
}
5 changes: 3 additions & 2 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
"Expire": "过期时间",
"Setting": "设置",
"SystemSetting": "应用设置",
"UserSetting": "用户设置"
"UserSetting": "用户设置",
"UpdateConfirm": "更新环境变量将重新启动应用,是否继续?"
},
"StoragePanel": {
"All": "总容量",
Expand Down Expand Up @@ -230,4 +231,4 @@
"Bucket": {
"StatusTip": "外部访问需要将 bucket 权限设置为 readonly"
}
}
}
14 changes: 11 additions & 3 deletions web/src/components/ConfirmButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ interface ConfirmButtonProps {
onSuccessAction: () => void;
headerText: string;
bodyText: string;

confirmButtonText?: string;
children: React.ReactElement;
}

const ConfirmButton = ({ onSuccessAction, headerText, bodyText, children }: ConfirmButtonProps) => {
const ConfirmButton = ({
onSuccessAction,
headerText,
bodyText,
confirmButtonText,
children,
}: ConfirmButtonProps) => {
const { isOpen, onOpen, onClose } = useDisclosure();
const cancelRef = React.useRef<any>();

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

<AlertDialogFooter>
<Button colorScheme={"red"} onClick={onSubmit}>
{t("Delete")}
{confirmButtonText && confirmButtonText.length !== 0
? confirmButtonText
: t("Delete")}
</Button>
</AlertDialogFooter>
</AlertDialogContent>
Expand Down
15 changes: 8 additions & 7 deletions web/src/pages/app/setting/AppEnvList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button } from "@chakra-ui/react";
import { t } from "i18next";

import ConfirmButton from "@/components/ConfirmButton";
import EditableTable from "@/components/EditableTable";
import { isExitInList } from "@/utils/format";

Expand Down Expand Up @@ -74,17 +75,17 @@ const AppEnvList = (props: { onClose?: () => {} }) => {
onDelete={(data) => delEnvironmentMutation.mutateAsync({ name: data })}
onCreate={(data) => addEnvironmentMutation.mutateAsync(data)}
/>
<Button
className="w-28 h-8 self-end mt-4"
type="submit"
variant={"secondary"}
onClick={() => {
<ConfirmButton
onSuccessAction={() => {
globalStore.restartCurrentApp();
props.onClose && props.onClose();
}}
headerText={String(t("Update"))}
bodyText={String(t("SettingPanel.UpdateConfirm"))}
confirmButtonText={String(t("Update"))}
>
{t("Update")}
</Button>
<Button className="w-28 h-8 self-end mt-4">{t("Update")}</Button>
</ConfirmButton>
</div>
</>
);
Expand Down