• Patrick Bajao's avatar
    Include inapplicable_reason in API response · 1f4d254e
    Patrick Bajao authored
    In order for frontend to display appropriate messages on why
    a suggestion can't be applied, it needs to know the reason.
    
    A new `inapplicable_reason` property is introduced and included in
    the API response to achieve that. It is based on the checks to
    determine whether a suggestion can be applied.
    
    The following reasons are:
    
    - "You don't have write access to the source branch." - when user
      has no write access to branch.
    - "This merge request was merged. To apply this suggestion, edit
      this file directly." - when MR was merged.
    - "This merge request is closed. To apply this suggestion, edit
      this file directly." - when MR is closed.
    - "Can't apply as the source branch was deleted." - when source
      branch is deleted.
    - "Can't apply as this line was changed in a more recent version."
      - when the line where suggestion is on is outdated.
    - "Can't apply as these lines were changed in a more recent
      version." - when lines where suggestion is on are outdated.
    - "This suggestion already matches its content." - when suggestion
      has the same content as the line it is on.
    - "Can't apply this suggestion." - default message when suggestion
      cannot be applied but doesn't fall into any of criteria above.
      We won't show this message anywhere right now but it makes sense
      to return something (e.g. when suggestion is already applied).
    1f4d254e
suggestion.rb 1.55 KB