Skip to content

Commit

Permalink
Ruby 3.1 is required. Ruby 3.0 is not maintained anymore (EOL), there…
Browse files Browse the repository at this point in the history
…fore we drop it
  • Loading branch information
alexandermeindl committed Aug 27, 2024
1 parent d9c4ea0 commit 57a6def
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require:
- rubocop-minitest

AllCops:
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
TargetRailsVersion: 6.1
NewCops: enable
ActiveSupportExtensionsEnabled: true
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
## Features

- Tags for issues. To use them you need to:
- *Activate issue tags* in the plugin configuration
- and update your role permissions in the Redmine administration *Roles & permissions / Issue tracking*.
- *Activate issue tags* in the plugin configuration
- and update your role permissions in the Redmine administration *Roles & permissions / Issue tracking*.
- Tags for wiki pages. To use them you need to:
- *Activate wiki tags* in the plugin configuration
- and update your role permissions in the Redmine administration *Roles & permissions / Wiki*
- and update your role permissions in the Redmine administration *Roles & permissions / Wiki*
- Available role permissions for issue tags (section *Issue tracking*):
- Add issue tags
- Edit issue tags
Expand Down Expand Up @@ -59,7 +59,7 @@ Start using it, too. The example image shows the centralized tag management in t
## Requirements

- Redmine `>= 5.0`
- Ruby `>= 3.0`
- Ruby `>= 3.1`
- Redmine plugins: [additionals](https://www.redmine.org/plugins/additionals)

## Installing
Expand Down
2 changes: 1 addition & 1 deletion additional_tags.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
f.match %r{^((doc|test|node_modules)/|Rakefile|Gemfile|Gemfile\.lock|additional_tags\.gemspec|package\.json|yarn\.lock)}
end
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 3.0'
spec.required_ruby_version = '>= 3.1'

spec.add_dependency 'acts-as-taggable-on'
spec.add_dependency 'redmine_plugin_kit'
Expand Down
34 changes: 17 additions & 17 deletions app/helpers/additional_tags_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def manageable_tag_columns
counts: WikiPage.available_tags.to_h { |tag| [tag.id, tag.count] } }
end

call_hook :helper_additional_manageable_tag_columns, columns: columns
call_hook(:helper_additional_manageable_tag_columns, columns:)

@manageable_tag_columns = columns
end
Expand Down Expand Up @@ -127,9 +127,9 @@ def additional_tag_link(tag_object,
use_colors = AdditionalTags.use_colors? if use_colors.nil?
color_theme = AdditionalTags.setting :tags_color_theme if color_theme.nil?

tag_info = AdditionalTag.new name: name.nil? ? tag_object.name : name,
tag_info = AdditionalTag.new(name: name.nil? ? tag_object.name : name,
disable_grouping: !use_colors,
color_theme: color_theme
color_theme:)
tag_name = [tag_info.tag_name]

tag_style = "background-color: #{tag_info.tag_bg_color}; color: #{tag_info.tag_fg_color}" if use_colors
Expand Down Expand Up @@ -206,7 +206,7 @@ def link_to_issue_tags_totals(entries:, project:, open_issues_only:)
sum = if entries.blank? || entries.empty?
0
else
query = IssueQuery.new project: project, name: '_'
query = IssueQuery.new project:, name: '_'
query.add_filter 'tags', '*'
query.filters['status_id'][:operator] = '*' if !open_issues_only && query.filters.key?('status_id')

Expand All @@ -221,7 +221,7 @@ def link_to_issue_tags_totals(entries:, project:, open_issues_only:)

def issue_tag_status_filter(operator: nil, open_issues_only: false)
if operator
{ field: :status_id, operator: operator }
{ field: :status_id, operator: }
elsif open_issues_only
{ field: :status_id, operator: 'o' }
end
Expand All @@ -230,7 +230,7 @@ def issue_tag_status_filter(operator: nil, open_issues_only: false)
def wiki_tags_on_show?
options = { enabled: AdditionalTags.setting?(:active_wiki_tags) }

call_hook :helper_wiki_tags_on_show, options: options
call_hook(:helper_wiki_tags_on_show, options:)

options[:enabled]
end
Expand All @@ -240,25 +240,25 @@ def wiki_tags_on_show?
def tag_url(tag_name, filter: nil, tag_action: nil, tag_controller: nil, project: nil, display_type: nil)
action = tag_action.presence || (controller_name == 'hrm_user_resources' ? 'show' : 'index')

fields = [:tags]
values = { tags: [tag_name] }
operators = { tags: '=' }
f = [:tags]
v = { tags: [tag_name] }
op = { tags: '=' }

if filter.present?
field = filter[:field]
fields << field
operators[field] = filter[:operator]
values[field] = filter[:value] if filter.key? :value
f << field
op[field] = filter[:operator]
v[field] = filter[:value] if filter.key? :value
end

{ controller: tag_controller.presence || controller_name,
action: action,
action:,
set_filter: 1,
display_type: display_type,
display_type:,
project_id: project,
f: fields,
v: values,
op: operators }
f:,
v:,
op: }
end

def add_tags(style, tags, content, item_el, options)
Expand Down
6 changes: 3 additions & 3 deletions app/views/additional_tags/settings/_manage_tags.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
td.checkbox.hide-when-print
= check_box_tag 'ids[]', tag.id, false, id: nil
td
= additional_tag_link tag,
= additional_tag_link(tag,
link: edit_additional_tag_path(tag),
use_colors: use_colors,
color_theme: color_theme
use_colors:,
color_theme:)

- manageable_tag_column_values(tag).each do |column|
td = column
Expand Down
32 changes: 16 additions & 16 deletions app/views/dashboards/blocks/_issue_tags.html.slim
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
h3 = block_definition[:label]

- open_issues_only = RedminePluginKit.true? settings[:open_issues_only]
- tags = Issue.available_tags project: @project, open_issues_only: open_issues_only
- counts = AdditionalTags::Tags.entity_group_by scope: Issue.group_by_status_with_tags(@project),
tags: tags,
- tags = Issue.available_tags(project: @project, open_issues_only:)
- counts = AdditionalTags::Tags.entity_group_by(scope: Issue.group_by_status_with_tags(@project),
tags:,
statuses: { true => :closed, false => :open },
group_id_is_bool: true
group_id_is_bool: true)

= render 'common/tag_summary_block',
tags: tags,
tags:,
entities_label: l(:label_issue_plural),
totals_link: link_to_issue_tags_totals(entries: counts,
project: @project,
open_issues_only: open_issues_only)
open_issues_only:)

- if RedminePluginKit.true? settings[:with_table_of_values]
- if tags.present?
Expand All @@ -31,30 +31,30 @@ h3 = block_definition[:label]
- color_theme = AdditionalTags.setting :tags_color_theme
- tags.each do |tag|
tr
td.name = additional_tag_link tag,
td.name = additional_tag_link(tag,
tag_action: 'index',
tag_controller: 'issues',
filter: issue_tag_status_filter(open_issues_only: open_issues_only),
filter: issue_tag_status_filter(open_issues_only:),
use_colors: RedminePluginKit.true?(settings[:use_colors]),
color_theme: color_theme
color_theme:)
- unless open_issues_only
td.value = additional_tag_link tag,
td.value = additional_tag_link(tag,
tag_action: 'index',
tag_controller: 'issues',
filter: issue_tag_status_filter(operator: 'o'),
use_colors: false,
name: counts[tag.name][:open]
td.value = additional_tag_link tag,
name: counts[tag.name][:open])
td.value = additional_tag_link(tag,
tag_action: 'index',
tag_controller: 'issues',
filter: issue_tag_status_filter(operator: 'c'),
use_colors: false,
name: counts[tag.name][:closed]
td.value = additional_tag_link tag,
name: counts[tag.name][:closed])
td.value = additional_tag_link(tag,
tag_action: 'index',
tag_controller: 'issues',
filter: issue_tag_status_filter(open_issues_only: open_issues_only),
filter: issue_tag_status_filter(open_issues_only:),
use_colors: false,
name: open_issues_only ? counts[tag.name][:open] : counts[tag.name][:total]
name: open_issues_only ? counts[tag.name][:open] : counts[tag.name][:total])
- else
p.nodata = l :label_no_data
2 changes: 1 addition & 1 deletion app/views/issues/_tags_form_details.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
div
p#issue_tags
= label_tag l(:field_tag_list)
= render tags_form, project: project
= render tags_form, project:
2 changes: 1 addition & 1 deletion app/views/wiki/_tags_form_bottom.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- if AdditionalTags.setting?(:active_wiki_tags) && User.current.allowed_to?(:add_wiki_tags, @project)
p#wiki_tags
= label_tag l(:field_tag_list)
= render 'wiki/tags_form', project: project, page: page
= render 'wiki/tags_form', project:, page:
10 changes: 5 additions & 5 deletions db/migrate/20201123093214_migrate_existing_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ def up
context = tagging.respond_to?(:context) && tagging.context.present? ? tagging.context : 'tags'

# old data can include dups
next if ActsAsTaggableOn::Tagging.exists? tag_id: tag.id,
next if ActsAsTaggableOn::Tagging.exists?(tag_id: tag.id,
taggable_id: tagging.taggable_id,
taggable_type: tagging.taggable_type,
context: context
context:)

ActsAsTaggableOn::Tagging.create! tag_id: tag.id,
ActsAsTaggableOn::Tagging.create!(tag_id: tag.id,
taggable_id: tagging.taggable_id,
taggable_type: tagging.taggable_type,
context: context,
created_at: tagging.created_at
context:,
created_at: tagging.created_at)
cnt += 1
end

Expand Down
2 changes: 1 addition & 1 deletion lib/additional_tags/patches/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def group_by_status_with_tags(project = nil, user = User.current)
scope = if project && Setting.display_subprojects_issues?
visible(user).where(AdditionalTags::Tags.subproject_sql(project))
else
visible user, project: project
visible user, project:
end

scope.joins(:status)
Expand Down
2 changes: 1 addition & 1 deletion lib/additional_tags/patches/issue_query_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def build_from_params(params, defaults = {})
def sql_for_tags_field(field, _operator, values)
build_sql_for_tags_field_with_permission klass: queried_class,
operator: operator_for(field),
values: values,
values:,
permission: :view_issue_tags
end
end
Expand Down
9 changes: 4 additions & 5 deletions lib/additional_tags/patches/query_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ module InstanceMethods
def sql_for_tags_field(field, _operator, values)
build_sql_for_tags_field klass: queried_class,
operator: operator_for(field),
values: values
values:
end

def initialize_tags_filter(position: nil)
add_available_filter 'tags', order: position,
type: :list_optional,
def initialize_tags_filter
add_available_filter 'tags', type: :list_optional,
values: -> { available_tag_values queried_class }
end

Expand All @@ -32,7 +31,7 @@ def initialize_issue_tags_filter
end

def available_tag_values(klass)
klass.available_tags(project: project)
klass.available_tags(project:)
.pluck(:name)
.map { |name| [name, name] }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/additional_tags/patches/time_entry_query_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def available_columns_with_tags
end

def sql_for_issue_tags_field(_field, operator, values)
build_sql_for_tags_field klass: Issue, operator: operator, values: values
build_sql_for_tags_field klass: Issue, operator:, values:
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/additional_tags/patches/wiki_page_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def with_tags_scope(project: nil, wiki: nil)
def with_tags(tag, project: nil, order: 'title_asc', max_entries: nil, exclude_page: nil)
wiki = project&.wiki

scope = with_tags_scope wiki: wiki, project: project
scope = with_tags_scope(wiki:, project:)
scope = scope.where.not id: exclude_page.id if exclude_page
scope = scope.limit max_entries if max_entries

Expand Down
18 changes: 9 additions & 9 deletions lib/additional_tags/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def visible_condition(user, **options)
permission = options[:permission] || :view_issue_tags
skip_pre_condition = options[:skip_pre_condition] || true

tag_access permission, user, skip_pre_condition: skip_pre_condition
tag_access permission, user, skip_pre_condition:
end

def available_tags(klass, **options)
Expand Down Expand Up @@ -48,7 +48,7 @@ def available_tags(klass, **options)
end

def all_type_tags(klass, without_projects: false)
ActsAsTaggableOn::Tag.joins(tag_for_joins(klass, without_projects: without_projects))
ActsAsTaggableOn::Tag.joins(tag_for_joins(klass, without_projects:))
.distinct
.order(:name)
end
Expand Down Expand Up @@ -114,22 +114,22 @@ def build_relation_tags(entries)
def entity_group_by(scope:, tags:, statuses: nil, sub_groups: nil, group_id_is_bool: false)
counts = {}
tags.each do |tag|
values = { tag: tag, total: 0, total_sub_groups: 0, groups: [] }
values = { tag:, total: 0, total_sub_groups: 0, groups: [] }

if statuses
statuses.each do |status|
group_id = status.first
group = status.second
values[group] = status_for_tag_value scope: scope,
values[group] = status_for_tag_value(scope:,
tag_id: tag.id,
group_id: group_id,
group_id_is_bool: group_id_is_bool
values[:groups] << { id: group_id, group: group, count: values[group] }
group_id:,
group_id_is_bool:)
values[:groups] << { id: group_id, group:, count: values[group] }
values[:total] += values[group]
values[:total_sub_groups] += values[group] if sub_groups&.include? group_id
end
else
values[:total] += status_for_tag_value scope: scope, tag_id: tag.id
values[:total] += status_for_tag_value scope:, tag_id: tag.id
end

values[:total_without_sub_groups] = values[:total] - values[:total_sub_groups]
Expand Down Expand Up @@ -210,7 +210,7 @@ def tag_access(permission, user, skip_pre_condition: false)
projects_allowed = if permission.nil?
Project.visible.ids
else
Project.where(Project.allowed_to_condition(user, permission, skip_pre_condition: skip_pre_condition)).ids
Project.where(Project.allowed_to_condition(user, permission, skip_pre_condition:)).ids
end

if projects_allowed.present?
Expand Down
4 changes: 2 additions & 2 deletions test/functional/issue_tags_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_edit_tags_permission
user = users :users_002

assert_not_equal @issue_1.tag_list, [tag]
assert_includes Issue.available_tags(user: user).map(&:name), tag
assert_includes Issue.available_tags(user:).map(&:name), tag
post :update,
params: { ids: [1], issue: { tag_list: [tag] } }

Expand All @@ -201,7 +201,7 @@ def test_edit_tags_permission
@role.remove_permission! :edit_issue_tags
tag2 = 'Third'

assert_includes Issue.available_tags(user: user).map(&:name), tag2
assert_includes Issue.available_tags(user:).map(&:name), tag2
post :update,
params: { ids: [1], issue: { tag_list: [tag2] } }

Expand Down
4 changes: 2 additions & 2 deletions test/functional/issues_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def test_edit_tags_permission
tag = 'First'

assert_not_equal Issue.find(2).tag_list, [tag]
assert_includes Issue.available_tags(user: user).map(&:name), tag
assert_includes Issue.available_tags(user:).map(&:name), tag
post :update,
params: { id: 2, issue: { project_id: 1, tag_list: [tag] } }

Expand All @@ -429,7 +429,7 @@ def test_do_not_edit_tags_without_permission
issue = issues :issues_001

assert_includes Issue.available_tags(user: users(:users_001)).map(&:name), new_tag
assert_not_includes Issue.available_tags(user: user).map(&:name), new_tag
assert_not_includes Issue.available_tags(user:).map(&:name), new_tag
assert_equal 'Unable to print recipes', issue.description
assert_not issue.tag_list.include?(new_tag)

Expand Down

0 comments on commit 57a6def

Please sign in to comment.