Commit 73e6ba44 authored by Camil Staps's avatar Camil Staps

Address reviewer comments

parent 1289efcc
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class StarredProjectsFinder < ProjectsFinder class StarredProjectsFinder < ProjectsFinder
def initialize(user, params: {}, current_user: nil) def initialize(user, params: {}, current_user: nil)
project_ids = user.starred_projects.select(:id) project_ids = user.starred_projects.select(:id)
super(params: params, current_user: current_user, project_ids_relation: project_ids) super(params: params, current_user: current_user, project_ids_relation: project_ids)
end end
end end
...@@ -475,21 +475,27 @@ GET /users/:user_id/starred_projects ...@@ -475,21 +475,27 @@ GET /users/:user_id/starred_projects
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `user_id` | string | yes | The ID or username of the user | | `user_id` | string | yes | The ID or username of the user. |
| `archived` | boolean | no | Limit by archived status | | `archived` | boolean | no | Limit by archived status. |
| `visibility` | string | no | Limit by visibility `public`, `internal`, or `private` | | `visibility` | string | no | Limit by visibility `public`, `internal`, or `private`. |
| `order_by` | string | no | Return projects ordered by `id`, `name`, `path`, `created_at`, `updated_at`, or `last_activity_at` fields. Default is `created_at` | | `order_by` | string | no | Return projects ordered by `id`, `name`, `path`, `created_at`, `updated_at`, or `last_activity_at` fields. Default is `created_at`. |
| `sort` | string | no | Return projects sorted in `asc` or `desc` order. Default is `desc` | | `sort` | string | no | Return projects sorted in `asc` or `desc` order. Default is `desc`. |
| `search` | string | no | Return list of projects matching the search criteria | | `search` | string | no | Return list of projects matching the search criteria. |
| `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned. | | `simple` | boolean | no | Return only limited fields for each project. This is a no-op without authentication as then _only_ simple fields are returned.. |
| `owned` | boolean | no | Limit by projects explicitly owned by the current user | | `owned` | boolean | no | Limit by projects explicitly owned by the current user. |
| `membership` | boolean | no | Limit by projects that the current user is a member of | | `membership` | boolean | no | Limit by projects that the current user is a member of. |
| `starred` | boolean | no | Limit by projects starred by the current user | | `starred` | boolean | no | Limit by projects starred by the current user. |
| `statistics` | boolean | no | Include project statistics | | `statistics` | boolean | no | Include project statistics. |
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) | | `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only). |
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature | | `with_issues_enabled` | boolean | no | Limit by enabled issues feature. |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature | | `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature. |
| `min_access_level` | integer | no | Limit by current user minimal [access level](members.md) | | `min_access_level` | integer | no | Limit by current user minimal [access level](members.md). |
```bash
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/5/starred_projects"
```
Example response:
```json ```json
[ [
...@@ -1339,7 +1345,7 @@ Example response: ...@@ -1339,7 +1345,7 @@ Example response:
## List Starrers of a project ## List Starrers of a project
List the users who starred the the specified project List the users who starred the specified project.
``` ```
GET /projects/:id/starrers GET /projects/:id/starrers
...@@ -1347,7 +1353,7 @@ GET /projects/:id/starrers ...@@ -1347,7 +1353,7 @@ GET /projects/:id/starrers
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `search` | string | no | Search for specific users | | `search` | string | no | Search for specific users. |
```bash ```bash
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/starrers" curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/starrers"
......
...@@ -8543,6 +8543,12 @@ msgstr "" ...@@ -8543,6 +8543,12 @@ msgstr ""
msgid "ProjectOverview|Star" msgid "ProjectOverview|Star"
msgstr "" msgstr ""
msgid "ProjectOverview|Starrer"
msgstr ""
msgid "ProjectOverview|Starrers"
msgstr ""
msgid "ProjectOverview|Unstar" msgid "ProjectOverview|Unstar"
msgstr "" msgstr ""
...@@ -10286,6 +10292,9 @@ msgstr "" ...@@ -10286,6 +10292,9 @@ msgstr ""
msgid "SortOptions|Recent sign in" msgid "SortOptions|Recent sign in"
msgstr "" msgstr ""
msgid "SortOptions|Recently starred"
msgstr ""
msgid "SortOptions|Sort direction" msgid "SortOptions|Sort direction"
msgstr "" msgstr ""
...@@ -10379,6 +10388,9 @@ msgstr "" ...@@ -10379,6 +10388,9 @@ msgstr ""
msgid "StarredProjectsEmptyState|You don't have starred projects yet." msgid "StarredProjectsEmptyState|You don't have starred projects yet."
msgstr "" msgstr ""
msgid "Starrers"
msgstr ""
msgid "Stars" msgid "Stars"
msgstr "" msgstr ""
...@@ -12221,6 +12233,9 @@ msgstr "" ...@@ -12221,6 +12233,9 @@ msgstr ""
msgid "UserProfile|Snippets in GitLab can either be private, internal, or public." msgid "UserProfile|Snippets in GitLab can either be private, internal, or public."
msgstr "" msgstr ""
msgid "UserProfile|Starred projects"
msgstr ""
msgid "UserProfile|Subscribe" msgid "UserProfile|Subscribe"
msgstr "" msgstr ""
......
...@@ -844,7 +844,7 @@ describe API::Projects do ...@@ -844,7 +844,7 @@ describe API::Projects do
end end
it 'returns error when user not found' do it 'returns error when user not found' do
get api('/users/9999/projects/') get api('/users/9999/starred_projects/')
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
expect(json_response['message']).to eq('404 User Not Found') expect(json_response['message']).to eq('404 User Not Found')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment