att / rcloud

Collaborative data analysis and visualization
http://rcloud.social
MIT License
432 stars 142 forks source link

notebook trash can / recycle bin #789

Open gordonwoodhull opened 10 years ago

gordonwoodhull commented 10 years ago

Some people are scared they will accidentally delete notebooks. Other people hate having to go through a confirmation dialog.

The established compromise is a trash can or recycle bin. (Maybe not so important but it's the kind of polish that helps people feel safe in a strange new world.)

I guess the Trash folder should have its own root entry in the notebook tree, with a cute icon of some sort. It is by user of course. When notebooks get removed they go to this folder instead of being immediately deleted. They can be restored back to their original place in the tree, or the Trash can be emptied.

There should not be subfolders in the Trash. Everything lands there at the same level, and if there are naming conflicts, so be it.

I can think of two approaches:

  1. Store the old folder somewhere in RCS (keyed on the notebook id) so that we know where to restore it.
  2. Have a special deleted bit which means the folder will be ignored and the notebook will only show up in the Trash folder.

I think the first approach might be simpler.

gordonwoodhull commented 9 years ago

I can think of an even easier approach: simply prepend trash/ to the name, and then add the special cases so that the trash folder is not shown in the regular folders, and is shown at the top level.

However, now we run into the inconsistency of having trash be top-level when My Notebooks is not #1081

holyguster commented 9 years ago

For notebooks in the Trash folder, the trashcan icon for deleting would be replaced by some other icon and an "undelete" function?

gordonwoodhull commented 9 years ago

Right, it should work pretty much like the trash can in Windows or OSX.

(Except that even when the trash can is emptied, the notebooks are still on GitHub. We could consider adding a stronger command Empty and Delete from GitHub/Repo, with a key modifier, but that's a separate issue.)

gordonwoodhull commented 9 years ago

I guess it's an open question whether there are subfolders in the trash can: when I first filed this, I thought no, but now I'm thinking you might want to restore a folder.

gordonwoodhull commented 9 years ago

@sujitbehera27, this one is particularly tricky, so don't get hung up if you can't solve it.

The notebook tree code is some of the earliest RCloud code, and it got really tangled because it went through rapid growth last year. I think I have cleaned it up a lot but don't feel bad if you have to give this back to me. (Same with #522.)

gordonwoodhull commented 9 years ago

If there are not subfolders, then the display problem becomes very similar to #522 sorting user's notebooks by date, because the folders go away and notebooks are displayed with their full path.

sujitbehera27 commented 9 years ago

@gordonwoodhull : Am thinking of below design. Please let me know if its ok.

Behaviour: 1>There will be a small trash can ikon with label as "Deleted Notebooks" at the root level as "Notebooks I starred". 2> It will not have any folder structure and shown plat at same level. 2>On click of that it will show all the notebooks which have been deleted. Questions : What should we show in the notebook-right section? I think we should show only last updated date , restore icon and permanently delete icon. On click of which it will restore the notebook to its respective folder. On click of permanently delete of that NB we will call our current delete function and delete it from RCS. There will be a small ikon for clearing the entire trashcan just after "Deleted Notebooks" label at root level. On click of this we will delete all the notebooks in the deleted folder.

Design : Currently we are removing the notebook from RCS using the current delete function. We will use this function to clear items from trashcan. We will have another function with will tag that notebook as "deleted" in RCS as explained below.

For non starred notebooks ("sujitbehera27/system/config/notebooks/" ) we will store deleted notebooks(update RCS) as "sujitbehera27/system/config/deleted/notebooks/" and for my_starrednotebooks .notebook//stars/sujitbehera27" will go to .notebook/_/deleted/stars/sujitbehera27

Now In order to populate the notebooks in the trashcan we will define two functions "rcloud.config.get.deleted.notebooks" & "rcloud.config.get.deleted.starred.notebooks" to get all deleted notebooks starred and unstarred.

On restoration from trascan For unstarred : "sujitbehera27/system/config/deleted/notebooks/" will go to "sujitbehera27/system/config/notebooks/" For starred: ".notebook//deleted/stars/sujitbehera27" will go to ".notebook//stars/sujitbehera27"

For properties restoration. For restoring path currently we are deleting the ".notebook/da4f9138f18cbb4deaa8/description" from the notebooks on click of delete But we will not delete it from RCS as this can help us to restore the folder structure. Rest all properties like starcount,visibility,last_commit etc are anyways retained.

A.The state of metadata in rcs is as below : 1) ".notebook/da4f9138f18cbb4deaa8/username" 2) ".notebook/da4f9138f18cbb4deaa8/description" 3) ".notebook/da4f9138f18cbb4deaa8/last_commit" 4) ".notebook/da4f9138f18cbb4deaa8/stars/sujitbehera27" 5) ".notebook/da4f9138f18cbb4deaa8/visible" 6) ".notebook/da4f9138f18cbb4deaa8/starcount" 7) "sujitbehera27/system/config/notebooks/da4f9138f18cbb4deaa8" 8) "sujitbehera27/system/config/recent/da4f9138f18cbb4deaa8"

B.State after delete(current delete) 1) ".notebook/da4f9138f18cbb4deaa8/username" 2) ".notebook/da4f9138f18cbb4deaa8/description" 3) ".notebook/da4f9138f18cbb4deaa8/last_commit" 4) ".notebook/da4f9138f18cbb4deaa8/visible" 5) ".notebook/da4f9138f18cbb4deaa8/starcount"

C.With the above design it will look something like this: 1) ".notebook/da4f9138f18cbb4deaa8/username" 2) ".notebook/da4f9138f18cbb4deaa8/description" 3) ".notebook/da4f9138f18cbb4deaa8/last_commit" 4) ".notebook/da4f9138f18cbb4deaa8/deleted/stars/sujitbehera27" 5) ".notebook/da4f9138f18cbb4deaa8/visible" 6) ".notebook/da4f9138f18cbb4deaa8/starcount" 7) "sujitbehera27/system/config/deleted/notebooks/da4f9138f18cbb4deaa8"

To summarize on delete of notebooks State A will go to State C and on permanent delete of notebooks from trashcan State C will go to State B.

gordonwoodhull commented 9 years ago

As we discussed, I think it will be simpler to just rename the notebooks into trash/, if that is possible.

This will not require any additional RCS keys, because the notebook will still be owned by the user, and starred if it was starred before.

Then, emptying the trash (or permanently deleting a single notebook) will execute deletions as is done now.

sujitbehera27 commented 9 years ago

Sure I am in mid of another issue after finishing that I will reanalyze it based on the comment and option 3.

gordonwoodhull commented 9 years ago

We could consider having "empty trash" delete on github... or have multiple levels of delete, sort of similar to OSX Secure Empty Trash and the like. Not sure how you would wipe notebooks that have been deleted but not really deleted.