File tree 4 files changed +74
-5
lines changed
packages/nextclade-web/src/components/Main
4 files changed +74
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { isEmpty } from 'lodash'
3
3
import React , { useCallback } from 'react'
4
4
import { Button } from 'reactstrap'
5
5
import { useRecoilValue } from 'recoil'
6
+ import { LinkExternal } from 'src/components/Link/LinkExternal'
6
7
import { useTranslationSafe } from 'src/helpers/useTranslationSafe'
7
8
import { useRunSeqAutodetect } from 'src/hooks/useRunSeqAutodetect'
8
9
import { useRunAnalysis } from 'src/hooks/useRunAnalysis'
@@ -11,6 +12,7 @@ import { datasetCurrentAtom } from 'src/state/dataset.state'
11
12
import { hasInputErrorsAtom } from 'src/state/error.state'
12
13
import { useQuerySeqInputs } from 'src/state/inputs.state'
13
14
import { shouldRunAutomaticallyAtom , shouldSuggestDatasetsOnDatasetPageAtom } from 'src/state/settings.state'
15
+ import styled from 'styled-components'
14
16
15
17
export function useSetExampleSequences ( ) {
16
18
const { addQryInputs } = useQuerySeqInputs ( )
@@ -50,8 +52,16 @@ export function ButtonLoadExample({ ...rest }) {
50
52
}
51
53
52
54
return (
53
- < Button { ...rest } color = "link" onClick = { onClick } disabled = { hasInputErrors || ! datasetCurrent } >
55
+ < ButtonStyled { ...rest } color = "link" onClick = { onClick } disabled = { hasInputErrors || ! datasetCurrent } >
54
56
{ t ( 'Load example' ) }
55
- </ Button >
57
+ </ ButtonStyled >
56
58
)
57
59
}
60
+
61
+ const ButtonStyled = styled ( Button ) `
62
+ margin: 0 0.5rem;
63
+ max-width: 300px;
64
+ overflow: hidden;
65
+ white-space: nowrap;
66
+ text-overflow: ellipsis;
67
+ `
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import { Col , Row , Container as ContainerBase } from 'reactstrap'
3
3
import { useRecoilValue } from 'recoil'
4
+ import { ButtonLoadExample } from 'src/components/Main/ButtonLoadExample'
4
5
import { ButtonRun } from 'src/components/Main/ButtonRun'
6
+ import { LinkOpenTree } from 'src/components/Main/LinkOpenTree'
5
7
import { useRunAnalysis } from 'src/hooks/useRunAnalysis'
6
8
import styled from 'styled-components'
7
9
import { useUpdatedDataset } from 'src/io/fetchDatasets'
@@ -87,6 +89,15 @@ export function DatasetCurrent() {
87
89
< DatasetInfo dataset = { dataset } />
88
90
</ Col >
89
91
</ Row >
92
+
93
+ < Row noGutters className = "d-flex w-100" >
94
+ < Col className = "d-flex" >
95
+ < div className = "d-flex ml-auto" >
96
+ < LinkOpenTree className = "my-auto" dataset = { dataset } />
97
+ < ButtonLoadExample />
98
+ </ div >
99
+ </ Col >
100
+ </ Row >
90
101
</ CurrentDatasetInfoBody >
91
102
</ Header >
92
103
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { MdClear as IconClearBase } from 'react-icons/md'
5
5
import { ButtonTransparent } from 'src/components/Common/ButtonTransparent'
6
6
import { ButtonLoadExample } from 'src/components/Main/ButtonLoadExample'
7
7
import { DatasetCustomizationsIndicatorLink } from 'src/components/Main/DatasetCustomizationIndicator'
8
+ import { LinkOpenTree } from 'src/components/Main/LinkOpenTree'
8
9
import { useTranslationSafe } from 'src/helpers/useTranslationSafe'
9
10
import styled from 'styled-components'
10
11
import { useUpdatedDataset } from 'src/io/fetchDatasets'
@@ -51,9 +52,13 @@ export function DatasetCurrentSummary() {
51
52
< DatasetCustomizationsIndicatorLink />
52
53
</ DatasetCustomizationWrapper >
53
54
</ Col >
54
-
55
- < Col className = "d-flex ml-auto mt-2" >
56
- < ButtonLoadExample className = "ml-auto" />
55
+ </ Row >
56
+ < Row noGutters className = "d-flex w-100" >
57
+ < Col className = "d-flex" >
58
+ < div className = "d-flex ml-auto" >
59
+ < LinkOpenTree className = "my-auto" dataset = { dataset } />
60
+ < ButtonLoadExample />
61
+ </ div >
57
62
</ Col >
58
63
</ Row >
59
64
</ Col >
Original file line number Diff line number Diff line change
1
+ import type { Dataset } from 'src/types'
2
+ import React , { HTMLProps , useMemo } from 'react'
3
+ import { LinkExternal } from 'src/components/Link/LinkExternal'
4
+ import { useTranslationSafe } from 'src/helpers/useTranslationSafe'
5
+ import styled from 'styled-components'
6
+ import urljoin from 'url-join'
7
+
8
+ export interface LinkOpenTreeProps extends HTMLProps < HTMLDivElement > {
9
+ dataset : Dataset
10
+ }
11
+
12
+ export function LinkOpenTree ( { dataset } : LinkOpenTreeProps ) {
13
+ const { t } = useTranslationSafe ( )
14
+ const nextstrainOrgTreeUrl = useMemo ( ( ) => {
15
+ if ( ! dataset . files ?. treeJson ) {
16
+ return undefined
17
+ }
18
+ const path = dataset . files . treeJson . replace ( / ^ h t t p s ? : \/ \/ / , '' )
19
+ return urljoin ( 'https://nextstrain.org/fetch' , path )
20
+ } , [ dataset . files ?. treeJson ] )
21
+ return (
22
+ < LinkContainer className = "mx-2" >
23
+ < LinkExternalStyled
24
+ disabled = { ! ! nextstrainOrgTreeUrl }
25
+ title = { t ( 'Open reference tree for this dataset on nextstrain.org' ) }
26
+ href = { nextstrainOrgTreeUrl }
27
+ >
28
+ { t ( 'Open tree' ) }
29
+ </ LinkExternalStyled >
30
+ </ LinkContainer >
31
+ )
32
+ }
33
+
34
+ const LinkContainer = styled . div `
35
+ margin: auto 0;
36
+ max-width: 200px;
37
+ overflow: hidden;
38
+ text-overflow: ellipsis;
39
+ `
40
+
41
+ const LinkExternalStyled = styled ( LinkExternal ) `
42
+ white-space: nowrap;
43
+ `
You can’t perform that action at this time.
0 commit comments