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

Add configuration options for visibility of track's graphical and table views #461

Merged
merged 5 commits into from
Oct 19, 2024
Merged
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
21 changes: 21 additions & 0 deletions packages/jbrowse-plugin-apollo/cypress/e2e/editFeature.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ describe('Different ways of editing features', () => {
.within(() => {
cy.get('[data-testid="CloseIcon"]').click()
})
cy.get('[data-testid="track_menu_icon"]').click()
cy.contains('Appearance').trigger('mouseover')
cy.contains('Show both graphical and table display').click()

cy.contains('Table')
.parent()
Expand Down Expand Up @@ -82,6 +85,9 @@ describe('Different ways of editing features', () => {
cy.addAssemblyFromGff('onegene.fasta.gff3', 'test_data/onegene.fasta.gff3')
cy.selectAssemblyToView('onegene.fasta.gff3')
cy.searchFeatures('gx1', 1)
cy.get('[data-testid="track_menu_icon"]').click()
cy.contains('Appearance').trigger('mouseover')
cy.contains('Show both graphical and table display').click()
cy.contains('td', 'CDS1').rightclick()
cy.contains('Edit attributes').click()
cy.contains('Feature attributes')
Expand All @@ -108,6 +114,9 @@ describe('Different ways of editing features', () => {
cy.addAssemblyFromGff('stopcodon', 'test_data/cdsChecks/stopcodon.gff3')
cy.selectAssemblyToView('stopcodon')
cy.searchFeatures('gene02', 1)
cy.get('[data-testid="track_menu_icon"]').click()
cy.contains('Appearance').trigger('mouseover')
cy.contains('Show both graphical and table display').click()
cy.contains('td', '=cds02.1').rightclick()
cy.contains('Delete feature').click()
cy.contains('Are you sure you want to delete the selected feature?')
Expand All @@ -126,6 +135,9 @@ describe('Different ways of editing features', () => {
cy.addAssemblyFromGff('stopcodon', 'test_data/cdsChecks/stopcodon.gff3')
cy.selectAssemblyToView('stopcodon')
cy.searchFeatures('gene04', 1)
cy.get('[data-testid="track_menu_icon"]').click()
cy.contains('Appearance').trigger('mouseover')
cy.contains('Show both graphical and table display').click()
cy.contains('td', '=cds04.1').rightclick()
cy.contains('Delete feature').click()

Expand All @@ -145,6 +157,9 @@ describe('Different ways of editing features', () => {
cy.addAssemblyFromGff('onegene.fasta.gff3', 'test_data/onegene.fasta.gff3')
cy.selectAssemblyToView('onegene.fasta.gff3')
cy.searchFeatures('gx1', 1)
cy.get('[data-testid="track_menu_icon"]').click()
cy.contains('Appearance').trigger('mouseover')
cy.contains('Show both graphical and table display').click()
cy.contains('td', '=CDS1')
cy.contains('td', '=tx1').rightclick()
cy.contains('Delete feature').click()
Expand All @@ -163,6 +178,9 @@ describe('Different ways of editing features', () => {
cy.addAssemblyFromGff('onegene.fasta.gff3', 'test_data/onegene.fasta.gff3')
cy.selectAssemblyToView('onegene.fasta.gff3')
cy.searchFeatures('gx1', 1)
cy.get('[data-testid="track_menu_icon"]').click()
cy.contains('Appearance').trigger('mouseover')
cy.contains('Show both graphical and table display').click()
// In headless mode it seems to take a long time for menus to be populated
cy.get('input[type="text"][value="CDS"]', { timeout: 60_000 }).click({
timeout: 60_000,
Expand All @@ -181,6 +199,9 @@ describe('Different ways of editing features', () => {
cy.addAssemblyFromGff('onegene.fasta.gff3', 'test_data/onegene.fasta.gff3')
cy.selectAssemblyToView('onegene.fasta.gff3')
cy.searchFeatures('gx1', 1)
cy.get('[data-testid="track_menu_icon"]').click()
cy.contains('Appearance').trigger('mouseover')
cy.contains('Show both graphical and table display').click()
// In headless mode it seems to take a long time for menus to be populated
cy.get('input[type="text"][value="CDS"]', { timeout: 60_000 }).rightclick({
timeout: 60_000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export const LinearApolloDisplay = observer(function LinearApolloDisplay(
setSeqTrackCanvas,
setSeqTrackOverlayCanvas,
setTheme,
tabularEditor,
} = model
const { classes } = useStyles()
const lgv = getContainingView(model) as unknown as LinearGenomeViewModel
Expand Down Expand Up @@ -170,9 +169,6 @@ export const LinearApolloDisplay = observer(function LinearApolloDisplay(
onMouseLeave={onMouseLeave}
onMouseDown={onMouseDown}
onMouseUp={onMouseUp}
onClick={() => {
tabularEditor.showPane()
}}
className={classes.canvas}
style={{ cursor: cursor ?? 'default' }}
data-testid="overlayCanvas"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { ConfigurationSchema } from '@jbrowse/core/configuration'
import PluginManager from '@jbrowse/core/PluginManager'
import type LinearGenomeViewPlugin from '@jbrowse/plugin-linear-genome-view'

export function configSchemaFactory(pluginManager: PluginManager) {
const LGVPlugin = pluginManager.getPlugin(
'LinearGenomeViewPlugin',
) as LinearGenomeViewPlugin
const { baseLinearDisplayConfigSchema } = LGVPlugin.exports

return ConfigurationSchema(
'LinearApolloDisplay',
{ height: { type: 'number', defaultValue: 500 } },
{ baseConfiguration: baseLinearDisplayConfigSchema, explicitlyTyped: true },
)
}
export const configSchema = ConfigurationSchema(

Check warning on line 3 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/configSchema.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/configSchema.ts#L3

Added line #L3 was not covered by tests
'LinearApolloDisplay',
{},
{ explicitIdentifier: 'displayId', explicitlyTyped: true },
)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { configSchemaFactory } from './configSchema'
export { configSchema } from './configSchema'

Check warning on line 1 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/index.ts#L1

Added line #L1 was not covered by tests
export { stateModelFactory } from './stateModel'
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,27 @@
import { ApolloInternetAccountModel } from '../../ApolloInternetAccount/model'
import { ApolloSessionModel } from '../../session'
import { ApolloRootModel } from '../../types'
import { TrackHeightMixin } from './trackHeightMixin'

const minDisplayHeight = 20

Check warning on line 26 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L26

Added line #L26 was not covered by tests

export function baseModelFactory(
_pluginManager: PluginManager,
configSchema: AnyConfigurationSchemaType,
) {
// TODO: Restore this when TRackHeightMixin is in LGV runtime exports

// const LGVPlugin = pluginManager.getPlugin(
// 'LinearGenomeViewPlugin',
// ) as LinearGenomeViewPlugin
// const { TrackHeightMixin } = LGVPlugin.exports

return types
.compose(BaseDisplay, TrackHeightMixin)
.named('BaseLinearApolloDisplay')
return BaseDisplay.named('BaseLinearApolloDisplay')

Check warning on line 32 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L32

Added line #L32 was not covered by tests
.props({
type: types.literal('LinearApolloDisplay'),
configuration: ConfigurationReference(configSchema),
graphical: true,
table: false,
heightPreConfig: types.maybe(
types.refinement(
'displayHeight',
types.number,
(n) => n >= minDisplayHeight,

Check warning on line 42 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L42

Added line #L42 was not covered by tests
),
),
})
.volatile((self) => ({
lgv: getContainingView(self) as unknown as LinearGenomeViewModel,
}))
.views((self) => {
const { configuration, renderProps: superRenderProps } = self
return {
Expand All @@ -57,6 +55,26 @@
},
}
})
.volatile(() => ({

Check warning on line 58 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L58

Added line #L58 was not covered by tests
scrollTop: 0,
}))
.views((self) => ({
get lgv() {
return getContainingView(self) as unknown as LinearGenomeViewModel

Check warning on line 63 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L61-L63

Added lines #L61 - L63 were not covered by tests
},
get height() {

Check warning on line 65 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L65

Added line #L65 was not covered by tests
if (self.heightPreConfig) {
return self.heightPreConfig

Check warning on line 67 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L67

Added line #L67 was not covered by tests
}
if (self.graphical && self.table) {
return 500

Check warning on line 70 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L70

Added line #L70 was not covered by tests
}
if (self.graphical) {
return 200

Check warning on line 73 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L73

Added line #L73 was not covered by tests
}
return 300

Check warning on line 75 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L75

Added line #L75 was not covered by tests
},
}))
.views((self) => ({
get rendererTypeName() {
return self.configuration.renderer.type
Expand Down Expand Up @@ -119,6 +137,73 @@
.apolloSelectedFeature
},
}))
.actions((self) => ({
setScrollTop(scrollTop: number) {
self.scrollTop = scrollTop

Check warning on line 142 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L140-L142

Added lines #L140 - L142 were not covered by tests
},
setHeight(displayHeight: number) {
self.heightPreConfig = Math.max(displayHeight, minDisplayHeight)
return self.height

Check warning on line 146 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L144-L146

Added lines #L144 - L146 were not covered by tests
},
resizeHeight(distance: number) {
const oldHeight = self.height
const newHeight = this.setHeight(self.height + distance)
return newHeight - oldHeight

Check warning on line 151 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L148-L151

Added lines #L148 - L151 were not covered by tests
},
showGraphicalOnly() {
self.graphical = true
self.table = false

Check warning on line 155 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L153-L155

Added lines #L153 - L155 were not covered by tests
},
showTableOnly() {
self.graphical = false
self.table = true

Check warning on line 159 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L157-L159

Added lines #L157 - L159 were not covered by tests
},
showGraphicalAndTable() {
self.graphical = true
self.table = true

Check warning on line 163 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L161-L163

Added lines #L161 - L163 were not covered by tests
},
}))
.views((self) => {
const { trackMenuItems: superTrackMenuItems } = self
return {
trackMenuItems() {
const { graphical, table } = self
return [

Check warning on line 171 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L166-L171

Added lines #L166 - L171 were not covered by tests
...superTrackMenuItems(),
{
type: 'subMenu',
label: 'Appearance',
subMenu: [
{
label: 'Show graphical display',
type: 'radio',
checked: graphical && !table,
onClick: () => {
self.showGraphicalOnly()

Check warning on line 182 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L181-L182

Added lines #L181 - L182 were not covered by tests
},
},
{
label: 'Show table display',
type: 'radio',
checked: table && !graphical,
onClick: () => {
self.showTableOnly()

Check warning on line 190 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L189-L190

Added lines #L189 - L190 were not covered by tests
},
},
{
label: 'Show both graphical and table display',
type: 'radio',
checked: table && graphical,
onClick: () => {
self.showGraphicalAndTable()

Check warning on line 198 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/base.ts#L197-L198

Added lines #L197 - L198 were not covered by tests
},
},
],
},
]
},
}
})
.actions((self) => ({
setSelectedFeature(feature?: AnnotationFeature) {
;(
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions packages/jbrowse-plugin-apollo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
} from './FeatureDetailsWidget'
import {
stateModelFactory as LinearApolloDisplayStateModelFactory,
configSchemaFactory as linearApolloDisplayConfigSchemaFactory,
configSchema as linearApolloDisplayConfigSchema,
} from './LinearApolloDisplay'
import {
DisplayComponent,
Expand Down Expand Up @@ -174,7 +174,7 @@
})

pluginManager.addDisplayType(() => {
const configSchema = linearApolloDisplayConfigSchemaFactory(pluginManager)
const configSchema = linearApolloDisplayConfigSchema

Check warning on line 177 in packages/jbrowse-plugin-apollo/src/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/index.ts#L177

Added line #L177 was not covered by tests
return new DisplayType({
name: 'LinearApolloDisplay',
configSchema,
Expand Down
Loading