Skip to content

Migrate badge form to `GlFormFields`

What does this MR do and why?

Related to #435579 (closed)

Taking over a Community contribution that was not able to be finished - !139997 (closed)

I went down a few rabbit holes on this one and after going back and forth between implementations multiple times this is what I settled on. The previous version of validation didn't play very nicely with GlFormGroup which is why I ended up switching to GlFormFields for frontend validation. There were also a couple other bugs and technical debit that this MR fixes:

  1. When editing a badge the modal would close even if there were validation errors
  2. There was inModal prop that was not needed because we have isEditing prop. This form is only used in a modal when editing so we know it is in a modal when in edit mode. Guessing at one point it was used other places but that is not the case anymore.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Group new badge

Before After
Screenshot_2024-08-09_at_2.33.47_PM Screenshot_2024-08-12_at_4.23.33_PM

Required fields

Before After
Screenshot_2024-08-09_at_2.14.04_PM Screenshot_2024-08-12_at_4.23.48_PM

Invalid fields

Before After
Screenshot_2024-08-09_at_2.14.04_PM Screenshot_2024-08-12_at_4.24.37_PM

Group edit badge

Before After
Screen_Recording_2024-08-09_at_2.15.18_PM Screen_Recording_2024-08-09_at_2.10.17_PM

Project new badge

Before After
Screenshot_2024-08-09_at_2.19.52_PM Screenshot_2024-08-12_at_4.25.54_PM

Required fields

Before After
Screenshot_2024-08-09_at_2.20.18_PM Screenshot_2024-08-12_at_4.26.08_PM

Invalid fields

Before After
Screenshot_2024-08-09_at_2.20.18_PM Screenshot_2024-08-12_at_4.26.36_PM

Project edit badge

Before After
Screen_Recording_2024-08-09_at_2.21.13_PM Screen_Recording_2024-08-09_at_2.12.29_PM

How to set up and validate locally

  1. Go to a group or project -> Settings -> General -> Badges
  2. Click Add new badge
  3. You can use something like http://gdk.test:3000/jashkenas/Underscore/badges/%{default_branch}/pipeline.svg for the Badge image URL field. Link can be a URL to anywhere (doesn't really matter for testing) and Name can be anything.
Edited by Peter Hegman

Merge request reports

Loading