Use the `link_to` helper in place of manually constructed links
Why are we doing this work
We have a number of places in the codebase where link HTML is being manually constructed with string concatenation. Why we shouldn't do this.
-
app/views/admin/application_settings/_gitpod.html.haml
!129062 (merged) -
app/views/admin/application_settings/_snowplow.html.haml
!129062 (merged) -
app/views/admin/application_settings/ci_cd.html.haml
!129062 (merged) -
app/views/admin/application_settings/service_usage_data.html.haml
!129062 (merged) -
app/views/groups/_import_group_from_another_instance_panel.html.haml
!131605 (merged) -
app/views/projects/settings/integrations/index.html.haml
!131605 (merged) -
app/views/projects/tags/new.html.haml
!131605 (merged) -
app/views/shared/issuable/_form.html.haml
!131605 (merged) -
app/views/shared/web_hooks/_hook_errors.html.haml
!129202 (merged) -
app/views/shared/web_hooks/_title_and_docs.html.haml
!129202 (merged) -
app/views/users/_deletion_guidance.html.haml
!129202 (merged) -
ee/app/views/admin/application_settings/_custom_templates_form.html.haml
!130496 (merged) -
ee/app/views/admin/application_settings/_ee_package_registry.haml
!130496 (merged) -
deleted in 5fbfe681ee/app/views/admin/application_settings/_free_user_cap.html.haml
-
ee/app/views/admin/application_settings/_license_compliance.html.haml
!130496 (merged) -
ee/app/views/admin/application_settings/_required_instance_ci_setting.html.haml
!130496 (merged) -
ee/app/views/admin/licenses/_breakdown.html.haml
!131605 (merged) -
ee/app/views/groups/_custom_project_templates_setting.html.haml
!131605 (merged) -
removed in !129022 (merged)ee/app/views/shared/_code_suggestions_third_party_alert.html.haml
Source
$ grep '<a href="%{url}">' app/**/*.haml ee/app/**/*.haml
app/views/admin/application_settings/_gitpod.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('integration/gitpod', anchor: 'enable-gitpod-in-your-user-settings') }
app/views/admin/application_settings/_snowplow.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('development/snowplow/index') }
app/views/admin/application_settings/ci_cd.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('ci/variables/index', anchor: 'protect-a-cicd-variable') }
app/views/admin/application_settings/service_usage_data.html.haml: - enable_service_ping_link = '<a href="%{url}">'.html_safe % { url: enable_service_ping_link_url }
app/views/groups/_import_group_from_another_instance_panel.html.haml: - admin_link_start = '<a href="%{url}">'.html_safe % { url: general_admin_application_settings_path(anchor: 'js-visibility-settings') }
app/views/projects/settings/integrations/index.html.haml: - integrations_link_start = '<a href="%{url}">'.html_safe % { url: help_page_url('user/project/integrations/index') }
app/views/projects/settings/integrations/index.html.haml: - webhooks_link_start = '<a href="%{url}">'.html_safe % { url: project_hooks_path(@project) }
app/views/projects/tags/new.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: new_namespace_project_release_path }
app/views/shared/issuable/_form.html.haml: - contribution_guidelines_start = '<strong><a href="%{url}">'.html_safe % {url: strip_tags(guide_url)}
app/views/shared/web_hooks/_hook_errors.html.haml:- link_start = '<a href="%{url}">'.html_safe
app/views/shared/web_hooks/_title_and_docs.html.haml:- webhooks_link_start = '<a href="%{url}">'.html_safe % { url: help_page_path(hook.help_path) }
app/views/shared/web_hooks/_title_and_docs.html.haml: - integrations_link_start = '<a href="%{url}">'.html_safe % { url: scoped_integrations_path(project: @project) }
app/views/users/_deletion_guidance.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path("user/profile/account/delete_account", anchor: "associated-records") }
ee/app/views/admin/application_settings/_custom_templates_form.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('user/admin_area/custom_project_templates.md') }
ee/app/views/admin/application_settings/_ee_package_registry.haml: - docs_link_start = '<a href="%{url}">'.html_safe % { url: docs_link_path }
ee/app/views/admin/application_settings/_free_user_cap.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/374023' }
ee/app/views/admin/application_settings/_license_compliance.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: "https://gitlab.com/groups/gitlab-org/-/epics/10415" }
ee/app/views/admin/application_settings/_required_instance_ci_setting.html.haml: - config_link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('administration/settings/continuous_integration', anchor: 'required-pipeline-configuration') }
ee/app/views/admin/application_settings/_required_instance_ci_setting.html.haml: - instance_link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('user/admin_area/settings/instance_template_repository') }
ee/app/views/admin/licenses/_breakdown.html.haml:- true_up_link_start = '<a href="%{url}">'.html_safe % { url: true_up_url }
ee/app/views/groups/_custom_project_templates_setting.html.haml: - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('user/group/custom_project_templates.md') }
ee/app/views/shared/_code_suggestions_third_party_alert.html.haml: - third_party_link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('user/group/manage', anchor: 'enable-third-party-ai-features') }
ee/app/views/shared/_code_suggestions_third_party_alert.html.haml: - code_suggestions_link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('user/project/repository/code_suggestions') }
ee/app/views/shared/_code_suggestions_third_party_alert.html.haml: - profile_settings_link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('user/project/repository/code_suggestions', anchor: 'enable-code-suggestions-for-an-individual-user') }
These links should be built using link_to
instead.
Relevant links
Non-functional requirements
Implementation plan
Replace "<a href="%{url}">%{text}</a>"
with link_to(text, url)
.
Verification steps
Edited by Michael Becker