-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add undo handler to allow undoing actions in apps #1610
Conversation
@ChristophWurst, thanks for your PR! By analyzing the history of the files in this pull request, we identified @PVince81, @icewind1991 and @LukasReschke to be potential reviewers. |
8d06e15
to
03503f8
Compare
this._currentCommand.execute(); | ||
} | ||
this._currentCommand = command; | ||
this._$notificationRow = OC.Notification.showHtml('<span>' + text + '</span> <a>' + t('core', 'Click to undo') + '</a>'); |
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.
I'd prefer if text
would be escaped.
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.
sure, I'll add Handlebars to render that html string
After thinking about this a bit more I'm a bit worried about handling errors in the @nextcloud/javascript does anybody have experience with implementing undo in js? It will also be tricky to add the undo feature to existing application logic, because you'd have to make sure the previously added undoable action is executed when another action is triggered that depends on the first one to have finished. |
(Btw @ChristophWurst let me know as soon as there is something to review for me. :) |
I think the undo queue should be cleared each time an user does an action. |
That's how Google Inbox handles the undo feature as well (in android and the webapp at inbox.google.com). So I guess from a UX perspective this is probably the expected result, or at least the user won't wonder about this method. |
@ChristophWurst any open questions here btw? As said, let me know if something is testable, I’m really excited to have this back. :) |
I don't see this happening because we'd either have to 1. adjust/rewrite most of the js code or 2. do major hacks that will probably cause more troubles than we currently have. Adding undo to existing code where the architecture was not designed for it is a major change to the existing functionalities. |
I see two possibility in my mind right now.
|
@skjnldsv if we add that progressbar – what if the user navigates to another folder? what if the user opens another app? what if the user renames another file to the same name? what if the user uploads a file with the same name? what if the user navigates one level up and deletes the folder? |
Like @tcitworld said. i think a user interraction should clear the queue too! :) |
@skjnldsv a very present progress bar like this would not really be in line with our simple and nonblocking design philosophy, would it? ;) I mean, when you navigate away and something is still deleting, we could show an alert if there’s really no other option … but not show something in every case. |
Well, we can make this discreet and subtle! :D |
@ChristophWurst @karlitschek I moved this to 12.0 milestone as discussed |
How about keeping the undo manager in the session? So you can load/execute/modify it when ever you need it and easily change pages, etc. |
I'm closing this now because the approach I tried won't work for various reasons (see my comments above). Let's re-think this and implement it properly. |
Opened an issue so we don’t forget about this! #3216 |
For NC11 we want to finally implement undo file deletion. Since this is a generic software pattern, I'd like to implement it in a reusable undo-handler that can later be used by Nextcloud apps too (e.g. we want to have a fake-undo for sending messages in Mail).
This PR is based on the command pattern, where the handler holds reference of a single command at a time. As soon as another command is added, we execute the previous one. That means that the commands are actually executed deferred, but I'm not yet sure if that is the preferred way for all actions we want to have an undo. Maybe some can be executed immediately, then we could add an option to the command. The current design should be flexible enough to work with both.
@nextcloud/javascript let me know what you think.
TODO:
onpageunload
event onwindow
and execute the command if one is set