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
Display a modal when saving a user script in the editor #2858
Display a modal when saving a user script in the editor #2858
Conversation
FYI it's very helpful for me when you put |
src/bg/user-script-registry.js
Outdated
@@ -290,6 +290,14 @@ async function saveUserScript(userScript) { | |||
onSaveError(e.target.error); | |||
reject(e); | |||
db.close(); | |||
} finally { | |||
// Send the script change event, even though the save may have failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worries me. If the save failed, I don't want the editor changing, and maybe throwing away unsaved details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The userScript
that's being saved should represent the editor as it is. You're basically returning the same details you submitted to the background, along with any downloaded resources. You shouldn't lose any unsaved details as userScript
represents all those unsaved details (that failed to save).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I suppose that if the external resources take a long time to download time you may be able to perform some edits before the async save is returned. But that issue applies to both successful saves and unsuccessful saves.
I think the best thing to do is popup some modal that says 'saving' and doesn't go away until the result is back. If a save error occurs then display the error in the modal. If no errors, then auto close.
By resolving the details directly there is no need for the "UserScriptChange" message to be sent to the editor.
No longer necessary to listen for "UserScriptChanged". All results will be passed directly into the response of the initial save message.
When saving a popup modal indicating a save is in progress is displayed. The modal also prevents any modifications and subsequent data lose during the asynchronous save. Once the save is complete close the modal. On Error display the message in the modal.
Updated with a different approach. |
I see in an email update (but can't find anywhere else) that @Sxderp said:
I agree. |
I plan on merging this, but after some other work of mine -- I'll have to resolve merge conflicts at that time. While we're waiting: does CodeMirror not have something to do (possibly modal) dialogs already? Maybe https://github.com/codemirror/CodeMirror/tree/master/addon/dialog ? If not is there a tidy general JS "modal dialog" component somewhere that we could simply reuse, rather than writing support for it from scratch? A few moments of searching finds me:
Which seem decent. The smaller/lighter the better IMO. Anything pre-existing with a documented API is good. |
If you want simple, I don't think you could get simpler than the code I wrote. It just uses rivets for the content and displays / undisplays by changing the body class (like the Monkey Menu). Is it necessary for a "full feature" modal of some sort? |
When I have time I'll work on this for the recent changes to master. Should be done by Monday. |
I'm going to wait on this until we have better error handling in the downloader. |
Closing this and reopening as a new branch / PR |
fixes #2847