Skip to content

Allow changing only the diffFiles in state without touching other state values

What does this MR do?

For #18140 (closed)

This MR adds a mutation that allows the MR Diffs app to change only the currently loaded Diff Files.

Why

Until now, we've never needed to change the loaded diff files on the fly in isolation from the MR.

In other words, we always loaded the entire MR (including metadata - for example to populate the file tree), and that naturally overwrote the loaded Diff Files. The only exception is batch and split diffs, which loads segments of diff files and merges them into the existing state.

Now, to support loading the same MR information, but one commit at a time, it would be convenient to be able to set only the Diff Files. The way we currently move commits is by reloading the whole page and changing the commit_id in the URL, which necessarily reloads the entire MR page and only loads the appropriate data.

Now that we're trying to add commit-by-commit navigation, we need to be able to clear the loaded Diff Files and replace them with a new set for the new commit; if we don't clear the files, the normal logic takes over and merges the existing diffs with the new diffs, resulting in duplicates of the same file in the UI.

In this situation, we don't need to reload the MR, we don't need to reload the file tree, etc. We just need to change which Diff Files are in state.


Currently, we don't have any mutations that set the Diff Files in isolation from the rest of state. This change adds just such a mutation.

Screenshots

NA, this change is ~backstage only.

Does this MR meet the acceptance criteria?

Conformity

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