Use project helper instead of helper patch
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
14
app/helpers/messenger_projects_helper.rb
Normal file
14
app/helpers/messenger_projects_helper.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user