Refactor MR FE components to rely on DiffViewer instead of DiffFile
During the call between ~Create BE and FE of January 4th, we've reached the conclusion that this work would be beneficial to reduce inconsistencies but also to prepare the ground for upcoming refactors (like the Compare and Commit views).
@DouweM outlined it very well, quoting his notes from the meeting doc:
- Douwe: On the backend, we have a Diff::File, and a DiffViewer. The viewer is effectively a “presenter” around the relatively low level underlying file. It contains logic to determine how the diff should be rendered, size limits, rendering errors, etc.
- Right now, the frontend mostly uses properties of Diff::File, and reimplements some of the logic that we already have on the DiffViewer, in ways that are not always consistent or correct.
- We can fix a few bugs, and prevent some future ones, by having the frontend reuse as much of the DiffViewer as possible.
- Specifically, of the properties currently exposed on the DiffFile entity, the frontend should not need to use: (these can be removed from the entity)
- collapsed
- too_large
- empty
- text
- stored_externally
- external_storage
- new_file
- renamed_file
- deleted_file
- mode_changed
- Instead, it should be able to get everything it needs from these properties of the DiffViewer entity (
diff_file.viewer) (some of these need to be added to the entity):
- name
- Can be:
- not_diffable
- no_preview
- added
- deleted
- renamed
- mode_changed
- text
- image
- Replaces new_file, renamed_file, deleted_file, mode_changed, empty, text
- render_error
- Already added in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23812!
- render_error_message
- Replaces too_large, stored_externally, external_storage
- collapsed
- Replaces collapsed
Edited by André Luís