Allow admins to list and restore projects pending delayed deletion

Merged Aishwarya Subramanian requested to merge list-removable-projects into master

Summary

This MR is a continuation of the original Community Contribution MR.

Most code is same as the original MR, except for few changes including moving code inside EE, spec addition and refinement.

What does this MR do?

This MR adds an ability for Admins to view Projects that are scheduled to be deleted (delayed deletion) in the Project Overview Dashboard.

The admins also have an option to restore any of the Projects scheduled to be deleted.

The Projects are listed until they are permanently deleted.

Since delayed deletion feature is available only for Premium or Silver or higher tiers, we display the list only if the license feature adjourned_deletion_for_projects_and_groups is available.

Mentions #24866 (closed)

Screenshots

Screen_Shot_2020-07-15_at_6.02.10_PM

Database Queries

Query:

SELECT
    "projects".*
FROM
    "projects"
WHERE (EXISTS (
        SELECT
            1
        FROM
            "project_authorizations"
        WHERE
            "project_authorizations"."user_id" = 506061
            AND (project_authorizations.project_id = projects.id))
        OR projects.visibility_level IN (0, 10, 20))
AND (marked_for_deletion_at <= '2020-07-21')
AND "projects"."pending_delete" = FALSE
ORDER BY
    "projects"."id" DESC

Plan:

https://explain.depesz.com/s/cOCU

Execution Time:

Time: 5.915 ms
  - planning: 0.950 ms
  - execution: 4.965 ms
    - I/O read: 0.181 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 1932 (~15.10 MiB) from the buffer pool
  - reads: 3 (~24.00 KiB) from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

#database-lab link: https://gitlab.slack.com/archives/CLJMDRD8C/p1595373968049600

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Dan Jensen