feat(modal): port Error and ShowToken

This commit is contained in:
Paul Makles
2022-06-18 12:25:56 +01:00
parent 374be319c4
commit d10bd96900
13 changed files with 92 additions and 61 deletions

View File

@@ -1,14 +1,10 @@
import { internalEmit } from "../../lib/eventEmitter";
//import { isModalClosing } from "../../components/ui/Modal";
import { Screen } from "./Intermediate";
import { ClipboardModal } from "./modals/Clipboard";
import { ErrorModal } from "./modals/Error";
import { ExternalLinkModal } from "./modals/ExternalLinkPrompt";
import { InputModal } from "./modals/Input";
import { OnboardingModal } from "./modals/Onboarding";
import { PromptModal } from "./modals/Prompt";
import { TokenRevealModal } from "./modals/TokenReveal";
export interface Props {
screen: Screen;
@@ -26,12 +22,8 @@ export default function Modals({ screen, openScreen }: Props) {
return <PromptModal onClose={onClose} {...screen} />;
case "_input":
return <InputModal onClose={onClose} {...screen} />;
case "error":
return <ErrorModal onClose={onClose} {...screen} />;
case "clipboard":
return <ClipboardModal onClose={onClose} {...screen} />;
case "token_reveal":
return <TokenRevealModal onClose={onClose} {...screen} />;
case "onboarding":
return <OnboardingModal onClose={onClose} {...screen} />;
case "external_link_prompt":

View File

@@ -1,29 +0,0 @@
import { Text } from "preact-i18n";
import { Modal } from "@revoltchat/ui";
interface Props {
onClose: () => void;
error: string;
}
export function ErrorModal({ onClose, error }: Props) {
return (
<Modal
onClose={onClose}
title={<Text id="app.special.modals.error" />}
actions={[
{
onClick: onClose,
confirmation: true,
children: <Text id="app.special.modals.actions.ok" />,
},
{
onClick: () => location.reload(),
children: <Text id="app.special.modals.actions.reload" />,
},
]}>
<Text id={`error.${error}`}>{error}</Text>
</Modal>
);
}

View File

@@ -1,31 +0,0 @@
import { Text } from "preact-i18n";
import { Modal } from "@revoltchat/ui";
interface Props {
onClose: () => void;
token: string;
username: string;
}
export function TokenRevealModal({ onClose, token, username }: Props) {
return (
<Modal
onClose={onClose}
title={
<Text
id={"app.special.modals.token_reveal"}
fields={{ name: username }}
/>
}
actions={[
{
onClick: onClose,
confirmation: true,
children: <Text id="app.special.modals.actions.close" />,
},
]}>
<code style={{ userSelect: "all" }}>{token}</code>
</Modal>
);
}