Skip to content

Public API for Group Level Reordering Issues

Problem to solve

Our REST API currently supports re-ordering issues within a project. This makes all the group users that want to re-order issues across many projects via public APIs very sad.

Proposal

Provide a public API for re-ordering issues globally across all subgroups and projects.

Context

Relevant code here is in https://gitlab.com/gitlab-org/gitlab/blob/e0d317ca8d7ba39e92fc7f89387055be087e0bae/app/services/issues/update_service.rb#L157:

issue =
  if board_group_id
    IssuesFinder.new(current_user, group_id: board_group_id, include_subgroups: true).find_by(id: id)
  else
    project.issues.find(id)
  end

We actually already accept global issue IDs in the API (not iids). The problem is that when we query, we scope it to the project if a group_id is not provided.

When ordering issues in an issue board, we pass in a group_id to the update service. We could do the same if we create a group-level reorder issues API endpoint.

Implementation Approach

Change project issue reordering API so that it accepts issues from another group.

We already accept an issue ID (not IID) for move_before_id and move_after_id in this API so the only thing that would change would be how we find the issue and our validations. We just need to validate that the before / after issues are part of the same scope for ordering.

Note that there's a tricky bug here similar to #13254 (closed). We use Issue#parent_ids for determining ordering scope and right now we scope it to the project's parent group when a group board is present. But this is not taking into account that there may be ancestor group boards that may also contain this issue.

So I'm not sure if we should limit this to parent group issues, or allow all group hierarchy issues and maybe just fix this other bug too.

Acceptance

  • Public API for global issue re-order across all subgroups and projects within a given top level group.
  • Expose relative_position attribute in the issue JSON API responses (#21297 (comment 372766565))
Edited by Gabe Weaver