-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
plugins/menus/src/SessionManager/components/SessionListItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react' | ||
import { | ||
ListItem, | ||
ListItemButton, | ||
ListItemIcon, | ||
ListItemText, | ||
} from '@mui/material' | ||
|
||
import { observer } from 'mobx-react' | ||
import pluralize from 'pluralize' | ||
|
||
// icons | ||
import ViewListIcon from '@mui/icons-material/ViewList' | ||
import { AbstractSessionModel, sum } from '@jbrowse/core/util' | ||
|
||
// locals | ||
import { SessionSnap } from './util' | ||
|
||
const SessionListItem = observer(function ({ | ||
session, | ||
sessionSnapshot, | ||
onClick, | ||
secondaryAction, | ||
}: { | ||
sessionSnapshot: SessionSnap | ||
session: AbstractSessionModel | ||
onClick: () => void | ||
secondaryAction?: React.ReactNode | ||
}) { | ||
const { views = [] } = sessionSnapshot || {} | ||
const totalTracks = sum(views.map(view => view.tracks?.length ?? 0)) | ||
const n = views.length | ||
|
||
return ( | ||
<ListItem secondaryAction={secondaryAction}> | ||
<ListItemButton onClick={onClick}> | ||
<ListItemIcon> | ||
<ViewListIcon /> | ||
</ListItemIcon> | ||
<ListItemText | ||
primary={sessionSnapshot.name} | ||
secondary={ | ||
session.name === sessionSnapshot.name | ||
? 'Currently open' | ||
: `${n} ${pluralize('view', n)}; ${totalTracks} open ${pluralize( | ||
'track', | ||
totalTracks, | ||
)}` | ||
} | ||
/> | ||
</ListItemButton> | ||
</ListItem> | ||
) | ||
}) | ||
|
||
export default SessionListItem |