UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

25 lines (24 loc) 2.05 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = FatalErrorDialog; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const material_1 = require("@mui/material"); const ErrorMessage_1 = __importDefault(require("./ErrorMessage")); const FactoryResetDialog_1 = __importDefault(require("./FactoryResetDialog")); const ResetComponent = ({ onFactoryReset, resetButtonText, }) => { const [dialogOpen, setDialogOpen] = (0, react_1.useState)(false); return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { "data-testid": "fatal-error", color: "primary", variant: "contained", onClick: () => { setDialogOpen(true); }, children: resetButtonText }), (0, jsx_runtime_1.jsx)(FactoryResetDialog_1.default, { onClose: () => { setDialogOpen(false); }, open: dialogOpen, onFactoryReset: onFactoryReset })] })); }; function FatalErrorDialog({ componentStack, error = 'No error message provided', onFactoryReset, resetButtonText = 'Factory Reset', }) { return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { maxWidth: "xl", open: true, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: "Fatal error" }), (0, jsx_runtime_1.jsxs)(material_1.DialogContent, { children: [(0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { error: error }), (0, jsx_runtime_1.jsx)("pre", { children: componentStack })] }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "secondary", variant: "contained", onClick: () => { window.location.reload(); }, children: "Refresh" }), (0, jsx_runtime_1.jsx)(ResetComponent, { onFactoryReset: onFactoryReset, resetButtonText: resetButtonText })] })] })); }