-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into 3685_pin_tracks
- Loading branch information
Showing
54 changed files
with
2,195 additions
and
2,633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}` | ||
|
@@ -143,6 +147,7 @@ function Contents({ text }: { text: string }) { | |
}} | ||
> | ||
{text} | ||
{extra ? `extra: ${extra}` : ''} | ||
</pre> | ||
</> | ||
) | ||
|
@@ -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>() | ||
|
@@ -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 | ||
|
@@ -194,7 +201,7 @@ export default function ErrorMessageStackTraceDialog({ | |
{mappedStackTrace === undefined ? ( | ||
<LoadingEllipses variant="h6" /> | ||
) : ( | ||
<Contents text={errorBoxText} /> | ||
<Contents text={errorBoxText} extra={extra} /> | ||
)} | ||
</DialogContent> | ||
<DialogActions> | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}, | ||
})) | ||
} |
Oops, something went wrong.