Skip to content

Commit

Permalink
Copy view
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 25, 2025
1 parent 73b24f4 commit 3bff8d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions packages/app-core/src/ui/App/ViewMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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}
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

0 comments on commit 3bff8d1

Please sign in to comment.