Skip to content

Add "Previous" and "Next" buttons for commit-by-commit navigation

What does this MR do?

For #18140 (closed)

This MR adds two buttons to the (Diffs) Commit Item component. If a commit has a prev_commit_id, a Previous button is added to seamlessly navigate to the previous commit in the MR.
If the commit has a next_commit_id, a Next button is added.

These buttons trigger an action that updates the current commit SHA references in all of the data endpoints, and then requests the metadata again, which effectively overwrites the current state with the new state for the updated SHA.

Once the state has updated, a new watcher in the Diffs app responds to the commit in state changing, and triggers a reload of the Diff Files. Just before, the same watcher pushes a new state into the user's browser History, which updates the browser URL to the correct value.

Because we've added two keyboard shortcuts, this MR also updates the Keyboard Shortcuts Modal (see below) with the new Merge Request Commits section.

Screenshots

At first commit At middle commit At last commit At only commit
image image image (buttons are not displayed) image
Keyboard Shortcuts Help Modal
image

Does this MR meet the acceptance criteria?

Conformity

Documentation is in a separate MR. Unfortunately, I can't mark it as dependent on this MR.

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports