Cleanup the SidebarsHelper#super_sidebar_context method

The following discussion from !123554 (merged) should be addressed:

  • @thutterer started a discussion: (+1 comment)

    thought: I think at some point (definitely not in this MR, but eventually) we should split this evergrowing dataset in this super_sidebar_context into two parts: one that potentially changes with every page, and one that is always the same, like this line here. And for the later part, find a better way to hand this information to the frontend. There is really no need to send this over the wire on every page load.


In app/helpers/sidebars_helper.rb, the SidebarsHelper#super_sidebar_context method is responsible for building the data hash that's being passed to the super sidebar component. Over time, this method has become unreasonably large. We've had to disable the Metrics/AbcSize cop already.

Also, many of the properties are the same regardless of the context, we might be able to pass them in a more efficient way to the client.

Finally, app/views/layouts/_page.html.haml is the view that actually calls that method and provides its output to the DOM element via the dataset API. For some reason, we are passing addition data- attributes though. It's not clear what differentiates direct data- attributes from the super_sidebar_context hash. We may be able to cleanup the HAML view to consolidate all the attributes in the same method(s).