Frontend API utility - getMemberRoles function for access dropdown
## Context
| | |
|---|---|
| **Phase** | 4 of 6 |
| **Parallel with** | https://gitlab.com/gitlab-org/gitlab/-/work_items/594886+ |
| **Blocked by** | https://gitlab.com/gitlab-org/gitlab/-/work_items/594880+ <br> https://gitlab.com/gitlab-org/gitlab/-/work_items/594881+ <br> https://gitlab.com/gitlab-org/gitlab/-/work_items/594882+ <br> https://gitlab.com/gitlab-org/gitlab/-/work_items/594883+ <br> https://gitlab.com/gitlab-org/gitlab/-/work_items/594884+ |
| **Unblocks** | https://gitlab.com/gitlab-org/gitlab/-/work_items/594887+ <br> https://gitlab.com/gitlab-org/gitlab/-/work_items/594888+ <br> https://gitlab.com/gitlab-org/gitlab/-/work_items/594890+ |
## Summary
Add a `getMemberRoles` API utility function to the project settings access dropdown API module so that the frontend can fetch the list of custom roles available for a namespace.
## Background
The project settings access dropdown fetches roles, users, groups, and deploy keys via dedicated API functions in `app/assets/javascripts/projects/settings/api/access_dropdown_api.js`. A new function is needed to fetch custom roles (member roles) for the project's root namespace.
The existing `GET /groups/:id/member_roles` REST API endpoint (in `ee/lib/api/member_roles.rb`) returns all custom roles for a group and is the correct endpoint to use. This is an EE-only feature, so the function should live in an EE counterpart file.
## Relevant files
- `app/assets/javascripts/projects/settings/api/access_dropdown_api.js` — CE API functions (reference)
- `ee/lib/api/member_roles.rb` — existing `GET /groups/:id/member_roles` endpoint
## Changes required
### New file: `ee/app/assets/javascripts/projects/settings/api/access_dropdown_api.js`
```javascript
import axios from '~/lib/utils/axios_utils';
import { buildUrl } from '~/projects/settings/api/access_dropdown_api';
export const getMemberRoles = (namespaceId) => {
return axios.get(buildUrl(gon.relative_url_root || '', `/api/v4/groups/${namespaceId}/member_roles`));
};
```
Note: `buildUrl` is exported from the CE file — import it from there. The namespace ID should be passed in from `gon.current_group_id` or a prop on the access dropdown component (to be wired up in Issue 13).
## Response shape
The endpoint returns an array of member role objects:
```json
[
{
"id": 42,
"name": "Lead Developer",
"base_access_level": 30,
"description": "Senior developers with merge rights"
}
]
```
## Testing
- Jest unit test: `getMemberRoles(123)` calls the correct URL
- Jest unit test: handles API errors gracefully
- Mock the axios call; do not make real HTTP requests in unit tests
## Dependencies
- The `GET /groups/:id/member_roles` endpoint already exists — no backend changes needed for this issue
- Issue 12 (frontend constants) can be done in parallel
## Labels
issue