-
Notifications
You must be signed in to change notification settings - Fork 60
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 #1323 from nextstrain/feat/web-warn-on-sugestions
- Loading branch information
Showing
6 changed files
with
206 additions
and
175 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
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
66 changes: 66 additions & 0 deletions
66
packages_rs/nextclade-web/src/components/Main/SuggestionAlertDatasetPage.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,66 @@ | ||
import React, { useMemo } from 'react' | ||
import { UncontrolledAlert } from 'reactstrap' | ||
import { useRecoilValue } from 'recoil' | ||
import styled from 'styled-components' | ||
import { useTranslationSafe } from 'src/helpers/useTranslationSafe' | ||
import { useDatasetSuggestionResults } from 'src/hooks/useRunSeqAutodetect' | ||
import { AutodetectRunState, autodetectRunStateAtom } from 'src/state/autodetect.state' | ||
|
||
export function SuggestionAlertDatasetPage({ ...restProps }) { | ||
const { t } = useTranslationSafe() | ||
const { numSuggestions } = useDatasetSuggestionResults() | ||
const autodetectRunState = useRecoilValue(autodetectRunStateAtom) | ||
|
||
const alert = useMemo(() => { | ||
if (autodetectRunState === AutodetectRunState.Done) { | ||
if (numSuggestions === 0) { | ||
return ( | ||
<Alert closeClassName="d-none" fade={false} color="danger"> | ||
<p className="small"> | ||
{t( | ||
'No datasets match your data. Select a dataset manually. If there is no suitable dataset, consider creating one and contributing it to Nextclade community dataset collection.', | ||
)} | ||
</p> | ||
</Alert> | ||
) | ||
} | ||
if (numSuggestions > 0) { | ||
return ( | ||
<Alert closeClassName="d-none" fade={false} color="none"> | ||
<p className="small"> | ||
{t('{{ n }} datasets appear to match your data. Select the one to use.', { | ||
n: numSuggestions, | ||
})} | ||
</p> | ||
</Alert> | ||
) | ||
} | ||
} | ||
if (autodetectRunState === AutodetectRunState.Failed) { | ||
return ( | ||
<Alert closeClassName="d-none" fade={false} color="danger"> | ||
<p className="small">{t('Suggestion algorithm failed. Please report this to developers.')}</p> | ||
</Alert> | ||
) | ||
} | ||
|
||
return null | ||
}, [autodetectRunState, numSuggestions, t]) | ||
|
||
return <AlertWrapper {...restProps}>{alert}</AlertWrapper> | ||
} | ||
|
||
const AlertWrapper = styled.div` | ||
display: flex; | ||
width: 100%; | ||
` | ||
|
||
const Alert = styled(UncontrolledAlert)` | ||
margin: 0; | ||
padding: 0.75rem 1rem; | ||
width: 100%; | ||
p { | ||
margin: 0; | ||
} | ||
` |
68 changes: 68 additions & 0 deletions
68
packages_rs/nextclade-web/src/components/Main/SuggestionAlertMainPage.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,68 @@ | ||
import React, { useMemo } from 'react' | ||
import { UncontrolledAlert } from 'reactstrap' | ||
import { useRecoilValue } from 'recoil' | ||
import styled from 'styled-components' | ||
import { useTranslationSafe } from 'src/helpers/useTranslationSafe' | ||
import { useDatasetSuggestionResults } from 'src/hooks/useRunSeqAutodetect' | ||
import { AutodetectRunState, autodetectRunStateAtom } from 'src/state/autodetect.state' | ||
|
||
export function SuggestionAlertMainPage({ ...restProps }) { | ||
const { t } = useTranslationSafe() | ||
const { numSuggestions } = useDatasetSuggestionResults() | ||
const autodetectRunState = useRecoilValue(autodetectRunStateAtom) | ||
|
||
const alert = useMemo(() => { | ||
if (autodetectRunState === AutodetectRunState.Done) { | ||
if (numSuggestions === 0) { | ||
return ( | ||
<Alert closeClassName="d-none" fade={false} color="danger"> | ||
<h6 className="font-weight-bold">{t('No matching datasets.')}</h6> | ||
<p className="small"> | ||
{t( | ||
'Suggestion algorithm was unable to find a matching dataset. Select a dataset manually. If there is no suitable dataset, consider creating and contributing one to Nextclade community dataset collection.', | ||
)} | ||
</p> | ||
</Alert> | ||
) | ||
} | ||
if (numSuggestions > 0) { | ||
return ( | ||
<Alert closeClassName="d-none" fade={false} color="info"> | ||
<h6 className="font-weight-bold">{t('Multiple matching datasets.')}</h6> | ||
<p className="small"> | ||
{t('{{ n }} datasets appear to match your data. Click "Change dataset" to select the one to use.', { | ||
n: numSuggestions, | ||
})} | ||
</p> | ||
</Alert> | ||
) | ||
} | ||
} | ||
if (autodetectRunState === AutodetectRunState.Failed) { | ||
return ( | ||
<Alert closeClassName="d-none" fade={false} color="danger"> | ||
<h6 className="font-weight-bold">{t('Suggestion algorithm failed.')}</h6> | ||
<p className="small">{t('Please report this to developers.')}</p> | ||
</Alert> | ||
) | ||
} | ||
|
||
return null | ||
}, [autodetectRunState, numSuggestions, t]) | ||
|
||
return <AlertWrapper {...restProps}>{alert}</AlertWrapper> | ||
} | ||
|
||
const AlertWrapper = styled.div` | ||
display: flex; | ||
` | ||
|
||
const Alert = styled(UncontrolledAlert)` | ||
margin: 0; | ||
padding: 0.75rem 1rem; | ||
width: 100%; | ||
p { | ||
margin: 0; | ||
} | ||
` |
Oops, something went wrong.
b258929
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-nextstrain.vercel.app
nextclade.vercel.app
nextclade-git-master-nextstrain.vercel.app