Deleting last file leaves empty package in UI

🔥 Problem

In #345755 (closed), we created a background job that process package files that are marked as pending_destruction.

The problem is if all package files are marked = the background job will remove all of them and leave the package object behind. That package object has no package files and can lead to a confusing UX :

Screenshot_2022-01-19_at_09.16.17

I will categorize this as a UX typebug

🚒 Solution

The most logical thing to do here is to check the package object at the end of the cleanup job.

If the package is empty, we can safely remove it.

Ideally, we should implement this when we introduce the first change that will mark package files as pending_destruction. This way, we will not have empty packages behind.

🌈 UX solution

🎨 See attached designs

Before After
Deleting last file leaves empty package in UI Deleting last file removes package and returns user to package registry page

Implementation plan

Edited by Rahul Chanila