diff --git a/packages/app-core/src/ui/App/ViewMenu.tsx b/packages/app-core/src/ui/App/ViewMenu.tsx index 28c5d575ee..87800aace0 100644 --- a/packages/app-core/src/ui/App/ViewMenu.tsx +++ b/packages/app-core/src/ui/App/ViewMenu.tsx @@ -12,6 +12,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' @@ -108,6 +109,13 @@ const ViewMenu = observer(function ({ }, ] : []), + { + label: 'Copy view', + onClick: () => { + const { id, ...rest } = getSnapshot(model) + session.addView(model.type, rest) + }, + }, ...model.menuItems(), ]} popupState={popupState} diff --git a/packages/app-core/src/ui/App/ViewPanel.tsx b/packages/app-core/src/ui/App/ViewPanel.tsx index c10cdd7e44..02c46c1b29 100644 --- a/packages/app-core/src/ui/App/ViewPanel.tsx +++ b/packages/app-core/src/ui/App/ViewPanel.tsx @@ -51,9 +51,7 @@ const ViewPanel = observer(function ({ - ) : ( - false - )} + ) : null} ) }) diff --git a/packages/core/pluggableElementTypes/models/BaseViewModel.ts b/packages/core/pluggableElementTypes/models/BaseViewModel.ts index ef12710158..6e3c80ed3c 100644 --- a/packages/core/pluggableElementTypes/models/BaseViewModel.ts +++ b/packages/core/pluggableElementTypes/models/BaseViewModel.ts @@ -74,7 +74,9 @@ const BaseViewModel = types export default BaseViewModel -export type IBaseViewModel = Instance +// the base view does not have type but any derived type needs to add type, so +// just add it here +export type IBaseViewModel = Instance & { type: string } export const BaseViewModelWithDisplayedRegions = BaseViewModel.props({ displayedRegions: types.array(Region),