Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Redmine 5 only work and fix icon-expanded class
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed Mar 30, 2022
1 parent 453f8ca commit 25827be
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
ruby-version: 3.0
bundler-cache: true

- name: Setup gems
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ jobs:

strategy:
matrix:
ruby: ['2.7', '2.6', '3.0']
redmine: ['4.1-stable', '4.2-stable', 'master']
ruby: ['2.7', '3.0', '3.1']
redmine: ['5.0-stable', 'master']
db: ['postgres', 'mysql']
exclude:
- ruby: '2.7'
redmine: 4.1-stable
- ruby: '3.0'
redmine: 4.1-stable
- ruby: '3.0'
redmine: 4.2-stable
fail-fast: false

services:
Expand Down
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Rails:
Enabled: true

AllCops:
TargetRubyVersion: 2.6
TargetRailsVersion: 5.2
TargetRubyVersion: 2.7
TargetRailsVersion: 6.1.4
NewCops: enable

Metrics/AbcSize:
Expand Down
2 changes: 1 addition & 1 deletion additionals.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|

spec.files = Dir['**/*'] - Dir['test/**/*'] - Dir['Gemfile', 'Gemfile.lock', 'README.rst']
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 2.6'
spec.required_ruby_version = '>= 2.7'

spec.add_runtime_dependency 'gemoji', '~> 3.0.0'
spec.add_runtime_dependency 'redmine_plugin_kit'
Expand Down
10 changes: 2 additions & 8 deletions app/models/additionals_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ def available_column_names(only_sortable: false, only_groupable: false, only_tot
names = send(method_name.join).dup
names.flatten!
names.select! { |col| col.sortable.present? } if only_sortable
if only_groupable
if Redmine::VERSION.to_s >= '4.2'
names.select!(&:groupable?)
else
names.select!(&:groupable)
end
end
names.select!(&:groupable?) if only_groupable
names.select!(&:totalable) if only_totalable
names.map(&:name)
end
Expand Down Expand Up @@ -222,7 +216,7 @@ def entries(**_)
end

def results_scope(**options)
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten!.to_a.reject(&:blank?)
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten!.to_a.compact_blank

objects_scope(**options.except(:order, :limit, :offset))
.order(order_option)
Expand Down
4 changes: 2 additions & 2 deletions app/models/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def async_params(block, options, settings)

if settings.present?
settings.each do |key, setting|
settings[key] = setting.reject(&:blank?).join(',') if setting.is_a? Array
settings[key] = setting.compact_blank.join ',' if setting.is_a? Array

next if options[:exposed_params].blank?

Expand All @@ -331,7 +331,7 @@ def async_params(block, options, settings)
end

unique_params = settings.flatten
unique_params += options[:unique_params].reject(&:blank?) if options[:unique_params].present?
unique_params += options[:unique_params].compact_blank if options[:unique_params].present?

# Rails.logger.debug "debug async_params for #{block}: unique_params=#{unique_params.inspect}"
# For truncating hash security, see https://crypto.stackexchange.com/questions/9435/is-truncating-a-sha512-hash-to-the-first-160-bits-as-secure-as-using-sha1
Expand Down
19 changes: 6 additions & 13 deletions app/overrides/issues_show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@ module IssuesShow
replace: 'erb[loud]:contains("User.current.allowed_to?(:log_time, @project)")',
original: '4bbf065b9f960687e07f76e7232eb21bf183a981',
partial: 'issues/additionals_action_menu_log_time'
if Redmine::VERSION.to_s >= '4.2'
Deface::Override.new virtual_path: 'issues/_action_menu',
name: 'add-issue-assign-to-me',
insert_after: 'erb[loud]:contains("watcher_link")',
original: 'a519feb931e157589bc506b2673abeef994aa96b',
partial: 'issues/additionals_action_menu'
else
Deface::Override.new virtual_path: 'issues/_action_menu',
name: 'add-issue-assign-to-me',
insert_bottom: 'div.contextual',
original: '44ef032156db0dfdb67301fdb9ef8901abeca18a',
partial: 'issues/additionals_action_menu'
end

Deface::Override.new virtual_path: 'issues/_action_menu',
name: 'add-issue-assign-to-me',
insert_after: 'erb[loud]:contains("watcher_link")',
original: 'a519feb931e157589bc506b2673abeef994aa96b',
partial: 'issues/additionals_action_menu'
end
18 changes: 5 additions & 13 deletions app/overrides/projects_settings_issues.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
# frozen_string_literal: true

module ProjectsSettingsIssues
if Rails.version > '6.0' # Redmine 5
Deface::Override.new virtual_path: 'projects/settings/_issues',
name: 'add-project-issue-settings',
insert_before: 'div.box.tabular',
original: 'f14b1e325de2e0de0e81443716705547a6c8471f',
text: '<%= call_hook :view_projects_issue_settings, f: f, project: @project %>'
else
Deface::Override.new virtual_path: 'projects/settings/_issues',
name: 'add-project-issue-settings',
insert_before: 'div.box.tabular',
original: '468bd73ed808b51fc5589f6c9c23e93a5b7b787a',
text: '<%= call_hook :view_projects_issue_settings, f: f, project: @project %>'
end
Deface::Override.new virtual_path: 'projects/settings/_issues',
name: 'add-project-issue-settings',
insert_before: 'div.box.tabular',
original: 'f14b1e325de2e0de0e81443716705547a6c8471f',
text: '<%= call_hook :view_projects_issue_settings, f: f, project: @project %>'
end
18 changes: 5 additions & 13 deletions app/overrides/users_show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@

module UsersShow
unless defined? RedmineHrm
if Redmine::VERSION.to_s >= '4.2'
Deface::Override.new virtual_path: 'users/show',
name: 'user-show-info-hook',
insert_top: 'div.splitcontentleft ul:first-child',
original: '9a47f38a2f2efe7ab824dd8d435db172a2344aa8',
partial: 'hooks/view_users_show_info'
else
Deface::Override.new virtual_path: 'users/show',
name: 'user-show-info-hook',
insert_top: 'div.splitcontentleft ul:first-child',
original: '743d616ab7942bb6bc65bd00626b6a5143247a37',
partial: 'hooks/view_users_show_info'
end
Deface::Override.new virtual_path: 'users/show',
name: 'user-show-info-hook',
insert_top: 'div.splitcontentleft ul:first-child',
original: '9a47f38a2f2efe7ab824dd8d435db172a2344aa8',
partial: 'hooks/view_users_show_info'

Deface::Override.new virtual_path: 'users/show',
name: 'user-contextual-hook',
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
data: { confirm: l(:text_are_you_sure) }, method: :post, class: 'icon icon-lock'
= link_to l(:button_copy), copy_project_path(@project), class: 'icon icon-copy'
= link_to l(:button_delete), project_path(@project), method: :delete, class: 'icon icon-del'
- elsif Redmine::VERSION.to_s >= '4.2' && @project.deletable?
- elsif @project.deletable?
= link_to l(:button_delete), project_path(@project), method: :delete, class: 'icon icon-del'

- if User.current.allowed_to? :save_dashboards, @project
Expand Down
2 changes: 1 addition & 1 deletion app/views/queries/_additionals_group_view.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- reset_cycle
tr.group.open
td colspan="#{query.inline_columns.size + 2}"
span.expander.icon.icon-expended[onclick="toggleRowGroup(this);"]
span.expander.icon.icon-expanded[onclick="toggleRowGroup(this);"]
'  
span.name = group_name
- if group_count.present?
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

# General information about the project.
project = u'additionals'
copyright = u'2013-2021, AlphaNodes GmbH'
copyright = u'2013-2022, AlphaNodes GmbH'
author = u'Alexander Meindl'

# The short X.Y version.
version = u'3.0.3'
version = u'3.0.6'
# The full version, including alpha/beta/rc tags.
release = u'3.0.3'
release = u'3.0.6'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ Requirements
------------

+--------------------+----------------------------------+
| `Redmine`_ version | >= 4.1.0 |
| `Redmine`_ version | >= 5.0 |
+--------------------+----------------------------------+
| `Ruby`_ version | >= 2.6 |
| `Ruby`_ version | >= 2.7 |
+--------------------+----------------------------------+
| Database version | MySQL >= 5.7 or PostgreSQL >= 10 |
| Database version | MySQL >= 8.0 or PostgreSQL >= 10 |
+--------------------+----------------------------------+

.. note::
Expand Down
4 changes: 1 addition & 3 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
end

# required redmine version
requires_redmine version_or_higher: '4.1'
requires_redmine version_or_higher: '5.0'

menu :admin_menu, :additionals, { controller: 'settings', action: 'plugin', id: 'additionals' }, caption: :label_additionals
end
Expand All @@ -68,5 +68,3 @@
far: AdditionalsFontAwesome.load_icons(:far),
fas: AdditionalsFontAwesome.load_icons(:fas) }.freeze
end

RedminePluginKit::Loader.to_prepare { Additionals.setup!(loader) } if Rails.version < '6.0'
1 change: 0 additions & 1 deletion lib/additionals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ class Plugin < ::Rails::Engine

# gem is used as redmine plugin
require File.expand_path '../init', __dir__
Additionals.setup! if Rails.version < '6.0'
Additionals::Gemify.install_assets plugin_id
Additionals::Gemify.create_plugin_hint plugin_id
end
Expand Down
2 changes: 0 additions & 2 deletions lib/additionals/hooks/model_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module Additionals
module Hooks
class ModelHook < Redmine::Hook::Listener
def after_plugins_loaded(_context = {})
return if Rails.version < '6.0'

Additionals.setup!
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/additionals/patches/access_control_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def disabled_project_modules
@database_ready = (RedminePluginKit::Loader.redmine_database_ready? Setting.table_name) unless defined? @database_ready
return [] unless @database_ready

mods = Additionals.setting(:disabled_modules).to_a.reject(&:blank?)
mods = Additionals.setting(:disabled_modules).to_a.compact_blank
mods.map(&:to_sym)
end

Expand Down
18 changes: 3 additions & 15 deletions test/unit/project_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ def test_destroy_project
end

def test_users_by_role
users_by_role = if Redmine::VERSION.to_s >= '4.2'
Project.find(1).principals_by_role
else
Project.find(1).users_by_role
end
users_by_role = Project.find(1).principals_by_role

assert_kind_of Hash, users_by_role
role = Role.find 1
Expand All @@ -85,19 +81,11 @@ def test_users_by_role_with_hidden_role
assert role.hide

# User.current = User.find 2
users_by_role = if Redmine::VERSION.to_s >= '4.2'
Project.find(1).principals_by_role
else
Project.find(1).users_by_role
end
users_by_role = Project.find(1).principals_by_role
assert_equal 1, users_by_role.count

User.current = User.find 1
users_by_role = if Redmine::VERSION.to_s >= '4.2'
Project.find(1).principals_by_role
else
Project.find(1).users_by_role
end
users_by_role = Project.find(1).principals_by_role
assert_equal 2, users_by_role.count
end
end

0 comments on commit 25827be

Please sign in to comment.