From 046d434f4ce0e4d8205500124870c4a05e80ad79 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Fri, 5 Jun 2020 14:23:09 +0200 Subject: [PATCH] added error modal (#124) added error modal component Signed-off-by: Philip Molares --- src/components/error-modal/error-modal.tsx | 32 +++++++++++++++++++ .../history-toolbar/import-history-button.tsx | 32 +++++++++---------- 2 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 src/components/error-modal/error-modal.tsx diff --git a/src/components/error-modal/error-modal.tsx b/src/components/error-modal/error-modal.tsx new file mode 100644 index 000000000..77a0633f6 --- /dev/null +++ b/src/components/error-modal/error-modal.tsx @@ -0,0 +1,32 @@ +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/landing/pages/history/history-toolbar/import-history-button.tsx b/src/components/landing/pages/history/history-toolbar/import-history-button.tsx index 20a8dc570..994135022 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 @@ -1,8 +1,9 @@ import React, { useRef, useState } from 'react' -import { Button, Modal } from 'react-bootstrap' +import { Button } from 'react-bootstrap' import { Trans, useTranslation } from 'react-i18next' import { ForkAwesomeIcon } from '../../../../../fork-awesome/fork-awesome-icon' import { convertV1History, V1HistoryEntry } from '../../../../../utils/historyUtils' +import { ErrorModal } from '../../../../error-modal/error-modal' import { HistoryEntry, HistoryJson } from '../history' export interface ImportHistoryButtonProps { @@ -67,27 +68,26 @@ export const ImportHistoryButton: React.FC = ({ onImpo return (
- + - - - -   - - - - {fileName !== '' - ?
- :
- } -
-
+ + {fileName !== '' + ?
+ +
+ :
+ } +
) }