Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 3685_pin_tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Mar 14, 2024
2 parents 3fbb664 + ab2f980 commit f618212
Show file tree
Hide file tree
Showing 54 changed files with 2,195 additions and 2,633 deletions.
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"@oclif/test": "^3.2.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
"@r2wc/react-to-web-component": "^2.0.3",
"@storybook/addon-essentials": "^7.0.0",
"@storybook/node-logger": "^7.0.0",
"@storybook/react": "^7.0.0",
"@storybook/react-webpack5": "^7.0.0",
"@storybook/addon-essentials": "^8.0.0",
"@storybook/node-logger": "^8.0.0",
"@storybook/react": "^8.0.0",
"@storybook/react-webpack5": "^8.0.0",
"@testing-library/dom": "^9.0.0",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
Expand Down Expand Up @@ -101,7 +101,7 @@
"dependency-graph": "^0.11.0",
"dotenv": "^16.3.1",
"dotenv-expand": "^11.0.3",
"electron": "29.1.0",
"electron": "29.1.2",
"electron-builder": "^24.9.0",
"electron-mock-ipc": "^0.3.8",
"eslint": "^8.0.0",
Expand Down Expand Up @@ -145,7 +145,7 @@
"semver": "^7.3.4",
"slugify": "^1.6.5",
"source-map-loader": "^5.0.0",
"storybook": "^7.0.0",
"storybook": "^8.0.0",
"style-loader": "^3.3.1",
"terser-webpack-plugin": "^5.2.5",
"ts-node": "^10.4.0",
Expand All @@ -158,6 +158,5 @@
"webpack-dev-server": "^5.0.0",
"webpack-manifest-plugin": "^5.0.0"
},
"version": "0.0.0",
"dependencies": {}
"version": "0.0.0"
}
19 changes: 13 additions & 6 deletions packages/core/ui/ErrorMessageStackTraceDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ function stripMessage(trace: string, error: unknown) {
}
}

function Contents({ text }: { text: string }) {
function Contents({ text, extra }: { text: string; extra?: unknown }) {
const err = encodeURIComponent(
'I got this error from JBrowse, here is the stack trace:\n\n```\n' +
text +
'\n```\n',
[
'I got this error from JBrowse, here is the stack trace:\n',
'```',
text,
'```',
extra ? `supporting data: ${extra}` : '',
].join('\n') + '\n',
)
const githubLink = `https://github.com/GMOD/jbrowse-components/issues/new?labels=bug&title=JBrowse+issue&body=${err}`
const emailLink = `mailto:[email protected]?subject=JBrowse%202%20error&body=${err}`
Expand All @@ -143,6 +147,7 @@ function Contents({ text }: { text: string }) {
}}
>
{text}
{extra ? `extra: ${extra}` : ''}
</pre>
</>
)
Expand All @@ -151,9 +156,11 @@ function Contents({ text }: { text: string }) {
export default function ErrorMessageStackTraceDialog({
error,
onClose,
extra,
}: {
onClose: () => void
error: unknown
extra?: unknown
}) {
const [mappedStackTrace, setMappedStackTrace] = useState<string>()
const [secondaryError, setSecondaryError] = useState<unknown>()
Expand Down Expand Up @@ -181,7 +188,7 @@ export default function ErrorMessageStackTraceDialog({
? 'Error loading source map, showing raw stack trace below:'
: '',
errorText.length > MAX_ERR_LEN
? errorText.slice(0, MAX_ERR_LEN) + '...'
? `${errorText.slice(0, MAX_ERR_LEN)}...`
: errorText,
mappedStackTrace || 'No stack trace available',
// @ts-expect-error add version info at bottom if we are in jbrowse-web
Expand All @@ -194,7 +201,7 @@ export default function ErrorMessageStackTraceDialog({
{mappedStackTrace === undefined ? (
<LoadingEllipses variant="h6" />
) : (
<Contents text={errorBoxText} />
<Contents text={errorBoxText} extra={extra} />
)}
</DialogContent>
<DialogActions>
Expand Down
82 changes: 0 additions & 82 deletions packages/core/ui/SnackbarModel.ts

This file was deleted.

87 changes: 87 additions & 0 deletions packages/core/ui/SnackbarModel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React, { lazy } from 'react'
import { types } from 'mobx-state-tree'
import { observable } from 'mobx'

// locals
import { NotificationLevel, SnackAction } from '../util/types'

// icons
import Report from '@mui/icons-material/Report'

// lazies

const ErrorMessageStackTraceDialog = lazy(
() => import('@jbrowse/core/ui/ErrorMessageStackTraceDialog'),
)

export interface SnackbarMessage {
message: string
level?: NotificationLevel
action?: SnackAction
}

/**
* #stateModel SnackbarModel
* #category session
*/
export default function SnackbarModel() {
return types
.model({})
.volatile(() => ({
snackbarMessages: observable.array<SnackbarMessage>(),
}))
.actions(self => ({
/**
* #action
*/
notify(message: string, level?: NotificationLevel, action?: SnackAction) {
this.pushSnackbarMessage(message, level, action)
if (level === 'info' || level === 'success') {
setTimeout(() => {
this.removeSnackbarMessage(message)
}, 5000)
}
},
notifyError(errorMessage: string, error?: unknown, extra?: unknown) {
this.notify(errorMessage, 'error', {
name: <Report />,
onClick: () => {
// @ts-expect-error
self.queueDialog((onClose: () => void) => [
ErrorMessageStackTraceDialog,
{
onClose,
error,
extra,
},
])
},
})
},
/**
* #action
*/
pushSnackbarMessage(
message: string,
level?: NotificationLevel,
action?: SnackAction,
) {
return self.snackbarMessages.push({ message, level, action })
},
/**
* #action
*/
popSnackbarMessage() {
return self.snackbarMessages.pop()
},
/**
* #action
*/
removeSnackbarMessage(message: string) {
const element = self.snackbarMessages.find(f => f.message === message)
if (element) {
self.snackbarMessages.remove(element)
}
},
}))
}
Loading

0 comments on commit f618212

Please sign in to comment.