[IMPLEMENTED] Easy to accidentally delete an asset folder with assets in it

I have…

  • [x] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

When paging through assets, if I move assets to another folder resulting in no more assets displayed on that page, it is not obvious that a folder is not empty. We accidentally deleted a folder full of assets for our website because we clicked to the parent, then deleted the folder we thought was empty.

Expected behavior

Ideally if the final asset in a folder is moved or deleted, the current page would be set to (currentPage - 1) if the currentPage is > 0. Or, a message should be displayed letting the user know they are on a page of assets so they should click to a previous page.

Another option would be to soft-delete assets. This would be a huge help because you could go to another location to confirm the final deletion of an asset or assets. Recycle bin type functionality.

It could also be good to show the total number of assets in a folder after the folder name (e.g. “Folder Name (34)”)

Minimal reproduction of the problem

  1. Go to an assets folder with > 50 assets (or greater than the page count selected)
  2. Click the arrow in the bottom right corner to go to page 2.
  3. Delete or move all the images on page 2.
  4. NOTE: It appears that no more images are in the folder because it’s difficult to notice that you’re on page 2 and not page 1. Nothing obvious tells you there are still images in your folder.
  5. Click
  6. Delete folder
  7. Oops, all the assets in page 1 are gone and it was easy to miss that there were still images in the folder.

Environment

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [x] Cloud version

Version: [VERSION]

Browser:

  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:
Maybe if the delete message reminded you of the folder count and made you double confirm the delete. That’s another idea.

I changed it to a feature request because it is not an unexpected behavior and I have this “fix it immediately” policy for bugs.

  1. Move to previous page if current page is empty => Makes sense and will be implemented.
  2. Show number of assets per folder => Potential performance issue, but very likely not.
  3. Soft delete assets => Is already the case, but there is no method to undelete them. I could make an endpoint for that as a first solution.
  4. Double confirm => Also a good idea, but a little bit tricky.
1 Like

How does soft delete on assets work? Is there a place to recover deleted folders of assets to more easily recover them or are the ids just reserved and available to links to old images don’t break? Help me understand what you mean, please.

At the moment from what Sebastian has said the only way to recover a soft-deleted asset is by modifying the record in the database, assuming it is similar to soft-deleted schemas it means going into the States_Assets2 collection, finding your deleted asset, and then setting the dl property to false instead of true.

Having said that you are on the cloud version so will not have access to the database, so I think only options are to either hope Sebastian manually recovers it on your behalf or wait for the endpoint to be added that allows API to recover soft deleted assets. You could be the first person to test it out!

Will there potentially be two endpoints, one to view all soft-deleted assets and another to recover one of them? Otherwise you’d need to remember the assets ID or something.

The endpoint should already be there and if not, it would work with the normal query system: $filter=isDeleted eq false. I think you can already do it, but I am not sure.

Thank you! The API call to get the deleted assets is:

https://cloud.squidex.io/api/apps/[site_name]/assets?top=500&$filter=isDeleted eq true

The API Docs don’t show an isDeleted parameter to update an asset, so I’m not sure how to do that. I haven’t tried it yet though.

Actually it does not work for assets yet. I will fix that soon.

I was wrong. it works totally fine and there is even an integration test for that. The flag is updated when you call delete, but there is no undelete endpoint yet.

I was just about to start with this feature and then I realized that it would be a second Create flow and would make everything complicated again. Therefore I will see what needs to be changed to get deleted asset content, so you recreate them with the same ID.

This has actually been implemented. I have just forgotten it.

2 Likes

This topic was automatically closed after 2 days. New replies are no longer allowed.