Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankbrgowda committed Sep 20, 2023
2 parents 0f58fb9 + f79c373 commit e1132a9
Show file tree
Hide file tree
Showing 17 changed files with 260 additions and 383 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ jobs:
run: yarn eslint --report-unused-disable-directives --max-warnings 0 --ext .js,.ts,.jsx,.tsx .
- name: Test codebase
run: yarn test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
9 changes: 9 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
comment: false
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start:server": "yarn workspace apollo-collaboration-server run start",
"start:plugin": "yarn workspace jbrowse-plugin-apollo run start",
"start": "npm-run-all --print-label --parallel start:shared start:server start:plugin",
"test": "yarn workspace jbrowse-plugin-apollo run test"
"test": "yarn workspace jbrowse-plugin-apollo run test:ci"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/jbrowse-plugin-apollo/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ module.exports = {
testPathIgnorePatterns: ['<rootDir>/cypress/'],
automock: false,
setupFiles: ['./jestSetup.js', 'fake-indexeddb/auto'],
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
}
1 change: 1 addition & 0 deletions packages/jbrowse-plugin-apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"build": "yarn build:shared && yarn clean && rollup --config",
"browse": "serve --listen 8999 .jbrowse",
"test": "jest",
"test:ci": "jest --coverage",
"test:e2e": "start-test \"npm-run-all --parallel start browse\" \"9000|8999\" \"npm-run-all cypress:run\"",
"cypress:run": "cypress run --browser chrome --config baseUrl=http://localhost:8999",
"cypress:open": "cypress open --config baseUrl=http://localhost:8999",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const LinearApolloDisplay = observer(function LinearApolloDisplay(
setCollaboratorCanvas,
setOverlayCanvas,
setTheme,
tabularEditor,
} = model
const { classes } = useStyles()
const lgv = getContainingView(model) as unknown as LinearGenomeViewModel
Expand Down Expand Up @@ -81,25 +82,30 @@ export const LinearApolloDisplay = observer(function LinearApolloDisplay(
</Tooltip>
</Alert>
) : (
// Promise.resolve() in these 3 callbacks is to avoid infinite rendering loop
// https://github.com/mobxjs/mobx/issues/3728#issuecomment-1715400931
<>
<canvas
ref={(node) => {
ref={async (node: HTMLCanvasElement) => {
await Promise.resolve()
setCollaboratorCanvas(node)
}}
width={lgv.dynamicBlocks.totalWidthPx}
height={featuresHeight}
className={classes.canvas}
/>
<canvas
ref={(node) => {
ref={async (node: HTMLCanvasElement) => {
await Promise.resolve()
setCanvas(node)
}}
width={lgv.dynamicBlocks.totalWidthPx}
height={featuresHeight}
className={classes.canvas}
/>
<canvas
ref={(node) => {
ref={async (node: HTMLCanvasElement) => {
await Promise.resolve()
setOverlayCanvas(node)
}}
width={lgv.dynamicBlocks.totalWidthPx}
Expand All @@ -108,6 +114,9 @@ export const LinearApolloDisplay = observer(function LinearApolloDisplay(
onMouseLeave={onMouseLeave}
onMouseDown={onMouseDown}
onMouseUp={onMouseUp}
onClick={() => {
tabularEditor.showPane()
}}
className={classes.canvas}
style={{ cursor: cursor ?? 'default' }}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function configSchemaFactory(pluginManager: PluginManager) {

return ConfigurationSchema(
'LinearApolloDisplay',
{},
{ height: { type: 'number', defaultValue: 500 } },
{ baseConfiguration: baseLinearDisplayConfigSchema, explicitlyTyped: true },
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MenuItem } from '@jbrowse/core/ui'
import { alpha } from '@mui/material'
import { AnnotationFeatureI } from 'apollo-mst'

import {
Expand Down Expand Up @@ -138,6 +139,98 @@ export abstract class Glyph {
return parentFeature

Check warning on line 139 in packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/Glyph.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/Glyph.ts#L139

Added line #L139 was not covered by tests
}

drawTooltip(
display: LinearApolloDisplayMouseEvents,
context: CanvasRenderingContext2D,
): void {
const { apolloHover, apolloRowHeight, displayedRegions, lgv, theme } =
display
if (!apolloHover) {
return
}
const { feature, mousePosition } = apolloHover
if (!(feature && mousePosition)) {
return
}
const { regionNumber, y } = mousePosition
const displayedRegion = displayedRegions[regionNumber]
const { refName, reversed } = displayedRegion
const { bpPerPx, bpToPx, offsetPx } = lgv

const { discontinuousLocations } = feature
let start: number, end: number, length: number
let location = 'Loc: '
if (discontinuousLocations && discontinuousLocations.length > 0) {
const lastLoc = discontinuousLocations.at(-1)
if (!lastLoc) {
return
}
start = lastLoc?.start
end = lastLoc?.end
length = lastLoc?.end - lastLoc?.start

if (discontinuousLocations.length <= 2) {
for (const [i, loc] of discontinuousLocations.entries()) {
location += `${loc.start.toString()}-${loc.end.toString()}`
if (i !== discontinuousLocations.length - 1) {
location += ','
}
}
} else {
location += `${feature.start}-${feature.end},..,${start}-${end}`
}
} else {
;({ end, length, start } = feature)
location += `${start.toString()}-${end.toString()}`
}

let startPx =
(bpToPx({ refName, coord: reversed ? end : start, regionNumber })
?.offsetPx ?? 0) - offsetPx
const row = Math.floor(y / apolloRowHeight)
const top = row * apolloRowHeight
const widthPx = length / bpPerPx

const featureType = `Type: ${feature.type}`
const { attributes } = feature
const featureName = attributes.get('gff_name')?.find((name) => name !== '')
const textWidth = [
context.measureText(featureType).width,
context.measureText(location).width,
]
if (featureName) {
textWidth.push(context.measureText(`Name: ${featureName}`).width)
}
const maxWidth = Math.max(...textWidth)

startPx = startPx + widthPx + 5
context.fillStyle = alpha(
theme?.palette.text.primary ?? 'rgb(1, 1, 1)',
0.7,
)
context.fillRect(
startPx,
top,
maxWidth + 4,
textWidth.length === 3 ? 45 : 35,
)
context.beginPath()
context.moveTo(startPx, top)
context.lineTo(startPx - 5, top + 5)
context.lineTo(startPx, top + 10)
context.fill()
context.fillStyle =
theme?.palette.background.default ?? 'rgba(255, 255, 255)'
let textTop = top + 12
context.fillText(featureType, startPx + 2, textTop)
if (featureName) {
textTop = textTop + 12
context.fillText(`Name: ${featureName}`, startPx + 2, textTop)
}
textTop = textTop + 12
context.fillText(location, startPx + 2, textTop)
}

getContextMenuItems(display: LinearApolloDisplayMouseEvents): MenuItem[] {
const {
apolloHover,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ export function mouseEventsModelFactory(
// draw mouseover hovers
glyph?.drawHover(self, ctx, rowNum, xOffset, reversed)

// draw tooltip on hover
glyph?.drawTooltip(self, ctx)

// dragging previews
if (apolloDragging) {
// NOTE: the glyph where the drag started is responsible for drawing the preview.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function renderingModelIntermediateFactory(
apolloRowHeight: 20,
detailsMinHeight: 200,
detailsHeight: 200,
lastRowTooltipBufferHeight: 40,
isShown: true,
})
.volatile(() => ({
Expand All @@ -33,7 +34,10 @@ export function renderingModelIntermediateFactory(
}))
.views((self) => ({
get featuresHeight() {
return (self.highestRow + 1) * self.apolloRowHeight
return (
(self.highestRow + 1) * self.apolloRowHeight +
self.lastRowTooltipBufferHeight
)
},
}))
.actions((self) => ({
Expand Down
Loading

0 comments on commit e1132a9

Please sign in to comment.