Skip to content

Commit e064f94

Browse files
committed
Copy view
1 parent 73b24f4 commit e064f94

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

packages/app-core/src/ui/App/ViewMenu.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import CascadingMenu from '@jbrowse/core/ui/CascadingMenu'
22
import { getSession } from '@jbrowse/core/util'
3+
import ContentCopyIcon from '@mui/icons-material/ContentCopy'
34
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'
45
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'
56
import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown'
@@ -12,6 +13,7 @@ import {
1213
usePopupState,
1314
} from 'material-ui-popup-state/hooks'
1415
import { observer } from 'mobx-react'
16+
import { getSnapshot } from 'mobx-state-tree'
1517

1618
import type { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models'
1719
import type { AbstractSessionModel } from '@jbrowse/core/util'
@@ -108,6 +110,17 @@ const ViewMenu = observer(function ({
108110
},
109111
]
110112
: []),
113+
{
114+
label: 'Copy view',
115+
icon: ContentCopyIcon,
116+
onClick: () => {
117+
const { id, ...rest } = getSnapshot(model)
118+
session.addView(model.type, rest)
119+
},
120+
},
121+
{
122+
type: 'divider',
123+
},
111124
...model.menuItems(),
112125
]}
113126
popupState={popupState}

packages/app-core/src/ui/App/ViewPanel.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ const ViewPanel = observer(function ({
5151
<ReactComponent model={view} session={session} />
5252
</Suspense>
5353
</ErrorBoundary>
54-
) : (
55-
false
56-
)}
54+
) : null}
5755
</ViewContainer>
5856
)
5957
})

packages/core/pluggableElementTypes/models/BaseViewModel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ const BaseViewModel = types
7474

7575
export default BaseViewModel
7676

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

7981
export const BaseViewModelWithDisplayedRegions = BaseViewModel.props({
8082
displayedRegions: types.array(Region),

0 commit comments

Comments
 (0)