diff --git a/.rubocop_todo/layout/line_length.yml b/.rubocop_todo/layout/line_length.yml index 3bfae692a38270db1e417b6d6e481f3f377b16a3..23c42bfcccfb48d2b24140eca537bbf6927a2b6f 100644 --- a/.rubocop_todo/layout/line_length.yml +++ b/.rubocop_todo/layout/line_length.yml @@ -173,7 +173,6 @@ Layout/LineLength: - 'app/helpers/compare_helper.rb' - 'app/helpers/diff_helper.rb' - 'app/helpers/dropdowns_helper.rb' - - 'app/helpers/emails_helper.rb' - 'app/helpers/events_helper.rb' - 'app/helpers/export_helper.rb' - 'app/helpers/external_link_helper.rb' diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index bb9c5a2bc01f534bfe9672199061f5b85cab96d3..14f4c0ba1826cc60573cae3a21c716469f371eb5 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -111,7 +111,10 @@ def closure_reason_text(closed_via, format:, name:) safe_format(_("Issue was closed by %{name} with merge request %{link}"), name: name, link: merge_request_link) else # If it's not HTML nor text then assume it's text to be safe - _("Issue was closed by %{name} with merge request %{link}") % { name: name, link: "#{merge_request.to_reference} (#{merge_request.web_url})" } + _("Issue was closed by %{name} with merge request %{link}") % { + name: name, + link: "#{merge_request.to_reference} (#{merge_request.web_url})" + } end when String # Technically speaking this should be Commit but per @@ -132,11 +135,25 @@ def closure_reason_text(closed_via, format:, name:) end # "You are receiving this email because ... on #{host}. ..." - def notification_reason_text(reason: nil, show_manage_notifications_link: false, show_help_link: false, manage_label_subscriptions_url: nil, unsubscribe_url: nil, format: :text) + def notification_reason_text( + reason: nil, + show_manage_notifications_link: false, + show_help_link: false, + manage_label_subscriptions_url: nil, + unsubscribe_url: nil, + format: :text + ) if unsubscribe_url && show_manage_notifications_link && show_help_link - notification_reason_text_with_unsubscribe_and_manage_notifications_and_help_links(reason: reason, unsubscribe_url: unsubscribe_url, format: format) + notification_reason_text_with_unsubscribe_and_manage_notifications_and_help_links( + reason: reason, + unsubscribe_url: unsubscribe_url, + format: format + ) elsif !reason && manage_label_subscriptions_url && show_help_link - notification_reason_text_with_manage_label_subscriptions_and_help_links(manage_label_subscriptions_url: manage_label_subscriptions_url, format: format) + notification_reason_text_with_manage_label_subscriptions_and_help_links( + manage_label_subscriptions_url: manage_label_subscriptions_url, + format: format + ) elsif show_manage_notifications_link && show_help_link notification_reason_text_with_manage_notifications_and_help_links(reason: reason, format: format) else @@ -213,10 +230,13 @@ def re_enable_two_factor_authentication_text(format: nil) case format when :html settings_link_to = generate_link(_('two-factor authentication settings'), url).html_safe - _("If you want to re-enable two-factor authentication, visit the %{settings_link_to} page.").html_safe % { settings_link_to: settings_link_to } + _("If you want to re-enable two-factor authentication, visit the %{settings_link_to} page.").html_safe % { + settings_link_to: settings_link_to + } else - _('If you want to re-enable two-factor authentication, visit %{two_factor_link}') % - { two_factor_link: url } + _('If you want to re-enable two-factor authentication, visit %{two_factor_link}') % { + two_factor_link: url + } end end @@ -230,7 +250,9 @@ def remove_email_address_text(format: nil) case format when :html settings_link_to = generate_link(_('email address settings'), url).html_safe - _("If you want to remove this email address, visit the %{settings_link_to} page.").html_safe % { settings_link_to: settings_link_to } + _("If you want to remove this email address, visit the %{settings_link_to} page.").html_safe % { + settings_link_to: settings_link_to + } else _('If you want to remove this email address, visit %{profile_link}') % { profile_link: url } @@ -262,9 +284,18 @@ def member_about_to_expire_text(member_source, days_to_expire, format: nil) case format when :html link_to = generate_link(member_source.human_name, url).html_safe - safe_format(_("Your membership in %{link_to} %{project_or_group_name} will expire in %{days_formatted}."), link_to: link_to, project_or_group_name: member_source.model_name.singular, days_formatted: days_formatted) + safe_format( + _("Your membership in %{link_to} %{project_or_group_name} will expire in %{days_formatted}."), + link_to: link_to, + project_or_group_name: member_source.model_name.singular, + days_formatted: days_formatted + ) else - _("Your membership in %{project_or_group} %{project_or_group_name} will expire in %{days_formatted}.") % { project_or_group: member_source.human_name, project_or_group_name: member_source.model_name.singular, days_formatted: days_formatted } + _("Your membership in %{project_or_group} %{project_or_group_name} will expire in %{days_formatted}.") % { + project_or_group: member_source.human_name, + project_or_group_name: member_source.model_name.singular, + days_formatted: days_formatted + } end end @@ -281,9 +312,17 @@ def member_about_to_expire_link(member, member_source, format: nil) case format when :html link_to = generate_link("#{member_source.class.name.downcase} membership", url).html_safe - safe_format(_('For additional information, review your %{link_to} or contact your %{project_or_group} owner.'), link_to: link_to, project_or_group: project_or_group) + safe_format( + _('For additional information, review your %{link_to} or contact your %{project_or_group} owner.'), + link_to: link_to, + project_or_group: project_or_group + ) else - _('For additional information, review your %{project_or_group} membership: %{url} or contact your %{project_or_group} owner.') % { project_or_group: project_or_group, url: url } + _('For additional information, review your %{project_or_group} membership: %{url} or contact your ' \ + '%{project_or_group} owner.') % { + project_or_group: project_or_group, + url: url + } end end @@ -304,14 +343,21 @@ def group_membership_expiration_changed_link(member, group, format: nil) case format when :html link_to = generate_link('group membership', url).html_safe - _('For additional information, review your %{link_to} or contact your group owner.').html_safe % { link_to: link_to } + _('For additional information, review your %{link_to} or contact your group owner.').html_safe % { + link_to: link_to + } else - _('For additional information, review your group membership: %{link_to} or contact your group owner.') % { link_to: url } + _('For additional information, review your group membership: %{link_to} or contact your group owner.') % { + link_to: url + } end end def instance_access_request_text(user, format: nil) - _('%{username} has asked for a GitLab account on your instance %{host}:').html_safe % { username: sanitize_name(user.name), host: gitlab_host_link(format) } + _('%{username} has asked for a GitLab account on your instance %{host}:').html_safe % { + username: sanitize_name(user.name), + host: gitlab_host_link(format) + } end def instance_access_request_link(user, format: nil) @@ -320,7 +366,10 @@ def instance_access_request_link(user, format: nil) case format when :html user_page = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: url } - _("Click %{link_start}here%{link_end} to view the request.").html_safe % { link_start: user_page, link_end: '</a>'.html_safe } + _("Click %{link_start}here%{link_end} to view the request.").html_safe % { + link_start: user_page, + link_end: '</a>'.html_safe + } else _('Click %{link_to} to view the request.') % { link_to: url } end @@ -412,63 +461,173 @@ def gitlab_host_link(format) end end - def notification_reason_text_with_unsubscribe_and_manage_notifications_and_help_links(reason:, unsubscribe_url:, format:) - unsubscribe_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: unsubscribe_url } + def notification_reason_text_with_unsubscribe_and_manage_notifications_and_help_links( + reason:, + unsubscribe_url:, + format: + ) + unsubscribe_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { + url: unsubscribe_url + } unsubscribe_link_end = '</a>'.html_safe - manage_notifications_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="mng-notif-link">'.html_safe % { url: profile_notifications_url } + manage_notifications_link_start = + '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="mng-notif-link">'.html_safe % { + url: profile_notifications_url + } manage_notifications_link_end = '</a>'.html_safe - help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="help-link">'.html_safe % { url: help_url } + help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="help-link">'.html_safe % { + url: help_url + } help_link_end = '</a>'.html_safe case reason when NotificationReason::OWN_ACTIVITY - _("You're receiving this email because of your activity on %{host}. %{unsubscribe_link_start}Unsubscribe%{unsubscribe_link_end} from this thread · %{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · %{help_link_start}Help%{help_link_end}").html_safe % { host: gitlab_host_link(format), unsubscribe_link_start: unsubscribe_link_start, unsubscribe_link_end: unsubscribe_link_end, manage_notifications_link_start: manage_notifications_link_start, manage_notifications_link_end: manage_notifications_link_end, help_link_start: help_link_start, help_link_end: help_link_end } + _( + "You're receiving this email because of your activity on %{host}. " \ + "%{unsubscribe_link_start}Unsubscribe%{unsubscribe_link_end} from this thread · " \ + "%{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · " \ + "%{help_link_start}Help%{help_link_end}" + ).html_safe % { + host: gitlab_host_link(format), + unsubscribe_link_start: unsubscribe_link_start, + unsubscribe_link_end: unsubscribe_link_end, + manage_notifications_link_start: manage_notifications_link_start, + manage_notifications_link_end: manage_notifications_link_end, + help_link_start: help_link_start, + help_link_end: help_link_end + } when NotificationReason::ASSIGNED - _("You're receiving this email because you have been assigned an item on %{host}. %{unsubscribe_link_start}Unsubscribe%{unsubscribe_link_end} from this thread · %{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · %{help_link_start}Help%{help_link_end}").html_safe % { host: gitlab_host_link(format), unsubscribe_link_start: unsubscribe_link_start, unsubscribe_link_end: unsubscribe_link_end, manage_notifications_link_start: manage_notifications_link_start, manage_notifications_link_end: manage_notifications_link_end, help_link_start: help_link_start, help_link_end: help_link_end } + _( + "You're receiving this email because you have been assigned an item on %{host}. " \ + "%{unsubscribe_link_start}Unsubscribe%{unsubscribe_link_end} from this thread · " \ + "%{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · " \ + "%{help_link_start}Help%{help_link_end}" + ).html_safe % { + host: gitlab_host_link(format), + unsubscribe_link_start: unsubscribe_link_start, + unsubscribe_link_end: unsubscribe_link_end, + manage_notifications_link_start: manage_notifications_link_start, + manage_notifications_link_end: manage_notifications_link_end, + help_link_start: help_link_start, + help_link_end: help_link_end + } when NotificationReason::MENTIONED - _("You're receiving this email because you have been mentioned on %{host}. %{unsubscribe_link_start}Unsubscribe%{unsubscribe_link_end} from this thread · %{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · %{help_link_start}Help%{help_link_end}").html_safe % { host: gitlab_host_link(format), unsubscribe_link_start: unsubscribe_link_start, unsubscribe_link_end: unsubscribe_link_end, manage_notifications_link_start: manage_notifications_link_start, manage_notifications_link_end: manage_notifications_link_end, help_link_start: help_link_start, help_link_end: help_link_end } + _( + "You're receiving this email because you have been mentioned on %{host}. " \ + "%{unsubscribe_link_start}Unsubscribe%{unsubscribe_link_end} from this thread · " \ + "%{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · " \ + "%{help_link_start}Help%{help_link_end}" + ).html_safe % { + host: gitlab_host_link(format), + unsubscribe_link_start: unsubscribe_link_start, + unsubscribe_link_end: unsubscribe_link_end, + manage_notifications_link_start: manage_notifications_link_start, + manage_notifications_link_end: manage_notifications_link_end, + help_link_start: help_link_start, + help_link_end: help_link_end + } else - _("You're receiving this email because of your account on %{host}. %{unsubscribe_link_start}Unsubscribe%{unsubscribe_link_end} from this thread · %{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · %{help_link_start}Help%{help_link_end}").html_safe % { host: gitlab_host_link(format), unsubscribe_link_start: unsubscribe_link_start, unsubscribe_link_end: unsubscribe_link_end, manage_notifications_link_start: manage_notifications_link_start, manage_notifications_link_end: manage_notifications_link_end, help_link_start: help_link_start, help_link_end: help_link_end } + _( + "You're receiving this email because of your account on %{host}. " \ + "%{unsubscribe_link_start}Unsubscribe%{unsubscribe_link_end} from this thread · " \ + "%{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · " \ + "%{help_link_start}Help%{help_link_end}" + ).html_safe % { + host: gitlab_host_link(format), + unsubscribe_link_start: unsubscribe_link_start, + unsubscribe_link_end: unsubscribe_link_end, + manage_notifications_link_start: manage_notifications_link_start, + manage_notifications_link_end: manage_notifications_link_end, + help_link_start: help_link_start, + help_link_end: help_link_end + } end end def notification_reason_text_with_manage_label_subscriptions_and_help_links(manage_label_subscriptions_url:, format:) - manage_label_subscriptions_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="mng-notif-link">'.html_safe % { url: manage_label_subscriptions_url } + manage_label_subscriptions_link_start = + '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="mng-notif-link">'.html_safe % { + url: manage_label_subscriptions_url + } manage_label_subscriptions_link_end = '</a>'.html_safe - help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="help-link">'.html_safe % { url: help_url } + help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="help-link">'.html_safe % { + url: help_url + } help_link_end = '</a>'.html_safe - _("You're receiving this email because of your account on %{host}. %{manage_label_subscriptions_link_start}Manage label subscriptions%{manage_label_subscriptions_link_end} · %{help_link_start}Help%{help_link_end}").html_safe % { host: gitlab_host_link(format), manage_label_subscriptions_link_start: manage_label_subscriptions_link_start, manage_label_subscriptions_link_end: manage_label_subscriptions_link_end, help_link_start: help_link_start, help_link_end: help_link_end } + _( + "You're receiving this email because of your account on %{host}. %{manage_label_subscriptions_link_start}" \ + "Manage label subscriptions%{manage_label_subscriptions_link_end} · " \ + "%{help_link_start}Help%{help_link_end}" + ).html_safe % { + host: gitlab_host_link(format), + manage_label_subscriptions_link_start: manage_label_subscriptions_link_start, + manage_label_subscriptions_link_end: manage_label_subscriptions_link_end, + help_link_start: help_link_start, + help_link_end: help_link_end + } end def notification_reason_text_with_manage_notifications_and_help_links(reason:, format:) - manage_notifications_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="mng-notif-link">'.html_safe % { url: profile_notifications_url } + manage_notifications_link_start = + '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="mng-notif-link">'.html_safe % { + url: profile_notifications_url + } manage_notifications_link_end = '</a>'.html_safe - help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="help-link">'.html_safe % { url: help_url } + help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="help-link">'.html_safe % { + url: help_url + } help_link_end = '</a>'.html_safe case reason when NotificationReason::MENTIONED - _("You're receiving this email because you have been mentioned on %{host}. %{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · %{help_link_start}Help%{help_link_end}").html_safe % { host: gitlab_host_link(format), manage_notifications_link_start: manage_notifications_link_start, manage_notifications_link_end: manage_notifications_link_end, help_link_start: help_link_start, help_link_end: help_link_end } + _( + "You're receiving this email because you have been mentioned on %{host}. " \ + "%{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · " \ + "%{help_link_start}Help%{help_link_end}" + ).html_safe % { + host: gitlab_host_link(format), + manage_notifications_link_start: manage_notifications_link_start, + manage_notifications_link_end: manage_notifications_link_end, + help_link_start: help_link_start, + help_link_end: help_link_end + } else - _("You're receiving this email because of your account on %{host}. %{manage_notifications_link_start}Manage all notifications%{manage_notifications_link_end} · %{help_link_start}Help%{help_link_end}").html_safe % { host: gitlab_host_link(format), manage_notifications_link_start: manage_notifications_link_start, manage_notifications_link_end: manage_notifications_link_end, help_link_start: help_link_start, help_link_end: help_link_end } + _( + "You're receiving this email because of your account on %{host}. %{manage_notifications_link_start}Manage " \ + "all notifications%{manage_notifications_link_end} · %{help_link_start}Help%{help_link_end}" + ).html_safe % { + host: gitlab_host_link(format), + manage_notifications_link_start: manage_notifications_link_start, + manage_notifications_link_end: manage_notifications_link_end, + help_link_start: help_link_start, + help_link_end: help_link_end + } end end def notification_reason_text_without_links(reason:, format:) case reason when NotificationReason::OWN_ACTIVITY - _("You're receiving this email because of your activity on %{host}.").html_safe % { host: gitlab_host_link(format) } + _("You're receiving this email because of your activity on %{host}.").html_safe % { + host: gitlab_host_link(format) + } when NotificationReason::ASSIGNED - _("You're receiving this email because you have been assigned an item on %{host}.").html_safe % { host: gitlab_host_link(format) } + _("You're receiving this email because you have been assigned an item on %{host}.").html_safe % { + host: gitlab_host_link(format) + } when NotificationReason::MENTIONED - _("You're receiving this email because you have been mentioned on %{host}.").html_safe % { host: gitlab_host_link(format) } + _("You're receiving this email because you have been mentioned on %{host}.").html_safe % { + host: gitlab_host_link(format) + } else - _("You're receiving this email because of your account on %{host}.").html_safe % { host: gitlab_host_link(format) } + _("You're receiving this email because of your account on %{host}.").html_safe % { + host: gitlab_host_link(format) + } end end end