Skip to content

Commit

Permalink
feat(web): re-add dataset customization
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Sep 28, 2023
1 parent 64e5578 commit 9b385f2
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function FilePickerAdvanced() {
<Row noGutters>
<Col>
<FilePicker
className="my-3"
className="mb-2"
compact
icon={iconJson}
title={t('Reference tree')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,29 @@ import {
import { useRecoilValue } from 'recoil'
import { MarkdownRemote } from 'src/components/Common/Markdown'
import { datasetCurrentAtom } from 'src/state/dataset.state'
import { DatasetContentTabAdvanced } from 'src/components/Main/DatasetContentTabAdvanced'

export function DatasetContentSection() {
const [activeTabId, setActiveTabId] = useState(0)
const currentDataset = useRecoilValue(datasetCurrentAtom)
return (
<ContentSection>
<Nav tabs>
<TabLabel tabId={0} activeTabId={activeTabId} setActiveTabId={setActiveTabId}>
{'README.md'}
</TabLabel>
<TabLabel tabId={1} activeTabId={activeTabId} setActiveTabId={setActiveTabId}>
{'CHANGELOG.md'}
</TabLabel>
{currentDataset?.files.readme && (
<TabLabel tabId={0} activeTabId={activeTabId} setActiveTabId={setActiveTabId}>
{'README.md'}
</TabLabel>
)}
{currentDataset?.files.changelog && (
<TabLabel tabId={1} activeTabId={activeTabId} setActiveTabId={setActiveTabId}>
{'CHANGELOG.md'}
</TabLabel>
)}
{currentDataset && (
<TabLabel tabId={2} activeTabId={activeTabId} setActiveTabId={setActiveTabId}>
{'Files'}
</TabLabel>
)}
</Nav>
<TabContent activeTab={activeTabId}>
<TabPane tabId={0}>
Expand All @@ -33,6 +43,7 @@ export function DatasetContentSection() {
<TabPane tabId={1}>
{currentDataset?.files.changelog && <MarkdownRemote url={currentDataset?.files.changelog} />}
</TabPane>
<TabPane tabId={2}>{currentDataset && <DatasetContentTabAdvanced />}</TabPane>
</TabContent>
</ContentSection>
)
Expand Down Expand Up @@ -68,15 +79,21 @@ const TabContent = styled(TabContentBase)`
flex: 1;
flex-direction: column;
overflow: hidden;
margin-top: -1px;
`

const TabPane = styled(TabPaneBase)`
display: flex;
flex: 1;
flex-direction: column;
overflow: auto;
border: 1px #ccc9 solid;
border-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
padding: 1rem;
`

Expand All @@ -100,6 +117,8 @@ const NavItem = styled(NavItemBase)`
border-bottom: 0 !important;
z-index: 2;
.active {
font-weight: bold;
background-color: ${(props) => props.theme.white} !important;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react'
import styled from 'styled-components'
import { FilePickerAdvanced } from 'src/components/FilePicker/FilePickerAdvanced'
import AdvancedModeExplanationContent from 'src/components/Main/AdvancedModeExplanation.mdx'

export function DatasetContentTabAdvanced() {
return (
<Container>
<Header>
<AdvancedModeExplanationWrapper>
<AdvancedModeExplanationContent />
</AdvancedModeExplanationWrapper>
</Header>

<Main>
<FilePickerAdvanced />
</Main>
</Container>
)
}

export const AdvancedModeExplanationWrapper = styled.div`
> p {
margin: 0;
}
`

const Container = styled.div`
display: flex;
flex: 1;
flex-direction: column;
overflow: hidden;
`

const Header = styled.div`
flex: 0;
`

const Main = styled.div`
display: flex;
flex: 1;
flex-direction: column;
overflow: auto;
width: 100%;
`
36 changes: 1 addition & 35 deletions packages_rs/nextclade-web/src/components/Main/DatasetCurrent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Main = styled.div`
overflow: auto;
width: 100%;
margin-top: 1rem;
margin: 0.5rem 0;
`

export const FlexLeft = styled.div`
Expand All @@ -69,15 +69,6 @@ const ChangeButton = styled(Button)`
margin-left: auto;
`

export const AdvancedModeExplanationWrapper = styled.div`
max-width: 550px;
margin-top: 0.5rem;
> p {
margin: 0;
}
`

export function DatasetCurrent() {
// Periodically checks if there's local update for the current dataset
useUpdatedDataset()
Expand All @@ -90,31 +81,6 @@ export function DatasetCurrent() {
resetDatasetCurrent()
}, [resetDatasetCurrent])

// const [advancedOpen, setAdvancedOpen] = useState(false)
// const onCustomizeClicked = useCallback(() => setAdvancedOpen((advancedOpen) => !advancedOpen), [])

// const customize = useMemo(() => {
// if (datasetCurrent?.path === 'autodetect') {
// return null
// }
//
// return (
// <Row noGutters>
// <Col>
// <ButtonCustomize isOpen={advancedOpen} onClick={onCustomizeClicked} />
//
// <Collapse isOpen={advancedOpen}>
// <AdvancedModeExplanationWrapper>
// <AdvancedModeExplanationContent />
// </AdvancedModeExplanationWrapper>
//
// <FilePickerAdvanced />
// </Collapse>
// </Col>
// </Row>
// )
// }, [advancedOpen, datasetCurrent?.path, onCustomizeClicked])

if (!datasetCurrent) {
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ const Container = styled(ContainerBase)`
flex: 1;
flex-direction: column;
overflow: hidden;
margin-right: 10px;
margin: 0 auto;
max-width: 800px;
`

const Header = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const Container = styled.div`
flex: 1;
flex-direction: column;
overflow: hidden;
margin: 0 auto;
`

const Header = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion packages_rs/nextclade-web/src/components/Main/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Main = styled.div`
margin: 0 auto;
width: 100%;
max-width: ${(props) => props.theme.containerMaxWidths.xxl};
max-width: 1400px;
`

export function MainPage() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import { Row as RowBase, Col as ColBase, Container as ContainerBase } from 'reactstrap'
import { Row as RowBase, Col as ColBase } from 'reactstrap'
import styled from 'styled-components'
import { QuerySequenceFilePicker } from 'src/components/Main/QuerySequenceFilePicker'
import { DatasetCurrent } from 'src/components/Main/DatasetCurrent'

export function WizardManualStep() {
return (
<Container fluid>
<Container>
<Row noGutters className="flex-column-reverse flex-lg-row h-100">
<Col lg={6}>
<DatasetCurrent />
Expand All @@ -19,15 +19,17 @@ export function WizardManualStep() {
)
}

const Container = styled(ContainerBase)`
const Container = styled.div`
width: 100% !important;
@media (min-width: 991.98px) {
overflow: hidden;
height: 100%;
}
`

const Row = styled(RowBase)`
width: 100%;
width: 100% !important;
@media (min-width: 991.98px) {
overflow: hidden;
Expand All @@ -36,7 +38,7 @@ const Row = styled(RowBase)`
`

const Col = styled(ColBase)`
width: 100%;
width: 100% !important;
@media (min-width: 991.98px) {
overflow: hidden;
Expand Down

0 comments on commit 9b385f2

Please sign in to comment.