Skip to content

Commit

Permalink
feature details navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankbrgowda committed Nov 26, 2024
1 parent eb301ba commit 55a31de
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Attributes } from './Attributes'
import { BasicInformation } from './BasicInformation'
import { ApolloFeatureDetailsWidget as ApolloFeatureDetails } from './model'
import { Sequence } from './Sequence'
import { FeatureDetailsNavigation } from './FeatureDetailsNavigation'

const useStyles = makeStyles()((theme) => ({
root: {
Expand Down Expand Up @@ -59,6 +60,9 @@ export const ApolloFeatureDetailsWidget = observer(
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'

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

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

export const FeatureDetailsNavigation = observer(
function FeatureDetailsNavigation(props: {
model: ApolloFeatureDetails
feature: AnnotationFeature
}) {
const { feature, model } = props
const { children, parent } = feature
const childrenSnapshot = []
if (children) {
for (const [, child] of children) {
childrenSnapshot.push(child)
}
}

return (
<div>
{parent && (
<div>
<Typography variant="h5">Parent: </Typography>
<Button
variant="contained"
onClick={() => {
model.setFeature(parent)
}}
>
{parent.type} ({parent.min}..{parent.max})
</Button>
</div>
)}
{childrenSnapshot.length > 0 && (
<div>
<Typography variant="h5">Children: </Typography>
{childrenSnapshot.map((child) => (
<div key={child._id} style={{ marginBottom: 5 }}>
<Button
variant="contained"
onClick={() => {
model.setFeature(child)
}}
>
{child.type} ({child.min}..{child.max})
</Button>
</div>
))}
</div>
)}
</div>
)
},
)

0 comments on commit 55a31de

Please sign in to comment.