From ea59fda3c4f0b27677dbb69e1cb66227e166096a Mon Sep 17 00:00:00 2001 From: Garrett Stevens Date: Mon, 19 Sep 2022 20:28:56 -0600 Subject: [PATCH] Use Alert component for track messages --- .../ServerSideRenderedBlockContent.tsx | 72 ++++++++----------- .../models/BaseLinearDisplayModel.tsx | 46 ++++++------ .../LinearGenomeView.test.js.snap | 11 ++- .../src/tests/ErrorConditions.test.tsx | 2 +- 4 files changed, 63 insertions(+), 68 deletions(-) diff --git a/plugins/linear-genome-view/src/BaseLinearDisplay/components/ServerSideRenderedBlockContent.tsx b/plugins/linear-genome-view/src/BaseLinearDisplay/components/ServerSideRenderedBlockContent.tsx index 4976029554..7d92b9aacd 100644 --- a/plugins/linear-genome-view/src/BaseLinearDisplay/components/ServerSideRenderedBlockContent.tsx +++ b/plugins/linear-genome-view/src/BaseLinearDisplay/components/ServerSideRenderedBlockContent.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react' -import { Typography, Button } from '@mui/material' +import { Typography, Button, Alert, Stack } from '@mui/material' import { makeStyles } from 'tss-react/mui' import { observer } from 'mobx-react' import { getParent } from 'mobx-state-tree' @@ -18,24 +18,8 @@ const useStyles = makeStyles()(theme => ({ textAlign: 'center', }, blockMessage: { - width: '100%', - background: theme.palette.action.disabledBackground, - padding: theme.spacing(2), - pointerEvents: 'none', - textAlign: 'center', - }, - blockError: { - padding: theme.spacing(2), - width: '100%', + margin: theme.spacing(2), whiteSpace: 'normal', - color: theme.palette.error.main, - overflowY: 'auto', - }, - blockReactNodeMessage: { - width: '100%', - background: theme.palette.action.disabledBackground, - padding: theme.spacing(2), - textAlign: 'center', }, dots: { '&::after': { @@ -61,10 +45,10 @@ const useStyles = makeStyles()(theme => ({ function Repeater({ children }: { children: React.ReactNode }) { return ( -
- {children} - {children} -
+ +
{children}
+
{children}
+
) } @@ -110,12 +94,14 @@ function BlockMessage({ }) { const { classes } = useStyles() - return React.isValidElement(messageContent) ? ( -
{messageContent}
- ) : ( - - {messageContent} - + return ( +
+ {React.isValidElement(messageContent) ? ( + messageContent + ) : ( + {messageContent} + )} +
) } @@ -130,19 +116,23 @@ function BlockError({ }) { const { classes } = useStyles() return ( -
- {reload ? ( - - ) : null} - - {`${error}`} - +
+ } + > + Reload + + ) : null + } + > + {error.message} +
) } diff --git a/plugins/linear-genome-view/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx b/plugins/linear-genome-view/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx index 80be34c2d1..bfcc6816ea 100644 --- a/plugins/linear-genome-view/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +++ b/plugins/linear-genome-view/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import React from 'react' -import { Button, Typography } from '@mui/material' +import { Alert, Button } from '@mui/material' import { BaseDisplay } from '@jbrowse/core/pluggableElementTypes/models' import { getConf } from '@jbrowse/core/configuration' import { MenuItem } from '@jbrowse/core/ui' @@ -502,29 +502,27 @@ export const BaseLinearDisplay = types if (regionTooLarge) { return ( - <> - - {regionTooLargeReason ? regionTooLargeReason + '. ' : ''} - Zoom in to see features or{' '} - - - - (force load may be slow) - - + { + if (!self.estimatedRegionStats) { + console.error('No global stats?') + } else { + self.updateStatsLimit(self.estimatedRegionStats) + self.reload() + } + }} + > + Force Load + + } + > + {regionTooLargeReason ? regionTooLargeReason + '. ' : ''} + Zoom in to see features or force load (may be slow). + ) } return undefined diff --git a/plugins/linear-genome-view/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap b/plugins/linear-genome-view/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap index c30748c2e3..82bd454f61 100644 --- a/plugins/linear-genome-view/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +++ b/plugins/linear-genome-view/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap @@ -524,8 +524,15 @@ exports[` renders one track, one region 1`] = ` style="width: 100px;" >
+ class="css-m69qwo-MuiStack-root" + > +
+
+
{ const { view, findAllByText } = createView() view.showTrack('volvox_wrong_assembly') await findAllByText( - 'Error: region assembly (volvox) does not match track assemblies (wombat)', + 'region assembly (volvox) does not match track assemblies (wombat)', {}, delay, )