Commit 1993a444 authored by gfyoung's avatar gfyoung

Enable frozen string for app/helpers/**/*.rb

Partially addresses #47424.
parent 07d5ee36
# frozen_string_literal: true
module AccountsHelper module AccountsHelper
def incoming_email_token_enabled? def incoming_email_token_enabled?
current_user.incoming_email_token && Gitlab::IncomingEmail.supports_issue_creation? current_user.incoming_email_token && Gitlab::IncomingEmail.supports_issue_creation?
......
# frozen_string_literal: true
module ActiveSessionsHelper module ActiveSessionsHelper
# Maps a device type as defined in `ActiveSession` to an svg icon name and # Maps a device type as defined in `ActiveSession` to an svg icon name and
# outputs the icon html. # outputs the icon html.
......
# frozen_string_literal: true
module AppearancesHelper module AppearancesHelper
def brand_title def brand_title
current_appearance&.title.presence || 'GitLab Community Edition' current_appearance&.title.presence || 'GitLab Community Edition'
......
# frozen_string_literal: true
require 'digest/md5' require 'digest/md5'
require 'uri' require 'uri'
...@@ -106,11 +108,11 @@ module ApplicationHelper ...@@ -106,11 +108,11 @@ module ApplicationHelper
# #
# Returns an HTML-safe String # Returns an HTML-safe String
def time_ago_with_tooltip(time, placement: 'top', html_class: '', short_format: false) def time_ago_with_tooltip(time, placement: 'top', html_class: '', short_format: false)
css_classes = short_format ? 'js-short-timeago' : 'js-timeago' css_classes = [short_format ? 'js-short-timeago' : 'js-timeago']
css_classes << " #{html_class}" unless html_class.blank? css_classes << html_class unless html_class.blank?
element = content_tag :time, l(time, format: "%b %d, %Y"), element = content_tag :time, l(time, format: "%b %d, %Y"),
class: css_classes, class: css_classes.join(' '),
title: l(time.to_time.in_time_zone, format: :timeago_tooltip), title: l(time.to_time.in_time_zone, format: :timeago_tooltip),
datetime: time.to_time.getutc.iso8601, datetime: time.to_time.getutc.iso8601,
data: { data: {
......
# frozen_string_literal: true
module ApplicationSettingsHelper module ApplicationSettingsHelper
extend self extend self
...@@ -73,12 +75,12 @@ module ApplicationSettingsHelper ...@@ -73,12 +75,12 @@ module ApplicationSettingsHelper
def oauth_providers_checkboxes def oauth_providers_checkboxes
button_based_providers.map do |source| button_based_providers.map do |source|
disabled = Gitlab::CurrentSettings.disabled_oauth_sign_in_sources.include?(source.to_s) disabled = Gitlab::CurrentSettings.disabled_oauth_sign_in_sources.include?(source.to_s)
css_class = 'btn' css_class = ['btn']
css_class << ' active' unless disabled css_class << 'active' unless disabled
checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]' checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]'
name = Gitlab::Auth::OAuth::Provider.label_for(source) name = Gitlab::Auth::OAuth::Provider.label_for(source)
label_tag(checkbox_name, class: css_class) do label_tag(checkbox_name, class: css_class.join(' ')) do
check_box_tag(checkbox_name, source, !disabled, check_box_tag(checkbox_name, source, !disabled,
autocomplete: 'off', autocomplete: 'off',
id: name.tr(' ', '_')) + name id: name.tr(' ', '_')) + name
......
# frozen_string_literal: true
module AuthHelper module AuthHelper
PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze
LDAP_PROVIDER = /\Aldap/ LDAP_PROVIDER = /\Aldap/
......
# frozen_string_literal: true
module AutoDevopsHelper module AutoDevopsHelper
def show_auto_devops_callout?(project) def show_auto_devops_callout?(project)
Feature.get(:auto_devops_banner_disabled).off? && Feature.get(:auto_devops_banner_disabled).off? &&
......
# frozen_string_literal: true
module AvatarsHelper module AvatarsHelper
def project_icon(project_id, options = {}) def project_icon(project_id, options = {})
source_icon(Project, project_id, options) source_icon(Project, project_id, options)
...@@ -125,9 +127,9 @@ module AvatarsHelper ...@@ -125,9 +127,9 @@ module AvatarsHelper
def source_identicon(source, options = {}) def source_identicon(source, options = {})
bg_key = (source.id % 7) + 1 bg_key = (source.id % 7) + 1
options[:class] ||= ''
options[:class] << ' identicon' options[:class] =
options[:class] << " bg#{bg_key}" [*options[:class], "identicon bg#{bg_key}"].join(' ')
content_tag(:div, class: options[:class].strip) do content_tag(:div, class: options[:class].strip) do
source.name[0, 1].upcase source.name[0, 1].upcase
......
# frozen_string_literal: true
module AwardEmojiHelper module AwardEmojiHelper
def toggle_award_url(awardable) def toggle_award_url(awardable)
return url_for([:toggle_award_emoji, awardable]) unless @project || awardable.is_a?(Note) return url_for([:toggle_award_emoji, awardable]) unless @project || awardable.is_a?(Note)
......
# frozen_string_literal: true
module BlameHelper module BlameHelper
def age_map_duration(blame_groups, project) def age_map_duration(blame_groups, project)
now = Time.zone.now now = Time.zone.now
......
# frozen_string_literal: true
module BlobHelper module BlobHelper
def highlight(blob_name, blob_content, repository: nil, plain: false) def highlight(blob_name, blob_content, repository: nil, plain: false)
plain ||= blob_content.length > Blob::MAXIMUM_TEXT_HIGHLIGHT_SIZE plain ||= blob_content.length > Blob::MAXIMUM_TEXT_HIGHLIGHT_SIZE
......
# frozen_string_literal: true
module BoardsHelper module BoardsHelper
def board def board
@board ||= @board || @boards.first @board ||= @board || @boards.first
......
# frozen_string_literal: true
module BranchesHelper module BranchesHelper
def project_branches def project_branches
options_for_select(@project.repository.branch_names, @project.default_branch) options_for_select(@project.repository.branch_names, @project.default_branch)
......
# frozen_string_literal: true
module BreadcrumbsHelper module BreadcrumbsHelper
def add_to_breadcrumbs(text, link) def add_to_breadcrumbs(text, link)
@breadcrumbs_extra_links ||= [] @breadcrumbs_extra_links ||= []
......
# frozen_string_literal: true
module BroadcastMessagesHelper module BroadcastMessagesHelper
def broadcast_message(message) def broadcast_message(message)
return unless message.present? return unless message.present?
...@@ -8,18 +10,17 @@ module BroadcastMessagesHelper ...@@ -8,18 +10,17 @@ module BroadcastMessagesHelper
end end
def broadcast_message_style(broadcast_message) def broadcast_message_style(broadcast_message)
style = '' style = []
if broadcast_message.color.present? if broadcast_message.color.present?
style << "background-color: #{broadcast_message.color}" style << "background-color: #{broadcast_message.color}"
style << '; ' if broadcast_message.font.present?
end end
if broadcast_message.font.present? if broadcast_message.font.present?
style << "color: #{broadcast_message.font}" style << "color: #{broadcast_message.font}"
end end
style style.join('; ')
end end
def broadcast_message_status(broadcast_message) def broadcast_message_status(broadcast_message)
......
# frozen_string_literal: true
module BuildsHelper module BuildsHelper
def build_summary(build, skip: false) def build_summary(build, skip: false)
if build.has_trace? if build.has_trace?
...@@ -12,10 +14,10 @@ module BuildsHelper ...@@ -12,10 +14,10 @@ module BuildsHelper
end end
def sidebar_build_class(build, current_build) def sidebar_build_class(build, current_build)
build_class = '' build_class = []
build_class += ' active' if build.id === current_build.id build_class << 'active' if build.id === current_build.id
build_class += ' retried' if build.retried? build_class << 'retried' if build.retried?
build_class build_class.join(' ')
end end
def javascript_build_options def javascript_build_options
......
# frozen_string_literal: true
module ButtonHelper module ButtonHelper
# Output a "Copy to Clipboard" button # Output a "Copy to Clipboard" button
# #
......
# frozen_string_literal: true
module CalendarHelper module CalendarHelper
def calendar_url_options def calendar_url_options
{ format: :ics, { format: :ics,
......
# frozen_string_literal: true
## ##
# DEPRECATED # DEPRECATED
# #
......
# frozen_string_literal: true
module ClustersHelper module ClustersHelper
def has_multiple_clusters?(project) def has_multiple_clusters?(project)
false false
......
# frozen_string_literal: true
module CommitsHelper module CommitsHelper
# Returns a link to the commit author. If the author has a matching user and # Returns a link to the commit author. If the author has a matching user and
# is a member of the current @project it will link to the team member page. # is a member of the current @project it will link to the team member page.
......
# frozen_string_literal: true
module CompareHelper module CompareHelper
def create_mr_button?(from = params[:from], to = params[:to], project = @project) def create_mr_button?(from = params[:from], to = params[:to], project = @project)
from.present? && from.present? &&
......
# frozen_string_literal: true
module ComponentsHelper module ComponentsHelper
def gitlab_workhorse_version def gitlab_workhorse_version
if request.headers['Gitlab-Workhorse'].present? if request.headers['Gitlab-Workhorse'].present?
......
# frozen_string_literal: true
module ConversationalDevelopmentIndexHelper module ConversationalDevelopmentIndexHelper
def score_level(score) def score_level(score)
if score < 33.33 if score < 33.33
......
# frozen_string_literal: true
module CountHelper module CountHelper
def approximate_count_with_delimiters(count_data, model) def approximate_count_with_delimiters(count_data, model)
count = count_data[model] count = count_data[model]
......
# frozen_string_literal: true
module DashboardHelper module DashboardHelper
def assigned_issues_dashboard_path def assigned_issues_dashboard_path
issues_dashboard_path(assignee_id: current_user.id) issues_dashboard_path(assignee_id: current_user.id)
......
# frozen_string_literal: true
module DeferScriptTagHelper module DeferScriptTagHelper
# Override the default ActionView `javascript_include_tag` helper to support page specific deferred loading # Override the default ActionView `javascript_include_tag` helper to support page specific deferred loading
def javascript_include_tag(*sources) def javascript_include_tag(*sources)
......
# frozen_string_literal: true
module DeployTokensHelper module DeployTokensHelper
def expand_deploy_tokens_section?(deploy_token) def expand_deploy_tokens_section?(deploy_token)
deploy_token.persisted? || deploy_token.persisted? ||
......
# frozen_string_literal: true
module DiffHelper module DiffHelper
def mark_inline_diffs(old_line, new_line) def mark_inline_diffs(old_line, new_line)
old_diffs, new_diffs = Gitlab::Diff::InlineDiff.new(old_line, new_line).inline_diffs old_diffs, new_diffs = Gitlab::Diff::InlineDiff.new(old_line, new_line).inline_diffs
...@@ -39,7 +41,8 @@ module DiffHelper ...@@ -39,7 +41,8 @@ module DiffHelper
line_num_class = %w[diff-line-num unfold js-unfold] line_num_class = %w[diff-line-num unfold js-unfold]
line_num_class << 'js-unfold-bottom' if bottom line_num_class << 'js-unfold-bottom' if bottom
html = '' html = []
if old_pos if old_pos
html << content_tag(:td, '...', class: [*line_num_class, 'old_line'], data: { linenumber: old_pos }) html << content_tag(:td, '...', class: [*line_num_class, 'old_line'], data: { linenumber: old_pos })
html << content_tag(:td, text, class: [*content_line_class, 'left-side']) if view == :parallel html << content_tag(:td, text, class: [*content_line_class, 'left-side']) if view == :parallel
...@@ -50,7 +53,7 @@ module DiffHelper ...@@ -50,7 +53,7 @@ module DiffHelper
html << content_tag(:td, text, class: [*content_line_class, ('right-side' if view == :parallel)]) html << content_tag(:td, text, class: [*content_line_class, ('right-side' if view == :parallel)])
end end
html.html_safe html.join.html_safe
end end
def diff_line_content(line) def diff_line_content(line)
...@@ -215,9 +218,7 @@ module DiffHelper ...@@ -215,9 +218,7 @@ module DiffHelper
end end
def toggle_whitespace_link(url, options) def toggle_whitespace_link(url, options)
options[:class] ||= '' options[:class] = [*options[:class], 'btn btn-default'].join(' ')
options[:class] << ' btn btn-default'
link_to "#{hide_whitespace? ? 'Show' : 'Hide'} whitespace changes", url, class: options[:class] link_to "#{hide_whitespace? ? 'Show' : 'Hide'} whitespace changes", url, class: options[:class]
end end
......
# frozen_string_literal: true
module DropdownsHelper module DropdownsHelper
def dropdown_tag(toggle_text, options: {}, &block) def dropdown_tag(toggle_text, options: {}, &block)
content_tag :div, class: "dropdown #{options[:wrapper_class] if options.key?(:wrapper_class)}" do content_tag :div, class: "dropdown #{options[:wrapper_class] if options.key?(:wrapper_class)}" do
...@@ -10,7 +12,7 @@ module DropdownsHelper ...@@ -10,7 +12,7 @@ module DropdownsHelper
dropdown_output = dropdown_toggle(toggle_text, data_attr, options) dropdown_output = dropdown_toggle(toggle_text, data_attr, options)
dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") do dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") do
output = "" output = []
if options.key?(:title) if options.key?(:title)
output << dropdown_title(options[:title]) output << dropdown_title(options[:title])
...@@ -31,8 +33,7 @@ module DropdownsHelper ...@@ -31,8 +33,7 @@ module DropdownsHelper
end end
output << dropdown_loading output << dropdown_loading
output.join.html_safe
output.html_safe
end end
dropdown_output.html_safe dropdown_output.html_safe
...@@ -50,7 +51,7 @@ module DropdownsHelper ...@@ -50,7 +51,7 @@ module DropdownsHelper
def dropdown_title(title, options: {}) def dropdown_title(title, options: {})
content_tag :div, class: "dropdown-title" do content_tag :div, class: "dropdown-title" do
title_output = "" title_output = []
if options.fetch(:back, false) if options.fetch(:back, false)
title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: { label: "Go back" }, type: "button") do title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: { label: "Go back" }, type: "button") do
...@@ -66,7 +67,7 @@ module DropdownsHelper ...@@ -66,7 +67,7 @@ module DropdownsHelper
end end
end end
title_output.html_safe title_output.join.html_safe
end end
end end
......
# frozen_string_literal: true
module EmailsHelper module EmailsHelper
include AppearancesHelper include AppearancesHelper
...@@ -49,8 +51,8 @@ module EmailsHelper ...@@ -49,8 +51,8 @@ module EmailsHelper
def reset_token_expire_message def reset_token_expire_message
link_tag = link_to('request a new one', new_user_password_url(user_email: @user.email)) link_tag = link_to('request a new one', new_user_password_url(user_email: @user.email))
msg = "This link is valid for #{password_reset_token_valid_time}. " "This link is valid for #{password_reset_token_valid_time}. " \
msg << "After it expires, you can #{link_tag}." "After it expires, you can #{link_tag}."
end end
def header_logo def header_logo
......
# frozen_string_literal: true
module EmojiHelper module EmojiHelper
def emoji_icon(*args) def emoji_icon(*args)
raw Gitlab::Emoji.gl_emoji_tag(*args) raw Gitlab::Emoji.gl_emoji_tag(*args)
......
# frozen_string_literal: true
module EnvironmentHelper module EnvironmentHelper
def environment_for_build(project, build) def environment_for_build(project, build)
return unless build.environment return unless build.environment
......
# frozen_string_literal: true
module EnvironmentsHelper module EnvironmentsHelper
def environments_list_data def environments_list_data
{ {
......
# frozen_string_literal: true
module EventsHelper module EventsHelper
ICON_NAMES_BY_EVENT_TYPE = { ICON_NAMES_BY_EVENT_TYPE = {
'pushed to' => 'commit', 'pushed to' => 'commit',
......
# frozen_string_literal: true
module ExploreHelper module ExploreHelper
def filter_projects_path(options = {}) def filter_projects_path(options = {})
exist_opts = { exist_opts = {
......
# frozen_string_literal: true
module ExternalWikiHelper module ExternalWikiHelper
def get_project_wiki_path(project) def get_project_wiki_path(project)
external_wiki_service = project.external_wiki external_wiki_service = project.external_wiki
......
# frozen_string_literal: true
module FaviconHelper module FaviconHelper
def favicon_extension_whitelist def favicon_extension_whitelist
FaviconUploader::EXTENSION_WHITELIST FaviconUploader::EXTENSION_WHITELIST
......
# frozen_string_literal: true
module FormHelper module FormHelper
def form_errors(model, type: 'form') def form_errors(model, type: 'form')
return unless model.errors.any? return unless model.errors.any?
......
# frozen_string_literal: true
module GitHelper module GitHelper
def strip_gpg_signature(text) def strip_gpg_signature(text)
text.gsub(/-----BEGIN PGP SIGNATURE-----(.*)-----END PGP SIGNATURE-----/m, "") text.gsub(/-----BEGIN PGP SIGNATURE-----(.*)-----END PGP SIGNATURE-----/m, "")
......
# frozen_string_literal: true
# Shorter routing method for some project items # Shorter routing method for some project items
module GitlabRoutingHelper module GitlabRoutingHelper
extend ActiveSupport::Concern extend ActiveSupport::Concern
......
# frozen_string_literal: true
module GraphHelper module GraphHelper
def refs(repo, commit) def refs(repo, commit)
refs = commit.ref_names(repo).join(' ') refs = [commit.ref_names(repo).join(' ')]
# append note count # append note count
notes_count = @graph.notes[commit.id] notes_count = @graph.notes[commit.id]
refs << "[#{pluralize(notes_count, 'note')}]" if notes_count > 0 refs << "[#{pluralize(notes_count, 'note')}]" if notes_count > 0
refs refs.join
end end
def parents_zip_spaces(parents, parent_spaces) def parents_zip_spaces(parents, parent_spaces)
......
# frozen_string_literal: true
module GroupsHelper module GroupsHelper
def group_nav_link_paths def group_nav_link_paths
%w[groups#projects groups#edit badges#index ci_cd#show ldap_group_links#index hooks#index audit_events#index pipeline_quota#index] %w[groups#projects groups#edit badges#index ci_cd#show ldap_group_links#index hooks#index audit_events#index pipeline_quota#index]
...@@ -43,22 +45,22 @@ module GroupsHelper ...@@ -43,22 +45,22 @@ module GroupsHelper
def group_title(group, name = nil, url = nil) def group_title(group, name = nil, url = nil)
@has_group_title = true @has_group_title = true
full_title = '' full_title = []
group.ancestors.reverse.each_with_index do |parent, index| group.ancestors.reverse.each_with_index do |parent, index|
if index > 0 if index > 0
add_to_breadcrumb_dropdown(group_title_link(parent, hidable: false, show_avatar: true, for_dropdown: true), location: :before) add_to_breadcrumb_dropdown(group_title_link(parent, hidable: false, show_avatar: true, for_dropdown: true), location: :before)
else else
full_title += breadcrumb_list_item group_title_link(parent, hidable: false) full_title << breadcrumb_list_item(group_title_link(parent, hidable: false))
end end
end end
full_title += render "layouts/nav/breadcrumbs/collapsed_dropdown", location: :before, title: _("Show parent subgroups") full_title << render("layouts/nav/breadcrumbs/collapsed_dropdown", location: :before, title: _("Show parent subgroups"))
full_title += breadcrumb_list_item group_title_link(group) full_title << breadcrumb_list_item(group_title_link(group))
full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url, class: 'group-path breadcrumb-item-text js-breadcrumb-item-text') if name full_title << ' &middot; '.html_safe + link_to(simple_sanitize(name), url, class: 'group-path breadcrumb-item-text js-breadcrumb-item-text') if name
full_title.html_safe full_title.join.html_safe
end end
def projects_lfs_status(group) def projects_lfs_status(group)
...@@ -138,15 +140,8 @@ module GroupsHelper ...@@ -138,15 +140,8 @@ module GroupsHelper
def group_title_link(group, hidable: false, show_avatar: false, for_dropdown: false) def group_title_link(group, hidable: false, show_avatar: false, for_dropdown: false)
link_to(group_path(group), class: "group-path #{'breadcrumb-item-text' unless for_dropdown} js-breadcrumb-item-text #{'hidable' if hidable}") do link_to(group_path(group), class: "group-path #{'breadcrumb-item-text' unless for_dropdown} js-breadcrumb-item-text #{'hidable' if hidable}") do
output = icon = group_icon(group, class: "avatar-tile", width: 15, height: 15) if (group.try(:avatar_url) || show_avatar) && !Rails.env.test?
if (group.try(:avatar_url) || show_avatar) && !Rails.env.test? [icon, simple_sanitize(group.name)].join.html_safe
group_icon(group, class: "avatar-tile", width: 15, height: 15)
else
""
end
output << simple_sanitize(group.name)
output.html_safe
end end
end end
......
# frozen_string_literal: true
module HooksHelper module HooksHelper
def link_to_test_hook(hook, trigger) def link_to_test_hook(hook, trigger)
path = case hook path = case hook
......
# frozen_string_literal: true
require 'json' require 'json'
module IconsHelper module IconsHelper
...@@ -47,9 +49,10 @@ module IconsHelper ...@@ -47,9 +49,10 @@ module IconsHelper
end end
end end
css_classes = size ? "s#{size}" : "" css_classes = []
css_classes << " #{css_class}" unless css_class.blank? css_classes << "s#{size}" if size
content_tag(:svg, content_tag(:use, "", { "xlink:href" => "#{sprite_icon_path}##{icon_name}" } ), class: css_classes.empty? ? nil : css_classes) css_classes << "#{css_class}" unless css_class.blank?
content_tag(:svg, content_tag(:use, "", { "xlink:href" => "#{sprite_icon_path}##{icon_name}" } ), class: css_classes.empty? ? nil : css_classes.join(' '))
end end
def external_snippet_icon(name) def external_snippet_icon(name)
...@@ -70,10 +73,10 @@ module IconsHelper ...@@ -70,10 +73,10 @@ module IconsHelper
end end
def spinner(text = nil, visible = false) def spinner(text = nil, visible = false)
css_class = 'loading' css_class = ['loading']
css_class << ' hide' unless visible css_class << 'hide' unless visible
content_tag :div, class: css_class do content_tag :div, class: css_class.join(' ') do
icon('spinner spin') + text icon('spinner spin') + text
end end
end end
...@@ -97,9 +100,10 @@ module IconsHelper ...@@ -97,9 +100,10 @@ module IconsHelper
'globe' 'globe'
end end
name << " fw" if fw name = [name]
name << "fw" if fw
icon(name, options) icon(name.join(' '), options)
end end
def file_type_icon_class(type, mode, name) def file_type_icon_class(type, mode, name)
......
# frozen_string_literal: true
module ImportHelper module ImportHelper
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module InstanceConfigurationHelper module InstanceConfigurationHelper
def instance_configuration_cell_html(value, &block) def instance_configuration_cell_html(value, &block)
return '-' unless value.to_s.presence return '-' unless value.to_s.presence
......
# frozen_string_literal: true
module IssuablesHelper module IssuablesHelper
include GitlabRoutingHelper include GitlabRoutingHelper
...@@ -167,8 +169,9 @@ module IssuablesHelper ...@@ -167,8 +169,9 @@ module IssuablesHelper
end end
def issuable_meta(issuable, project, text) def issuable_meta(issuable, project, text)
output = "" output = []
output << "Opened #{time_ago_with_tooltip(issuable.created_at)} by ".html_safe output << "Opened #{time_ago_with_tooltip(issuable.created_at)} by ".html_safe
output << content_tag(:strong) do output << content_tag(:strong) do
author_output = link_to_member(project, issuable.author, size: 24, mobile_classes: "d-none d-sm-inline", tooltip: true) author_output = link_to_member(project, issuable.author, size: 24, mobile_classes: "d-none d-sm-inline", tooltip: true)
author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "d-block d-sm-none") author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "d-block d-sm-none")
...@@ -185,7 +188,7 @@ module IssuablesHelper ...@@ -185,7 +188,7 @@ module IssuablesHelper
output << content_tag(:span, (issuable.task_status if issuable.tasks?), id: "task_status", class: "d-none d-sm-none d-md-inline-block") output << content_tag(:span, (issuable.task_status if issuable.tasks?), id: "task_status", class: "d-none d-sm-none d-md-inline-block")
output << content_tag(:span, (issuable.task_status_short if issuable.tasks?), id: "task_status_short", class: "d-md-none") output << content_tag(:span, (issuable.task_status_short if issuable.tasks?), id: "task_status_short", class: "d-md-none")
output.html_safe output.join.html_safe
end end
def issuable_todo(issuable) def issuable_todo(issuable)
......
# frozen_string_literal: true
module IssuesHelper module IssuesHelper
def issue_css_classes(issue) def issue_css_classes(issue)
classes = "issue" classes = ["issue"]
classes << " closed" if issue.closed? classes << "closed" if issue.closed?
classes << " today" if issue.today? classes << "today" if issue.today?
classes classes.join(' ')
end end
# Returns an OpenStruct object suitable for use by <tt>options_from_collection_for_select</tt> # Returns an OpenStruct object suitable for use by <tt>options_from_collection_for_select</tt>
...@@ -105,8 +107,8 @@ module IssuesHelper ...@@ -105,8 +107,8 @@ module IssuesHelper
end end
def link_to_discussions_to_resolve(merge_request, single_discussion = nil) def link_to_discussions_to_resolve(merge_request, single_discussion = nil)
link_text = merge_request.to_reference link_text = [merge_request.to_reference]
link_text += " (discussion #{single_discussion.first_note.id})" if single_discussion link_text << "(discussion #{single_discussion.first_note.id})" if single_discussion
path = if single_discussion path = if single_discussion
Gitlab::UrlBuilder.build(single_discussion.first_note) Gitlab::UrlBuilder.build(single_discussion.first_note)
...@@ -115,7 +117,7 @@ module IssuesHelper ...@@ -115,7 +117,7 @@ module IssuesHelper
project_merge_request_path(project, merge_request) project_merge_request_path(project, merge_request)
end end
link_to link_text, path link_to link_text.join(' '), path
end end
def show_new_issue_link?(project) def show_new_issue_link?(project)
......
# frozen_string_literal: true
module JavascriptHelper module JavascriptHelper
def page_specific_javascript_tag(js) def page_specific_javascript_tag(js)
javascript_include_tag asset_path(js) javascript_include_tag asset_path(js)
......
# frozen_string_literal: true
module KerberosSpnegoHelper module KerberosSpnegoHelper
def allow_basic_auth? def allow_basic_auth?
true # different behavior in GitLab Enterprise Edition true # different behavior in GitLab Enterprise Edition
......
# frozen_string_literal: true
module LabelsHelper module LabelsHelper
extend self extend self
include ActionView::Helpers::TagHelper include ActionView::Helpers::TagHelper
......
# frozen_string_literal: true
module LazyImageTagHelper module LazyImageTagHelper
def placeholder_image def placeholder_image
"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
...@@ -11,9 +13,11 @@ module LazyImageTagHelper ...@@ -11,9 +13,11 @@ module LazyImageTagHelper
options[:data] ||= {} options[:data] ||= {}
options[:data][:src] = path_to_image(source) options[:data][:src] = path_to_image(source)
options[:class] ||= "" # options[:class] can be either String or Array.
options[:class] << " lazy" klass_opts = Array.wrap(options[:class])
klass_opts << "lazy"
options[:class] = klass_opts.join(' ')
source = placeholder_image source = placeholder_image
end end
......
# frozen_string_literal: true
require 'nokogiri' require 'nokogiri'
module MarkupHelper module MarkupHelper
......
# frozen_string_literal: true
module MattermostHelper module MattermostHelper
def mattermost_teams_options(teams) def mattermost_teams_options(teams)
teams.map do |team| teams.map do |team|
......
# frozen_string_literal: true
module MembersHelper module MembersHelper
def remove_member_message(member, user: nil) def remove_member_message(member, user: nil)
user = current_user if defined?(current_user) user = current_user if defined?(current_user)
text = 'Are you sure you want to'
text = 'Are you sure you want to '
action = action =
if member.request? if member.request?
if member.user == user if member.user == user
...@@ -16,13 +18,12 @@ module MembersHelper ...@@ -16,13 +18,12 @@ module MembersHelper
"remove #{member.user.name} from" "remove #{member.user.name} from"
end end
text << action << " the #{member.source.human_name} #{member.real_source_type.humanize(capitalize: false)}?" "#{text} #{action} the #{member.source.human_name} #{member.real_source_type.humanize(capitalize: false)}?"
end end
def remove_member_title(member) def remove_member_title(member)
text = " from #{member.real_source_type.humanize(capitalize: false)}" action = member.request? ? 'Deny access request' : 'Remove user'
"#{action} from #{member.real_source_type.humanize(capitalize: false)}"
text.prepend(member.request? ? 'Deny access request' : 'Remove user')
end end
def leave_confirmation_message(member_source) def leave_confirmation_message(member_source)
...@@ -32,9 +33,6 @@ module MembersHelper ...@@ -32,9 +33,6 @@ module MembersHelper
def filter_group_project_member_path(options = {}) def filter_group_project_member_path(options = {})
options = params.slice(:search, :sort).merge(options) options = params.slice(:search, :sort).merge(options)
"#{request.path}?#{options.to_param}"
path = request.path
path << "?#{options.to_param}"
path
end end
end end
# frozen_string_literal: true
module MergeRequestsHelper module MergeRequestsHelper
def new_mr_path_from_push_event(event) def new_mr_path_from_push_event(event)
target_project = event.project.default_merge_request_target target_project = event.project.default_merge_request_target
...@@ -19,10 +21,10 @@ module MergeRequestsHelper ...@@ -19,10 +21,10 @@ module MergeRequestsHelper
end end
def mr_css_classes(mr) def mr_css_classes(mr)
classes = "merge-request" classes = ["merge-request"]
classes << " closed" if mr.closed? classes << "closed" if mr.closed?
classes << " merged" if mr.merged? classes << "merged" if mr.merged?
classes classes.join(' ')
end end
def ci_build_details_path(merge_request) def ci_build_details_path(merge_request)
......
# frozen_string_literal: true
module MilestonesHelper module MilestonesHelper
include EntityDateHelper include EntityDateHelper
...@@ -119,20 +121,18 @@ module MilestonesHelper ...@@ -119,20 +121,18 @@ module MilestonesHelper
title = date_type == :start ? "Start date" : "End date" title = date_type == :start ? "Start date" : "End date"
if date if date
time_ago = time_ago_in_words(date) time_ago = time_ago_in_words(date).sub("about ", "")
time_ago.slice!("about ") state = if date.past?
"ago"
time_ago << if date.past?
" ago"
else else
" remaining" "remaining"
end end
content = [ content = [
title, title,
"<br />", "<br />",
date.to_s(:medium), date.to_s(:medium),
"(#{time_ago})" "(#{time_ago} #{state})"
].join(" ") ].join(" ")
content.html_safe content.html_safe
......
# frozen_string_literal: true
module MilestonesRoutingHelper module MilestonesRoutingHelper
def milestone_path(milestone, *args) def milestone_path(milestone, *args)
if milestone.group_milestone? if milestone.group_milestone?
......
# frozen_string_literal: true
module MirrorHelper module MirrorHelper
def mirrors_form_data_attributes def mirrors_form_data_attributes
{ project_mirror_endpoint: project_mirror_path(@project) } { project_mirror_endpoint: project_mirror_path(@project) }
......
# frozen_string_literal: true
module NamespacesHelper module NamespacesHelper
def namespace_id_from(params) def namespace_id_from(params)
params.dig(:project, :namespace_id) || params[:namespace_id] params.dig(:project, :namespace_id) || params[:namespace_id]
......
# frozen_string_literal: true
module NavHelper module NavHelper
def header_links def header_links
@header_links ||= get_header_links @header_links ||= get_header_links
......
# frozen_string_literal: true
module NotesHelper module NotesHelper
def note_target_fields(note) def note_target_fields(note)
if note.noteable if note.noteable
......
# frozen_string_literal: true
module NotificationsHelper module NotificationsHelper
include IconsHelper include IconsHelper
......
# frozen_string_literal: true
module NumbersHelper module NumbersHelper
def limited_counter_with_delimiter(resource, **options) def limited_counter_with_delimiter(resource, **options)
limit = options.fetch(:limit, 1000).to_i limit = options.fetch(:limit, 1000).to_i
......
# frozen_string_literal: true
module PageLayoutHelper module PageLayoutHelper
def page_title(*titles) def page_title(*titles)
@page_title ||= [] @page_title ||= []
...@@ -65,14 +67,14 @@ module PageLayoutHelper ...@@ -65,14 +67,14 @@ module PageLayoutHelper
end end
def page_card_meta_tags def page_card_meta_tags
tags = '' tags = []
page_card_attributes.each_with_index do |pair, i| page_card_attributes.each_with_index do |pair, i|
tags << tag(:meta, property: "twitter:label#{i + 1}", content: pair[0]) tags << tag(:meta, property: "twitter:label#{i + 1}", content: pair[0])
tags << tag(:meta, property: "twitter:data#{i + 1}", content: pair[1]) tags << tag(:meta, property: "twitter:data#{i + 1}", content: pair[1])
end end
tags.html_safe tags.join.html_safe
end end
def header_title(title = nil, title_url = nil) def header_title(title = nil, title_url = nil)
...@@ -115,16 +117,16 @@ module PageLayoutHelper ...@@ -115,16 +117,16 @@ module PageLayoutHelper
end end
def container_class def container_class
css_class = "container-fluid" css_class = ["container-fluid"]
unless fluid_layout unless fluid_layout
css_class += " container-limited" css_class << "container-limited"
end end
if blank_container if blank_container
css_class += " container-blank" css_class << "container-blank"
end end
css_class css_class.join(' ')
end end
end end
# frozen_string_literal: true
module PaginationHelper module PaginationHelper
def paginate_collection(collection, remote: nil) def paginate_collection(collection, remote: nil)
if collection.is_a?(Kaminari::PaginatableWithoutCount) if collection.is_a?(Kaminari::PaginatableWithoutCount)
......
# frozen_string_literal: true
module PerformanceBarHelper module PerformanceBarHelper
# This is a hack since using `alias_method :performance_bar_enabled?, :peek_enabled?` # This is a hack since using `alias_method :performance_bar_enabled?, :peek_enabled?`
# in WithPerformanceBar breaks tests (but works in the browser). # in WithPerformanceBar breaks tests (but works in the browser).
......
# frozen_string_literal: true
module PipelineSchedulesHelper module PipelineSchedulesHelper
def timezone_data def timezone_data
ActiveSupport::TimeZone.all.map do |timezone| ActiveSupport::TimeZone.all.map do |timezone|
......
# frozen_string_literal: true
# Helper methods for per-User preferences # Helper methods for per-User preferences
module PreferencesHelper module PreferencesHelper
def layout_choices def layout_choices
......
# frozen_string_literal: true
module ProfilesHelper module ProfilesHelper
def attribute_provider_label(attribute) def attribute_provider_label(attribute)
user_synced_attributes_metadata = current_user.user_synced_attributes_metadata user_synced_attributes_metadata = current_user.user_synced_attributes_metadata
......
# frozen_string_literal: true
module ProjectsHelper module ProjectsHelper
def link_to_project(project) def link_to_project(project)
link_to [project.namespace.becomes(Namespace), project], title: h(project.name) do link_to [project.namespace.becomes(Namespace), project], title: h(project.name) do
...@@ -50,7 +52,7 @@ module ProjectsHelper ...@@ -50,7 +52,7 @@ module ProjectsHelper
return "(deleted)" unless author return "(deleted)" unless author
author_html = "" author_html = []
# Build avatar image tag # Build avatar image tag
author_html << link_to_member_avatar(author, opts) if opts[:avatar] author_html << link_to_member_avatar(author, opts) if opts[:avatar]
...@@ -60,7 +62,7 @@ module ProjectsHelper ...@@ -60,7 +62,7 @@ module ProjectsHelper
author_html << capture(&block) if block author_html << capture(&block) if block
author_html = author_html.html_safe author_html = author_html.join.html_safe
if opts[:name] if opts[:name]
link_to(author_html, user_path(author), class: "author-link #{"#{opts[:extra_class]}" if opts[:extra_class]} #{"#{opts[:mobile_classes]}" if opts[:mobile_classes]}").html_safe link_to(author_html, user_path(author), class: "author-link #{"#{opts[:extra_class]}" if opts[:extra_class]} #{"#{opts[:mobile_classes]}" if opts[:mobile_classes]}").html_safe
...@@ -80,15 +82,8 @@ module ProjectsHelper ...@@ -80,15 +82,8 @@ module ProjectsHelper
end end
project_link = link_to project_path(project) do project_link = link_to project_path(project) do
output = icon = project_icon(project, alt: project.name, class: 'avatar-tile', width: 15, height: 15) if project.avatar_url && !Rails.env.test?
if project.avatar_url && !Rails.env.test? [icon, content_tag("span", simple_sanitize(project.name), class: "breadcrumb-item-text js-breadcrumb-item-text")].join.html_safe
project_icon(project, alt: project.name, class: 'avatar-tile', width: 15, height: 15)
else
""
end
output << content_tag("span", simple_sanitize(project.name), class: "breadcrumb-item-text js-breadcrumb-item-text")
output.html_safe
end end
namespace_link = breadcrumb_list_item(namespace_link) unless project.group namespace_link = breadcrumb_list_item(namespace_link) unless project.group
......
# frozen_string_literal: true
module RepositoryLanguagesHelper module RepositoryLanguagesHelper
def repository_languages_bar(languages) def repository_languages_bar(languages)
return if languages.none? return if languages.none?
......
# frozen_string_literal: true
module RssHelper module RssHelper
def rss_url_options def rss_url_options
{ format: :atom, feed_token: current_user.try(:feed_token) } { format: :atom, feed_token: current_user.try(:feed_token) }
......
# frozen_string_literal: true
module RunnersHelper module RunnersHelper
def runner_status_icon(runner) def runner_status_icon(runner)
status = runner.status status = runner.status
......
# frozen_string_literal: true
module SafeParamsHelper module SafeParamsHelper
# Rails 5.0 requires to permit `params` if they're used in url helpers. # Rails 5.0 requires to permit `params` if they're used in url helpers.
# Use this helper when generating links with `params.merge(...)` # Use this helper when generating links with `params.merge(...)`
......
# frozen_string_literal: true
module SearchHelper module SearchHelper
def search_autocomplete_opts(term) def search_autocomplete_opts(term)
return unless current_user return unless current_user
......
# frozen_string_literal: true
module SelectsHelper module SelectsHelper
def users_select_tag(id, opts = {}) def users_select_tag(id, opts = {})
css_class = "ajax-users-select " css_class = ["ajax-users-select"]
css_class << "multiselect " if opts[:multiple] css_class << "multiselect" if opts[:multiple]
css_class << "skip_ldap " if opts[:skip_ldap] css_class << "skip_ldap" if opts[:skip_ldap]
css_class << (opts[:class] || '') css_class << (opts[:class] || '')
value = opts[:selected] || '' value = opts[:selected] || ''
html = { html = {
class: css_class, class: css_class.join(' '),
data: users_select_data_attributes(opts) data: users_select_data_attributes(opts)
} }
...@@ -24,20 +26,21 @@ module SelectsHelper ...@@ -24,20 +26,21 @@ module SelectsHelper
end end
def groups_select_tag(id, opts = {}) def groups_select_tag(id, opts = {})
opts[:class] ||= '' classes = Array.wrap(opts[:class])
opts[:class] << ' ajax-groups-select' classes << 'ajax-groups-select'
opts[:class] = classes.join(' ')
select2_tag(id, opts) select2_tag(id, opts)
end end
def namespace_select_tag(id, opts = {}) def namespace_select_tag(id, opts = {})
opts[:class] ||= '' opts[:class] = [*opts[:class], 'ajax-namespace-select'].join(' ')
opts[:class] << ' ajax-namespace-select'
select2_tag(id, opts) select2_tag(id, opts)
end end
def project_select_tag(id, opts = {}) def project_select_tag(id, opts = {})
opts[:class] ||= '' opts[:class] = [*opts[:class], 'ajax-project-select'].join(' ')
opts[:class] << ' ajax-project-select'
unless opts.delete(:scope) == :all unless opts.delete(:scope) == :all
if @group if @group
...@@ -57,7 +60,10 @@ module SelectsHelper ...@@ -57,7 +60,10 @@ module SelectsHelper
end end
def select2_tag(id, opts = {}) def select2_tag(id, opts = {})
opts[:class] << ' multiselect' if opts[:multiple] klass_opts = [opts[:class]]
klass_opts << 'multiselect' if opts[:multiple]
opts[:class] = klass_opts.join(' ')
value = opts[:selected] || '' value = opts[:selected] || ''
hidden_field_tag(id, value, opts) hidden_field_tag(id, value, opts)
......
# frozen_string_literal: true
module SentryHelper module SentryHelper
def sentry_enabled? def sentry_enabled?
Gitlab::Sentry.enabled? Gitlab::Sentry.enabled?
......
# frozen_string_literal: true
module ServicesHelper module ServicesHelper
def service_event_description(event) def service_event_description(event)
case event case event
......
# frozen_string_literal: true
module SidekiqHelper module SidekiqHelper
SIDEKIQ_PS_REGEXP = %r{\A SIDEKIQ_PS_REGEXP = %r{\A
(?<pid>\d+)\s+ (?<pid>\d+)\s+
......
# frozen_string_literal: true
module SnippetsHelper module SnippetsHelper
def reliable_snippet_path(snippet, opts = nil) def reliable_snippet_path(snippet, opts = nil)
if snippet.project_id? if snippet.project_id?
......
# frozen_string_literal: true
module SortingHelper module SortingHelper
def sort_options_hash def sort_options_hash
{ {
......
# frozen_string_literal: true
module StorageHealthHelper module StorageHealthHelper
def failing_storage_health_message(storage_health) def failing_storage_health_message(storage_health)
storage_name = content_tag(:strong, h(storage_health.storage_name)) storage_name = content_tag(:strong, h(storage_health.storage_name))
......
# frozen_string_literal: true
module StorageHelper module StorageHelper
def storage_counter(size_in_bytes) def storage_counter(size_in_bytes)
precision = size_in_bytes < 1.megabyte ? 0 : 1 precision = size_in_bytes < 1.megabyte ? 0 : 1
......
# frozen_string_literal: true
module SubmoduleHelper module SubmoduleHelper
extend self extend self
......
# frozen_string_literal: true
module SystemNoteHelper module SystemNoteHelper
ICON_NAMES_BY_ACTION = { ICON_NAMES_BY_ACTION = {
'commit' => 'commit', 'commit' => 'commit',
......
# frozen_string_literal: true
module TabHelper module TabHelper
# Navigation link helper # Navigation link helper
# #
...@@ -47,9 +49,7 @@ module TabHelper ...@@ -47,9 +49,7 @@ module TabHelper
# Add our custom class into the html_options, which may or may not exist # Add our custom class into the html_options, which may or may not exist
# and which may or may not already have a :class key # and which may or may not already have a :class key
o = options.delete(:html_options) || {} o = options.delete(:html_options) || {}
o[:class] ||= '' o[:class] = [*o[:class], klass].join(' ').strip
o[:class] += ' ' + klass
o[:class].strip!
if block_given? if block_given?
content_tag(:li, capture(&block), o) content_tag(:li, capture(&block), o)
......
# frozen_string_literal: true
module TagsHelper module TagsHelper
def tag_path(tag) def tag_path(tag)
"/tags/#{tag}" "/tags/#{tag}"
...@@ -14,12 +16,13 @@ module TagsHelper ...@@ -14,12 +16,13 @@ module TagsHelper
end end
def tag_list(project) def tag_list(project)
html = '' html = []
project.tag_list.each do |tag| project.tag_list.each do |tag|
html << link_to(tag, tag_path(tag)) html << link_to(tag, tag_path(tag))
end end
html.html_safe html.join.html_safe
end end
def protected_tag?(project, tag) def protected_tag?(project, tag)
......
# frozen_string_literal: true
module TimeHelper module TimeHelper
def time_interval_in_words(interval_in_seconds) def time_interval_in_words(interval_in_seconds)
interval_in_seconds = interval_in_seconds.to_i interval_in_seconds = interval_in_seconds.to_i
......
# frozen_string_literal: true
module TodosHelper module TodosHelper
def todos_pending_count def todos_pending_count
@todos_pending_count ||= current_user.todos_pending_count @todos_pending_count ||= current_user.todos_pending_count
...@@ -94,9 +96,7 @@ module TodosHelper ...@@ -94,9 +96,7 @@ module TodosHelper
end end
end end
path = request.path "#{request.path}?#{options.to_param}"
path << "?#{options.to_param}"
path
end end
def todo_actions_options def todo_actions_options
...@@ -152,10 +152,11 @@ module TodosHelper ...@@ -152,10 +152,11 @@ module TodosHelper
'' ''
end end
html = "&middot; ".html_safe content = content_tag(:span, class: css_class) do
html << content_tag(:span, class: css_class) do
"Due #{is_due_today ? "today" : todo.target.due_date.to_s(:medium)}" "Due #{is_due_today ? "today" : todo.target.due_date.to_s(:medium)}"
end end
"&middot; #{content}".html_safe
end end
private private
......
# frozen_string_literal: true
module TreeHelper module TreeHelper
FILE_LIMIT = 1_000 FILE_LIMIT = 1_000
...@@ -8,7 +10,7 @@ module TreeHelper ...@@ -8,7 +10,7 @@ module TreeHelper
def render_tree(tree) def render_tree(tree)
# Sort submodules and folders together by name ahead of files # Sort submodules and folders together by name ahead of files
folders, files, submodules = tree.trees, tree.blobs, tree.submodules folders, files, submodules = tree.trees, tree.blobs, tree.submodules
tree = '' tree = []
items = (folders + submodules).sort_by(&:name) + files items = (folders + submodules).sort_by(&:name) + files
if items.size > FILE_LIMIT if items.size > FILE_LIMIT
...@@ -18,7 +20,7 @@ module TreeHelper ...@@ -18,7 +20,7 @@ module TreeHelper
end end
tree << render(partial: 'projects/tree/tree_row', collection: items) if items.present? tree << render(partial: 'projects/tree/tree_row', collection: items) if items.present?
tree.html_safe tree.join.html_safe
end end
# Return an image icon depending on the file type and mode # Return an image icon depending on the file type and mode
......
# frozen_string_literal: true
module TriggersHelper module TriggersHelper
def builds_trigger_url(project_id, ref: nil) def builds_trigger_url(project_id, ref: nil)
if ref.nil? if ref.nil?
......
# frozen_string_literal: true
module UserCalloutsHelper module UserCalloutsHelper
GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze
GCP_SIGNUP_OFFER = 'gcp_signup_offer'.freeze GCP_SIGNUP_OFFER = 'gcp_signup_offer'.freeze
......
# frozen_string_literal: true
module UsersHelper module UsersHelper
def user_link(user) def user_link(user)
link_to(user.name, user_path(user), link_to(user.name, user_path(user),
......
# frozen_string_literal: true
module VersionCheckHelper module VersionCheckHelper
def version_status_badge def version_status_badge
if Rails.env.production? && Gitlab::CurrentSettings.version_check_enabled if Rails.env.production? && Gitlab::CurrentSettings.version_check_enabled
......
# frozen_string_literal: true
module VisibilityLevelHelper module VisibilityLevelHelper
def visibility_level_color(level) def visibility_level_color(level)
case level case level
...@@ -82,7 +84,7 @@ module VisibilityLevelHelper ...@@ -82,7 +84,7 @@ module VisibilityLevelHelper
def disallowed_project_visibility_level_description(level, project) def disallowed_project_visibility_level_description(level, project)
level_name = Gitlab::VisibilityLevel.level_name(level).downcase level_name = Gitlab::VisibilityLevel.level_name(level).downcase
reasons = [] reasons = []
instructions = '' instructions = []
unless project.visibility_level_allowed_as_fork?(level) unless project.visibility_level_allowed_as_fork?(level)
reasons << "the fork source project has lower visibility" reasons << "the fork source project has lower visibility"
...@@ -96,7 +98,7 @@ module VisibilityLevelHelper ...@@ -96,7 +98,7 @@ module VisibilityLevelHelper
end end
reasons = reasons.any? ? ' because ' + reasons.to_sentence : '' reasons = reasons.any? ? ' because ' + reasons.to_sentence : ''
"This project cannot be #{level_name}#{reasons}.#{instructions}".html_safe "This project cannot be #{level_name}#{reasons}.#{instructions.join}".html_safe
end end
# Note: these messages closely mirror the form validation strings found in the group # Note: these messages closely mirror the form validation strings found in the group
...@@ -104,7 +106,7 @@ module VisibilityLevelHelper ...@@ -104,7 +106,7 @@ module VisibilityLevelHelper
def disallowed_group_visibility_level_description(level, group) def disallowed_group_visibility_level_description(level, group)
level_name = Gitlab::VisibilityLevel.level_name(level).downcase level_name = Gitlab::VisibilityLevel.level_name(level).downcase
reasons = [] reasons = []
instructions = '' instructions = []
unless group.visibility_level_allowed_by_projects?(level) unless group.visibility_level_allowed_by_projects?(level)
reasons << "it contains projects with higher visibility" reasons << "it contains projects with higher visibility"
...@@ -122,7 +124,7 @@ module VisibilityLevelHelper ...@@ -122,7 +124,7 @@ module VisibilityLevelHelper
end end
reasons = reasons.any? ? ' because ' + reasons.to_sentence : '' reasons = reasons.any? ? ' because ' + reasons.to_sentence : ''
"This group cannot be #{level_name}#{reasons}.#{instructions}".html_safe "This group cannot be #{level_name}#{reasons}.#{instructions.join}".html_safe
end end
def visibility_icon_description(form_model) def visibility_icon_description(form_model)
......
# frozen_string_literal: true
module WebpackHelper module WebpackHelper
def webpack_bundle_tag(bundle) def webpack_bundle_tag(bundle)
javascript_include_tag(*webpack_entrypoint_paths(bundle)) javascript_include_tag(*webpack_entrypoint_paths(bundle))
......
# frozen_string_literal: true
module WikiHelper module WikiHelper
include API::Helpers::RelatedResourcesHelpers include API::Helpers::RelatedResourcesHelpers
......
# frozen_string_literal: true
# Helpers to send Git blobs, diffs, patches or archives through Workhorse. # Helpers to send Git blobs, diffs, patches or archives through Workhorse.
# Workhorse will also serve files when using `send_file`. # Workhorse will also serve files when using `send_file`.
module WorkhorseHelper module WorkhorseHelper
......
# frozen_string_literal: true
class LicenseTemplate class LicenseTemplate
PROJECT_TEMPLATE_REGEX = PROJECT_TEMPLATE_REGEX =
%r{[\<\{\[] %r{[\<\{\[]
......
---
title: Enable frozen string for app/helpers/**/*.rb
merge_request:
author: gfyoung
type: performance
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment