Skip to content

Commit

Permalink
Merge pull request #1282 from nextstrain/fix/web-tree-page-blank
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov authored Oct 20, 2023
2 parents 040693e + e345c4f commit eb24265
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 114 deletions.
121 changes: 12 additions & 109 deletions packages_rs/nextclade-web/src/components/Tree/TreePage.tsx
Original file line number Diff line number Diff line change
@@ -1,117 +1,20 @@
import React, { useMemo } from 'react'
import styled from 'styled-components'
import { I18nextProvider } from 'react-i18next'
import { connect } from 'react-redux'
import { AuspiceMetadata } from 'auspice'
import type { State } from 'src/state/reducer'
import i18nAuspice from 'src/i18n/i18n.auspice'
import FiltersSummary from 'auspice/src/components/info/filtersSummary'
import React from 'react'
import dynamic from 'next/dynamic'
import { Layout } from 'src/components/Layout/Layout'
import { LogoGisaid as LogoGisaidBase } from 'src/components/Common/LogoGisaid'
import { Tree } from 'src/components/Tree/Tree'
import { Sidebar } from 'src/components/Tree/Sidebar'

export const Container = styled.div`
flex: 1;
flex-basis: 100%;
width: 100%;
height: 100%;
min-width: 1080px;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
`

const MainContent = styled.main`
flex: 1;
flex-basis: 100%;
overflow-y: hidden;
`

const AuspiceContainer = styled.div`
display: flex;
flex: 1;
flex-basis: 99%;
height: 100%;
`

const SidebarContainer = styled.div`
flex: 0 0 260px;
background-color: #30353f;
overflow-y: auto;
`

const TreeContainer = styled.div`
flex: 1 1;
overflow-y: scroll;
`

const TreeTopPanel = styled.div`
display: flex;
`

const FiltersSummaryWrapper = styled.div`
flex: 1 1 100%;
`

const LogoGisaidWrapper = styled.div`
display: flex;
flex: 0 0 auto;
margin: 0 auto;
margin-right: 2.25rem;
margin-top: 10px;
`

const LogoGisaid = styled(LogoGisaidBase)`
margin-top: auto;
`

export interface TreePageProps {
treeMeta?: AuspiceMetadata
}

const mapStateToProps = (state: State) => ({
treeMeta: state.metadata,
import { LOADING } from 'src/components/Loading/Loading'

const TreePageContent = dynamic(() => import('src/components/Tree/TreePageContent'), {
ssr: false,
loading() {
// eslint-disable-next-line react/jsx-no-useless-fragment
return <>{LOADING}</>
},
})

export const TreePage = connect(mapStateToProps, null)(TreePageDisconnected)

function TreePageDisconnected({ treeMeta }: TreePageProps) {
const isDataFromGisaid = useMemo(
() => treeMeta?.dataProvenance?.some((provenance) => provenance.name?.toLowerCase() === 'gisaid'),
[treeMeta],
)

export function TreePage() {
return (
<Layout>
<Container>
<MainContent>
<AuspiceContainer>
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
{/* @ts-ignore */}
<I18nextProvider i18n={i18nAuspice}>
<SidebarContainer>
<Sidebar />
</SidebarContainer>
<TreeContainer>
<TreeTopPanel>
<FiltersSummaryWrapper>
<FiltersSummary />
</FiltersSummaryWrapper>
{isDataFromGisaid && (
<LogoGisaidWrapper>
<LogoGisaid />
</LogoGisaidWrapper>
)}
</TreeTopPanel>
<Tree />
</TreeContainer>
</I18nextProvider>
</AuspiceContainer>
</MainContent>
</Container>
<TreePageContent />
</Layout>
)
}

export default TreePage
113 changes: 113 additions & 0 deletions packages_rs/nextclade-web/src/components/Tree/TreePageContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React, { useMemo } from 'react'
import styled from 'styled-components'
import { I18nextProvider } from 'react-i18next'
import { connect } from 'react-redux'
import { AuspiceMetadata } from 'auspice'
import type { State } from 'src/state/reducer'
import i18nAuspice from 'src/i18n/i18n.auspice'
import FiltersSummary from 'auspice/src/components/info/filtersSummary'
import { LogoGisaid as LogoGisaidBase } from 'src/components/Common/LogoGisaid'
import { Tree } from 'src/components/Tree/Tree'
import { Sidebar } from 'src/components/Tree/Sidebar'

export const Container = styled.div`
flex: 1;
flex-basis: 100%;
width: 100%;
height: 100%;
min-width: 1080px;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
`

const MainContent = styled.main`
flex: 1;
flex-basis: 100%;
overflow-y: hidden;
`

const AuspiceContainer = styled.div`
display: flex;
flex: 1;
flex-basis: 99%;
height: 100%;
`

const SidebarContainer = styled.div`
flex: 0 0 260px;
background-color: #30353f;
overflow-y: auto;
`

const TreeContainer = styled.div`
flex: 1 1;
overflow-y: scroll;
`

const TreeTopPanel = styled.div`
display: flex;
`

const FiltersSummaryWrapper = styled.div`
flex: 1 1 100%;
`

const LogoGisaidWrapper = styled.div`
display: flex;
flex: 0 0 auto;
margin: 0 auto;
margin-right: 2.25rem;
margin-top: 10px;
`

const LogoGisaid = styled(LogoGisaidBase)`
margin-top: auto;
`

export interface TreePageProps {
treeMeta?: AuspiceMetadata
}

const mapStateToProps = (state: State) => ({
treeMeta: state.metadata,
})

const TreePageContent = connect(mapStateToProps, null)(TreePageContentDisconnected)
export default TreePageContent

function TreePageContentDisconnected({ treeMeta }: TreePageProps) {
const isDataFromGisaid = useMemo(
() => treeMeta?.dataProvenance?.some((provenance) => provenance.name?.toLowerCase() === 'gisaid'),
[treeMeta],
)

return (
<Container>
<MainContent>
<AuspiceContainer>
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
{/* @ts-ignore */}
<I18nextProvider i18n={i18nAuspice}>
<SidebarContainer>
<Sidebar />
</SidebarContainer>
<TreeContainer>
<TreeTopPanel>
<FiltersSummaryWrapper>
<FiltersSummary />
</FiltersSummaryWrapper>
{isDataFromGisaid && (
<LogoGisaidWrapper>
<LogoGisaid />
</LogoGisaidWrapper>
)}
</TreeTopPanel>
<Tree />
</TreeContainer>
</I18nextProvider>
</AuspiceContainer>
</MainContent>
</Container>
)
}
6 changes: 1 addition & 5 deletions packages_rs/nextclade-web/src/pages/tree.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
import dynamic from 'next/dynamic'

const TreePage = dynamic(() => import('src/components/Tree/TreePage'), { ssr: false })

export default TreePage
export { TreePage as default } from 'src/components/Tree/TreePage'

1 comment on commit eb24265

@vercel
Copy link

@vercel vercel bot commented on eb24265 Oct 20, 2023

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-nextstrain.vercel.app
nextclade-git-master-nextstrain.vercel.app

Please sign in to comment.