Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add navigation to parent/child features in feature details widget #483

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { BasicInformation } from './BasicInformation'
import { ApolloFeatureDetailsWidget as ApolloFeatureDetails } from './model'
import { Sequence } from './Sequence'
import { FeatureDetailsNavigation } from './FeatureDetailsNavigation'

Check warning on line 11 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/ApolloFeatureDetailsWidget.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/ApolloFeatureDetailsWidget.tsx#L11

Added line #L11 was not covered by tests

const useStyles = makeStyles()((theme) => ({
root: {
Expand Down Expand Up @@ -59,6 +60,9 @@
assembly={currentAssembly._id}
refName={refName}
/>
<hr />
<FeatureDetailsNavigation model={model} feature={feature} />
<hr />
</div>
)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react'

Check warning on line 1 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L1

Added line #L1 was not covered by tests

import { Button, Typography } from '@mui/material'
import { observer } from 'mobx-react'

Check warning on line 4 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L3-L4

Added lines #L3 - L4 were not covered by tests

import { AnnotationFeature } from '@apollo-annotation/mst'
import { ApolloFeatureDetailsWidget as ApolloFeatureDetails } from './model'

export const FeatureDetailsNavigation = observer(

Check warning on line 9 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L9

Added line #L9 was not covered by tests
function FeatureDetailsNavigation(props: {
model: ApolloFeatureDetails
feature: AnnotationFeature
}) {
const { feature, model } = props
const { children, parent } = feature
const childFeatures = []

Check warning on line 16 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L13-L16

Added lines #L13 - L16 were not covered by tests
if (children) {
for (const [, child] of children) {
childFeatures.push(child)

Check warning on line 19 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L18-L19

Added lines #L18 - L19 were not covered by tests
}
}

return (

Check warning on line 23 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L23

Added line #L23 was not covered by tests
<div>
{parent && (
<div>

Check warning on line 26 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L26

Added line #L26 was not covered by tests
<Typography variant="h5">Parent: </Typography>
<Button
variant="contained"
onClick={() => {
model.setFeature(parent)

Check warning on line 31 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L30-L31

Added lines #L30 - L31 were not covered by tests
}}
>
{parent.type} ({parent.min}..{parent.max})
</Button>
</div>
)}
{childFeatures.length > 0 && (
<div>

Check warning on line 39 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L39

Added line #L39 was not covered by tests
<Typography variant="h5">Children: </Typography>
{childFeatures.map((child) => (
<div key={child._id} style={{ marginBottom: 5 }}>

Check warning on line 42 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L42

Added line #L42 was not covered by tests
<Button
variant="contained"
onClick={() => {
model.setFeature(child)

Check warning on line 46 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/FeatureDetailsNavigation.tsx#L45-L46

Added lines #L45 - L46 were not covered by tests
}}
>
{child.type} ({child.min}..{child.max})
</Button>
</div>
))}
</div>
)}
</div>
)
},
)