diff --git a/public/locales/en.json b/public/locales/en.json index a3eaedd..17be5ff 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -135,6 +135,7 @@ "dialogOkAdd": "Add", "dialogOkCreate": "Create", "dialogOkEdit": "Save", + "dialogAddExisting": "Add existing wallet", "walletLabel": "Wallet label", "walletLabelPlaceholder": "Wallet label (optional)", diff --git a/src/pages/wallets/AddWalletModal.tsx b/src/pages/wallets/AddWalletModal.tsx index e4bb004..881ce27 100644 --- a/src/pages/wallets/AddWalletModal.tsx +++ b/src/pages/wallets/AddWalletModal.tsx @@ -1,5 +1,5 @@ import React, { useState, useRef, useEffect } from "react"; -import { Modal, Form, Input, Checkbox, Collapse, Button, Tooltip, Typography, Row, Col, message, notification } from "antd"; +import { Modal, Form, Input, Checkbox, Collapse, Button, Tooltip, Typography, Row, Col, message, notification, Grid } from "antd"; import { ReloadOutlined } from "@ant-design/icons"; import { useDispatch, useSelector, shallowEqual } from "react-redux"; @@ -18,6 +18,7 @@ import { addWallet, decryptWallet, editWallet, Wallet, ADDRESS_LIST_LIMIT } from "../../krist/wallets/Wallet"; const { Text } = Typography; +const { useBreakpoint } = Grid; interface FormValues { label?: string; @@ -36,9 +37,10 @@ visible: boolean; setVisible: React.Dispatch>; + setAddExistingVisible?: React.Dispatch>; } -export function AddWalletModal({ create, editing, visible, setVisible }: Props): JSX.Element { +export function AddWalletModal({ create, editing, visible, setVisible, setAddExistingVisible }: Props): JSX.Element { if (editing && create) throw new Error("AddWalletModal: 'editing' and 'create' simultaneously, uh oh!"); @@ -51,6 +53,7 @@ const dispatch = useDispatch(); const { t } = useTranslation(); + const bps = useBreakpoint(); const [form] = Form.useForm(); const passwordInput = useRef(null); @@ -63,6 +66,12 @@ setVisible(false); } + function addExistingWallet() { + if (!setAddExistingVisible) return; + setAddExistingVisible(true); + closeModal(); + } + async function onSubmit() { if (!masterPassword) return notification.error({ message: t("addWallet.errorUnexpectedTitle"), @@ -176,14 +185,29 @@ title={t(editing ? "addWallet.dialogTitleEdit" : (create ? "addWallet.dialogTitleCreate" : "addWallet.dialogTitle"))} - okText={t(editing - ? "addWallet.dialogOkEdit" - : (create ? "addWallet.dialogOkCreate" : "addWallet.dialogOkAdd"))} - cancelText={t("dialog.cancel")} - onCancel={() => closeModal()} - onOk={onSubmit} + footer={[ + /* Add existing wallet button */ + create && bps.sm && ( + + ), + /* Cancel button */ + , + + /* OK button */ + , + ]} + + onCancel={closeModal} destroyOnClose >
- + setAddWalletVisible(true)}>