diff --git a/src/components/common/error-modal/error-modal.tsx b/src/components/common/error-modal/error-modal.tsx deleted file mode 100644 index 1ff475793..000000000 --- a/src/components/common/error-modal/error-modal.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import React, { Fragment } from 'react' -import { Modal } from 'react-bootstrap' -import { Trans } from 'react-i18next' -import { ForkAwesomeIcon, IconName } from '../fork-awesome/fork-awesome-icon' - -export interface ErrorModalProps { - show: boolean - onHide: () => void - title: string - icon?: IconName -} - -export const ErrorModal: React.FC = ({ show, onHide, title, icon, children }) => { - return ( - - - - {icon - ? -   - - : - } - - - - - {children} - - - ) -} diff --git a/src/components/common/modals/common-modal.tsx b/src/components/common/modals/common-modal.tsx new file mode 100644 index 000000000..0d1492568 --- /dev/null +++ b/src/components/common/modals/common-modal.tsx @@ -0,0 +1,31 @@ +import React from 'react' +import { Modal } from 'react-bootstrap' +import { Trans, useTranslation } from 'react-i18next' +import { ForkAwesomeIcon, IconName } from '../fork-awesome/fork-awesome-icon' +import { ShowIf } from '../show-if/show-if' + +export interface CommonModalProps { + show: boolean + onHide: () => void + titleI18nKey: string + closeButton?: boolean + icon?: IconName +} + +export const CommonModal: React.FC = ({ show, onHide, titleI18nKey, closeButton, icon, children }) => { + useTranslation() + + return ( + + + + +   + + + + + { children } + + ) +} diff --git a/src/components/common/modals/deletion-modal.tsx b/src/components/common/modals/deletion-modal.tsx new file mode 100644 index 000000000..02c947e72 --- /dev/null +++ b/src/components/common/modals/deletion-modal.tsx @@ -0,0 +1,26 @@ +import React from 'react' +import { Modal, Button } from 'react-bootstrap' +import { Trans, useTranslation } from 'react-i18next' +import { CommonModal, CommonModalProps } from './common-modal' + +export interface DeletionModalProps extends CommonModalProps { + onConfirm: () => void + deletionButtonI18nKey: string +} + +export const DeletionModal: React.FC = ({ show, onHide, titleI18nKey, onConfirm, deletionButtonI18nKey, icon, children }) => { + useTranslation() + + return ( + + + { children } + + + + + + ) +} diff --git a/src/components/common/modals/error-modal.tsx b/src/components/common/modals/error-modal.tsx new file mode 100644 index 000000000..9a0b9b475 --- /dev/null +++ b/src/components/common/modals/error-modal.tsx @@ -0,0 +1,13 @@ +import React from 'react' +import { Modal } from 'react-bootstrap' +import { CommonModal, CommonModalProps } from './common-modal' + +export const ErrorModal: React.FC = ({ show, onHide, titleI18nKey, icon, children }) => { + return ( + + + { children } + + + ) +} diff --git a/src/components/landing/pages/history/history-toolbar/clear-history-button.tsx b/src/components/landing/pages/history/history-toolbar/clear-history-button.tsx index bdaba3d0a..f5752576f 100644 --- a/src/components/landing/pages/history/history-toolbar/clear-history-button.tsx +++ b/src/components/landing/pages/history/history-toolbar/clear-history-button.tsx @@ -1,7 +1,8 @@ import React, { Fragment, useState } from 'react' -import { Button, Modal } from 'react-bootstrap' +import { Button } from 'react-bootstrap' import { Trans, useTranslation } from 'react-i18next' import { ForkAwesomeIcon } from '../../../../common/fork-awesome/fork-awesome-icon' +import { DeletionModal } from '../../../../common/modals/deletion-modal' export interface ClearHistoryButtonProps { onClearHistory: () => void @@ -19,25 +20,19 @@ export const ClearHistoryButton: React.FC = ({ onClearH - - - - - - - -
-
-
- - - -
+ { + onClearHistory() + handleClose() + }} + deletionButtonI18nKey={'landing.history.toolbar.clear'} + show={show} + onHide={handleClose} + titleI18nKey={'landing.history.modal.clearHistory.title'} + > +
+
+
) } diff --git a/src/components/landing/pages/history/history-toolbar/import-history-button.tsx b/src/components/landing/pages/history/history-toolbar/import-history-button.tsx index d2599628c..2d549d95e 100644 --- a/src/components/landing/pages/history/history-toolbar/import-history-button.tsx +++ b/src/components/landing/pages/history/history-toolbar/import-history-button.tsx @@ -2,7 +2,7 @@ import React, { useRef, useState } from 'react' import { Button } from 'react-bootstrap' import { Trans, useTranslation } from 'react-i18next' import { convertV1History, V1HistoryEntry } from '../../../../../utils/historyUtils' -import { ErrorModal } from '../../../../common/error-modal/error-modal' +import { ErrorModal } from '../../../../common/modals/error-modal' import { ForkAwesomeIcon } from '../../../../common/fork-awesome/fork-awesome-icon' import { HistoryEntry, HistoryJson } from '../history' @@ -78,7 +78,7 @@ export const ImportHistoryButton: React.FC = ({ onImpo {fileName !== '' diff --git a/src/components/landing/pages/history/history.tsx b/src/components/landing/pages/history/history.tsx index 7472a9f66..f6137feae 100644 --- a/src/components/landing/pages/history/history.tsx +++ b/src/components/landing/pages/history/history.tsx @@ -13,7 +13,7 @@ import { setHistoryToLocalStore, sortAndFilterEntries } from '../../../../utils/historyUtils' -import { ErrorModal } from '../../../common/error-modal/error-modal' +import { ErrorModal } from '../../../common/modals/error-modal' import { HistoryContent } from './history-content/history-content' import { HistoryToolbar, HistoryToolbarState, initState as toolbarInitState } from './history-toolbar/history-toolbar' @@ -195,7 +195,7 @@ export const History: React.FC = () => { return ( + titleI18nKey={error !== '' ? `landing.history.error.${error}.title` : ''}>