Use an event hub to coordinate all possible ways to expand all diff files
What does this MR do?
For #273475 (closed).
The current flow for expanding files (and expanding all files) is something like this:
- In some component, trigger a Vuex action
- In state, update the property on the file(s)
- In the file component, react to the property changing
- As a reaction, do all the behavior for loading a diff (with lots of exceptions)
This MR modifies this flow to "cut out the middle man." The new flow is like this:
- In some component, emit an event to the shared Diffs event hub
- In the Diff File component, listen for events telling it to expand
- Do all the behavior for loading a diff (with lots of exceptions)
The biggest immediate benefit is that there's only a single way to toggle the collapsed state of a Diff File, and it's in the diff file, rather than being spread around the codebase. This resolves some bugs around deviant expansion that isn't implemented the same way.
The next largest benefit is that we're not publishing a store update to every single store consumer when the diff files need to be expanded; we're only listening for that event in the components that know how to handle it (the diff files themselves).
Screenshots (strongly suggested)
N/A, file expansion works the same way, it's just being triggered differently.
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers - [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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