Use project helper instead of helper patch

This commit is contained in:
Alexander Meindl
2018-07-27 19:49:36 +02:00
parent f670a44c66
commit 4f5868cc57
4 changed files with 20 additions and 32 deletions

View File

@@ -3,7 +3,7 @@ Rails:
AllCops:
TargetRubyVersion: 2.2
TargetRailsVersion: 4.2
TargetRailsVersion: 5.2
Metrics/AbcSize:
Max: 65
@@ -35,6 +35,10 @@ Rails/SkipsModelValidations:
Rails/CreateTableWithTimestamps:
Enabled: false
# we drop this, if we drop Rails 4.2 support
Rails/ApplicationRecord:
Enabled: false
Style/AutoResourceCleanup:
Enabled: true

View File

@@ -0,0 +1,14 @@
module MessengerProjectsHelper
def project_settings_tabs
tabs = super
if User.current.allowed_to?(:manage_messenger, @project)
tabs << { name: 'messenger',
action: :show,
partial: 'messenger_settings/show',
label: :label_messenger }
end
tabs
end
end

View File

@@ -18,7 +18,7 @@ Rails.configuration.to_prepare do
# Patches
require_dependency 'redmine_messenger/patches/issue_patch'
require_dependency 'redmine_messenger/patches/wiki_page_patch'
require_dependency 'redmine_messenger/patches/projects_helper_patch'
ProjectsController.send :helper, MessengerProjectsHelper
require 'redmine_messenger/patches/contact_patch' if RedmineMessenger::REDMINE_CONTACTS_SUPPORT
require 'redmine_messenger/patches/db_entry_patch' if RedmineMessenger::REDMINE_DB_SUPPORT

View File

@@ -1,30 +0,0 @@
module RedmineMessenger
module Patches
module ProjectsHelperPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :project_settings_tabs_without_messenger, :project_settings_tabs
alias_method :project_settings_tabs, :project_settings_tabs_with_messenger
end
end
module InstanceMethods
def project_settings_tabs_with_messenger
tabs = project_settings_tabs_without_messenger
action = { name: 'messenger',
action: :show,
partial: 'messenger_settings/show',
label: :label_messenger }
tabs << action if User.current.allowed_to?(:manage_messenger, @project)
tabs
end
end
end
end
end
unless ProjectsHelper.included_modules.include?(RedmineMessenger::Patches::ProjectsHelperPatch)
ProjectsHelper.send(:include, RedmineMessenger::Patches::ProjectsHelperPatch)
end