diff --git a/CHANGELOG b/CHANGELOG index 207ddf1dd64f4f8730454e3fa8c6f8194830827f..5bccb80a64d46e7317b815b7409bec0608c6d52d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.5.0 (unreleased) + - Add "public" flag to GET /projects api endpoint v 8.4.0 (unreleased) - Ensure Gravatar host looks like an actual host diff --git a/doc/api/projects.md b/doc/api/projects.md index 241229221db2d8de459a0af4739eb8ef8fb92c15..29ed327d983de68c7971b88a69a52c9dc661d135 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -29,6 +29,7 @@ GET /projects Parameters: - `archived` (optional) - if passed, limit by archived status +- `public` (optional) - if passed, limit by public visibility - `order_by` (optional) - Return requests ordered by `id`, `name`, `path`, `created_at`, `updated_at` or `last_activity_at` fields. Default is `created_at` - `sort` (optional) - Return requests sorted in `asc` or `desc` order. Default is `desc` - `search` (optional) - Return list of authorized projects according to a search criteria diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 6d2380cf47dd4b3c7a4933153eda7585106fa061..68d0aa671b6e4a9c66b5f1cef47562010a44ed1b 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -264,6 +264,10 @@ module API projects = projects.search(params[:search]) end + if params[:public].present? && parse_boolean(params[:public]) + projects = projects.public_only + end + projects.reorder(project_order_by => project_sort) end