Commit 7602e839 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'move-helper-prepends' into 'master'

Move EE prepend/include to the end of helpers

See merge request gitlab-org/gitlab-ee!8422
parents 0724350f 2c3daf77
# frozen_string_literal: true # frozen_string_literal: true
module AppearancesHelper module AppearancesHelper
prepend EE::AppearancesHelper
def brand_title def brand_title
current_appearance&.title.presence || 'GitLab Enterprise Edition' current_appearance&.title.presence || 'GitLab Enterprise Edition'
end end
...@@ -38,3 +36,5 @@ module AppearancesHelper ...@@ -38,3 +36,5 @@ module AppearancesHelper
end end
end end
end end
AppearancesHelper.prepend(EE::AppearancesHelper)
...@@ -4,8 +4,6 @@ require 'digest/md5' ...@@ -4,8 +4,6 @@ require 'digest/md5'
require 'uri' require 'uri'
module ApplicationHelper module ApplicationHelper
prepend EE::ApplicationHelper
# See https://docs.gitlab.com/ee/development/ee_features.html#code-in-app-views # See https://docs.gitlab.com/ee/development/ee_features.html#code-in-app-views
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def render_if_exists(partial, locals = {}) def render_if_exists(partial, locals = {})
...@@ -303,3 +301,5 @@ module ApplicationHelper ...@@ -303,3 +301,5 @@ module ApplicationHelper
} }
end end
end end
ApplicationHelper.prepend(EE::ApplicationHelper)
# frozen_string_literal: true # frozen_string_literal: true
module ApplicationSettingsHelper module ApplicationSettingsHelper
prepend EE::ApplicationSettingsHelper
extend self extend self
delegate :allow_signup?, delegate :allow_signup?,
...@@ -227,3 +226,9 @@ module ApplicationSettingsHelper ...@@ -227,3 +226,9 @@ module ApplicationSettingsHelper
Rails.env.test? Rails.env.test?
end end
end end
ApplicationSettingsHelper.prepend(EE::ApplicationSettingsHelper)
# The methods in `EE::ApplicationSettingsHelper` should be available as both
# instance and class methods.
ApplicationSettingsHelper.extend(EE::ApplicationSettingsHelper)
# frozen_string_literal: true # frozen_string_literal: true
module AuthHelper module AuthHelper
prepend EE::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/
...@@ -80,3 +78,9 @@ module AuthHelper ...@@ -80,3 +78,9 @@ module AuthHelper
extend self extend self
end end
AuthHelper.prepend(EE::AuthHelper)
# The methods added in EE should be available as both class and instance
# methods, just like the methods provided by `AuthHelper` itself.
AuthHelper.extend(EE::AuthHelper)
# frozen_string_literal: true # frozen_string_literal: true
module AwardEmojiHelper module AwardEmojiHelper
prepend EE::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)
...@@ -18,3 +16,5 @@ module AwardEmojiHelper ...@@ -18,3 +16,5 @@ module AwardEmojiHelper
end end
end end
end end
AwardEmojiHelper.prepend(EE::AwardEmojiHelper)
# frozen_string_literal: true # frozen_string_literal: true
module BoardsHelper module BoardsHelper
prepend EE::BoardsHelper
def board def board
@board ||= @board || @boards.first @board ||= @board || @boards.first
end end
...@@ -91,3 +89,5 @@ module BoardsHelper ...@@ -91,3 +89,5 @@ module BoardsHelper
s_("IssueBoards|Board") s_("IssueBoards|Board")
end end
end end
BoardsHelper.prepend(EE::BoardsHelper)
# frozen_string_literal: true # frozen_string_literal: true
module BranchesHelper module BranchesHelper
prepend EE::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)
end end
...@@ -19,3 +17,5 @@ module BranchesHelper ...@@ -19,3 +17,5 @@ module BranchesHelper
end end
end end
end end
BranchesHelper.prepend(EE::BranchesHelper)
# frozen_string_literal: true # frozen_string_literal: true
module ClustersHelper module ClustersHelper
prepend EE::ClustersHelper
# EE overrides this # EE overrides this
def has_multiple_clusters? def has_multiple_clusters?
false false
...@@ -17,3 +15,5 @@ module ClustersHelper ...@@ -17,3 +15,5 @@ module ClustersHelper
end end
end end
end end
ClustersHelper.prepend(EE::ClustersHelper)
# frozen_string_literal: true # frozen_string_literal: true
module EmailsHelper module EmailsHelper
prepend EE::EmailsHelper
include AppearancesHelper include AppearancesHelper
# Google Actions # Google Actions
...@@ -101,3 +99,5 @@ module EmailsHelper ...@@ -101,3 +99,5 @@ module EmailsHelper
"#{string} on #{Gitlab.config.gitlab.host}" "#{string} on #{Gitlab.config.gitlab.host}"
end end
end end
EmailsHelper.prepend(EE::EmailsHelper)
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
# Shorter routing method for some project items # Shorter routing method for some project items
module GitlabRoutingHelper module GitlabRoutingHelper
include EE::GitlabRoutingHelper
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
...@@ -196,3 +194,5 @@ module GitlabRoutingHelper ...@@ -196,3 +194,5 @@ module GitlabRoutingHelper
take_ownership_project_pipeline_schedule_path(project, schedule, *args) take_ownership_project_pipeline_schedule_path(project, schedule, *args)
end end
end end
GitlabRoutingHelper.include(EE::GitlabRoutingHelper)
# frozen_string_literal: true # frozen_string_literal: true
module GroupsHelper module GroupsHelper
prepend EE::GroupsHelper
def group_overview_nav_link_paths def group_overview_nav_link_paths
%w[ %w[
groups#show groups#show
...@@ -201,3 +199,5 @@ module GroupsHelper ...@@ -201,3 +199,5 @@ module GroupsHelper
s_("GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup.").html_safe % { ancestor_group: ancestor_group(group) } s_("GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup.").html_safe % { ancestor_group: ancestor_group(group) }
end end
end end
GroupsHelper.prepend(EE::GroupsHelper)
# frozen_string_literal: true # frozen_string_literal: true
module IssuablesHelper module IssuablesHelper
prepend EE::IssuablesHelper
include GitlabRoutingHelper include GitlabRoutingHelper
def sidebar_gutter_toggle_icon def sidebar_gutter_toggle_icon
...@@ -440,3 +438,5 @@ module IssuablesHelper ...@@ -440,3 +438,5 @@ module IssuablesHelper
end end
end end
end end
IssuablesHelper.prepend(EE::IssuablesHelper)
# frozen_string_literal: true # frozen_string_literal: true
module IssuesHelper module IssuesHelper
include EE::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?
...@@ -142,3 +140,5 @@ module IssuesHelper ...@@ -142,3 +140,5 @@ module IssuesHelper
module_function :url_for_internal_issue module_function :url_for_internal_issue
module_function :url_for_tracker_issue module_function :url_for_tracker_issue
end end
IssuesHelper.include(EE::IssuesHelper)
# frozen_string_literal: true # frozen_string_literal: true
module MergeRequestsHelper module MergeRequestsHelper
prepend EE::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
project_new_merge_request_path( project_new_merge_request_path(
...@@ -161,3 +159,5 @@ module MergeRequestsHelper ...@@ -161,3 +159,5 @@ module MergeRequestsHelper
end end
end end
end end
MergeRequestsHelper.prepend(EE::MergeRequestsHelper)
# frozen_string_literal: true # frozen_string_literal: true
module MilestonesHelper module MilestonesHelper
prepend EE::MilestonesHelper
include EntityDateHelper include EntityDateHelper
def milestones_filter_path(opts = {}) def milestones_filter_path(opts = {})
...@@ -245,3 +244,5 @@ module MilestonesHelper ...@@ -245,3 +244,5 @@ module MilestonesHelper
end end
end end
end end
MilestonesHelper.prepend(EE::MilestonesHelper)
# frozen_string_literal: true # frozen_string_literal: true
module NamespacesHelper module NamespacesHelper
include EE::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]
end end
...@@ -87,3 +85,5 @@ module NamespacesHelper ...@@ -87,3 +85,5 @@ module NamespacesHelper
[group_label.camelize, elements] [group_label.camelize, elements]
end end
end end
NamespacesHelper.include(EE::NamespacesHelper)
# frozen_string_literal: true # frozen_string_literal: true
module NotesHelper module NotesHelper
prepend EE::NotesHelper
def note_target_fields(note) def note_target_fields(note)
if note.noteable if note.noteable
hidden_field_tag(:target_type, note.noteable.class.name.underscore) + hidden_field_tag(:target_type, note.noteable.class.name.underscore) +
...@@ -195,3 +193,5 @@ module NotesHelper ...@@ -195,3 +193,5 @@ module NotesHelper
rendered_for_merge_request? || params['html'].nil? rendered_for_merge_request? || params['html'].nil?
end end
end end
NotesHelper.prepend(EE::NotesHelper)
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
# Helper methods for per-User preferences # Helper methods for per-User preferences
module PreferencesHelper module PreferencesHelper
prepend EE::PreferencesHelper
def layout_choices def layout_choices
[ [
['Fixed', :fixed], ['Fixed', :fixed],
...@@ -69,3 +67,5 @@ module PreferencesHelper ...@@ -69,3 +67,5 @@ module PreferencesHelper
['operations'] ['operations']
end end
end end
PreferencesHelper.prepend(EE::PreferencesHelper)
# frozen_string_literal: true # frozen_string_literal: true
module SearchHelper module SearchHelper
prepend EE::SearchHelper
def search_autocomplete_opts(term) def search_autocomplete_opts(term)
return unless current_user return unless current_user
...@@ -193,3 +191,5 @@ module SearchHelper ...@@ -193,3 +191,5 @@ module SearchHelper
count > limit ? "#{limit}+" : count count > limit ? "#{limit}+" : count
end end
end end
SearchHelper.prepend(EE::SearchHelper)
# frozen_string_literal: true # frozen_string_literal: true
module ServicesHelper module ServicesHelper
prepend EE::ServicesHelper
def service_event_description(event) def service_event_description(event)
case event case event
when "push", "push_events" when "push", "push_events"
...@@ -46,3 +44,9 @@ module ServicesHelper ...@@ -46,3 +44,9 @@ module ServicesHelper
extend self extend self
end end
ServicesHelper.prepend(EE::ServicesHelper)
# The methods in `EE::ServicesHelper` should be available as both instance and
# class methods.
ServicesHelper.extend(EE::ServicesHelper)
# frozen_string_literal: true # frozen_string_literal: true
module SystemNoteHelper module SystemNoteHelper
prepend EE::SystemNoteHelper
ICON_NAMES_BY_ACTION = { ICON_NAMES_BY_ACTION = {
'commit' => 'commit', 'commit' => 'commit',
'description' => 'pencil-square', 'description' => 'pencil-square',
...@@ -40,3 +38,9 @@ module SystemNoteHelper ...@@ -40,3 +38,9 @@ module SystemNoteHelper
extend self extend self
end end
SystemNoteHelper.prepend(EE::SystemNoteHelper)
# The methods in `EE::SystemNoteHelper` should be available as both instance and
# class methods.
SystemNoteHelper.extend(EE::SystemNoteHelper)
# frozen_string_literal: true # frozen_string_literal: true
module TodosHelper module TodosHelper
prepend EE::NotesHelper
def todos_pending_count def todos_pending_count
@todos_pending_count ||= current_user.todos_pending_count @todos_pending_count ||= current_user.todos_pending_count
end end
...@@ -179,3 +177,5 @@ module TodosHelper ...@@ -179,3 +177,5 @@ module TodosHelper
groups.unshift({ id: '', text: 'Any Group' }).to_json groups.unshift({ id: '', text: 'Any Group' }).to_json
end end
end end
TodosHelper.prepend(EE::NotesHelper)
# frozen_string_literal: true # frozen_string_literal: true
module VersionCheckHelper module VersionCheckHelper
prepend EE::VersionCheckHelper
def version_status_badge def version_status_badge
return unless Rails.env.production? return unless Rails.env.production?
return unless Gitlab::CurrentSettings.version_check_enabled return unless Gitlab::CurrentSettings.version_check_enabled
...@@ -25,3 +23,5 @@ module VersionCheckHelper ...@@ -25,3 +23,5 @@ module VersionCheckHelper
'gitlab-ce' 'gitlab-ce'
end end
end end
VersionCheckHelper.prepend(EE::VersionCheckHelper)
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