mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-28 19:31:14 +08:00
feat(showDetails): Allow a "Show Details" option on error dialogs
Summary: Pass in more details on sending errors, so that they can be viewed more easily by clicking "Show Details", rather than having to check the worker window console. Test Plan: tested locally Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3505
This commit is contained in:
parent
9b9df21c93
commit
ace6cf4c9e
5 changed files with 40 additions and 22 deletions
|
@ -58,7 +58,7 @@ class ComposerWithWindowProps extends React.Component {
|
|||
NylasEnv.displayWindow();
|
||||
|
||||
if (this.state.errorMessage) {
|
||||
this._showInitialErrorDialog(this.state.errorMessage);
|
||||
this._showInitialErrorDialog(this.state.errorMessage, this.state.errorDetail);
|
||||
}
|
||||
|
||||
// This will start loading the rest of the composer's plugins. This
|
||||
|
@ -87,18 +87,12 @@ class ComposerWithWindowProps extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
_showInitialErrorDialog(msg) {
|
||||
const dialog = remote.dialog;
|
||||
_showInitialErrorDialog(msg, detail) {
|
||||
// We delay so the view has time to update the restored draft. If we
|
||||
// don't delay the modal may come up in a state where the draft looks
|
||||
// like it hasn't been restored or has been lost.
|
||||
_.delay(() => {
|
||||
dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||
type: 'warning',
|
||||
buttons: ['Okay'],
|
||||
message: "Error",
|
||||
detail: msg,
|
||||
});
|
||||
NylasEnv.showErrorDialog({title: 'Error', message: msg}, {detail: detail})
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
|
2
src/K2
2
src/K2
|
@ -1 +1 @@
|
|||
Subproject commit 67d1e14e60fe204faf56622de38f2124ac7ffe24
|
||||
Subproject commit d34cfa86b0a09d90189cc1f5237c26123fd5b6ab
|
|
@ -425,7 +425,7 @@ class DraftStore extends NylasStore {
|
|||
this.trigger(draftClientId);
|
||||
}
|
||||
|
||||
_onSendDraftFailed = ({draftClientId, threadId, errorMessage}) => {
|
||||
_onSendDraftFailed = ({draftClientId, threadId, errorMessage, errorDetail}) => {
|
||||
this._draftsSending[draftClientId] = false;
|
||||
this.trigger(draftClientId);
|
||||
if (NylasEnv.isMainWindow()) {
|
||||
|
@ -436,17 +436,17 @@ class DraftStore extends NylasStore {
|
|||
// We also need to delay because the old draft window needs to fully
|
||||
// close. It takes windows currently (June 2016) 100ms to close by
|
||||
setTimeout(() => {
|
||||
this._notifyUserOfError({draftClientId, threadId, errorMessage});
|
||||
this._notifyUserOfError({draftClientId, threadId, errorMessage, errorDetail});
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
_notifyUserOfError({draftClientId, threadId, errorMessage}) {
|
||||
_notifyUserOfError({draftClientId, threadId, errorMessage, errorDetail}) {
|
||||
const focusedThread = FocusedContentStore.focused('thread');
|
||||
if (threadId && focusedThread && focusedThread.id === threadId) {
|
||||
NylasEnv.showErrorDialog(errorMessage);
|
||||
NylasEnv.showErrorDialog(errorMessage, {detail: errorDetail});
|
||||
} else {
|
||||
Actions.composePopoutDraft(draftClientId, {errorMessage});
|
||||
Actions.composePopoutDraft(draftClientId, {errorMessage, errorDetail});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,6 +256,7 @@ export default class SendDraftTask extends BaseDraftTask {
|
|||
threadId: this.draft.threadId,
|
||||
draftClientId: this.draft.clientId,
|
||||
errorMessage: message,
|
||||
errorDetail: err.message + (err.error ? err.error.stack : '') + err.stack,
|
||||
});
|
||||
}
|
||||
NylasEnv.reportError(err);
|
||||
|
|
|
@ -865,7 +865,7 @@ class NylasEnvConstructor
|
|||
options.title ?= 'Save File'
|
||||
callback(remote.dialog.showSaveDialog(@getCurrentWindow(), options))
|
||||
|
||||
showErrorDialog: (messageData, {showInMainWindow}={}) ->
|
||||
showErrorDialog: (messageData, {showInMainWindow, detail}={}) ->
|
||||
if _.isString(messageData) or _.isNumber(messageData)
|
||||
message = messageData
|
||||
title = "Error"
|
||||
|
@ -879,12 +879,35 @@ class NylasEnvConstructor
|
|||
if showInMainWindow
|
||||
winToShow = remote.getGlobal('application').getMainWindow()
|
||||
|
||||
remote.dialog.showMessageBox winToShow, {
|
||||
type: 'warning'
|
||||
buttons: ['Okay'],
|
||||
message: title
|
||||
detail: message
|
||||
}
|
||||
if !detail
|
||||
remote.dialog.showMessageBox winToShow, {
|
||||
type: 'warning'
|
||||
buttons: ['Okay'],
|
||||
message: title
|
||||
detail: message
|
||||
}
|
||||
else
|
||||
withoutDetails = ->
|
||||
remote.dialog.showMessageBox winToShow, {
|
||||
type: 'warning'
|
||||
buttons: ['Okay', 'Show Details'],
|
||||
message: title
|
||||
detail: message
|
||||
}, (buttonIndex) ->
|
||||
if buttonIndex == 1
|
||||
withDetails()
|
||||
|
||||
withDetails = ->
|
||||
remote.dialog.showMessageBox winToShow, {
|
||||
type: 'warning'
|
||||
buttons: ['Okay', 'Hide Details'],
|
||||
message: title
|
||||
detail: message + '\n\nDetails\n‾‾‾‾‾‾‾‾‾‾\n' + detail
|
||||
}, (buttonIndex) ->
|
||||
if buttonIndex == 1
|
||||
withoutDetails()
|
||||
|
||||
withoutDetails()
|
||||
|
||||
# Delegate to the browser's process fileListCache
|
||||
fileListCache: ->
|
||||
|
|
Loading…
Reference in a new issue