-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #866 from nextstrain/feat/web-unsipported-browser-…
…warning
- Loading branch information
Showing
5 changed files
with
49 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
packages_rs/nextclade-web/src/components/Common/BrowserWarning.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,40 @@ | ||
import React, { useMemo } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { UncontrolledAlert } from 'reactstrap' | ||
import Bowser from 'bowser' | ||
|
||
import { notUndefinedOrNull } from 'src/helpers/notUndefined' | ||
|
||
export function BrowserWarning() { | ||
const { t } = useTranslation() | ||
|
||
const warningText = useMemo(() => { | ||
const browser = Bowser.getParser(window?.navigator?.userAgent) | ||
const isSupportedBrowser = browser.satisfies({ | ||
chrome: '>60', | ||
edge: '>79', | ||
firefox: '>52', | ||
}) | ||
|
||
if (isSupportedBrowser) { | ||
return null | ||
} | ||
|
||
const { name, version } = browser.getBrowser() | ||
const nameAndVersion = [name, version].filter(notUndefinedOrNull).join(' ') | ||
|
||
return t( | ||
`This browser version (${nameAndVersion}) is not supported. Nextclade works best in the latest version of Chrome or Firefox.`, | ||
) | ||
}, [t]) | ||
|
||
if (!warningText) { | ||
return null | ||
} | ||
|
||
return ( | ||
<UncontrolledAlert color="warning" className="text-center m-0"> | ||
{warningText} | ||
</UncontrolledAlert> | ||
) | ||
} |
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
c91d006
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:
nextclade – ./
nextclade.vercel.app
nextclade-git-master-nextstrain.vercel.app
nextclade-nextstrain.vercel.app