Fix validation in UI when updating a draft note in MR diff
What does this MR do and why?
- Resolves sub-task 4 of https://gitlab.com/gitlab-org/gitlab/-/issues/411329
- Changes the position of the error, so it's right above the invalid note instead of at the top of the page. And, it improves the error message.
- Related to !122849 (merged)
Screenshots or screen recordings
Before | After |
---|---|
before | after |
How to set up and validate locally
- Create a Merge Request with at least 1 file change and 1 image file added.
- Add a validator
DraftNote
class since we don't have a lot of validations for comments.
# Add it to class DraftNote < ApplicationRecord in models folder
validate :test_ui_validation, on: [:create, :update]
def test_ui_validation
if note.include? 'TEST_VALIDATION'
self.errors.add(:base, _('it failed validation'))
end
end
- Try to add comment
TEST_VALIDATION
in theChanges
section and click onStart a review
orAdd to review
.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #411329
Edited by Hinam Mehra