Skip to content

Add GitLab UI form builder and custom checkbox field

Peter Hegman requested to merge peterhegman/gitlab-ui-checkbox-haml-partial into master

📖 What does this MR do?

This MR adds a custom rails form builder for GitLab UI form fields (checkboxes, radio buttons, etc). This pattern allows us to reduce the amount of markup we write for each field and keep the markup consistent. Currently this MR only adds a custom field for checkboxes but this pattern could be extended to add fields for radio buttons and other GitLab UI components. To demonstrate how this custom rails form builder works this MR updates a setting in "Group" -> "Settings" -> "Permissions, LFS, 2FA"

🤔 How to use?

  1. In HAML change form_for to gitlab_ui_form_for
  2. Change f.check_box to f.gitlab_ui_checkbox_component and pass the label in as the second argument
= gitlab_ui_form_for @group do |f|
  .form-group
    = f.gitlab_ui_checkbox_component :example_field, _('Example field')

💻 Local testing

  1. Create a group
  2. Navigate to "Settings" -> "Permissions, LFS, 2FA"
  3. The "Prevent members from sending invitations to groups outside of <group_name> and its subgroups." should look the same

📷 Screenshots

Expected to be the same

Before After
Screen_Shot_2021-06-21_at_9.58.49_AM Screen_Shot_2021-06-21_at_9.58.15_AM

🚦 Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Peter Hegman

Merge request reports

Loading