Skip to content

Add `include_hidden`, `include_pending_delete` option to Project API

What does this MR do and why?

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/430064

Problem

It's not possible to request projects in pending_delete or hidden state via Projects API.

Solution

Add two optional disabled by default parameters include_hidden and include_pending_delete to Projects API.

They can be set only by the admin.

Screenshots or screen recordings

Before

Screenshot_2023-11-02_at_10.29.15

After

Screenshot_2023-11-02_at_10.28.50

How to set up and validate locally

To verify hidden state

  1. Open Rails console
  2. Temporary mark last project as hidden Project.last.update(hidden: true)
  3. Go to project list (http://127.0.0.1:3000/api/v4/projects)
  4. The project should be missing in the list
  5. Visit page http://127.0.0.1:3000/api/v4/projects?include_hidden=true as an admin
  6. You should see a hidden project
  7. Visit page http://127.0.0.1:3000/api/v4/projects?include_hidden=true as a regular user
  8. You shouldn't see a hidden project
  9. Remove hidden state from the project Project.last.update(hidden: false)

To verify pending delete state

  1. Open Rails console
  2. Temporary mark last project as pending delete Project.last.update(pending_delete: true)
  3. Go to project list (http://127.0.0.1:3000/api/v4/projects)
  4. The project should be missing in the list
  5. Visit page http://127.0.0.1:3000/api/v4/projects?include_pending_delete=true as an admin
  6. You should see a pending delete project
  7. Visit page http://127.0.0.1:3000/api/v4/projects?include_pending_delete=true as a regular user
  8. You shouldn't see a pending delete project
  9. Remove pending delete state from the project Project.last.update(pending_delete: false)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Vasilii Iakliushin

Merge request reports