Skip to content

Add the API-provided sort order to Diff files when they are ingested into Vuex

Thomas Randolph requested to merge tor/defect/add-sort-order-to-diff-files into master

For #344133 (closed)

Context

We have issues knowing exactly what file is "next" (or "previous", for that matter) when processing through Diff files.

In a typical scenario, we'd be able to rely on the implicit sorting of the diff files OR on a manual sort (e.g. by sorting them based on filename).

There are multiple confounding factors, however:

  1. The Diff files (as rendered) are not the ultimate source of truth for files. One example is when moving through Discussions: each discussion has its own copy of a Diff file attached, rather than pointing to a canonical UUID of a file. This removes the Discussion (and its file) from the implicit sort order.
  2. Manually sorting the files requires substantial effort. The way the API returns the files does not appear to be based solely on - for example - file name. It's likely that the front end could implement the same sort, but that would require maintenance to stay in sync.

Changes

Instead of anything complicated like

(either of which would make a single source of authoritative truth much simpler)

...this MR adds a single value to each Diff file that represents its own position in the array of Diff files that the API returned to the front end. This value should not be updated ever by the front end, which should make it a reliable source of sorting information.

Roadmap

This is part of a multi-stage effort to standardize the sort order of Diff files.

MR Description
We're here! 👉🏻 This change stores the order as received from the API on each Diff file before it's processed and - eventually - placed in the local store.
!85536 (merged) This future change will swap the processing of files when progressing through unresolved discussions to use the API-provided sort order, since that's the order files are displayed in the UI.
?? This future change will add more nuance to the progression through unresolved discussions by handling certain cases that aren't currently handled, like when a file is collapsed because it's too big (but has had a comment attached to it anyway!), or if a file is manually collapsed (and so the comment is not visible).
Edited by Thomas Randolph

Merge request reports