Mass button migration
|
---|
Before diving into the review, pick the files you'll be reviewing and add your name in the UX review tracker below. |
What does this MR do and why?
This migrates many links that are styled to look like buttons to a new helper, link_button_to
.
These migrations were largely done blind, in that a codemod was used to perform them.
Note that a number of the migrated link buttons have existing issues, for instance:
- many do not have an accessible name;
- some use a
disabled
attribute/style, which makes no sense for a link.
This MR does not fix those issues. It is simply about replacing link_to
calls with CSS classes applied with a better encapsulated link_button_to
helper.
Part of https://gitlab.com/gitlab-com/gitlab-OKRs/-/work_items/2030.
Commit messages
Remove unnecessary gl-button classes
The app/views/shared/issuable/_search_bar.html.haml
template renders
the deprecated, jQuery-based filtered search (which should eventually be
replaced with the GlFilteredSearch
Vue component). It's used in places
like the Merge Requests list and Issue Analytics.
These buttons should never have had the gl-button
class applied to
them, since their styles are fully described by the (deprecated)
filtered search styles anyway. Due to the existence of the class, they
are false positive findings detected by the Pajamas Adoption
Scanner. Removing the class will prevent the Scanner from detecting
them.
Remove unnecessary gl-btn classes
This class doesn't do anything. These should also not have the
.gl-button
class, since they're part of dropdown's options, which are
styled differently anyway.
Manually rewrite disabled button
Replace pluralize calls with n_
For improved localisation.
Add link_button_to helper
This provides an easier migration path for links that look like buttons
than using Pajamas::ButtonComponent
itself. This is because the method
signature is much more similar to link_to
than
Pajamas::ButtonComponent
.
It's also slightly less verbose, which seems reasonable for such a common use case.
Mass button migration
Executed with:
comby \
-config ~/dev/pajamas-adoption-scanner/comby/button.toml \
-custom-matcher ~/dev/pajamas-adoption-scanner/comby/haml.json \
-matcher .generic -in-place \
-f {ee/,}app/views/**/*.haml
Using the button-migration
branch of the Pajamas Adoption Scanner:
https://gitlab.com/gitlab-org/frontend/pajamas-adoption-scanner/-/commits/button-migration
Button post-migration manual fixes
- Translate untranslated button text
- Use double quotes for interpolation of classes
- Migrate some link buttons in the vicinity not caught by migration
- Clean up html_options hashes, empty class attributes
- Unwrap unnecessary span element surrounding link
- Use keyword arguments rather than an explicit hash argument
Fix custom icon rendering
The Gitea logo isn't available as a regular icon, so cannot be set via
the icon
argument. It must be handled specially.
The styling here ensures that the icon and the text are displayed on the same line.
Replace .sr-only with aria-label
While the screen-reader-only label seems redundant given the link already has accessible text, it exists so that the confirmation modal picks up the text for its confirm button.
For some reason, it explicitly looks for screen-reader-only text. The original MR does not explain why. There is an issue to explore changing this.
Why switch from .sr-only to aria-label:
- To be consistent with link button above it.
- The
sr-only
class is from Bootstrap, and generally we're trying to move away from that.
Rename parameters and call block with yield
Move helper to more appropriate file
Remove Gitea icon button hack
It turns out the Gitea logo is in our sprite icon set, so the icon
option can be used.
Screenshots or screen recordings
In theory, there should be no visual or behavioral differences.
How to set up and validate locally
Because this changes buttons in various places across the app, there's no single process to validate this. Instead, I can provide some heuristics:
- Choose a file in the diff.
- Based on its name, or the user-facing strings inside it, guess where it appears in the app.
- Either:
- try to perform the actions necessary to render the button(s) in the file, or
- change the code to force the button to render.
- Verify the button looks correct.
- Verify clicking the button has the correct behavior. Note: this might not always be a simple page load! Buttons which have, e.g.,
method: :post
or similar on them might have other behavior.
UX review tracker
- Once you have picked the files you will review, add your username next to them (or to the containing folder) so that everyone's aware of who is reviewing what, and we avoid duplicate efforts.
- After you've reviewed them, check them off. Thank you!
-
📂 app/views/admin/ — @annabeldunstone-
labels/_label.html.haml — @annabeldunstone -
users/projects.html.haml — @annabeldunstone -
users/show.html.haml — @annabeldunstone
-
-
📂 app/views/profiles/ — @annabeldunstone-
active_sessions/_active_session.html.haml — @annabeldunstone -
emails/index.html.haml — @annabeldunstone -
gpg_keys/_key.html.haml — @annabeldunstone
-
-
📂 app/views/projects/ —@reviewer
-
_activity.html.haml — @annabeldunstone -
_find_file_link.html.haml — @annabeldunstone -
_import_project_pane.html.haml — @pedroms -
artifacts/browse.html.haml — @tauriedavis -
branches/index.html.haml — @annabeldunstone -
buttons/_fork.html.haml — @annabeldunstone -
buttons/_star.html.haml — @annabeldunstone -
ci/builds/_build.html.haml — @pedroms -
commits/show.html.haml — @annabeldunstone -
confluences/show.html.haml — @tauriedavis -
diffs/_file.html.haml — @annabeldunstone -
environments/terminal.html.haml — @emilybauman - Need developer help to identify
-
forks/index.html.haml — @tauriedavis -
integrations/shimos/show.html.haml — @pedroms -
milestones/index.html.haml — @ameliabauerly -
no_repo.html.haml — @lvanc -
pipeline_schedules/_pipeline_schedule.html.haml — @sunjungp -
pipeline_schedules/index.html.haml — @sunjungp -
runners/_group_runners.html.haml — @gdoyle -
runners/_runner.html.haml — @gdoyle -
tags/index.html.haml — @sunjungp -
tags/show.html.haml — @sunjungp
-
-
📂 app/views/shared/ —@reviewer
-
_remote_mirror_update_button.html.haml — @veethika -
_two_factor_auth_recovery_settings_check.html.haml — @veethika -
doorkeeper/applications/_index.html.haml — @tauriedavis -
issuable/_search_bar.html.haml — @veethika -
members/_manage_access_button.html.haml — @veethika -
milestones/_labels_tab.html.haml — @veethika -
projects/_search_form.html.haml — @ameliabauerly -
📂 wikis/ — @pedroms-
_main_links.html.haml -
_sidebar.html.haml -
diff.html.haml -
pages.html.haml
-
-
-
📂 ee/app/views/admin/ — @danmh -
ee/app/views/dashboard/projects/_blank_state_ee_trial.html.haml — @reviewer
-
ee/app/views/ldap_group_links/_ldap_group_link.html.haml — @reviewer
-
ee/app/views/projects/mirrors/_table_pull_row.html.haml — @tauriedavis -
ee/app/views/projects/path_locks/_path_lock.html.haml — @lvanc -
ee/app/views/projects/settings/subscriptions/_project.html.haml — @aregnery -
ee/app/views/shared/_mirror_update_button.html.haml — @aregnery -
ee/app/views/shared/integrations/gitlab_slack_application/_slack_button.html.haml — @pedroms
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.