From 817d96fa42973e823fd7547d01914a7bace09f34 Mon Sep 17 00:00:00 2001 From: jan_sevecek_sperling <jan.sevecek@sperling.cz> Date: Tue, 31 Aug 2021 14:52:57 +0200 Subject: [PATCH] Update lib/sparkline_hook_listener.rb, lib/settings_controller_patch.rb, lib/sparkline_projects_helper_patch.rb, init.rb files Deleted lib/patches/projects_helper_patch.rb, lib/patches/settings_controller_patch.rb files --- init.rb | 8 +++ lib/patches/projects_helper_patch.rb | 54 ------------------- .../settings_controller_patch.rb | 2 +- lib/sparkline_hook_listener.rb | 2 +- lib/sparkline_projects_helper_patch.rb | 17 ++++++ 5 files changed, 27 insertions(+), 56 deletions(-) delete mode 100644 lib/patches/projects_helper_patch.rb rename lib/{patches => }/settings_controller_patch.rb (99%) create mode 100644 lib/sparkline_projects_helper_patch.rb diff --git a/init.rb b/init.rb index d559d38..b2a472f 100644 --- a/init.rb +++ b/init.rb @@ -1,3 +1,5 @@ +require 'redmine' + Redmine::Plugin.register :sparkline do name 'Sparkline plugin' author 'Sperling' @@ -21,4 +23,10 @@ Redmine::Plugin.register :sparkline do } end + Rails.configuration.to_prepare do + require_dependency 'projects_helper' + unless ProjectsHelper.included_modules.include? SparklineProjectsHelperPatch + ProjectsHelper.send(:include, SparklineProjectsHelperPatch) + end + end end diff --git a/lib/patches/projects_helper_patch.rb b/lib/patches/projects_helper_patch.rb deleted file mode 100644 index e22b85b..0000000 --- a/lib/patches/projects_helper_patch.rb +++ /dev/null @@ -1,54 +0,0 @@ -# frozen_string_literal: true - -# Redmine - project management software -# Copyright (C) 2006-2019 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -module ProjectsHelperPatch - def self.included(base) - # :nodoc: - base.extend(ClassMethods) - - base.send(:include, InstanceMethods) - # Same as typing in the class - base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development - - alias_method :project_settings_tabs_without_sparkline, :project_settings_tabs - alias_method :project_settings_tabs, :project_settings_tabs_with_sparkline - end - end - - module ClassMethods - end - - module InstanceMethods - def project_settings_tabs_with_sparkline - tabs = project_settings_tabs_without_sparkline - if @project.enabled_module(:sparkline) - tabs.push ( {:name => 'sparkline', :action => :sparkline, :partial => 'settings/plugin_sparkline', :label => :sparkline}) - end - tabs - end - end -end - - - -unless ProjectsHelper.included_modules.include? ProjectsHelperPatch - ProjectsHelper.send(:include, ProjectsHelperPatch) -end diff --git a/lib/patches/settings_controller_patch.rb b/lib/settings_controller_patch.rb similarity index 99% rename from lib/patches/settings_controller_patch.rb rename to lib/settings_controller_patch.rb index 8a7eba3..a3d25c7 100644 --- a/lib/patches/settings_controller_patch.rb +++ b/lib/settings_controller_patch.rb @@ -62,4 +62,4 @@ end unless SettingsController.included_modules.include? SettingsControllerPatch SettingsController.send(:include, SettingsControllerPatch) -end \ No newline at end of file +end diff --git a/lib/sparkline_hook_listener.rb b/lib/sparkline_hook_listener.rb index 07a3651..aceabb6 100644 --- a/lib/sparkline_hook_listener.rb +++ b/lib/sparkline_hook_listener.rb @@ -2,4 +2,4 @@ class SparklineHookListener < Redmine::Hook::ViewListener render_on :view_issues_index_bottom, partial: "hooks/sparkline_issues_list" render_on :view_issues_show_details_bottom, partial: "hooks/sparkline_issues_show" -end \ No newline at end of file +end diff --git a/lib/sparkline_projects_helper_patch.rb b/lib/sparkline_projects_helper_patch.rb new file mode 100644 index 0000000..55a8f0c --- /dev/null +++ b/lib/sparkline_projects_helper_patch.rb @@ -0,0 +1,17 @@ +require_dependency 'projects_helper' + +module SparklineProjectsHelperPatch + module ProjectsHelperPatch + def project_settings_tabs + tabs = super + action = {:name => 'sparkline', + :action => :sparkline, + :partial => 'settings/plugin_sparkline', + :label => :sparkline} + tabs << action if @project.enabled_module(:sparkline) + tabs + end + end +end + +ProjectsHelper.prepend SparklineProjectsHelperPatch::ProjectsHelperPatch -- GitLab