-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Alert component for track messages (#3200)
* Use Alert component for track messages * T1 * Possible BlockMsg update type * Possible BlockMsg update type * Update snaps * Update snaps again Co-authored-by: Colin <[email protected]>
- Loading branch information
1 parent
e6c8ca8
commit 8b2dfbe
Showing
7 changed files
with
99 additions
and
135 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
plugins/linear-genome-view/src/BaseLinearDisplay/components/BlockMsg.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react' | ||
import { Tooltip, Button, Alert, AlertColor } from '@mui/material' | ||
import { makeStyles } from 'tss-react/mui' | ||
|
||
const useStyles = makeStyles()({ | ||
ellipses: { | ||
textOverflow: 'ellipsis', | ||
overflow: 'hidden', | ||
}, | ||
}) | ||
|
||
export default function BlockMsg({ | ||
message, | ||
severity, | ||
buttonText, | ||
icon, | ||
action, | ||
}: { | ||
message: string | ||
severity?: AlertColor | ||
buttonText?: string | ||
icon?: React.ReactNode | ||
action?: () => void | ||
}) { | ||
const { classes } = useStyles() | ||
const button = action ? ( | ||
<Button data-testid="reload_button" onClick={action} startIcon={icon}> | ||
{buttonText} | ||
</Button> | ||
) : null | ||
return ( | ||
<Tooltip title={message}> | ||
<Alert | ||
severity={severity} | ||
action={button} | ||
classes={{ message: classes.ellipses }} | ||
> | ||
{message} | ||
</Alert> | ||
</Tooltip> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
plugins/linear-genome-view/src/BaseLinearDisplay/models/TooLargeMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
import BlockMsg from '../components/BlockMsg' | ||
import { Stats } from '@jbrowse/core/data_adapters/BaseAdapter' | ||
|
||
function TooLargeMessage({ | ||
model, | ||
}: { | ||
model: { | ||
regionTooLargeReason: string | ||
estimatedRegionStats?: Stats | ||
updateStatsLimit: (s: Stats) => void | ||
reload: () => void | ||
} | ||
}) { | ||
const { regionTooLargeReason } = model | ||
return ( | ||
<BlockMsg | ||
severity="warning" | ||
action={() => { | ||
if (!model.estimatedRegionStats) { | ||
console.error('No global stats?') | ||
} else { | ||
model.updateStatsLimit(model.estimatedRegionStats) | ||
model.reload() | ||
} | ||
}} | ||
buttonText="Force load" | ||
message={`${regionTooLargeReason ? regionTooLargeReason + '. ' : ''} | ||
Zoom in to see features or force load (may be slow).`} | ||
/> | ||
) | ||
} | ||
|
||
export default TooLargeMessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters