Pass translated values instead of strings to ContinueCancelModal
(#4412)
This commit is contained in:
parent
174b3af6fc
commit
f894ca361b
3 changed files with 13 additions and 27 deletions
|
@ -84,6 +84,7 @@
|
||||||
"signOut": "Sign out",
|
"signOut": "Sign out",
|
||||||
"signOutAllDevices": "Sign out all devices",
|
"signOutAllDevices": "Sign out all devices",
|
||||||
"signOutAllDevicesWarning": "This action will sign out all the devices that have signed in to your account, including the current device you are using.",
|
"signOutAllDevicesWarning": "This action will sign out all the devices that have signed in to your account, including the current device you are using.",
|
||||||
|
"signOutWarning": "Sign out the session?",
|
||||||
"somethingWentWrong": "Something went wrong",
|
"somethingWentWrong": "Something went wrong",
|
||||||
"somethingWentWrongDescription": "Sorry, an unexpected error has occurred.",
|
"somethingWentWrongDescription": "Sorry, an unexpected error has occurred.",
|
||||||
"started": "Started",
|
"started": "Started",
|
||||||
|
|
|
@ -128,9 +128,9 @@ const DeviceActivity = () => {
|
||||||
|
|
||||||
{(devices.length > 1 || devices[0].sessions.length > 1) && (
|
{(devices.length > 1 || devices[0].sessions.length > 1) && (
|
||||||
<ContinueCancelModal
|
<ContinueCancelModal
|
||||||
buttonTitle="signOutAllDevices"
|
buttonTitle={t("signOutAllDevices")}
|
||||||
modalTitle="signOutAllDevices"
|
modalTitle={t("signOutAllDevices")}
|
||||||
modalMessage="signOutAllDevicesWarning"
|
modalMessage={t("signOutAllDevicesWarning")}
|
||||||
onContinue={() => signOutAll()}
|
onContinue={() => signOutAll()}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -173,10 +173,10 @@ const DeviceActivity = () => {
|
||||||
>
|
>
|
||||||
{!session.current && (
|
{!session.current && (
|
||||||
<ContinueCancelModal
|
<ContinueCancelModal
|
||||||
buttonTitle="doSignOut"
|
buttonTitle={t("doSignOut")}
|
||||||
modalTitle="doSignOut"
|
modalTitle={t("doSignOut")}
|
||||||
buttonVariant="secondary"
|
buttonVariant="secondary"
|
||||||
modalMessage="signOutWarning"
|
modalMessage={t("signOutWarning")}
|
||||||
onContinue={() => signOutSession(session, device)}
|
onContinue={() => signOutSession(session, device)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { ReactNode, useState } from "react";
|
import { ReactNode, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { Button, ButtonProps, Modal, ModalProps } from "@patternfly/react-core";
|
import { Button, ButtonProps, Modal, ModalProps } from "@patternfly/react-core";
|
||||||
|
|
||||||
export type ContinueCancelModalProps = Omit<ModalProps, "ref" | "children"> & {
|
export type ContinueCancelModalProps = Omit<ModalProps, "ref" | "children"> & {
|
||||||
|
@ -24,11 +23,10 @@ export const ContinueCancelModal = ({
|
||||||
onContinue,
|
onContinue,
|
||||||
continueLabel = "continue",
|
continueLabel = "continue",
|
||||||
cancelLabel = "doCancel",
|
cancelLabel = "doCancel",
|
||||||
component = "button",
|
component = Button,
|
||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
}: ContinueCancelModalProps) => {
|
}: ContinueCancelModalProps) => {
|
||||||
const { t } = useTranslation();
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const Component = component;
|
const Component = component;
|
||||||
|
|
||||||
|
@ -39,16 +37,12 @@ export const ContinueCancelModal = ({
|
||||||
onClick={() => setOpen(true)}
|
onClick={() => setOpen(true)}
|
||||||
isDisabled={isDisabled}
|
isDisabled={isDisabled}
|
||||||
>
|
>
|
||||||
{
|
{buttonTitle}
|
||||||
//@ts-ignore
|
|
||||||
typeof buttonTitle === "string" ? t(buttonTitle) : buttonTitle
|
|
||||||
}
|
|
||||||
</Component>
|
</Component>
|
||||||
<Modal
|
<Modal
|
||||||
variant="small"
|
variant="small"
|
||||||
{...rest}
|
{...rest}
|
||||||
//@ts-ignore
|
title={modalTitle}
|
||||||
title={t(modalTitle)}
|
|
||||||
isOpen={open}
|
isOpen={open}
|
||||||
onClose={() => setOpen(false)}
|
onClose={() => setOpen(false)}
|
||||||
actions={[
|
actions={[
|
||||||
|
@ -61,10 +55,7 @@ export const ContinueCancelModal = ({
|
||||||
onContinue();
|
onContinue();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{
|
{continueLabel}
|
||||||
//@ts-ignore
|
|
||||||
t(continueLabel)
|
|
||||||
}
|
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button
|
<Button
|
||||||
id="modal-cancel"
|
id="modal-cancel"
|
||||||
|
@ -72,17 +63,11 @@ export const ContinueCancelModal = ({
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
onClick={() => setOpen(false)}
|
onClick={() => setOpen(false)}
|
||||||
>
|
>
|
||||||
{
|
{cancelLabel}
|
||||||
//@ts-ignore
|
|
||||||
t(cancelLabel)
|
|
||||||
}
|
|
||||||
</Button>,
|
</Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{
|
{modalMessage ? modalMessage : children}
|
||||||
//@ts-ignore
|
|
||||||
modalMessage ? t(modalMessage) : children
|
|
||||||
}
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue