After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 661599 - Undo-able deletion of documents and collections
Undo-able deletion of documents and collections
Status: RESOLVED FIXED
Product: gnome-documents
Classification: Core
Component: general
0.2.x
Other All
: Normal enhancement
: ---
Assigned To: GNOME documents maintainer(s)
GNOME documents maintainer(s)
ready
: 760555 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-10-12 21:49 UTC by Cosimo Cecchi
Modified: 2016-01-13 15:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
documents: Let everybody provide their own trash implementation (1.88 KB, patch)
2014-07-30 16:23 UTC, Debarshi Ray
committed Details | Review
notifications: Add DeleteNotification (4.49 KB, patch)
2014-08-11 12:55 UTC, Debarshi Ray
reviewed Details | Review
notifications: Add DeleteNotification (4.47 KB, patch)
2014-08-12 08:01 UTC, Debarshi Ray
committed Details | Review

Description Cosimo Cecchi 2011-10-12 21:49:17 UTC
We should be able to delete a document.
This opens up a bit of a can of worms, since we don't probably want to expose a Trash item in the UI.
An in-app notification could probably be used, offering an Undo option there instead.
Comment 1 Cosimo Cecchi 2011-11-23 19:37:46 UTC
This is implemented for local collections now, but it's still missing a way to undo.
Comment 2 martin_ziel 2013-06-11 09:52:54 UTC
I implemented a trash function for local documents, but without any undo functionality whatsoever. Is this a requirement? Otherwise I'd create a patch for this.
Comment 3 Cosimo Cecchi 2013-06-12 05:21:24 UTC
I think an undo functionality in a little infobar/banner would be good to have for this; feel free to create and attach a patch though even if you don't plan to implement that though, it can be useful to others to iterate on top of.
Comment 4 Allan Day 2014-03-28 13:26:58 UTC
Current state for this bug:

 * Delete works for locally created collections. Not for cloud-stored collections.
 * Delete does not work for documents.
 * Deletion of locally created collections is not undoable.

Changes that we want:

 * Deletion for local documents.
 * Undo for deleting documents and local collections (this should work similar to the behaviour in Contacts or Boxes).
Comment 5 Pranav Kant 2014-07-07 20:46:46 UTC
Do we want to still trash the items or delete (Shift + Delete) the items ?
Comment 6 Debarshi Ray 2014-07-08 08:56:30 UTC
After talking to jimmac, we don't want to involve the trash at all. Atleast not for the moment. The idea is that people rarely go there looking for something that they accidentally deleted two days ago.

When a user deletes, we should hide it from the view and let the action be undone in the next N seconds. If I recall correctly N == 10 in Boxes. If not undone, then it would be gone for ever.
Comment 7 Debarshi Ray 2014-07-30 16:23:16 UTC
Created attachment 282092 [details] [review]
documents: Let everybody provide their own trash implementation
Comment 8 Cosimo Cecchi 2014-07-30 21:57:33 UTC
Review of attachment 282092 [details] [review]:

::: src/documents.js
@@ +377,3 @@
+
+        let job = new DeleteItemJob(this.id);
+        job.run(null);

I'm a bit confused by this part... Shouldn't it go inside the if (collection) switch in LocalDocument's trashImpl override?
Comment 9 Debarshi Ray 2014-08-11 12:55:09 UTC
Created attachment 283095 [details] [review]
notifications: Add DeleteNotification
Comment 10 Debarshi Ray 2014-08-11 13:03:47 UTC
(In reply to comment #8)
> Review of attachment 282092 [details] [review]:
> 
> ::: src/documents.js
> @@ +377,3 @@
> +
> +        let job = new DeleteItemJob(this.id);
> +        job.run(null);
> 
> I'm a bit confused by this part... Shouldn't it go inside the if (collection)
> switch in LocalDocument's trashImpl override?

I wanted to minimize the amount of code in trashImpl because it will be implemented every subclass.

Strictly speaking there is no need to run DeleteItemJob for local documents because tracker will notice that the file was removed from the filesystem and update itself, but there is no harm in running it either. This way, every subclass that offers trashImpl won't have to bother about DeleteItemJob.
Comment 11 Debarshi Ray 2014-08-11 13:05:40 UTC
By the way, the "undo" button is too tall at the moment. Since the button in Boxes is affected in the same way, I am trying to figure out whether this really needs fixing or it is a theme issue.
Comment 12 Debarshi Ray 2014-08-11 21:46:05 UTC
(In reply to comment #11)
> By the way, the "undo" button is too tall at the moment. Since the button in
> Boxes is affected in the same way, I am trying to figure out whether this
> really needs fixing or it is a theme issue.

Filed as bug 734614
Comment 13 Cosimo Cecchi 2014-08-11 22:24:47 UTC
Review of attachment 282092 [details] [review]:

OK then, thanks for the explanation.
Comment 14 Cosimo Cecchi 2014-08-11 22:29:23 UTC
Review of attachment 283095 [details] [review]:

Two stylistic comments here, looks good otherwise.

::: src/notifications.js
@@ +95,3 @@
+
+    _destroy: function() {
+            }));

I would move this in the undo callback for clarity.

::: src/selections.js
@@ +904,3 @@
             function(urn) {
                 let doc = Application.documentManager.getItemById(urn);
+                docs.push(doc);

You could here call removeItem at the same time, to avoid iterating over the array twice.
Comment 15 Debarshi Ray 2014-08-12 00:21:19 UTC
(In reply to comment #14)
> Review of attachment 283095 [details] [review]:

Thanks for the review, Cosimo.

> ::: src/selections.js
> @@ +904,3 @@
>              function(urn) {
>                  let doc = Application.documentManager.getItemById(urn);
> +                docs.push(doc);
> 
> You could here call removeItem at the same time, to avoid iterating over the
> array twice.

The thing is that removing items from DocumentManager results in the selection array inside SelectionsController being modified. I was not sure if the selection is returned as a deep copy or is a reference to the one in SelectionsController. If it is a reference then removing the documents while iterating over the selection could be a problem.
Comment 16 Cosimo Cecchi 2014-08-12 00:37:45 UTC
(In reply to comment #15)

> The thing is that removing items from DocumentManager results in the selection
> array inside SelectionsController being modified. I was not sure if the
> selection is returned as a deep copy or is a reference to the one in
> SelectionsController. If it is a reference then removing the documents while
> iterating over the selection could be a problem.

Ah, makes sense then; feel free to push the patch with the other stylistic comment addressed.
Comment 17 Debarshi Ray 2014-08-12 08:01:01 UTC
Created attachment 283164 [details] [review]
notifications: Add DeleteNotification

Move _destroy into the callbacks.
Comment 18 Debarshi Ray 2016-01-13 15:26:37 UTC
*** Bug 760555 has been marked as a duplicate of this bug. ***