Add an explicit license check for merge train conditionals in `ready_to_merge`

Summary

In the ready_to_merge widget and mixins, we have a check that is implicitly checking the user license, but nothing explicit. Example:

if (this.mr.preferredAutoMergeStrategy === MTWPS_MERGE_STRATEGY)

This condition can only be true if the user turned the merge train on in the settings and so we know implicitly that the user has the right tier access.

Comment about how to proceed from @sstern:

We can draw our attention to ee/app/models/license.rb and see that merge_trains are in EEP. So well need to check if Premium is available to show this component. Pushing this to the frontend using project.feature_available?(:merge_trains), then we can access this in this.glFeatures on the FE. For example, look at how we handle ee/app/controllers/concerns/ee/boards_actions.rb in #push_wip_limits

Improvements

It would be better to have a condition that is explicit for all of these so that:

  • It's easier to read
  • Feel safer to modify as we can see the tier it's behind
  • If a bug ever occurred in the settings section, it would not affect the widget itself.

Risks

Make sure Merge train still work for Premium/Silver and Ultimate only.

Involved components

ee/app/assets/javascripts/vue_merge_request_widget/mixins/ready_to_merge.js app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue

Edited by Frédéric Caplette