-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(shell): [#155] show error in unsupported environment * feat(shell): [#155] show details about unsupported environment
- Loading branch information
1 parent
d988620
commit d06bbcf
Showing
2 changed files
with
155 additions
and
64 deletions.
There are no files selected for viewing
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,79 @@ | ||
import Box from '@mui/material/Box' | ||
import Dialog from '@mui/material/Dialog' | ||
import DialogContent from '@mui/material/DialogContent' | ||
import DialogContentText from '@mui/material/DialogContentText' | ||
import DialogTitle from '@mui/material/DialogTitle' | ||
import ErrorIcon from '@mui/icons-material/Error' | ||
import Typography from '@mui/material/Typography' | ||
import useTheme from '@mui/material/styles/useTheme' | ||
import Link from '@mui/material/Link' | ||
|
||
const { isSecureContext, RTCDataChannel } = window | ||
const doesSupportWebRtc = RTCDataChannel !== undefined | ||
|
||
export const isEnvironmentSupported = | ||
(isSecureContext && doesSupportWebRtc) || process.env.NODE_ENV === 'test' | ||
|
||
export const EnvironmentUnsupportedDialog = () => { | ||
const theme = useTheme() | ||
|
||
return ( | ||
<Dialog | ||
open={!isEnvironmentSupported} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
> | ||
<DialogTitle id="alert-dialog-title"> | ||
<Box sx={{ display: 'flex', alignItems: 'center' }}> | ||
<ErrorIcon | ||
fontSize="medium" | ||
sx={theme => ({ | ||
color: theme.palette.error.main, | ||
mr: theme.spacing(1), | ||
})} | ||
/> | ||
Environment unsupported | ||
</Box> | ||
</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description"> | ||
Chitchatter is unable to start up. The following issues were detected: | ||
</DialogContentText> | ||
<Typography | ||
component="ul" | ||
sx={{ | ||
color: theme.palette.text.secondary, | ||
m: 1, | ||
}} | ||
> | ||
{!isSecureContext ? ( | ||
<li> | ||
The app is not being served from a{' '} | ||
<Link | ||
href="https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts" | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
secure context | ||
</Link> | ||
. | ||
</li> | ||
) : null} | ||
{!doesSupportWebRtc ? ( | ||
<li> | ||
Your browser does not support WebRTC. Consider using{' '} | ||
<Link | ||
href="https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection#browser_compatibility" | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
a browser that does | ||
</Link> | ||
. | ||
</li> | ||
) : null} | ||
</Typography> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} |
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
d06bbcf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
chitchatter – ./
chitchatter-git-main-jeremyckahn.vercel.app
chitchatter-jeremyckahn.vercel.app
chitchatter.vercel.app