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

Create "Copy view" item in view menu #4793

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
13 changes: 13 additions & 0 deletions packages/app-core/src/ui/App/ViewMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import CascadingMenu from '@jbrowse/core/ui/CascadingMenu'
import { getSession } from '@jbrowse/core/util'
import ContentCopyIcon from '@mui/icons-material/ContentCopy'
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'
import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown'
Expand All @@ -12,6 +13,7 @@ import {
usePopupState,
} from 'material-ui-popup-state/hooks'
import { observer } from 'mobx-react'
import { getSnapshot } from 'mobx-state-tree'

import type { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models'
import type { AbstractSessionModel } from '@jbrowse/core/util'
Expand Down Expand Up @@ -108,6 +110,17 @@ const ViewMenu = observer(function ({
},
]
: []),
{
label: 'Copy view',
icon: ContentCopyIcon,
onClick: () => {
const { id, ...rest } = getSnapshot(model)
session.addView(model.type, rest)
},
},
{
type: 'divider',
},
...model.menuItems(),
]}
popupState={popupState}
Expand Down
4 changes: 1 addition & 3 deletions packages/app-core/src/ui/App/ViewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ const ViewPanel = observer(function ({
<ReactComponent model={view} session={session} />
</Suspense>
</ErrorBoundary>
) : (
false
)}
) : null}
</ViewContainer>
)
})
Expand Down
4 changes: 3 additions & 1 deletion packages/core/pluggableElementTypes/models/BaseViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ const BaseViewModel = types

export default BaseViewModel

export type IBaseViewModel = Instance<typeof BaseViewModel>
// the base view does not have type but any derived type needs to add type, so
// just add it here
export type IBaseViewModel = Instance<typeof BaseViewModel> & { type: string }

export const BaseViewModelWithDisplayedRegions = BaseViewModel.props({
displayedRegions: types.array(Region),
Expand Down
Loading